The first step in optimizing for speed is finding the slowest sections of code. The Timer VBA function returns the number of seconds elapsed since midnight with a precision of 1/256th of a second (3.90625 milliseconds) on Windows based PCs. The VBA functions Now and Time are only accurate to a secon...
std::sort, found in the standard library header algorithm, is a standard library algorithm for sorting a range of values, defined by a pair of iterators. std::sort takes as the last parameter a functor used to compare two values; this is how it determines the order. Note that std::sort is not stable...
A series is a one-dimension data structure. It's a bit like a supercharged array, or a dictionary.
import pandas as pd
s = pd.Series([10, 20, 30])
>>> s
0 10
1 20
2 30
dtype: int64
Every value in a series has an index. By default, the indices are integers, running fro...
Simple example of how to create a custom plugin and DSL for your gradle project.
This sample uses one of the three possible ways of creating plugins.
The three ways are:
inline
buildSrc
standalone plugins
This example shows creating a plugin from the buildSrc folder.
This sample will crea...
Detailed instructions on getting openerp set up or installed in Debian/Ubuntu.
To install from source code, we need Python 2.7, Git and a PostgreSQL database:
$ sudo apt-get install git python-pip python2.7-dev -y
$ sudo apt-get install postgresql -y
$ sudo su -c "createuser -s $(whoami)&qu...
The Flex compiler (mxmlc) is one of the most important parts of the Flex SDK. You can edit AS3 code in any text editor you like. Create a main class file that extends from DisplayObject.
You can trigger builds at the command line as follows:
mxmlc -source-path="." -default-size [width in...
To round a value to the nearest multiple of x:
function roundTo(value:Number, to:Number):Number {
return Math.round(value / to) * to;
}
Example:
roundTo(8, 5); // 10
roundTo(17, 3); // 18
Imagine the following XML:
<root>
<element>hello</element>
<another>
hello
</another>
<example>Hello, <nested> I am an example </nested>.</example>
</root>
The following XPath expression:
//*[text() = 'hel...
To make a Haskell program executable you must provide a file with a main function of type IO ()
main :: IO ()
main = putStrLn "Hello world!"
When Haskell is compiled it examines the IO data here and turns it into a executable. When we run this program it will print Hello world!.
If y...
Output some information about a known remote: origin
git remote show origin
Print just the remote's URL:
git config --get remote.origin.url
With 2.7+, it is also possible to do, which is arguably better than the above one that uses the config command.
git remote get-url origin
The static method Date.now returns the number of milliseconds that have elapsed since 1 January 1970 00:00:00 UTC. To get the number of milliseconds that have elapsed since that time using an instance of a Date object, use its getTime method.
// get milliseconds using static method now of Date
co...
This command is useful if you want to serve a single site in a directory and not the entire directory.
cd ~/Projects/my-blog/
valet link awesome-blog
Valet will create a symbolic link in ~/.valet/Sites which points to your current working directory.
After running the link command, you can acce...
cd ~/Projects
valet park
This command will register your current working directory as a path that Valet should search for sites. Now, any Laravel project you create within your "parked" directory will automatically be served using the http://folder-name.dev convention.
In a Service Provider register method we can bind an interface to an implementation:
public function register()
{
App::bind( UserRepositoryInterface::class, EloquentUserRepository::class );
}
From now on, everytime the app will need an instance of UserRepositoryInterface, Larave...
We can use the Service Container as a Registry by binding an instance of an object in it and get it back when we'll need it:
// Create an instance.
$john = new User('John');
// Bind it to the service container.
App::instance('the-user', $john);
// ...somewhere and/or in another class...
...