The ref keyword for callers of methods is now optional when calling into methods supplied by COM interfaces. Given a COM method with the signature
void Increment(ref int x);
the invocation can now be written as either
Increment(0); // no need for "ref" or a place holder variable any m...
Random and ThreadLocalRandom are good enough for everyday use, but they have a big problem: They are based on a linear congruential generator, an algorithm whose output can be predicted rather easily. Thus, these two classes are not suitable for cryptographic uses (such as key generation).
One can ...
Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScript is a new C# script engine.
var code = "(1 + 2).ToString()";
var run = await CSharpScript.RunAsync(code, ScriptOptions.Default);
var result = (string)run.ReturnValue;
Console.WriteLine(result); //output 3
You can compile and run an...
The option -v followed by an assignment of the form variable=value can be used to pass parameters to an awk program. This is illustrated by the punishment program below, whose job is to write count times the sentence “I shall not talk in class.” on standard output. The following example uses the v...
ng-model-options allows to change the default behavior of ng-model, this directive allows to register events that will fire when the ng-model is updated and to attach a debounce effect.
This directive accepts an expression that will evaluate to a definition object or a reference to a scope value.
...
_.map is useful for changing a list into a different list in a purely
declarative way. Rather than using imperative techniques like a while or
for loop in javascript, you can just specify how you want to manipulate an
element of a list and
Use _.map to make a new list transformed by the functio...
Sometimes one wants to capture the records that have just been updated.
CREATE TABLE #TempUpdated(ID INT)
Update TableName SET Col1 = 42
OUTPUT inserted.ID INTO #TempUpdated
WHERE Id > 50
When files are not available, the require family will throw a LoadError. This is an example which illustrates loading optional modules only if they exist.
module TidBits
@@unavailableModules = []
[
{ name: 'CoreExtend', file: 'core_extend/lib/core_extend' } \
, { name: 'Fs' ...
Visual Studio Code is an open-source and feature-rich code editor from Microsoft. To set it up it for NativeScript development, open the Command Palette (F1 or ⌘+Shift+P) and type ext install NativeScript.
Once the NativeScript extension is installed, the debugger should allow you to set breakpoint...
User Prompts are methods part of the Web Application API used to invoke Browser modals requesting a user action such as confirmation or input.
window.alert(message)
Show a modal popup with a message to the user.
Requires the user to click [OK] to dismiss.
alert("Hello World");
More...
When using prompt a user can always click Cancel and no value will be returned.
To prevent empty values and make it more persistent:
<h2>Welcome <span id="name"></span>!</h2>
<script>
// Persistent Prompt modal
var userName;
while(!userName) {
userN...
A While loop starts by evaluating a condition. If it is true, the body of the loop is executed. After the body of the loop is executed, the While condition is evaluated again to determine whether to re-execute the body.
Dim iteration As Integer = 1
While iteration <= 10
Console.Writeline(ite...
Any time you instantiate a class that Implements IDisposable, you should call .Dispose1 on that class when you have finished using it. This allows the class to clean up any managed or unmanaged dependencies that it may be using. Not doing this could cause a memory leak.
The Using keyword ensures th...
When you need to set a pixel value for something like Paint.setTextSize but still want it be scaled based on the device, you can convert dp and sp values.
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12f, m...
Mesos is a cluster manager aiming for improved resource utilization by dynamically
sharing resources among multiple frameworks. It was started at the University of
California, Berkeley in 2009 and is in production use in many companies, including
Twitter and Airbnb. It became an Apache top-level ...