Skip to content

Instantly share code, notes, and snippets.

View smartkiwi's full-sized avatar

Vladimir Vladimirov smartkiwi

View GitHub Profile

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@liaoliaopro
liaoliaopro / supervisor_win.py
Created March 30, 2016 02:51
a lite supervisord for windows
#!/usr/bin/env python
# coding:utf-8
import sys
import os
import re
import time
import socket
import subprocess
import threading
@erikbern
erikbern / install-tensorflow.sh
Last active June 26, 2023 00:40
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
#
# This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
#
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# Install various packages
sudo apt-get update
@niedbalski
niedbalski / no-madvise.c
Created August 19, 2015 13:12
madvise tests
niedbalski@theos-mobile:~$ cat test-madvise.c
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(void) {
size_t size = sysconf(_SC_PAGE_SIZE) * 6; //24K
@rgorsuch
rgorsuch / gist:b404c658551a6a8aeb35
Created July 31, 2015 13:03 — forked from jessitron/gist:8376139
scala: print all URLs on classpath
def urlses(cl: ClassLoader): Array[java.net.URL] = cl match {
case null => Array()
case u: java.net.URLClassLoader => u.getURLs() ++ urlses(cl.getParent)
case _ => urlses(cl.getParent)
}
val urls = urlses(getClass.getClassLoader)
println(urls.filterNot(_.toString.contains("ivy")).mkString("\n"))
@nikhilRP
nikhilRP / filter.scala
Last active October 13, 2015 12:52
Utility scala class to load and filter alignments
import org.bdgenomics.formats.avro.AlignmentRecord
import org.bdgenomics.adam.rdd.ADAMContext._
import org.bdgenomics.adam.projections.Projection
import org.apache.spark.rdd.RDD
import org.apache.parquet.filter2.dsl.Dsl._
import org.apache.parquet.filter2.predicate.FilterPredicate
import org.bdgenomics.adam.projections.AlignmentRecordField._
val adamFile = "/user/nikhilrp/encoded-data/mm10/chr1/ENCFF891NNX.adam"
val proj = Projection(readName, contig, start, end, qual)
@msukmanowsky
msukmanowsky / spark_gzip.py
Created November 14, 2014 01:32
Example of how to save Spark RDDs to disk using GZip compression in response to https://twitter.com/rjurney/status/533061960128929793.
from pyspark import SparkContext
def main():
sc = SparkContext(appName="Test Compression")
# RDD has to be key, value pairs
data = sc.parallelize([
("key1", "value1"),
("key2", "value2"),
("key3", "value3"),
@debugger87
debugger87 / SparkRowConverter.scala
Last active July 6, 2017 11:06
Convert Array[org.apache.spark.sql.Row] to Array[Map[String, Any]]
import org.apache.spark.sql.catalyst.expressions.Row
import org.apache.spark.sql.catalyst.types._
import scala.collection.mutable.{ArrayBuffer}
object SparkRowFormatter {
def formatRowsWithSchema(rowArr: Array[Row], schema: StructType) = {
rowArr.map(r => formatStruct(schema.fields, r))
}
@chintak
chintak / install_simplecv.sh
Last active June 1, 2018 15:56
Install SimpleCV/OpenCV in a Virtual Environment on Mac OSX
# First install homebrew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
# Choose the name of the virtualenv as simplecv
virtualenv simplecv --no-site-packages
source simplecv/bin/activate
# This activates the virtualenv; your command prompt should change from `$` to `(simplecv)$`
# Next the dependencies
sudo easy_install pip # Can be ignored, if pip already present
@temoto
temoto / helpers_data.py
Last active March 22, 2022 05:19
Part of py-helpers. Gzip compression shortcuts. Encoding. Database helpers. Retry decorator.
def namedlist(typename, field_names):
"""Returns a new subclass of list with named fields.
>>> Point = namedlist('Point', ('x', 'y'))
>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate with positional args or keywords
>>> p[0] + p[1] # indexable like a plain list
33
>>> x, y = p # unpack like a regular list