Skip to content

Instantly share code, notes, and snippets.

import matplotlib.pyplot as plt
from matplotlib.colors import rgb2hex
import matplotlib as mpl
class BokehColorMapper(plt.cm.ScalarMappable):
"""A callable that maps cold colors to low values, and hot to high.
"""
def __init__(self, vmin=None,vmax=None, cmap=plt.cm.hot_r):
norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)
#!/bin/sh
# Author: Nikita Kovalev, https://gist.github.com/maizy/c4d31c1f539694f721f6
# Based on: https://gist.github.com/visenger/5496675
# Use java7 dependency (openjdk) instead of java6.
# Tested in Ubuntu 12.04.5 (precise)
SCALA="2.11.2"
SBT="0.13.5"
HTTPoison.start
urls = ["http://www.wikipedia.org","www.apple.com"] # or load your urls from a file
urls |> Enum.map fn url -> HTTPoison.get!(url).status_code end
# [200, 200]
/**
Usage: Just include this script after Marionette and Handlebars loading
IF you use require.js add script to shim and describe it in the requirements
*/
(function(Handlebars, Marionette) {
Marionette.Handlebars = {
path: 'templates/',
extension: '.handlebars'
};
@aldwyish
aldwyish / exam.hs
Created November 20, 2011 22:25
sampleexam10 Q6
-- | a traversal that only return the concatenation of all the lists in the tree
module Exam where
data Ttree a = Nil | Node3 a (Ttree a) (Ttree a) (Ttree a)
ttree= (Node3 [0] (Node3 [1,11] Nil Nil Nil) (Node3 [2,21] Nil Nil Nil) (Node3 [3,31] Nil Nil Nil))
concate_tree:: Ttree [a] -> [a]
concate_tree t = concate_tree' t []
concate_tree':: Ttree [a] -> [a] -> [a]
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
@aldwyish
aldwyish / prime_factor.m
Created October 15, 2011 03:39
a demonstration on how to use the solution predicate in Mercury
:- module prime_factor.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module list,solutions,int.
%
@aldwyish
aldwyish / ReadWriteJAI.java
Created June 4, 2010 17:19
Snippets on how to read and write images with Java Advanced Imaging
public bufferedImage load (String filepath ) {
PlanarImage image = JAI.create("fileload","filepath");
BufferedImage bufferedImage = image.getAsBufferedImage();
return bufferedImage;
}
public void save (BufferedImage bufferedImage,String filepath,String format){
JAI.create("filestore",bufferedImage,"filepath","format");
}