This file contains 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
#!/bin/bash | |
set -o errexit -o nounset -o pipefail | |
package=$1 | |
package_dir=$(go list -f '{{.Dir}}' ${package}) | |
pushd ${package_dir} > /dev/null | |
git_root=$(git rev-parse --show-toplevel) | |
pushd ${git_root} > /dev/null |
This file contains 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" | |
"os/exec" | |
"syscall" | |
"time" | |
) | |
func main() { |
This file contains 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
{Heap before time travel invocations=2863 (full 0): | |
par new generation total 26424128K, used 23502462K [0x00007f5be2710000, 0x00007f62e2710000, 0x00007f62e2710000) | |
eden space 23488128K, 100% used [0x00007f5be2710000, 0x00007f617c0b0000, 0x00007f617c0b0000) | |
from space 2936000K, 0% used [0x00007f622f3e0000, 0x00007f62301dfbc8, 0x00007f62e2710000) | |
to space 2936000K, 0% used [0x00007f617c0b0000, 0x00007f617c0b0000, 0x00007f622f3e0000) | |
concurrent mark-sweep generation total 4070400K, used 1401580K [0x00007f62e2710000, 0x00007f63dae10000, 0x00007f63daf10000) | |
concurrent-mark-sweep perm gen total 122880K, used 56338K [0x00007f63daf10000, 0x00007f63e2710000, 0x00007f63e2710000) | |
2012-11-28T06:39:17.165+0000: 50432.440: [GC 50432.440: [ParNew | |
Desired survivor size 1503232000 bytes, new threshold 6 (max 6) | |
- age 1: 62804920 bytes, 62804920 total |
This file contains 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
scala> class Foo extends scala.collection.mutable.Queue[Int] { | |
| | |
| def foo = last0 | |
| } | |
defined class Foo | |
scala> new Foo | |
res0: Foo = () | |
scala> res0.enqueue(1) |
This file contains 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 Module | |
UNITS = %w{second minute hour day week month year solar_year}.map { |s| s.upcase } | |
CONVERSIONS = [1, 60, 60, 24, 7, 30 / 7.0, 365 / 30.0, 31558150 / 31536000.0] | |
def const_missing(name) | |
if name.to_s =~ /^T_([0-9]+)_(#{UNITS.join("|")})S?$/ | |
num = $1.to_i | |
unit = $2 | |
previous_unit_index = UNITS.index(unit) - 1 | |
value = if previous_unit_index < 0 | |
num |
This file contains 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 MemcacheLock | |
class LockTimeout < StandardError; end | |
LOCK_VALUE = "#{Process.pid}#{Time.now.usec}".to_i # not really important right now | |
LOCK_TTL = 40 | |
KEEP_DURATIONS = 100 | |
EXPIRE_DURATION_ESTIMATE = 60 | |
MAX_RETRIES = 20 | |
MAX_RETRY_DELAY = 0.7 | |
def initialize(memcache, default_duration = nil) |
This file contains 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 MergeColumn | |
def initialize(array) | |
@array = array | |
@index = 0 | |
end | |
def value | |
@array[@index] | |
end | |
This file contains 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
int | |
rb_str_hash(str) | |
VALUE str; | |
{ | |
register long len = RSTRING(str)->len; | |
register char *p = RSTRING(str)->ptr; | |
register int key = 0; | |
#if defined(HASH_ELFHASH) | |
register unsigned int g; |
This file contains 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
module Bluepill | |
module ProcessConditions | |
class ProcMemUsage < MemUsage | |
def run(pid) | |
begin | |
total = 0 | |
File.read("/proc/#{pid}/smaps").split("\n").each do |line| | |
line =~ /^(Private)_Dirty: +(\d+)/ | |
if $2 | |
total += $2.to_i |
This file contains 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
module User::Extras | |
# ActiveRecord, at the time of this writing, always writes serialized attributes to the database, even if it hasn't changed. | |
# See http://github.com/rails/rails/commit/992fda16ed662f028700d63a8dcbd1837f1d58ab for the patch that introduced this. | |
# So to get around it, we're going to handle the serialization of the extras hash ourselves. | |
def self.included(klass) | |
klass.class_eval do | |
before_save :serialize_extras_attribute | |
end | |
klass.extend(ClassMethods) |
NewerOlder