Skip to content

Instantly share code, notes, and snippets.

@worace
worace / solo.rb
Created June 4, 2012 03:21
Sample chef solo base file
file_cache_path File.expand_path("../", __FILE__)
cookbook_path File.expand_path("../cookbooks", __FILE__)
json_attribs "https://raw.github.com/gist/2861861/f4a5f4b78f5cd88813151be598a4782bfbbb0ed4/node.json"
recipe_url "https://github.com/worace/chef-repo/blob/master/vim-chef-solo-tar.gz?raw=true"
# tassilo's zsh from http://tsdh.wordpress.com/2007/12/06/my-funky-zsh-prompt/
# stashing this for reference for colors :)
local blue_op="%{$fg[blue]%}[%{$reset_color%}"
local blue_cp="%{$fg[blue]%}]%{$reset_color%}"
local path_p="${blue_op}%~${blue_cp}"
local user_host="${blue_op}%n@%m${blue_cp}"
local ret_status="${blue_op}%?${blue_cp}"
local hist_no="${blue_op}%h${blue_cp}"
local smiley="%(?,%{$fg[green]%}:%)%{$reset_color%},%{$fg[red]%}:(%{$reset_color%})"
PROMPT="╭─${path_p}─${user_host}─${ret_status}─${hist_no}
@worace
worace / memoize.rb
Last active December 30, 2015 04:39
1.9.3-p448 :014 > class MyClass
1.9.3-p448 :015?> def my_config
1.9.3-p448 :016?> @@my_config ||= nil
1.9.3-p448 :017?> end
1.9.3-p448 :018?> def my_config=(setting)
1.9.3-p448 :019?> @@my_config = setting
1.9.3-p448 :020?> end
1.9.3-p448 :021?> end
1.9.3-p448 :022 > config = MyClass.new
=> #<MyClass:0x007faa21080d40>
horacewilliams @ WoracesWorkshop / level1 / master ➸ ruby miner.rb
the content is:
tree 0dcb7aa769718cbded43797b27130f2387335ac6
parent 0000002cb344c4fb2cd6d8d08e4c0f0b4c8bb5ff
author CTF user <me@example.com> 12345 +0000
committer CTF user <me@example.com> 12345 +0000
Give me a Gitcoin
require 'digest/sha1'
class Miner
attr_reader :tree, :parent, :timestamp
def initialize
@tree=`git write-tree`.chomp
@parent=`git rev-parse HEAD`.chomp
@timestamp=12345
prepare_index
end
require 'sinatra'
require 'json'
require 'ruby-prof'
class Index
attr_reader :base_path, :index
def initialize(base_path)
@base_path = base_path
end
def cracklepop(i)
if i % 15 == 0
"CracklePop"
elsif i % 5 == 0
"Pop"
elsif i % 3 == 0
"Crackle"
else
i
end
module TicTacToe
class Application
def run
display_launch_options
end
def display_launch_options
puts "n: New Game"
puts "q: Quit"
selection = gets
@worace
worace / gist:4b1d430db1c7be257023
Created September 15, 2014 04:15
ios error log
2014-09-15 00:13:11.917 troutr-ios[37485:60b] Cannot find executable for CFBundle 0xb76f4e0 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/AccessibilityBundles/GeoServices.axbundle> (not loaded)
2014-09-15 00:13:11.922 troutr-ios[37485:60b] Cannot find executable for CFBundle 0xb64f090 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/AccessibilityBundles/StoreKitFramework.axbundle> (not loaded)
2014-09-15 00:13:11.925 troutr-ios[37485:60b] Cannot find executable for CFBundle 0xb65a190 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/AccessibilityBundles/CertUIFramework.axbundle> (not loaded)
2014-09-15 00:13:11.992 troutr-ios[37485:60b] authentication loadview
2014-09-15 00:13:11.992 troutr-ios[37485:60b] auth view init
2014-09-15 00:13:11.993 troutr-ios[37485:60
@worace
worace / exercise-loops-and-functions.go
Last active August 29, 2015 14:13
Golang Tour Exercises
package main
import (
"fmt"
"math"
)
func guessOutsideDelta(guess, x float64) bool {
delta := .00000000001
return (math.Abs(guess * guess - x) > delta)