Skip to content

Instantly share code, notes, and snippets.

View arturopie's full-sized avatar
:shipit:
shipping

Arturo Pie arturopie

:shipit:
shipping
View GitHub Profile
@arturopie
arturopie / run_js_specs.rb
Created June 4, 2014 16:36
Observr configuration to run karma tests
# setup: gem install observr
# usage:
# observr run_js_specs.rb
watch('spec/.*_spec.js') { |_| run_all_tests }
watch('client/.*.js') { |_| run_all_tests }
def run_all_tests
puts "RUNNING ALL TESTS"
system 'xvfb-run --auto-servernum node_modules/karma/bin/karma start karma.amd.conf.js --single-run'
@arturopie
arturopie / rails4_association_bug.rb
Created November 22, 2014 15:15
Rails bug when setting association using same child record, but different child instances
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'rack', github: 'rack/rack'
gem 'i18n', github: 'svenfuchs/i18n'
gem 'sqlite3'
GEMFILE

Keybase proof

I hereby claim:

  • I am arturopie on github.
  • I am arturo_nulogy (https://keybase.io/arturo_nulogy) on keybase.
  • I have a public key whose fingerprint is D0EA 60F3 EA18 4418 33CC 970C 5F5D 1814 E167 2015

To claim this, I am signing this object:

@arturopie
arturopie / sy2.rb
Created October 3, 2011 19:44
scripts to run sy2 and sy3 severak times and check if they pass
#!/usr/bin/ruby
require 'open3'
failed = false
for i in 1..20
puts i
stdin, stdout, stderr = Open3.popen3("sys161 kernel-ASST1 'sy2; q'")
if ((str = stderr.gets) =~ /sys161: Cannot/)
@arturopie
arturopie / bash-functions.zsh
Created March 5, 2012 04:30
some bash/zsh useful functions
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low --hint int:transient:1 -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# to use no fast-forward by deafult
function git() {
if [[ $@ == merge* ]]; then
if [[ $@ == *--no-ff* ]]; then
command git "$@"
@arturopie
arturopie / .zsh
Created March 6, 2012 00:53
.zsh
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="gnzh"
@arturopie
arturopie / 0-readme.md
Created March 8, 2012 03:39
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p0 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.

@arturopie
arturopie / _rake
Created April 9, 2012 18:31
rake fast autocomplition
# rake autocompletion from:
_rake_does_task_list_need_generating () {
if [ ! -f .rake_tasks~ ]; then return 0;
else
accurate=$(stat -c=%y .rake_tasks~)
changed=$(stat -c=%y Rakefile)
return $(expr $accurate '>=' $changed)
fi
}
@arturopie
arturopie / remote_commands.rb
Created September 26, 2012 01:55
Using EventMachine to execute commands in several host at once
require 'eventmachine'
require 'colorize'
class RemoteCommands < EM::Connection
attr_reader :queue
def initialize(q)
@queue = q
cb = Proc.new do |msg|
@arturopie
arturopie / ruby_require_load_tree.rb
Created November 2, 2012 17:13
Print require/load tree
$require_level = []
alias :orig_require :require
def require(file)
puts "#{$require_level.join}#{file}"
$require_level << "-"
r = orig_require(file)
$require_level.pop
r
end