Skip to content

Instantly share code, notes, and snippets.

View unplugandplay's full-sized avatar
💫

unplugandplay unplugandplay

💫
View GitHub Profile
@chrishamant
chrishamant / gist:1168189
Created August 24, 2011 14:28
A* pathfinding
/**
* A* (A-Star) Pathfinding Algorithm in JavaScript
* @author Matthew Trost
* @license Creative Commons Attribution-ShareAlike 3.0 Unported License
* @datepublished December 2010
*/
function astar (map, heuristic, cutCorners) {
var listOpen = [];
var listClosed = [];
@eclubb
eclubb / sqlite2pg.sh
Created March 30, 2012 17:20
Script to import SQLite3 database into PostgreSQL
#!/bin/sh
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
SQLITE_DB_PATH=$1
PG_DB_NAME=$2
PG_USER_NAME=$3
@peterc
peterc / msqq.rb
Created May 3, 2012 02:52
Sys V message queues in Ruby on OS X (take one)
# Lightweight library to access the System V message queue functionality on Mac OS X (32 and 64 bit)
# Still quite scrappy and needs to be packaged up properly but.. it works!
require 'fiddle'
class MsgQ
LIBC = DL.dlopen('libc.dylib')
IPC_CREAT = 001000
IPC_EXCL = 002000
@sandys
sandys / table_to_csv.rb
Created October 18, 2012 10:04
convert a html table to CSV using ruby
# run using ```rvm jruby-1.6.7 do jruby "-J-Xmx2000m" "--1.9" tej.rb```
require 'rubygems'
require 'nokogiri'
require 'csv'
f = File.open("/tmp/preview.html")
doc = Nokogiri::HTML(f)
csv = CSV.open("/tmp/output.csv", 'w',{:col_sep => ",", :quote_char => '\'', :force_quotes => true})
@tpitale
tpitale / reel_ws_pg_example.rb
Last active March 23, 2017 13:03
Reel Websocket Server using PG Listen/Notify for crude pubsub
require 'rubygems'
require 'bundler/setup'
require 'reel'
require 'celluloid/io'
require 'pg'
module PGNotifications
def self.included(actor)
actor.send(:include, Celluloid::IO)
end
@mbostock
mbostock / .block
Last active November 25, 2019 01:17
Milky Way
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/raster-reprojection
@mbostock
mbostock / .block
Last active March 23, 2018 08:45
Dynamic Hexbin
license: gpl-3.0
@mbostock
mbostock / .block
Last active March 23, 2018 08:45
Phyllotaxis
license: gpl-3.0
@stevenyap
stevenyap / repl-with-pry.md
Created June 20, 2014 10:21
REPL-driven development in Ruby
gem 'pry'
@REPOmAN2v2
REPOmAN2v2 / gist:c3ab203e7cbf2fd2fa47
Created October 24, 2014 19:15
Text input example in SDL
/*
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely.