Skip to content

Instantly share code, notes, and snippets.

@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

helpers do
def body(arg = nil)
arg &&= arg.to_json
super(arg)
end
end
@numberwhun
numberwhun / gist:1399592
Created November 28, 2011 08:20
Project Ideas for class
I actually found this on a college programming course site. Its a list of ideas for the class to draw from for project ideas.
###################################################################3
Ideas for the class project
Here are some rough notes that may be useful for deciding on a topic for the class project. You should treat the following as starting points for further discussion and development, not as canned project suggestions (which you can find elsewhere). In particular, the following are not intended to serve as replacements for discussing project ideas and plans (among project team members and with the instructor and TA).
Note that some of these are too simple for a project and others may be too complex. Treat the following merely as a collection of ideas from which you can pick some you like, combining them to get a project that both interests you and is sufficiently challenging from a technical viewpoint. You are encouraged to stop by during office hours to discuss any of the following that
@tecoholic
tecoholic / .vimrc
Last active April 19, 2016 04:11
My Vim Setup
"" Vim, not Vi.
" This must be first, because it changes other options as a side effect.
set nocompatible
filetype off
"" General Settings
" Enable syntax highlighting.
syntax on
" Line endings should be Unix-style unless the file is from someone else.
@ralph
ralph / github-flavored-markdown.rb
Created October 20, 2011 11:39
Markdown Processor for Redcarpet version 2, for usage on the command line, in Marked etc. Supports syntax highlighting via Pygments.
#!/usr/bin/env ruby
# Processor for Github flavored markdown, inspired by:
# https://github.com/alampros/Docter/blob/master/bin/github-flavored-markdown.rb
#
# Current version of this script can be found here:
# https://gist.github.com/1300939
#
# Adapted for Redcarpet version 2 by Ralph von der Heyden
# http://github.com/ralph
# http://twitter.com/ralph
@dkubb
dkubb / .rvmrc
Created August 10, 2011 22:44
Web framework Spike
rvm use @$(basename `pwd`) --create
@dkubb
dkubb / gist:1130086
Created August 7, 2011 05:21 — forked from flazz/gist:838163
case with predicates
require 'rubygems'
require 'backports' # aliases Proc#=== to Proc#call
rs = (0..10000).to_a.sample(30)
rs.each do |r|
case r
when lambda { |n| n.zero? } then puts "#{r} is zero"
when lambda { |n| (n % 5).zero? } then puts "#{r} is fiven"
when lambda { |n| (n % 4).zero? } then puts "#{r} is fourven"
@sbp
sbp / data.js
Created July 26, 2011 15:30
jQuery to add "Download" links to PRE and XMP elements
// Download Preformatted Sections
function makeDownloadable() {
// Iconza by Turbolink, Creative Commons BY 3.0 Unported
// http://www.softicons.com/free-icons/designers/turbomilk
var png = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABxVBMVEUAAACFhYaBgYGHh4iHiImLjI2Gh4eGhodbW1xqa2toaGlpampVVVdhYWJTU1RmZmf///+JiYmkpKR8fHysrKyYmJiHh4e2trZmZmaRkZGIiIiTk5OKiopQUVKDhIZ+fn7ExMTGxsbMzMxhYWFkZGSCgoSGhoaurq5oaGhsbGxubm7JycmAgIJPT1CFhojq6uq+vr6cnJzh4eG1tbWUlJS8vLzn5+eenp69vb1nZ2dlZWXT09Ozs7PAwMCoqKrR0dHPz8/Ozs7i4uLCwsLBwcHZ2dnU1NS3t7eqqqp+f4CmpqaoqKjt7e3Hx8eVlZV7fH58fX6ampqZmZmdnZ3o6Ojl5eXk5OTf39/e3t50dXfd3d2Pj4+NjY2Li4uhoqOOjo6HiIrb29va2tp6enp3d3dub3BwcXOioqKBgYGFhYXv7+/IyMj5+fliYmLKystgYGBwcHBpaWpra21zc3NycnJcXFyQkJBhYmNlZWZtbW3Ly8xcXV6jo6Nra2u/v793eHpjY2N2dnaCg4OLjI7g4OBmZmeCgoLLy8u5ubmEhIRfX2Dc3NzW1tbKysqxsbFPT1Gvr69NTk9NTU9NTk5NTU7m5ua7u7tu8VCdAAAAEHRSTlMAnxe99/evvfC1qKf4+PGpMlfdYgAAAPdJREFUGBlFwYNuRAEQAMCt3e6zz7ZZ27Zt27b9vW2aSzoDySkX/9LSATKKfV9d3eW+y57e/ofH4SQYHRuvjpeUlplp+4JWt
@mattheworiordan
mattheworiordan / rate_limit.js
Created July 15, 2011 14:49
Rate limiting function calls with JavaScript and Underscore.js
/* Extend the Underscore object with the following methods */
// Rate limit ensures a function is never called more than every [rate]ms
// Unlike underscore's _.throttle function, function calls are queued so that
// requests are never lost and simply deferred until some other time
//
// Parameters
// * func - function to rate limit
// * rate - minimum time to wait between function calls
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request
@vorushin
vorushin / jquery-csrf.js
Created June 24, 2011 08:51
Small jQuery plugin for adding csrf-token to Ajax/Ajaj requests
$.ajaxSetup({
beforeSend: function(xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {