Skip to content

Instantly share code, notes, and snippets.

@imiric
imiric / PKGBUILD
Last active December 16, 2015 10:59
PKGBUILD for Vagrant 1.2.1
pkgname=vagrant
pkgver=1.2.1
pkgrel=4
pkgdesc="Tool for building and distributing virtualized development environments"
arch=('i686' 'x86_64')
url='http://vagrantup.com/'
license=('MIT')
depends=('ruby' 'virtualbox>=4.0' 'ruby-net-ssh>=2.6.6' \
'ruby-net-scp>=1.1.0' 'ruby-erubis>=2.7.0' 'ruby-i18n>=0.6.0' \
'ruby-log4r>=1.1.9' 'ruby-childprocess>=0.3.7')
@teh
teh / grind_coarseness.py
Created June 8, 2013 14:39
Measure average grind coarseness from a picture.
from PIL import Image
import numpy
from skimage.filter import sobel
from skimage.morphology import watershed
from scipy import ndimage as nd
grind = numpy.asarray(Image.open('grind.png')).mean(axis=2)
edges = sobel(grind)
markers = numpy.zeros_like(grind)
@vincentdavis
vincentdavis / gist:8588879
Last active January 4, 2016 07:29
De Bruijn sequence
def debruijn(k, n):
"""
De Bruijn sequence for alphabet size k (0,1,2...k-1)
and subsequences of length n.
From wikipedia Sep 22 2013
"""
a = [0] * k * n
sequence = []
def db(t, p,):
if t > n:
@lh3
lh3 / inthash.c
Last active December 11, 2022 07:27
Invertible integer hash functions
/*
For any 1<k<=64, let mask=(1<<k)-1. hash_64() is a bijection on [0,1<<k), which means
hash_64(x, mask)==hash_64(y, mask) if and only if x==y. hash_64i() is the inversion of
hash_64(): hash_64i(hash_64(x, mask), mask) == hash_64(hash_64i(x, mask), mask) == x.
*/
// Thomas Wang's integer hash functions. See <https://gist.github.com/lh3/59882d6b96166dfc3d8d> for a snapshot.
uint64_t hash_64(uint64_t key, uint64_t mask)
{
key = (~key + (key << 21)) & mask; // key = (key << 21) - key - 1;
#!/bin/sh
jq -r 'def banner: "\(.) " + (28-(.|length))*"-";
("Non-cell info" | banner), del(.cells), "",
(.cells[] | ("\(.cell_type) cell" | banner),
"\(.source|add)",
if ($show_output == "1") then
"",
( select(.cell_type=="code" and (.outputs|length)>0) |
("output" | banner),
(.outputs[] |
@0XDE57
0XDE57 / config.md
Last active July 7, 2024 00:25
Firefox about:config privacy settings

ABOUT

about:config settings to harden the Firefox browser. Privacy and performance enhancements.
To change these settings type 'about:config' in the url bar. Then search the setting you would like to change and modify the value. Some settings may break certain websites from functioning and rendering normally. Some settings may also make firefox unstable. I am not liable for any damages/loss of data.

Not all these changes are necessary and will be dependent upon your usage and hardware. Do some research on settings if you don't understand what they do. These settings are best combined with your standard privacy extensions (HTTPS Everywhere No longer required: Enable HTTPS-Only Mode, NoScript/Request Policy, uBlock origin, agent spoofing, Privacy Badger etc), and all plugins set to "Ask To Activate".

@vasanthk
vasanthk / System Design.md
Last active July 15, 2024 10:23
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@shoyer
shoyer / xarray-tutorial-cleared.ipynb
Last active November 25, 2023 03:59
Xarray tutorial for Rossbypalooza
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dkoslicki
dkoslicki / JaccardEstimateViaContainment.py
Created April 24, 2017 17:11
Testing typical bottom-k min hash estimate of Jaccard index versus containment estimate of Jaccard index
import sourmash_lib
import numpy as np
import matplotlib.pyplot as plt
from pybloom import BloomFilter
n = 10000 # sequence length
ksize = 10 # k-mer length
h = 100 # number of hashes in sketch
i_range = range(1, 50000, 500) # range of intersection sizes
#i_range = [10000]
@blahah
blahah / internet_of_data_transforms.md
Last active February 29, 2020 17:50
Ways dat can be leveraged to transform science, #1 - the internet of data transforms

dat is an incredibly powerful technology for peer to peer sharing of versioned, secure, integrity-guaranteed data.

One thing it excels at is populating a live feed of data points from one source, and allowing any number of peers to subscribe to that feed. The data can only originate from the original source (this is guaranteed using public-key encryption), but the peers in the network can still sync the new data with one another. To subscribe to a given source you only need to know an alphanumeric key that uniquely identifies the source, and is automatically generated by dat.

There are many ways that this simple system can be used to build a new infrastructure for science. This is the first in a series of posts in which I'll explain how.

Here I briefly describe some ways dat can be used to automate some aspects of scientific discovery, increase resource and information reuse efficiency, and help keep our information resources up to date with science (a topic I will expand on signif