Skip to content

Instantly share code, notes, and snippets.

@andershammar
andershammar / matplotlib-zeppelin
Created July 1, 2015 07:42
Example showing how to use matplotlib from a Zeppelin notebook
%pyspark
import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt
import StringIO
def show(p):
img = StringIO.StringIO()
p.savefig(img, format='svg')
@JamesDullaghan
JamesDullaghan / digitalocean.md
Created July 6, 2013 20:54
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@jugyo
jugyo / Gemfile
Created April 16, 2013 10:01
How to use Rack::RubyProf on ruby 1.9 and rails 3
gem 'ruby-prof'
@igrigorik
igrigorik / README.md
Last active December 10, 2015 02:48
Home router latency (Linksys E1550) - quick test.

Quick, take a guess, what's the first hop latency to your home wireless router?

Below 1ms, right? Yeah, you wish!

Below are results from a quick test on my home router (Linksys E1550). Some lessons learned:

  • 3-8ms median
  • very different latency tails on different channels (1,6,11)
  • running in mixed mode helps tame the long tails (do it, if you can)
  • all tests on 2.4Ghz, unfortunately E1550 can't do 5Ghz
@owainlewis
owainlewis / haskell_http.hs
Created December 14, 2012 15:24
Haskell HTTP basics
-- Basic HTTP stuff
module Parser where
import System.Environment
import Data.List
import Data.Maybe
import Network.HTTP
import Network.URI
@owainlewis
owainlewis / Example.hs
Last active June 1, 2020 20:30
Haskell HTTP GET request example
module Example () where
import Network.HTTP
-- Non HTTPS
-- 1. Perform a basic HTTP get request and return the body
get :: String -> IO String
get url = simpleHTTP (getRequest url) >>= getResponseBody
@stas
stas / Rakefile
Created November 22, 2012 15:51
Rails Engine: rake task and generator to DRY `spec/dummy`
#!/usr/bin/env rake
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec => :dummy_app) do |t|
t.pattern = File.expand_path('../spec/**/*_spec.rb', __FILE__)
end
task :default => :spec
desc 'Generates a dummy app for testing'
task :dummy_app => [:setup, :migrate]
@jtan189
jtan189 / JavaPasswordSecurity.java
Created September 29, 2012 15:10
Java PBKDF2 Password Hashing Code
import java.security.SecureRandom;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.SecretKeyFactory;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
/*
* PBKDF2 salted password hashing.
* Author: havoc AT defuse.ca
@tomohiro
tomohiro / install-command-line-tools-for-xcode.sh
Created July 5, 2012 14:26
A shell script for installing some applications on OS X
#!/bin/sh
# This script will install Command Line Tools for Xcode on a fresh installation of OS X.
# Usage: curl https://raw.github.com/gist/3053979/install-command-line-tools-for-xcode.sh | sh
DMG='command_line_tools_for_xcode_june_2012.dmg'
cd $HOME/Downloads
if [ ! -f ./$DMG ]; then
echo 'Command Line Tools for Xcode not downloaded.'
require 'thread'
class Foo
attr_reader :a
attr_reader :assignment_count, :evaluation_count
def initialize
@a = nil
@evaluation_lock = Mutex.new
@assignment_lock = Mutex.new