Skip to content

Instantly share code, notes, and snippets.

@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 24, 2025 17:21
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add [email protected]:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@wcharczuk
wcharczuk / numpy.cs
Created October 24, 2012 20:20
Implementation of LogSpace and LinSpace from Numpy for C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace libSVM
{
public static class Numpy
{
public static IEnumerable<double> Arange(double start, int count)
@alanstevens
alanstevens / newgemset.sh
Last active September 28, 2015 21:39
A shell script for creating a new gemset. The default gemset name is the current working directory but there is an optional parameter for creating a custom gemset name
#!/usr/bin/env bash
readonly rubyversion="1.9.3"
# Source RVM as a function into local environment.
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
@jakejscott
jakejscott / MongoCache.cs
Created October 5, 2011 15:01
Lightspeed ORM second level cache using MongoDB (Doesn't support expirying items yet..todo)
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Loot.Logging;
using Mindscape.LightSpeed.Caching;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
namespace Loot
{
@ismasan
ismasan / phantom_js_url_cycle.js
Created May 15, 2011 15:24
Super easy web screen scraping with Phantom.js. Screenshots example.
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Cycle array of URLs and process with phantom.js (http://www.phantomjs.org/)
Adds Array.prototype.forEachWebPage() iterator.
EXAMPLE:
Save screenshots. Command line:
phantomjs phantom_js_url_cycle.js ./screenshots
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[
@dauger
dauger / IListOfTExtensions.cs
Created January 19, 2011 21:37
Extension method to determine if a list is ordered asc
public static class IListOfTExtensions
{
public static bool IsOrdered<T, T2>(this IList<T> @this, Func<T, T2> orderedOnProperty)
where T2 : IComparable<T2>
{
var isLessThanOrEqualTo = true;
for (int i = 1; i < @this.Count; i++)
{
var comparer = Comparer<T2>.Default;
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end