/**
* returns a array of random numbers with no duplicates
* @param range the range of possible numbers for ex. if 100 then it can be anywhere from 1-100
* @param length the length of the array of random numbers
* @return array of random numbers with no duplicates.
*/
public static int[] ...
Add React to your project:
meteor npm install --save react react-dom react-mounter
Create the client/helloworld.jsx file to display a simple React component:
import React, { Component } from 'react';
import { mount } from 'react-mounter';
// This component only renders a paragraph containin...
section .data
msg db "Hello world!",10 ; 10 is the ASCII code for a new line (LF)
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 13
syscall
mov rax, 60
mov rdi, 0
syscall
If you want to e...
Using GNU grep
grep -r 'pattern' <directory path>
To also list line numbers of matches use -n option
grep -rn 'pattern' <directory path>
To search only files with particular glob pattern
grep --include='*.txt' -r 'pattern' <directory path>
Exclude file patterns or direc...
Programming in general often requires a decision or a branch within the code to account for how the code operates under different inputs or conditions. Within the C# programming language (and most programming languages for this matter), the simplest and sometimes the most useful way of creating a br...
Following on from the If-Else Statement example, it is now time to introduce the Else If statement. The Else If statement follows directly after the If statement in the If-Else If-Else structure, but intrinsically has has a similar syntax as the If statement. It is used to add more branches to the c...
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.
...
A cancelable event can be raised by a class when it is about to perform an action that can be canceled, such as the FormClosing event of a Form.
To create such event:
Create a new event arg deriving from CancelEventArgs and add additional properties for event data.
Create an event using EventH...
Download and install Visual Studio Community 2015
Open Visual Studio Community
Click File -> New -> Project
Click Templates -> Visual C++ -> Win32 Console Application and then name the project MyFirstProgram.
Click Ok
Click Next in the following window.
Check the Empty proj...
::This is a label that acts as a comment
The double-colon :: comment shown above is not documented as being a comment command, but it is a special case of a label that acts as a comment.
Caution: when labels are used as comments within a bracketed code block or for command, the command processor...
string strCmdText = "/C copy /b Image1.jpg + Archive.rar Image2.jpg";
System.Diagnostics.Process.Start("CMD.exe",strCmdText);
This is to hide the cmd window.
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo...
A minimal Dockerfile looks like this:
FROM alpine
CMD ["echo", "Hello StackOverflow!"]
This will instruct Docker to build an image based on Alpine (FROM), a minimal distribution for containers, and to run a specific command (CMD) when executing the resulting image.
Build an...
When results need to have some logic applied 'on the fly' one can use CASE statement to implement it.
SELECT CASE WHEN Col1 < 50 THEN 'under' ELSE 'over' END threshold
FROM TableName
also can be chained
SELECT
CASE WHEN Col1 < 50 THEN 'under'
WHEN Col1 > 50 AND Col1 ...
Sometimes when tables are used mostly (or only) for reads, indexing does not help anymore and every little bit counts, one might use selects without LOCK to improve performance.
SQL Server
SELECT * FROM TableName WITH (nolock)
MySQL
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;...
WITH cte AS (
SELECT ProjectID,
ROW_NUMBER() OVER (PARTITION BY ProjectID ORDER BY InsertDate DESC) AS rn
FROM ProjectNotes
)
DELETE FROM cte WHERE rn > 1;
The Kernel#require method will load files only once (several calls to require will result in the code in that file being evaluated only once). It will search your ruby $LOAD_PATH to find the required file if the parameter is not an absolute path. Extensions like .rb, .so, .o or .dll are optional. Re...
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...
The following example declares a piece of code to be written in Racket, and then prints the string Hello, world.
#lang racket
"Hello, world!"
Racket code can either be run directly from the command line or on the DrRacket IDE. Typing racket on the command line will start a REPL, and t...