Skip to content

Instantly share code, notes, and snippets.

View carlosipe's full-sized avatar
⛰️
🪂

Carlos I. Peña carlosipe

⛰️
🪂
View GitHub Profile
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
# usage: ruby import.rb my-blog.xml
# my-blog.xml is a file from Settings -> Basic -> Export in blogger.
data = File.read ARGV[0]
# in spec/support/omniauth_macros.rb
module OmniauthMacros
def mock_auth_hash
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:twitter] = {
'provider' => 'twitter',
'uid' => '123545',
'user_info' => {
'name' => 'mockuser',

Dissecting Ruby with Ruby

Richard Schneeman (@schneems)

  • Get into a library
    • bundle open wicked
    • Make sure you've set your $EDITOR
  • Forget fancy debuggers
    • All you need is puts
    • A rubyist's tracer round: puts "================="
  • Notation
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@carlosipe
carlosipe / log.txt
Created June 23, 2013 23:37 — forked from solnic/log.txt
$ history | awk {'print $2, $3, $4'} | sort | uniq -c | sort -k1 -rn | head -n 30
610 git status
568 git commit -m
491 git add .
252 git push origin
176 bundle
138 rails s
128 ls
120 git commit --amend
114 git reset --hard
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
profile["network.proxy.type"] = 1 # manual proxy config
profile["network.proxy.http"] = "localhost"
profile["network.proxy.http_port"] = 8080
Capybara::Selenium::Driver.new(app, :profile => profile)
end
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@carlosipe
carlosipe / cache.rb
Last active August 29, 2015 14:08 — forked from alfanick/cache.rb
# Amadeusz Juskowiak <[email protected]> 2012 - MIT License
# 1. Put inside helpers do .. end
# 2. Set CACHE_DIR to somewhere writable and private (like CACHE_DIR=File.dirname(__FILE__) + '/tmp'
# 3. Use it! You can use fragment_expire to remove cache with given name.
#
# Example:
# %h1 foo
# = cache_fragment(:report, 300) do
# - data = get_data_slowly
f you try to install any version of Windows from USB falsh drive you may got this error: “Setup was unable to create a new system partition or locate an existing system partition”
I have already found tricky solution for Windows 7 but it didn’t help me with Windows 8.1.
So I have found another solution that will be suitable for any Windows version.
Basically you just need to copy all installation files from USB flash drive to your HDD (or SDD) drive and make it bootable, and then continue installation from HDD to HDD
Step by step instruction:
var casper = require('casper').create({
viewportSize: {width: 950, height: 950}
});
casper.start('http://www.google.com/', function() {
this.captureSelector('/tmp/pp.png', 'body');
});
casper.run();