Skip to content

Instantly share code, notes, and snippets.

View eaorak's full-sized avatar
💭
I'd rather be here and now.

ender eaorak

💭
I'd rather be here and now.
View GitHub Profile
@eaorak
eaorak / charity.csv
Last active February 19, 2020 14:30
Country Value
Cancer Research UK 3394
the Save The Children Fund 8593
Oxfam 2415
The British Red Cross Society 9401
British Heart Foundation 4728
Dogs Trust 3740
Age UK 7483
WWW - UK 12039
@eaorak
eaorak / webpack.config.dev.js
Created November 3, 2017 15:12 — forked from coryhouse/webpack.config.dev.js
Development Webpack config for "Building a JavaScript Development Environment" on Pluralsight
import path from 'path';
export default {
debug: true,
devtool: 'inline-source-map',
noInfo: false,
entry: [
path.resolve(__dirname, 'src/index')
],
target: 'web',
@eaorak
eaorak / package.json
Created November 2, 2017 16:18 — forked from coryhouse/package.json
package.json for Building a JS Development Environment on Pluralsight
{
"name": "javascript-development-environment",
"version": "1.0.0",
"description": "JavaScript development environment Pluralsight course by Cory House",
"scripts": {
},
"author": "Cory House",
"license": "MIT",
"dependencies": {
"whatwg-fetch": "1.0.0"
@eaorak
eaorak / anorm.scala
Created April 30, 2017 21:39 — forked from davegurnell/anorm.scala
A short guide to Anorm
/*
Overview
--------
To run a query using anorm you need to do three things:
1. Connect to the database (with or without a transaction)
2. Create an instance of `anorm.SqlQuery` using the `SQL` string interpolator
3. Call one of the methods on `SqlQuery` to actually run the query
@eaorak
eaorak / rddprinter.scala
Last active February 26, 2018 20:42
Simple Scala method to print RDD content in Spark
// To be able to easily print RDD content, you can either create a function inside the shell or an implicit class
// Ref to my answer: http://stackoverflow.com/a/41317574/1095213
def p(rdd: org.apache.spark.rdd.RDD[_]) = rdd.foreach(println) // Option 1
implicit class Printer(rdd: org.apache.spark.rdd.RDD[_]) { // Option 2
def print = rdd.foreach(println)
}
// Example
@eaorak
eaorak / latency.markdown
Created December 22, 2016 08:29 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@eaorak
eaorak / latency.txt
Created December 22, 2016 08:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
@eaorak
eaorak / gist:d8d50656fdfc1b7e5687ea9149c67d62
Created August 7, 2016 19:40 — forked from ngocdaothanh/gist:3764694
Scala Assignment: Recursion
package recfun
import scala.collection.mutable.ListBuffer
import common._
/** https://class.coursera.org/progfun-2012-001/assignment/view?assignment_id=4 */
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {
@eaorak
eaorak / change_color.py
Created July 25, 2016 11:32
Change a certain color (RGB) in a GIF file to something else for all files in the directory.
__author__ = 'ender'
import numpy as np
import Image
import os
os.chdir('image_dir')
for file in os.listdir('.'):
if not file.endswith('.gif'):
continue
##############################################################################
# This script can be used for setting DNS on Mac computers from command line.
# It either sets dns to google dns servers when no parameter is provided
# or empties DNS settings when called with 'none'.
##################################################################### eaorak #
#!/bin/bash
dns='8.8.8.8 8.8.4.4'
empty='empty'