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...
The is macro is the core of the clojure.test library. It returns the value of its body expression, printing an error message if the expression returns a falsey value.
(defn square [x]
(+ x x))
(require '[clojure.test :as t])
(t/is (= 0 (square 0)))
;;=> true
(t/is (= 1 (square 1)))
...
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...
6.0
Since C# 6.0 it is possible to use string interpolation in place of String.Format.
string name = "John";
string lastname = "Doe";
Console.WriteLine($"Hello {name} {lastname}!");
Hello John Doe!
More examples for this under the topic C# 6.0 features: Stri...
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
List all the existing remotes associated with this repository:
git remote
List all the existing remotes associated with this repository in detail including the fetch and push URLs:
git remote --verbose
or simply
git remote -v
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...
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...
...