Skip to content

Instantly share code, notes, and snippets.

@wmertens
wmertens / nix-store-in-git.md
Last active September 7, 2022 19:57
Store Nix store in git

Store Nix store in git

The Nix store is an immutable file tree store, addressed by output hashes ($outhash-$name or $out), but could also be tweaked to be addressed by the content hash of the file tree ($cas).

Git is a content-addressed immutable object store. It is optimized for storing files as blobs and directories as tree objects.

Here we consider using a git repository for deduplicating, compressing and distributing the Nix store. We want to achieve maximum deduplication so we extract small changes from files before storing, so they become more similar.

Method

@michaelfairley
michaelfairley / stuff.md
Last active June 11, 2017 21:02
Makin' Games with Ruby
@jferris
jferris / array_matching.rb
Created May 13, 2013 19:06
Example: custom rspec-mocks argument matcher
module ArrayMatching
class ArrayMatching
def initialize(array)
@array = array
end
def ==(other_array)
Set.new(@array) == Set.new(other_array)
end
@iogakos
iogakos / wma_hash.rb
Created November 22, 2012 09:40
Weighted Moving Average - Ruby Implementation
# Weighted Moving Average (WMA)
# http://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average
#
# Given a hash, calculates the weighted moving averages of its values within
# a window size given. Modifies the original hash values.
#
# @param hash [Hash] the hash for whom values calculate the weighted moving
# averages.
# @param maws [Fixnum] the Moving Average Window Size. The greatest this
# number is the smoothest the calculated averages will be.
@ngauthier
ngauthier / Procfile
Created February 24, 2012 22:36
Heroku Serving a Directory
web: ruby serve.rb $PORT
@jstorimer
jstorimer / hilong.rb
Last active July 30, 2020 06:52
hilong -- A simply utility to show character counts for each line of input and highlight lines longer than 80 characters.
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
#
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
#
# Examples:
#
# $ hilong Gemfile
@ches
ches / post-checkout
Created February 7, 2011 13:17
post-checkout git hook to intelligently run `bundle` if Gemfile was changed
#!/bin/sh
# Via http://tbaggery.com/2011/02/07/bundle-while-you-git.html
# Save as http://.git/hooks/post-checkout in your project and `chmod +x`
# See the post for how to tell Git you want this in new/newly cloned repos
if [ $1 = 0000000000000000000000000000000000000000 ]; then
# Special case for initial clone: compare to empty directory.
old=4b825dc642cb6eb9a060e54bf8d69288fbee4904
else
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')