Skip to content

Instantly share code, notes, and snippets.

View even4void's full-sized avatar

chl even4void

View GitHub Profile
@rougier
rougier / material-colors.el
Created July 31, 2020 17:54
Emacs year calendar in a dedicated frame
;; Material colors from https://material.io/design/color/
(defconst levels
(list "L50" "L100" "L200" "L300" "L400"
"L500" "L600" "L700" "L800" "L900"
"A100" "A200" "A400" "A700"))
(defconst red
(list "#FFEBEE" "#FFCDD2" "#EF9A9A" "#E57373" "#EF5350"
"#F44336" "#E53935" "#D32F2F" "#C62828" "#B71C1C"
"#FF8A80" "#FF5252" "#FF1744" "#D50000"))
@fonnesbeck
fonnesbeck / install_superpack_brew.sh
Created June 19, 2014 03:00
Install the Python scientific stack (a.k.a. the Scipy Superpack) via Brew and pip
#!/bin/sh
hash brew &> /dev/null
if [ $? -eq 1 ]; then
echo 'Installing Homebrew ...'
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
fi
# Ensure Homebrew formulae are updated
brew update
@mike-lawrence
mike-lawrence / lmer_oneway_Gaussian.R
Created November 16, 2011 13:03
Simulating a mixed effects model with one random effect, one fixed effect. Gaussian and binomial versions.
library(MASS)
library(lme4)
generate_data = function(
n # number of units
, k # number of trials within each condition within each unit
, noise # measurement noise variance
, I # population intercept
, vI # across-units variance of intercepts
, A # population A effect
@mike-lawrence
mike-lawrence / lmer_oneway_sim.R
Created October 29, 2011 14:33
lmer_oneway_sim
library(plyr)
library(MASS)
library(lme4a)
generate_data = function(
n # number of units
, k # number of trials within each condition within each unit
, noise # measurement noise variance
, I # population intercept
, vI # across-units variance of intercepts
@carlohamalainen
carlohamalainen / gist:1124157
Created August 3, 2011 23:38
Run ggplot2 from Clojure using rincanter
; http://carlo-hamalainen.net/blog/2011/08/04/ggplot2-from-clojure
; To dump the plot to a file:
(use '(com.evocomputing rincanter)) ; https://github.com/jolby/rincanter
(r-eval "library(ggplot2)")
(r-eval-raw "qplot(rating, data=movies, geom=\"histogram\")") ; see http://had.co.nz/ggplot2/geom_histogram.html
(r-eval "ggsave('histogram-example.png')")
; To display on your screen (Unix example; see rincanter docs for alternatives to x11() call)
(use '(com.evocomputing rincanter))
@brendano
brendano / analysis.txt
Created June 14, 2011 02:56
How much text versus metadata is in a tweet?
How much text versus metadata is in a tweet?
Brendan O'Connor (brenocon.com), 2011-06-13
http://twitter.com/brendan642/status/80473880111742976
What's it mean to compare the amount of text versus metadata?
Let's start with raw size of the data that comes over the wire from Twitter.
## Get tweets out of a sample stream archive.
## (e.g. curl http://stream.twitter.com/1/statuses/sample.json)
% cat tweets.2011-05-19 | grep -P '"text":' | head -100000 > 100k_tweets
@HarlanH
HarlanH / visualizing-categorizations.R
Created April 22, 2011 22:23
Visualizing Categorizations blog post code
# Demo of techniques to visualize the predictions made by a categorization model.
library(ROCR)
library(ggplot2)
load(url('http://dl.dropbox.com/u/7644953/classifier-visualization.Rdata'))
pred.df$actual.bin <- ifelse(pred.df$actual == 'yes', 1, 0)
pred.df <- pred.df[order(pred.df$predicted, decreasing=TRUE), ]
@mike-lawrence
mike-lawrence / get_vars_and_rel.R
Created April 6, 2011 23:19
an attempt to compute reliability (and contributing variances) using variance estimates from a mixed effects model
#define two useful helper functions
colMean = function(x){
dimx = dim(x)
.Internal(colMeans(x,dimx[1],dimx[2],na.rm=TRUE))
}
colVar = function(x){
dimx = dim(x)
x.mean = .Internal(colMeans(x,dimx[1],dimx[2],na.rm=TRUE))
err = t(t(x)-x.mean)
err.sq = err*err
@drewconway
drewconway / google_counts.R
Created January 22, 2011 22:26
Function takes a string as parameter and returns the approximate number of Google search results containing that string
require(RCurl)
require(XML)
google.counts<-function(s){
search.url<-paste("http://www.google.com/search?q=",gsub(" ","+",s),sep="")
search.html<-getURL(search.url)
parse.search<-htmlTreeParse(search.html,useInternalNodes = TRUE)
search.nodes<-getNodeSet(parse.search,"//div[@id='resultStats']")
search.value<-strsplit(xmlValue(search.nodes[[1]])," ",fixed=TRUE)[[1]][2]
return(as.numeric(gsub(",","",search.value,fixed=TRUE)))
@mblondel
mblondel / perceptron.py
Last active April 21, 2024 13:42
Kernel Perceptron
# Mathieu Blondel, October 2010
# License: BSD 3 clause
import numpy as np
from numpy import linalg
def linear_kernel(x1, x2):
return np.dot(x1, x2)
def polynomial_kernel(x, y, p=3):