Skip to content

Instantly share code, notes, and snippets.

View berkus's full-sized avatar
🎯
Haptic drift

Berkus Decker berkus

🎯
Haptic drift
View GitHub Profile
@Sija
Sija / NSArray-Blocks.h
Created November 15, 2009 05:22
Making NSArray more ruby-ish
//
// NSArray-Blocks.h
// Handy codebits
//
// If you want to keep block definitions terse, simple and dynamic, have no
// problems with the incompatible block pointer types and you don't mind
// compiler warnings about sending a message without matching signature,
// DO NOT IMPORT THIS FILE, seriously.
//
// Created by Sijawusz Pur Rahnama on 15/11/09.
@mobius
mobius / lisp_in_200_cpp_lines.cpp
Created December 1, 2010 02:56
Lisp interpreter in 200 lines
// Scheme Interpreter in 90 lines of C++ (not counting lines after the first 90).
// Inspired by Peter Norvig's Lis.py.
// Copyright (c) 2010 Anthony C. Hay. This program leaks memory.
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <map>
@tvogel
tvogel / git-merge-associate
Created March 30, 2011 13:23
git script to manually associate files in a conflicting merge when rename detection fails
#!/bin/bash
#
# Purpose: manually associate missed renames in merge conflicts
#
# Usage: git merge-associate <our-target> <base> <theirs>
#
# Example: After a failed rename detection A/a -> B/b which results
# in CONFLICT (delete/modify) for A/a and corresponding "deleted by us"
# messages in git status, the following invocation can be used to manually
# establish the link:
@bradfordcp
bradfordcp / RemoteEntity.h
Created August 3, 2011 01:32
RemoteEntity Example - Assumes the AppDelegate has a connection to the ManagedObjectContext.
//
// RemoteEntity.h
//
// Created by Christopher Bradford on 5/6/10.
// Copyright 2010 INM United. All rights reserved.
//
@interface RemoteEntity : NSManagedObject
{
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@timcowlishaw
timcowlishaw / Trie.scala
Created November 14, 2011 10:06
A Trie (Prefix-tree) implementation in Scala
package uk.ac.ucl.cs.GI15.timNancyKawal {
class Trie[V](key: Option[Char]) {
def this() {
this(None);
}
import scala.collection.Seq
import scala.collection.immutable.TreeMap
import scala.collection.immutable.WrappedString
@ssp
ssp / git-extract-file.markdown
Created January 23, 2012 13:21
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

@rdingwall
rdingwall / DynamicJsonDeserializer.cs
Created February 22, 2012 12:22
RestSharp deserialize JSON to dynamic
// ReSharper disable CheckNamespace
namespace RestSharp.Deserializers
// ReSharper restore CheckNamespace
{
public class DynamicJsonDeserializer : IDeserializer
{
public string RootElement { get; set; }
public string Namespace { get; set; }
public string DateFormat { get; set; }
@Kentzo
Kentzo / gist:2271865
Created April 1, 2012 06:00
JTR's implement ion of SHA1 on OpenCL
/* Keep values shared by code and the OpenCL kernels here. This file is
* prepended to the OpenCL kernels during make. */
#define MD4_NUM_KEYS 1024*2048
#define MD4_PLAINTEXT_LENGTH 15
#ifdef MD4
#define PLAINTEXT_LENGTH 15
#endif
@yeban
yeban / jekyll.tag-cloud.rb
Created April 3, 2012 07:36
Flexible, logarithmic distribution, tag cloud for Jekyll.
# Copyright (C) 2011 Anurag Priyam - MIT License
module Jekyll
# Jekyll plugin to generate tag clouds.
#
# The plugin defines a `tag_cloud` tag that is rendered by Liquid into a tag
# cloud:
#
# <div class='cloud'>