Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I'd rather be here and now.

ender eaorak

💭
I'd rather be here and now.
View GitHub Profile
View charity.csv
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 Nov 3, 2017 — forked from coryhouse/webpack.config.dev.js
Development Webpack config for "Building a JavaScript Development Environment" on Pluralsight
View webpack.config.dev.js
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 Nov 2, 2017 — forked from coryhouse/package.json
package.json for Building a JS Development Environment on Pluralsight
View package.json
{
"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 Apr 30, 2017 — forked from davegurnell/anorm.scala
A short guide to Anorm
View anorm.scala
/*
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 Feb 26, 2018
Simple Scala method to print RDD content in Spark
View rddprinter.scala
// 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 Dec 22, 2016 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know
View latency.markdown

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 Dec 22, 2016 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
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
View gist:d8d50656fdfc1b7e5687ea9149c67d62
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 Jul 25, 2016
Change a certain color (RGB) in a GIF file to something else for all files in the directory.
View change_color.py
__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
View dns.sh
##############################################################################
# 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'