static T[] Rotate(int n, T[] arr) { var temp = new T[arr.Length]; for (int i = 0; i < arr.Length; i++) { var destIndex = i - n; if (destIndex < 0) { var mul = -1 * destIndex / arr.Length; destIndex = (arr.Length * mul) + destIndex;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type State<'S,'a> = 'S -> ('a * 'S) | |
module State = | |
let unit a : State<_,_> = fun s -> (a, s) | |
let map<'s,'a,'b> (f : 'a -> 'b) (r : State<'s,'a>) = | |
fun s -> | |
let a,next = r(s) | |
f(a), next |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global diff.tool diffmerge | |
git config --global difftool.diffmerge.cmd 'c:/tools/diffmerge/sgdm.exe \"$LOCAL\" \"$REMOTE\"' | |
git config --global merge.tool diffmerge | |
git config --global mergetool.diffmerge.cmd 'c:/tools/diffmerge/sgdm.exe --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"' | |
git config --global mergetool.diffmerge.trustExitCode true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) explain the life of an http request. | |
2) what does the FLP result teach us? | |
3) what is a byzantine failure? | |
4) explain CRDTs | |
5) explain linearizability. | |
6) how does DNS work? | |
7) crash-stop vs crash-recovery? | |
8) difference between soft and hard real time | |
9) model GC in an eventually consistent system | |
10) discuss clock skew, NTP, and AWS vs metal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let inline recordMetrics< ^T when ^T : (member MessageCountDetails : MessageCountDetails) | |
and ^T : (member Path : string)> (all : ^T seq) = | |
recordMetricsForPath (fun e -> (((^T : (member Path : string) e)))) all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
learning/hello-paket/HelloPaket master ✗ 103d ✖ ⚑ ◒ | |
▶ wget https://github.com/fsprojects/Paket/releases/download/0.30.3/paket.bootstrapper.exe | |
--2015-02-23 21:20:58-- https://github.com/fsprojects/Paket/releases/download/0.30.3/paket.bootstrapper.exe | |
Resolving github.com... 192.30.252.131 | |
Connecting to github.com|192.30.252.131|:443... connected. | |
HTTP request sent, awaiting response... 302 Found | |
Location: https://s3.amazonaws.com/github-cloud/releases/22755810/f2133dfe-bb80-11e4-9f9d-f777da134aed.exe?response-content-disposition=attachment%3B%20filename%3Dpaket.bootstrapper.exe&response-content-type=application/octet-stream&AWSAccessKeyId=AKIAISTNZFOVBIJMK3TQ&Expires=1424744518&Signature=v8wt6BYpfl2y0QOeTkmPQe18xUE%3D [following] | |
--2015-02-23 21:20:58-- https://s3.amazonaws.com/github-cloud/releases/22755810/f2133dfe-bb80-11e4-9f9d-f777da134aed.exe?response-content-disposition=attachment%3B%20filename%3Dpaket.bootstrapper.exe&response-content-type=application/octet-stream&AWSAccess |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/Unit-1/DoThis master ✗ 23h17m ◒ | |
▶ ls -l | |
total 7456 | |
-rw-r--r-- 1 bhargava staff 182 Feb 23 08:16 App.config | |
-rw-r--r-- 1 bhargava staff 1140 Feb 23 08:16 ConsoleReaderActor.cs | |
-rw-r--r-- 1 bhargava staff 1092 Feb 23 08:16 ConsoleWriterActor.cs | |
-rw-r--r-- 1 bhargava staff 1530 Feb 23 08:16 Program.cs | |
drwxr-xr-x 3 bhargava staff 102 Feb 23 08:16 Properties | |
-rw-r--r-- 1 bhargava staff 2595 Feb 23 08:16 WinTail.csproj | |
-rw-r--r-- 1 bhargava staff 960 Feb 23 08:16 WinTail.sln |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec gcd a b = match (a,b) with | |
| (x,y) when x = y -> x | |
| (x,y) when x > y -> gcd (x-y) y | |
| (x,y) -> gcd x (y-x) | |
let lcm a b = a*b/(gcd a b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sizeOfFolder folder = | |
let allFiles = Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories) | |
let fileInfos = allFiles |> Array.map (fun x -> new FileInfo(x)) | |
let allSizes = fileInfos |> Array.map (fun x -> x.Length) | |
Array.sum allSizes | |
///This version requires explicit type annotations in the lambda | |
let sizeOfFolder2 folder = | |
let allFiles = Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories) | |
let fileInfos = Array.map (fun (x:string) -> new FileInfo(x)) allFiles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sqlContext = new org.apache.spark.sql.SQLContext(sc); //sc is SparkContext | |
import sqlContext._ | |
case class Person(name: String, age: Int) | |
val randomPeople = sc.parallelize(1 to 1000).map(i => Person("Yu_"+i,i)) | |
randomPeople.registerAsTable("people") | |
val aged30 = sql("select * from people where age = 30") |