This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.alternate = function(other){ | |
var result = []; | |
this.forEach(function(i){ | |
result.push(i); | |
if(other.length > 0){ | |
result.push(other.shift()); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack | |
class UnderFlowError < StandardError;end | |
def initialize | |
@stack = [] | |
end | |
def empty? | |
@stack.empty? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'set' | |
class TicTacToe | |
WINNING_LINES = [ | |
Set.new([0, 1, 2]), | |
Set.new([0, 3, 6]), | |
Set.new([0, 4, 8]), | |
Set.new([1, 4, 7]), | |
Set.new([2, 5, 8]), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
type Person struct { | |
Name string `json:"name" xml:"name"` | |
Gender string `json:"gender" xml:"gender"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def longest_palind(s) | |
# First find all palindromes. The way we can do | |
# this is to scan through the letters searching for | |
# the middle. We can find the middle by detecting a letter | |
# that meets one of two criteria- has the same letter before and after it, | |
# or is the same letter. Once we have found that it is a palindrome, | |
# continue to expand the search finding the length. Once we have the length | |
# extract the string and append to the array. Sort the array by the longest | |
# and shift. | |
all_pals = pals_in_str(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given an array_of_ints, find the highest_product you can get from three of the integers. | |
# The input array_of_ints will always have at least three integers. | |
def highest_product(arr) | |
highest = arr[0] | |
lowest = arr[0] | |
# This just set the absolute baseline to work with. | |
# Grab the first (n) elements and multiply them. Then as we walk through continue to look for | |
# higher numbers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# usage - ./pics.sh dir sleep-len | |
command -v brew >/dev/null 2>&1 || { exit 1; } | |
command -v imagesnap >/dev/null 2>&1 || { brew install imagesnap; } | |
while :; do | |
imagesnap $1/$(date +%y%m%d%H%M%S).png | |
sleep $2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nameInString(name, text) | |
{ | |
var myName = name.toLowerCase(); // Lower case so we don't have to worry about case sensitivity | |
var text = text.toLowerCase(); // Lower case so we don't have to worry about case sensitivity | |
var nameLen = myName.length; // Assign to variable so we don't have to keep checking | |
var hits = []; | |
var found = false; | |
for(i = 0; i < text.length; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stdClass Object | |
( | |
[id] => 16250400 | |
[id_str] => 16250400 | |
[name] => jesusculture | |
[screen_name] => jesusculture | |
[location] => Sacramento, CA | |
[description] => a ministry to ignite revival in the nations of the earth. | |
[url] => http://t.co/YseR3v8K0j | |
[entities] => stdClass Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add all of our contestants to an array. | |
# We will assign the array to a variable called contestants | |
# A variable lets us access the array later. | |
contestants = [ | |
"Krystyna Marie Wood", | |
"Wissam Ali-Ahmad", | |
"Adrian Brightmoore", | |
"Diana Hall", | |
"Jonathan Zee", | |
"Todd Guerra", |
NewerOlder