Skip to content

Instantly share code, notes, and snippets.

View mharris717's full-sized avatar

Mike Harris mharris717

View GitHub Profile
require 'mharris_ext'
#CONTAINER_ID=$(docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done") && echo $CONTAINER_ID
module Docker
class Instance
include FromHash
fattr(:commands) { [] }
attr_accessor :container_id
@mharris717
mharris717 / gist:5468236
Created April 26, 2013 15:44
Docker - vagrant up error
unknown14109fe8fee8:docker mharris717$ git checkout -b 0.2 v0.2.0
Switched to a new branch '0.2'
unknown14109fe8fee8:docker mharris717$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
@mharris717
mharris717 / Gemfile
Last active February 2, 2016 04:07
Minimal Pagination Example (Rails + Ember)
ruby '1.9.3'
source 'https://rubygems.org'
gem 'rails', '3.2.13'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
@mharris717
mharris717 / eak.rb
Created October 16, 2013 16:12
EAK Gen
MultiGen.register do |d|
d.project :eak do |p|
p.compound :model do |c|
c.model do |m|
m.file "app/models/NAME.coffee"
m.body "CAMEL_NAME = DS.Model.extend()\n\n`export default CAMEL_NAME`"
end
c.test do |s|
s.file "tests/unit/NAME_test.coffee"
@mharris717
mharris717 / follow_testing.rb
Created October 31, 2013 20:44
Follow Testing
require 'json'
require 'open-uri'
url = "http://letsrevolutionizetesting.com/challenge.json"
loop do
payload = JSON.parse(open(url).read)
url = payload["follow"]
puts url
url = url.gsub("/challenge","/challenge.json")
@mharris717
mharris717 / number_pairs.rb
Created December 5, 2013 23:47
Rainforest Tech Screen Code
sample_data = [0, 1, 100, 99, 0, 10, 90, 30, 55, 33, 55, 75, 50, 51, 49, 50, 51, 49, 51]
def get_matching_pairs(data)
result_pairs = []
count_hash = Hash.new { |h,k| h[k] = 0 }
data.each do |num|
count_hash[num] += 1
end
@mharris717
mharris717 / server_setup.sh
Last active February 2, 2016 04:49
server setup
# Deps for Full
set -e
echo "deb http://archive.ubuntu.com/ubuntu precise main universe" | sudo tee -a /etc/apt/sources.list
sudo apt-get update -y
# Deps for utll
sudo apt-get install -y libxslt-dev
sudo apt-get install -y libxml2-dev
sudo apt-get install -y libssl-dev
sudo apt-get install -y zlib1g-dev
load "lib/baseball_lottery.rb"
MGC.connect! :production
def big_hash
res = {}
(1..100).each do |i|
res[i] = {}
50.times do
res[i][rand(100000000000)] = rand(1000000000000).to_s
end
@mharris717
mharris717 / ufc.R
Created October 13, 2014 17:17
Parse UFC
library(rvest)
page <- html("http://www.sherdog.com/events/UFC-Fight-Night-MacDonald-vs-Saffiedine-35509")
rows <- page %>%
html_nodes("tr[itemprop=subEvent]")
for (row in rows) {
names <- row %>%
html_nodes("span[itemprop=name]") %>%
html_text()
@mharris717
mharris717 / Kill-The-Loop-Man.R
Created October 16, 2014 21:31
We must kill the Loop .... Man.
# pretending to fetch HTML
getBody <- function(url) {
if (url == "http://garbage.broken") return(0)
else return(paste("this is the html for ",url))
}
sites.names <- c("Google","ESPN","Garbage","ROK")
sites.urls <- c("http://google.com","http://espn.com","http://garbage.broken","http://returnofkings.com")
sites.df <- data.frame(Name=sites.names, Url=sites.urls, stringsAsFactors=FALSE)