Skip to content

Instantly share code, notes, and snippets.

View aishfenton's full-sized avatar

Aish aishfenton

  • Netflix
  • San Francisco
View GitHub Profile
@visfleet
visfleet / performance_of_yaml_vs_marshal.rb
Created September 22, 2009 05:55
Performance comparison of Ruby's YAML vs Marshal
require 'benchmark'
require 'yaml'
def encode(msg, format)
case format
when :yaml
str = msg.to_yaml
when :binary
str = Marshal.dump(msg)
end
require 'rubygems'
require "builder"
require "benchmark"
require 'nokogiri'
require 'erb'
require 'erubis'
ITERATIONS = 1_000
ERB_TEMPLATE = <<-EOL
@non
non / transducers.scala
Created October 30, 2014 00:39
Slightly simpler example of typed transducers in Scala. See http://blog.podsnap.com/ducers2.html for more context.
object Transducer {
type RF[R, A] = (R, A) => R
def apply[A, B](f: A => B) =
new Transducer[B, A] {
def apply[R](rf: RF[R, B]) = (r, a) => rf(r, f(a))
}
}
import Transducer.RF
@zentrope
zentrope / MemoryMapInputStream.scala
Created July 1, 2011 03:38
Scala InputStream for Memory Mapped File
// Just an example of some code I ended up not using, but which is kinda neat.
object Utils {
def linesFromFile(file: File) = {
io.Source.fromInputStream(getMemoryMappedFileInputStream(file)).getLines
}
def getMemoryMappedFileInputStream(file: File): InputStream = {
@stober
stober / gp.py
Created February 16, 2013 00:17
Gaussian Process in Python
#!/usr/bin/python
"""
Author: Jeremy M. Stober
Program: GP.PY
Date: Thursday, July 17 2008
Description: Example of Gaussian Process Regression.
"""
from numpy import *
import pylab
@pathikrit
pathikrit / README.md
Last active April 24, 2021 17:36
My highly opinionated list of things needed to build an app in Scala
@non
non / half.scala
Last active June 10, 2022 03:11
Scala implementation of 16-bit floating point numbers. Also, a test prgoram.
package half
import scala.math.{pow, round, signum}
import scala.util.Random.nextInt
import java.lang.{Float => JFloat}
/**
* Float16 represents 16-bit floating-point values.
*
* This type does not actually support arithmetic directly. The
@mmozeiko
mmozeiko / MemSpeed.cpp
Created December 21, 2014 19:48
Memory copy benchmark
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <xmmintrin.h> // SSE
#include <immintrin.h> // AVX
#ifdef _WIN32
#include <intrin.h> // for __movsb, __movsd, __movsq
@mblondel
mblondel / lda_gibbs.py
Last active October 9, 2023 11:31
Latent Dirichlet Allocation with Gibbs sampler
"""
(C) Mathieu Blondel - 2010
License: BSD 3 clause
Implementation of the collapsed Gibbs sampler for
Latent Dirichlet Allocation, as described in
Finding scientifc topics (Griffiths and Steyvers)
"""