Skip to content

Instantly share code, notes, and snippets.

@fvbock
fvbock / cleanup_globals.py
Created September 1, 2011 13:29
clean up the globals to an initial state
dont_clean = [ 'initial_vars' ]
def cleanup():
print dont_clean
vars_to_free = [ k for k in set( globals().copy() ).difference( initial_vars.union( set( dont_clean ) ) ) ]
print vars_to_free,
for c in vars_to_free:
del globals()[ c ]
print "cleaned"
@fvbock
fvbock / rolling_sum.sql
Created December 4, 2012 12:58
rolling sum in sql - window aggregates and CTE much faster than subquery or join
-- table
-- name number
-- 1 10
-- 2 20
-- 3 10
-- 4 30
-- ...
-- result
-- name amount
@fvbock
fvbock / func_streams.go
Created March 15, 2013 09:23
functions/io_streams
package main
import (
"fmt"
"time"
"math/rand"
"sort"
)
func printMemStats() {
memstats := new(runtime.MemStats)
runtime.ReadMemStats(memstats)
s.Log.Printf("memstats before GC: bytes = %d footprint = %d mallocs = %d frees = %d",
memstats.HeapAlloc, memstats.Sys, memstats.Mallocs, memstats.Frees)
}
function [J grad] = nnCostFunction(nn_params, ...
input_layer_size, ...
hidden_layer_size, ...
num_labels, ...
X, y, lambda)
%NNCOSTFUNCTION Implements the neural network cost function for a two layer
%neural network which performs classification
% [J grad] = NNCOSTFUNCTON(nn_params, hidden_layer_size, num_labels, ...
% X, y, lambda) computes the cost and gradient of the neural network. The
% parameters for the neural network are "unrolled" into the vector
GET /entries/_search
{
"query": {
"function_score": {
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
@fvbock
fvbock / .emacs
Created August 9, 2014 01:45
.emacs
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-newline-function (quote newline))
'(auto-image-file-mode t nil (image-file))
'(blink-cursor-mode nil)
'(case-fold-search t)
'(deft-auto-save-interval 120.0)
@fvbock
fvbock / gecko_highcharts.go
Created December 2, 2014 06:37
geckoboard highcharts payload
type HighChart struct {
Chart struct {
Style struct {
Color string `json:"color,omitempty"`
} `json:"style,omitempty"`
RenderTo string `json:"renderTo,omitempty"`
BackgroundColor string `json:"backgroundColor,omitempty"`
LineColor string `json:"lineColor,omitempty"`
PlotShadpw bool `json:"plotShadow,omitempty"`
} `json:"chart,omitempty"`
$ ssh -A vm
$ git config --global url."[email protected]:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "[email protected]:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
@fvbock
fvbock / gol2.go
Created June 1, 2015 03:14
game of life - section 2
package main
import (
"fmt"
"math/rand"
"time"
)
type World struct {
Width int