Skip to content

Instantly share code, notes, and snippets.

View hauntedhost's full-sized avatar
💭
👻

Jules Omlor hauntedhost

💭
👻
View GitHub Profile
@hauntedhost
hauntedhost / fizzbuzz.rb
Last active October 13, 2015 22:28
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
def fizz_buzz(rounds)
1.upto(rounds) do |num|
phrase = { fizz: 3, buzz: 5 }.select { |key, m| (num % m).zero? }.keys.join
puts phrase.empty? ? num : phrase
end
end
@hauntedhost
hauntedhost / raisin.js
Last active December 16, 2015 14:09
wordpress soundclip player for "raisin" the dog
<script type="text/javascript">
jQuery(document).ready(function(){
// soundclip player
<?php
$raisin_id = get_latest_raisin_id();
$mp3_id = get_post_meta($raisin_id, "raisin_mp3_id", true);
$mp3_url = wp_get_attachment_url($mp3_id);
$ogg_id = get_post_meta($raisin_id, "raisin_ogg_id", true);
$ogg_url = wp_get_attachment_url($ogg_id);
@hauntedhost
hauntedhost / nearest_larger.rb
Created April 28, 2013 07:17
nearest_larger
def left_match(arr, idx)
num = arr[idx]
unless idx.zero?
(idx - 1).downto(0) do |i|
return i if arr[i] > num
end
end
nil
end
@hauntedhost
hauntedhost / nearest_larger.rb
Created April 28, 2013 07:41
nearest_larger
def nearest_larger(arr, idx)
diff = 1
loop do
left = idx - diff
right = idx + diff
diff += 1
if (left >= 0) && (arr[left] > arr[idx])
return left
elsif (right < arr.length) && (arr[right] > arr[idx])
@hauntedhost
hauntedhost / solarized_dark.terminal
Created May 18, 2013 23:45
solarized_dark.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECgw
LjE1NjE5MDIxMDUgMC4wMTk1OTcyNTAxNSAwLjEzOTY3MzE4NjEAEAGAAtIQERITWiRj
bGFzc25hbWVYJGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNo
{
"font_size": 20,
"date_format": "(%Y-%m-%d %H:%M)",
"color_scheme": "Packages/PlainTasks/tasks-monokai.hidden-tmTheme"
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>MSL</string>
<!-- based on Monokai Soda -->
<key>settings</key>
<array>
<dict>
// Write a function to get the common letters out of two strings
// commonLetters('hello world', 'hello moon') => should return 'helo'
function commonLetters(str1, str2) {
var map = {},
common = '';
for (var i = 0; i < str1.length; i++) {
var letter = str1[i];
if (letter != ' ') map[letter] = true;
@hauntedhost
hauntedhost / jasmine-spy-cheatsheet.js
Created October 18, 2013 17:12
jasmine spy cheatsheet
//= require jquery
//= require track-events
describe('TrackEvents', function () {
beforeEach(function () {
loadFixtures('track-events_fixture');
});
it('triggers a Test.fire', function() {
Test = function () { }
# Build a function morse_encode that takes in a word (no numbers or
# punctuation) and outputs the morse code for it. Put two spaces between
# words and one space between letters.
# http://www.w1wc.com/pdf_files/international_morse_code.pdf
def morse_encode(str)
morse_codes = { a: ".-", b: "-...", c: "-.-.", d: "-..", e: ".", f: "..-.",
g: "--.", h: "....", i: "..", j: ".---", k: "-.-", l: ".-..",
m: "--", n: "-.", o: "---", p: ".--.", q: "--.-", r: ".-.",
s: "...", t: "-", u: "..-", v: "...-", w: ".--", x: "-..-",