Skip to content

Instantly share code, notes, and snippets.

View nathankleyn's full-sized avatar
👨‍💻
Creating!

Nathan Kleyn nathankleyn

👨‍💻
Creating!
View GitHub Profile
#!/usr/bin/env ruby
# Made by Pieter de Bie <frimmirf@gmail.com>
# Based on a "Pastie" task by someone
require "tempfile"
GIST_URL = 'http://gist.github.com/gists'
GIST_LOGIN_URL = 'https://gist.github.com/session'
USERNAME = "pieter"
TOKEN = "SweetTokenPower"
@nooodl
nooodl / futoshiki.lhs
Last active August 29, 2015 14:05
Literate Futoshiki solver
Introduction
============
Futoshiki (不等式, meaning “inequality”) is a Japanese logic puzzle similar to
Sudoku and the like. Numbers from 1 to n must be placed on an n-by-n grid
(which usually already contains some values) such that each row and each column
is a permutation of `[1..n]`. Additionally, less-than or greater-than signs are
placed between cells, constraining their mutual ordering.
An example puzzle looks like this:
@redoPop
redoPop / jquery.loadshiv.js
Created December 10, 2010 05:35
Replacement jQuery.load() for use with innerShiv
// jQuery plugin based on .load() for use with innerShiv
// http://jdbartlett.github.com/innershiv for more info
// $('selector').loadShiv('example.html selector');
jQuery.fn.loadShiv = function (url, params, callback) {
var off, selector, self, type;
if (!this.length || typeof url !== 'string') {
return this;
}
@polotek
polotek / underscore_deep_extend.js
Created January 1, 2011 20:38
A version of underscore extend method that does deep copy with own properties
_.extend = function(target) {
var i = 1, length = arguments.length, source;
for ( ; i < length; i++ ) {
// Only deal with defined values
if ( (source = arguments[i]) !== undefined ) {
Object.getOwnPropertyNames(source).forEach(function(k){
var d = Object.getOwnPropertyDescriptor(source, k) || {value:source[k]};
if (d.get) {
target.__defineGetter__(k, d.get);
if (d.set) target.__defineSetter__(k, d.set);
@lynaghk
lynaghk / create_db.rb
Created June 17, 2011 17:39
Create UK University Stats Database
#!/usr/bin/env ruby
#
# Copyright Keming Labs 2011
# But you can use it under the MIT license. Yay!
# See our visualization of these data here:
#
# http://keminglabs.com/ukuni/
#
# This script imports data from UCAS
#
@durran
durran / moped.txt
Created February 16, 2012 10:59
First run perf numbers, Moped.
##################################################################
# ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]
# 10gen: mongo-1.5.2
# bson-1.5.2 (BSON::BSON_C)
##################################################################
user system total real
10gen: insert 10,000 blank documents 0.670000 0.060000 0.730000 ( 0.744400)
10gen: insert 10,000 blank documents safe mode 1.200000 0.140000 1.340000 ( 1.800714)
10gen: insert 1,000 normal documents 0.090000 0.010000 0.100000 ( 0.091035)
@MrJoy
MrJoy / git_ls_files.rb
Created October 10, 2012 22:42
A VERY partial implementation of .gitignore semantics in Ruby...
#!/usr/bin/env ruby
require 'set'
# This code is meant to demonstrate the difficulty of actually applying .gitignore semantics manually. It supports a key subset of .gitignore
# behaviors, including:
# * Anchored and unanchored patterns/globs.
# * Un-ignoring of patterns/globs, with the same quirky semantics as git.
# * Escaping a leading hash in a pattern.
# * User-wide exclusion list.
# * Top-of-repo .gitignore.
@slojo404
slojo404 / index.html
Created April 18, 2012 20:20 — forked from bunkat/index.html
Timeline using d3.js
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Chronological Diagram of Asia</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style type="text/css">
.chart {
shape-rendering: crispEdges;
}
@wilmoore
wilmoore / sass_and_less_compared.markdown
Created February 10, 2011 06:17 — forked from chriseppstein/sass_and_less_compared.markdown
Sass/Less Comparison (updated 2011-02-09) -- thanks to chriseppstein for starting this

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For less, I'm using the ruby version because this is what they suggest on the website. The javascript version may be different.

Variables

@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests