Skip to content

Instantly share code, notes, and snippets.

View saraswatmks's full-sized avatar
💭
I may be slow to respond.

Manish Saraswat saraswatmks

💭
I may be slow to respond.
View GitHub Profile
@rafapereirabr
rafapereirabr / life_expect_world_map_gif.md
Last active November 15, 2020 06:31
creating an animated (gif) world map of life expectancy using ggplot2

This gist shows how to create an animated world map of life expectancy using R. The data comes the UN World Population Prospects, 2015 Revision, and it brings life expectancy data from 1950 untill 2015 and projeceted data up to 2100. Thanks Topi Tjukanov, who reminded me of the UN DESA data portal, where you can find this dataset and many others

The idea is to use open data to create a GIF, much like the ones created by Aron Strandberg but his maps look much nicer. The output of this script is a map like this one:

[![enter image description here][1]][1]

Now diving into the code. First, let's load the necessary libraries and get the data. As of this writing, the current version of gganimate has a bug that messes the aesthetics of the .gif file. As a temporary solution, I've intalled an older version of the package, [as recommended by the author of the gganimate, David Ro

@ramnov
ramnov / MicrosoftML_NYC_Taxi_Tip_Prediction.R
Last active March 21, 2017 00:20
Predict whether or not a tip was paid for a taxi trip using different MicrosoftML functions and compare them to find the best fit
library(MicrosoftML)
sqlConnString <- "Driver=SQL Server;Server=.;Database=nyctaxi;Trusted_Connection=True"
dataSetSource <- RxSqlServerData(connectionString = sqlConnString, table = "nyctaxi_sample", rowsPerRead = 2000000)
dataset <- rxImport(dataSetSource)
rxGetVarInfo(dataset)
head(dataset)
# Set the random seed for reproducibility of randomness.
set.seed(2345, "L'Ecuyer-CMRG")
# Randomly split the data 75-25 between train and test sets.
dataProb <- c(Train = 0.75, Test = 0.25)
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD