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
def replace(path, pattern, replacement) | |
File.open(path, "r+") do |file| | |
contents = file.read | |
file.truncate(0) | |
file.pos = 0 | |
file << contents.gsub(pattern, replacement) | |
end | |
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
#!/usr/bin/env ruby | |
require "date" | |
require "digest/md5" | |
require "erb" | |
require "optparse" | |
require "ostruct" | |
require "shellwords" | |
require "tempfile" |
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
#include <pthread.h> | |
#include <stdio.h> | |
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; | |
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; | |
extern void __wait() { | |
printf("__wait pthread_mutex_lock # => %d\n", pthread_mutex_lock(&mutex)); | |
printf("__wait pthread_cond_wait # => %d\n", pthread_cond_wait(&cond, &mutex)); | |
printf("__wait pthread_mutex_unlock # => %d\n", pthread_mutex_unlock(&mutex)); |
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
$ sudo lsof -p 26564 | |
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME | |
ruby 26564 root cwd DIR 202,1 4096 524302 APP_PATH/releases/20120726200801 | |
ruby 26564 root rtd DIR 202,1 4096 2 / | |
ruby 26564 root txt REG 202,1 7265143 279257 /usr/lib/ruby/1.9.3-p194/bin/ruby | |
ruby 26564 root mem REG 202,1 101192 20884 /lib/x86_64-linux-gnu/libresolv-2.13.so | |
ruby 26564 root mem REG 202,1 31120 20306 /lib/x86_64-linux-gnu/libnss_dns-2.13.so | |
ruby 26564 root mem REG 202,1 88384 3968 /lib/x86_64-linux-gnu/libgcc_s.so.1 | |
ruby 26564 root mem REG 202,1 5920 278994 /usr/lib/ruby/1.9.3-p194/lib/ruby/1.9.1/x86_64-linux/fiber.so | |
ruby 26564 root mem REG 202,1 6120 279010 /usr/lib/ruby/1.9.3-p194/lib/ruby/1.9.1/x86_64-linux/digest/md5.so |
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
D, [2012-07-19T03:46:53.479610 #22645] DEBUG -- : waiting 4.0s after suspend/hibernation | |
I, [2012-07-19T03:46:48.494536 #28377] INFO -- : Rainbows! ThreadPool worker_connections=100 | |
E, [2012-07-19T03:46:47.459752 #22645] ERROR -- : reaped #<Process::Status: pid 22656 SIGKILL (signal 9)> worker=0 | |
E, [2012-07-19T03:46:47.439877 #22645] ERROR -- : worker=0 PID:22656 timeout (7s > 6s), killing | |
D, [2012-07-19T03:45:11.205523 #14678] DEBUG -- : waiting 4.0s after suspend/hibernation | |
I, [2012-07-19T03:45:06.220187 #20041] INFO -- : Rainbows! ThreadPool worker_connections=100 | |
E, [2012-07-19T03:45:05.185902 #14678] ERROR -- : reaped #<Process::Status: pid 14689 SIGKILL (signal 9)> worker=0 | |
E, [2012-07-19T03:45:05.167189 #14678] ERROR -- : worker=0 PID:14689 timeout (7s > 6s), killing | |
D, [2012-07-19T03:42:08.010851 #30981] DEBUG -- : waiting 4.0s after suspend/hibernation | |
I, [2012-07-19T03:42:03.025937 #3666] INFO -- : Rainbows! ThreadPool worker_connections=100 |
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
* json (1.7.3) | |
* kgio (2.7.4) | |
* linecache19 (0.5.12) | |
* mongrel (1.2.0.pre2) | |
* mysql2 (0.2.6) | |
* nokogiri (1.5.5) | |
* raindrops (0.10.0) | |
* unicorn (4.3.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 String | |
def parse_unicode | |
dup.parse_unicode! | |
end | |
def parse_unicode! | |
gsub!(/\\u([0-9a-fA-F]{4})/) { [$1.to_i(16)].pack("U") } | |
end | |
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
method(:foo).to_java.source_location(Thread.current.to_java.getContext()) |
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
require "ffi" | |
class ULLEnum < FFI::Enum | |
def native_type | |
FFI::Type::ULONG_LONG | |
end | |
end | |
class MachMsgHeader < FFI::Struct | |
layout :bits, :uint, :size, :uint, :remote_port, :uint, :local_port, :uint, :reserved, :uint, :id, :int |
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
require "ffi" | |
module GetPass | |
extend FFI::Library | |
ffi_lib "libc" | |
attach_function :getpass, [:string], :string | |
end | |
GetPass.getpass("Prompt: ") # => "secret" |
NewerOlder