Skip to content

Instantly share code, notes, and snippets.

View ready4god2513's full-sized avatar

Brandon Hansen ready4god2513

View GitHub Profile
Array.prototype.alternate = function(other){
var result = [];
this.forEach(function(i){
result.push(i);
if(other.length > 0){
result.push(other.shift());
}
});
class Stack
class UnderFlowError < StandardError;end
def initialize
@stack = []
end
def empty?
@stack.empty?
end
@ready4god2513
ready4god2513 / tictactoe.rb
Created October 3, 2014 22:24
Simple game of tictactoe
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]),
package main
import (
"encoding/json"
"fmt"
)
type Person struct {
Name string `json:"name" xml:"name"`
Gender string `json:"gender" xml:"gender"`
@ready4god2513
ready4god2513 / gist:37800036bd7d36bef288
Last active August 29, 2015 14:06
Longest Palindrome Finder in Ruby
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)
# 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
@ready4god2513
ready4god2513 / pics.sh
Last active August 29, 2015 13:57
Watch Yoself
#! /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
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++)
{
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
@ready4god2513
ready4god2513 / giveaway.rb
Created June 14, 2013 20:55
The winners from the A is for Array 5 book giveaway!
# 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",