Skip to content

Instantly share code, notes, and snippets.

View ninjapanzer's full-sized avatar
🌋
Back to the FOSS

Paul Scarrone ninjapanzer

🌋
Back to the FOSS
View GitHub Profile
namespace :db do
require 'uri'
desc "Uses heroku:config for APP to forcefully create ~/.pgpass"
task :create_pgpass do
app = ENV['APP'] || 'whatever-your-default-app-is'
uri = URI(`heroku config:get DATABASE_URL -a #{app}`)
entry = "*:5432:#{uri.path.gsub /\//, ''}:#{uri.user}:#{uri.password}"
`echo '#{entry}' > ~/.pgpass; chmod 0600 ~/.pgpass`
end
@ninjapanzer
ninjapanzer / mergsort_coursera_algo
Last active December 11, 2015 23:18
Merge Sort with so Debugging Statements I pulled this from the web somewhere but I don't remember the URL and made some modifications
a = [5,4,1,8,7,2,6,3,5,2,3,45,1,1,3,4,99,2,3]
puts a.size
@recurse = 0
def mergesort(list)
return list if list.size <= 1
mid = list.size / 2
left = list[0, mid]
right = list[mid, list.size]
@recurse = @recurse + 1
@ninjapanzer
ninjapanzer / WordCounters
Created February 28, 2013 20:04
A toy that sums up a string
class WordCounters
def self.count_up_word word
count = 0
word.each_char do |l|
count = l.ord + count
end
count
end
@ninjapanzer
ninjapanzer / lexer.ex
Created February 28, 2013 20:04 — forked from swarley/lexer.ex
defmodule Lexer do
defmodule PIR do
require LexChar
defmacrop line(opts) do
quote do: elem(unquote(opts),1)
end
defmacrop file(opts) do
quote do: elem(unquote(opts),2)
end
@ninjapanzer
ninjapanzer / frame.html
Last active December 14, 2015 12:18
Some cross browser iframe testing for responsive iframes. All vanilla JS and some simple styles
FRAME
@ninjapanzer
ninjapanzer / gist:5693920
Last active December 18, 2015 00:08
MIT will make me broke and I am not even a student
Algorithms Unlocked
Thomas H. Cormen
ISBN: 9780262518802
Machine Learning
Kevin P. Murphy
ISBN: 9780262018029
Introduction to Machine Learning, second edition
Ethem Alpaydin
@ninjapanzer
ninjapanzer / gist:6023103
Created July 17, 2013 18:26
Nice console snipet
if (typeof(console) !== 'undefined') {
if ('debug' in console) {
console.debug('Hey, you have your debugger enabled :)');
} else {
console.log('Hey, you have your IE debugger enabled :-/');
}
} else {
var Console = Class.create();
Console.prototype = {
initialize: function() {},
@ninjapanzer
ninjapanzer / gist:6205619
Last active December 20, 2015 22:29
Ruby Warrior Level 9 Works for levels 8 and 9 - Does a pass to see if the warrior is between enemies an then goes to work
class Player
def init(warrior)
@warrior = warrior
@low_side ||= 10
@current_direction ||= :forward
@backsteps ||= 0
@skip ||= false
@turn_count ||= 0
@ninjapanzer
ninjapanzer / ruby_warrior_respond_to.rb
Created August 12, 2013 13:07
respond_to? ruby warrior rewrite
class Player
def init(warrior)
@warrior = warrior
@low_side ||= 10
@current_direction ||= :forward
@backsteps ||= 0
@skip ||= false
@turn_count ||= 0
@health ||= 20
@ninjapanzer
ninjapanzer / gist:6550440
Created September 13, 2013 13:06
Rortated headers 45degrees
&.rotated{
tr{
& th:first-child div{
width: 100%;
}
background: transparent;
height: 80px;
&.ie{
background: lighten($body_text_color, 60%);
height: 20px;