Create a simple DataFrame.
import numpy as np
import pandas as pd
# Set the seed so that the numbers can be reproduced.
np.random.seed(0)
df = pd.DataFrame(np.random.randn(5, 3), columns=list('ABC'))
# Another way to set column names is "columns=['column_1_name','column_2_name','c...
To transfer a file securely to another machine - type:
scp file1.txt tom@server2:$HOME
This example presents transferring file1.txt from our host to server2's user tom's home directory.
scp can also be used to transfer multiple files from one server to another. Below is example of transferring all files from my_folder directory with extension .txt to server2. In Below example all files will be transferred to user tom home directory.
scp /my_folder/*.txt tom@server2:$HOME
To download a file from remote server to the local machine - type:
scp tom@server2:$HOME/file.txt /local/machine/path/
This example shows how to download the file named file.txt from user tom's home directory to our local machine's current directory.
There is a mantra that some Java experts are wont to recite:
"Exceptions should only be used for exceptional cases."
(For example: http://programmers.stackexchange.com/questions/184654 )
The essence of this is that is it is a bad idea (in Java) to use exceptions and exception handli...
A for loop iterates from the starting value down to the ending value inclusive, as a "count-down" example.
program CountDown;
{$APPTYPE CONSOLE}
var
i : Integer;
begin
for i := 10 downto 0 do
WriteLn(i);
end.
Output:
10
9
8
7
6
5
4
3
2
1
0
Internal Table Declaration Based on Local Type Definition
" Declaration of type
TYPES: BEGIN OF ty_flightb,
id TYPE fl_id,
dat TYPE fl_date,
seatno TYPE fl_seatno,
firstname TYPE fl_fname,
lastname TYPE fl_lname,
fl...
This function will insert an element into an array at a given index:
insert(){
h='
################## insert ########################
# Usage:
# insert arr_name index element
#
# Parameters:
# arr_name : Name of the array variable
# index : Index to insert at
#...
foo() {
while [[ "$#" -gt 0 ]]
do
case $1 in
-f|--follow)
local FOLLOW="following"
;;
-t|--tail)
local TAIL="tail=$2"
;;
esac
shift
done
echo "FOLLOW: $FOLLOW"
echo "TAIL: $...
Canvas apps often rely heavily on user interaction with the mouse, but when the window is resized, the mouse event coordinates that canvas relies on are likely changed because resizing causes the canvas to be offset in a different position relative to the window. Thus, responsive design requires tha...
core.async is about making processes that take values from and put values into channels.
(require [clojure.core.async :as a])
Creating channels with chan
You create a channel using the chan function:
(def chan-0 (a/chan)) ;; unbuffered channel: acts as a rendez-vous point.
(def chan-1 (a/chan...
One of the core benefits of Typescript is that it enforces data types of values that you are passing around your code to help prevent mistakes.
Let's say you're making a pet dating application.
You have this simple function that checks if two pets are compatible with each other...
checkCompatible...
Code
class Program
{
static void Main(string[] args)
{
int a = 20;
Console.WriteLine("Inside Main - Before Callee: a = {0}", a);
Callee(a);
Console.WriteLine("Inside Main - After Callee: a = {0}", a);
Console.WriteLine();
...
Traditionally Prolog performed arithmetic using the is and =:= operators. However, several current Prologs offer CLP(FD) (Constraint Logic Programming over Finite Domains) as a cleaner alternative for integer arithmetic. CLP(FD) is based on storing the constraints that apply to an integer value and ...
Some "classic" Prolog textbooks still use the confusing and error-prone failure-driven loop syntax where a fail construct is used to force backtracking to apply a goal to every value of a generator. For example, to print all numbers up to a given limit:
fdl(X) :- between(1,X,Y), print(Y),...
Traditionally in Prolog, "functions" (with one output and bound inputs) were written as regular predicates:
mangle(X,Y) :- Y is (X*5)+2.
This can create the difficulty that if a function-style predicate is called multiple times, it is necessary to "daisy chain" temporary vari...