Skip to content

Instantly share code, notes, and snippets.

View mikeweber's full-sized avatar

Mike Weber mikeweber

View GitHub Profile
@mikeweber
mikeweber / Astar.ex
Created January 24, 2018 19:14
A-star implementation in Elixir
defmodule Astar do
# When the frontier is empty, we're done
def traverse_graph({[], came_from}, _, _), do: {[], came_from}
# Otherwise get the next lowest scored frontier and visit it
def traverse_graph({frontier, came_from}, graph, target) do
{current_node_name, frontier} = PriorityQueue.get(frontier)
current_node = graph |> Graph.get_node(current_node_name)
visit({frontier, came_from}, graph, target, current_node)
end
@mikeweber
mikeweber / Description
Created April 15, 2014 17:11
Solar system tour at speed of light
Experience our solar system at the speed of light (it's not as exciting as it sounds)
Step 1) Visit http://joshworth.com/dev/pixelspace/pixelspace_solarsystem.html.
Step 2) Open the JS console and paste in the following code.
Step 3) Watch the solar system "fly" by (BTW it'll take more than 5 hours to get to Pluto)
@mikeweber
mikeweber / map_collector.rb
Created July 5, 2012 16:30
Combines all Minecraft map .dat files found in the same directory as the script. TODO: add coord grid system
require 'chunky_png'
require 'nbtfile'
COLOR_MAP = %q{
255,255,255
255,255,255
255,255,255
255,255,255
89,125,39
@mikeweber
mikeweber / gist:2891088
Created June 7, 2012 19:37
inline YAML
YAML::load(%{
hello:
world:
id: 1
value: #{@foo.bar}
everyone_else:
id: 2
value: "Yazoo!"
})
@mikeweber
mikeweber / gist:2148233
Created March 21, 2012 15:14
state testing
let(:state1) {
FactoryGirl.build(:workflow)
}
let(:state2) {
state1.run_step1
state1
}
let(:state3) {
state2.run_step2
state2
@mikeweber
mikeweber / output.png
Created June 27, 2011 17:26
Convert an image to a 10x10 pixelated version
output.png
@mikeweber
mikeweber / update_ip.sh
Created March 25, 2011 04:14
Get your router's IP address and add it to your current ~/.ssh/config file
#!/bin/sh
SNMPKEY="public"
HOMEPATH="/Users/username"
SSH_CONFIG="$HOMEPATH/Dropbox/dotfiles/.ssh/config"
if [ $# = 1 ] ; then
SNMPKEY="$1"
fi
IFS=" "
// To get this code to work, simply add a placeholder attribute to any of your inputs.
// This code requires no-conflict jQuery (var $j = jQuery.noConflict();) and Modernizr.
// Also you should add something similar to the following to your stylesheets.
//
// .placeholder{
// color: #666;
// }
jQuery.fn.set_placeholder = function() {
if ($j(this).attr('placeholder') && ($j(this).val() == '' || $j(this).val() == $j(this).attr('placeholder'))) {
nokogiri_find_header: checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... -------------------- yes
"gcc -E -I. -I/usr/local/lib/ruby/1.8/i686-darwin10.0.0 -I. -I/opt/local/include/ -I/opt/local/include/libxml2 -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE=1 -fno-common -pipe -fno-common -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -I/opt/local/include/ conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <iconv.h>
/* end */
--------------------