Skip to content

Instantly share code, notes, and snippets.

View carlosipe's full-sized avatar
⛰️
🪂

Carlos I. Peña carlosipe

⛰️
🪂
View GitHub Profile
@carlosipe
carlosipe / ssh-keys.sh
Last active December 15, 2015 10:19
Adding ssh keys to remote server at once
#ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'
@carlosipe
carlosipe / install-add-apt-repository.sh
Created March 26, 2013 16:07
install add-apt-repository ubuntu
apt-get install python-software-properties -y
apt-get install software-properties-common -y
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',
@carlosipe
carlosipe / reverse-ssh-tunnel.sh
Created April 17, 2013 00:12
Reverse ssh tunnel
ssh -R 10002:localhost:22 rocinante
@carlosipe
carlosipe / convert-utf8.sh
Created April 24, 2013 04:02
convert to utf8
for i in `find . -name "*.php"`; do iconv -f utf8 -t utf8 $i 2>&1 > /dev/null | perl -e "while(<>){print \"$i\\n\"}";done
for i in `cat convertir`; do cp $i tmp; iconv -f iso-8859-1 -t utf8 tmp > $i;done
@carlosipe
carlosipe / image_uploader.rb
Last active December 16, 2015 16:40
CarrierWave ImageUploader, thumb resizing on the fly
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
# storage :fog
# Process files as they are uploaded (if width >1024):
process :resize_to_limit =>[1024, 10000]
@carlosipe
carlosipe / activeadmin.rb
Created May 3, 2013 14:25
active admin render template
f.inputs 'Content' do
f.form_buffers.last << f.template.render("shared/partial_name")
f.input :content
end

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
@carlosipe
carlosipe / capistrano-tail-log.rb
Created May 10, 2013 12:53
Capistrano - Tail log
desc "tail production log files"
task :tail_logs, :roles => :app do
trap("INT") { puts 'Interupted'; exit 0; }
run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
puts # for an extra line break before the host name
puts "#{channel[:host]}: #{data}"
break if stream == :err
end
end