Skip to content

Instantly share code, notes, and snippets.

@styliii
styliii / stack_trace
Created August 16, 2013 23:35
stack trace for error adding chef-hipchat cookbook
[2013-08-16T23:33:35+00:00] DEBUG: Gem::InstallError: ruby_block[Compile Custom OpsWorks Run List] (opsworks_custom_cookbooks::execute line 3) had an error: Gem::InstallError: chef_gem[hipchat] (hipchat::default line 1) had an error: Gem::InstallError: httparty requires multi_xml (>= 0.5.2)
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:232:in `ensure_dependency'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:408:in `ensure_dependencies_met'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:407:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:407:in `ensure_dependencies_met'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:158:in `install'
/usr/lib/ruby/vendor_ruby/rubygems/dependency_installer.rb:297:in `install'
/usr/lib/ruby/1.8/fileutils.rb:243:in `each_with_index'
/usr/lib/ruby/vendor_ruby/rubygems/dependency_installer.rb:270:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/dependency_installer.rb:270:in `each_with_index'
@styliii
styliii / default.rb
Created July 17, 2013 22:25
redis recipe for cookbook
package "python-software-properties" do
action :install
end
execute "redis ppa install" do
command "/usr/bin/add-apt-repository ppa:chris-lea/redis-server"
command "/usr/bin/apt-get -y update"
action :run
end
@styliii
styliii / jquery.stop
Last active December 12, 2015 06:48
for chhay
$('a.cne-google').on('mouseenter', function() {
$('div#cne-google-tooltip').fadeIn();
})
$('#cne-google').mouseleave( function() {
$('#cne-google-tooltip').delay(1000).fadeOut("slow");
})
$('#cne-google-tooltip').mouseenter(function(){
$('a.cne-google').stop();
@styliii
styliii / SortAge.rb
Created December 29, 2012 00:06
Interview Question
# Given an array of objects with people's name and age
# sort this array based on a person's age
# for a given age, do not change the order of the original array
people = [
{:name => "Jake", :age => 33},
{:name => "Larry", :age => 31},
{:name => "Chhay", :age => 33},
{:name => "Li", :age => 29},
{:name => "Li2", :age => 32},
@styliii
styliii / leaderboard.js
Created December 28, 2012 02:11
JS file to my leaderboard app
// Set up a collection to contain player information. On the server,
// it is backed by a MongoDB collection named "players".
Players = new Meteor.Collection("players");
var randomScore = function() {
return Math.floor(Math.random()*10)*5;
}
if (Meteor.isClient) {
Template.leaderboard.players = function () {
@styliii
styliii / shipping.rb
Created December 20, 2012 04:12
mock code interview example
require 'yaml'
file_data = YAML.load_file('shipping.yaml')
class ShippingData
def initialize(attr={})
@sd_data = attr
end
@styliii
styliii / git-completion.bash
Created December 3, 2012 15:03
git completion
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@styliii
styliii / test_example
Created November 6, 2012 20:15
test example
# 11.6.12
# Jack Dorsey - creator of Twitter
# gem 'rspec'
# bundle
# rails g rspec: install
# in spec, create new folder, models
# rails g test_unit: model Song #=> didn't work as expected
# create songs_spec.rb
@styliii
styliii / jukebox.rb
Created October 18, 2012 05:22
JukeBox Challenge
class JukeBox
# attr_accessor :request
@@songs = [
"The Phoenix - 1901",
"Tokyo Police Club - Wait Up",
"Sufjan Stevens - Too Much",
"The Naked and the Famous - Young Blood",
"(Far From) Home - Tiga",
"The Cults - Abducted",
"The Phoenix - Consolation Prizes"
@styliii
styliii / song_library.rb
Created October 17, 2012 19:55
Solutions to Song Library mini
def assert_equal(actual, expected)
if expected == actual
puts 'pass'
else
puts "fail: expected #{expected}, got #{actual}"
end
end
def assert(statement)
if statement