Skip to content

Instantly share code, notes, and snippets.

files = (Dir["{app,config,db/migrate,lib,test}/**/*.rb"] + Dir['app/views/**/*.{rhtml,rxml,erb,builder,haml}']).sort
files -= ['config/boot.rb']
for a, b in list
unless b['found'].empty?
# ...
end
end
def word_wrap(line_width = 78)
require 'pty'
require 'expect'
require 'hec_getopts'
# Global variables
$expect_verbose = true # Writes all characters read from the I/O
stram to STDOUT.
class MyExpect
def initialize(switch='cisco1')
test_jruby$ cat test4.rb
require 'benchmark'
def rb_test1(a,b) return a+b end
Benchmark.bm do |x|
x.report("ruby") { for i in 1..10000000 do rb_test1(1,2) end }
end
test_jruby$ ruby test4.rb
user system total real
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
#include <stdio.h>
int main(int argc, char const *argv[]){
int i=1;
for(;i<argc; ++i){
if (argv[i][1] == '\0'){
char t = (tolower(argv[i][0])-'a'+1);
if (t>0 && t<='z')
printf("%s = %d\n", argv[i], t);
}
}
➜ ~ sudo gem install rails
Successfully installed activesupport-3.0.0
Successfully installed activemodel-3.0.0
Successfully installed rack-mount-0.6.12
Successfully installed tzinfo-0.3.23
Successfully installed actionpack-3.0.0
Successfully installed arel-1.0.1
Successfully installed activerecord-3.0.0
Successfully installed activeresource-3.0.0
Successfully installed actionmailer-3.0.0
➜ test cat brew_upgrade_log.txt | sed 's:.*in ::g' | grep minutes | awk '{print $1, "* 60"}' | bc | sed 's:\.0::g'
198
168
258
120
➜ test cat brew_upgrade_log.txt | sed 's:.*in ::g' | grep minutes | awk '{print $1, "* 60"}' | bc | sed 's:\.0::g' | pbcopy
➜ test echo "82 + 66 + 5 + 2 + 21 + 51 + 2 + 2 + 38 + 31 + 14 + 45 + 21 + 198 + 168 + 258 + 120" | bc
1124
➜ test echo "(82 + 66 + 5 + 2 + 21 + 51 + 2 + 2 + 38 + 31 + 14 + 45 + 21 + 198 + 168 + 258 + 120) / 60" | bc
18
# trajanje `brew upgrade`-a
(grep "built in" in.txt | sed 's:.*in ::g' | tee >(echo ---) >(grep minutes | awk '{print $1, "* 60"}' | bc | sed 's:\.0::g') >(grep seconds | awk '{print $1}' | bc) ) | awk 'BEGIN{total=0}; {total += $1} END{print total, " / 60"}' | bc | awk '{print $1," minuta"}'
18 minuta
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
# nginx/conf/vhosts/
cat * | grep server_name | sed 's/.*name *//g' | sed 's:;::g'