Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 ( | |
| "fmt" | |
| "log" | |
| "net" | |
| "sync" | |
| "time" | |
| "strings" | |
| "runtime" |
This file contains hidden or 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
| =begin | |
| 3,5,2,7,1 | |
| 3 | |
| 2 5 | |
| 1 7 | |
| =end |
This file contains hidden or 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
| context 'performance' do | |
| before do | |
| require 'benchmark' | |
| @posts = [] | |
| @users = [] | |
| 8.times do |n| | |
| user = Factory.create(:user) | |
| @users << user | |
| aspect = user.aspects.create(:name => 'people') | |
| connect_users(@user, @aspect0, user, aspect) |
This file contains hidden or 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 Player | |
| def initialize | |
| @max_health = 20 | |
| @last_health = @max_health | |
| @taking_damage = false | |
| @directions = [:backward, :forward] | |
| @current_direction = :forward | |
| @reached_wall = false | |
| end | |
This file contains hidden or 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
| # http://zookeeper.apache.org/doc/r3.3.4/recipes.html#sc_leaderElection | |
| require 'rubygems' | |
| require 'bundler/setup' | |
| require 'zookeeper' | |
| require 'hashie' | |
| class ElectionCandidate | |
| ROOT_PATH = "/election" | |
| NODE_PATH = "candidate_" |
This file contains hidden or 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
| new File("/tmp/java_timezones.txt").withWriter { out -> | |
| TimeZone.getAvailableIDs().each{ timezoneId -> | |
| timezone = TimeZone.getTimeZone(timezoneId) | |
| def items = [timezone.getID(), | |
| (int)(timezone.getRawOffset()/1000), | |
| (int)(timezone.getDSTSavings()/1000)] | |
| out.print sprintf("%6d %32s %6d\n",items[1],items[0],items[2]) | |
| } | |
| } |
This file contains hidden or 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
| sudo tcpdump -w /tmp/memcached.pcap -i any -A -vv 'port 11211' |
This file contains hidden or 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
| # can probably cross reference with ltrace | |
| # this removes shared libraries from the total memory count | |
| def memory_estimate(pid) | |
| `sudo pmap #{pid}`.lines.reject{|line| | |
| line[%r[/lib[^.]+\.so]] or line[/^ total/] | |
| }.drop(1).reduce(0){|total,line| | |
| total + line.match(/(\d+)K/)[1].to_i | |
| } | |
| end |
This file contains hidden or 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
| -- Read: http://en.wikipedia.org/wiki/Graham_scan | |
| -- ================================================ -- | |
| -- =========== Definitions/Imports ============== -- | |
| -- ================================================ -- | |
| import Data.List | |
| -- ch03/ex09.hs | |
| data Direction = LeftTurn | RightTurn | Straight deriving (Show,Eq) | |
| data Point2D = Point2D {x :: Double, y :: Double} deriving (Show,Ord,Eq) |