Skip to content

Instantly share code, notes, and snippets.

View raphaelcosta's full-sized avatar

Raphael Costa raphaelcosta

View GitHub Profile
@austenito
austenito / integration_spec.rb
Created April 11, 2012 12:50
Integration Testing w/ Sorcery
describe "Shopping Cart Requests" do
let!(:user) { Fabricate(:user) }
before(:each) do
login_user_post("admin", "admin")
end
context "when I visit the shopping cart" do
it " show the logged in users' cart items " do
#Test stuff
@remi
remi / jekyll
Created May 12, 2012 10:31
I18n dates with Jekyll (dirty hack version)
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'jekyll' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
@rtekie
rtekie / subdomains.rb
Created May 14, 2012 13:14
Support for Rspec / Capybara subdomain integration testing
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
#
# Sample subdomain test:
# it "should test subdomain" do
# switch_to_subdomain("mysubdomain")
# visit root_path
# end
DEFAULT_HOST = "lvh.me"
@danshultz
danshultz / liquid_view.rb
Created June 12, 2012 03:11
liquid/lib/extras/liquid_view.rb file to use in Rails 3 with layouts
# LiquidView is a action view extension class. You can register it with rails
# and use liquid as an template system for .liquid files
#
# Example
#
# ActionView::Base::register_template_handler :liquid, LiquidView
class LiquidView
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
_response url _request _cookies variables_added _flash params _headers request cookies
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 13, 2024 05:29
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
tell application "iTerm"
activate
tell (make new terminal)
tell (launch session "initial_session") to write text "cd ~/workspace/project1; clear"
tell i term application "System Events" to keystroke "D" using command down
tell last item of sessions to write text "cd ~/workspace/work/project2; clear"
tell i term application "System Events" to keystroke "d" using command down
tell last item of sessions to write text "cd ~/workspace/work/project3; clear"
@lexmag
lexmag / application.js
Created August 4, 2012 19:28
Rails streaming
//= require jquery
//= require jquery_ujs
$(function() {
var source = new EventSource('/stream');
source.addEventListener('counter', function(e) {
$('body').after(e.data + '<br />');
});
});
def draw_feature(context, atPoint:feature_point)
size = 6
startx = feature_point.x - (size/2)
starty = feature_point.y - (size/2)
CGContextAddRect(context, [[startx, starty], [size, size]])
CGContextDrawPath(context, KCGPathFillStroke)
end
@johnkary
johnkary / vagrant-nfs-vpn-solution.md
Last active April 8, 2020 10:30
Workaround for using an NFS mount with Vagrant and VirtualBox while connecting to a VPN network restricting local network connections

Fixing NFS disconnecting with Vagrant and VirtualBox on Mac OS

Symptoms and Known Conditions

  • Mac OS host machine (10.6+)
  • VirtualBox (4.1+)
  • Vagrant (1.0+)
  • Connecting via VPN to a remote network
  • Mounting a directory from your host machine to the guest machine using NFS with something like this:
@mislav
mislav / OpenSSL fix.md
Last active June 8, 2023 07:48
Fix OpenSSL certificate errors on Ruby 2.0

The reason why you might get certificate errors in Ruby 2.0 when talking HTTPS is because there isn't a default certificate bundle that OpenSSL (which was used when building Ruby) trusts.

Update: this problem is solved in edge versions of rbenv and RVM.

$ ruby -rnet/https -e "Net::HTTP.get URI('https://github.com')"
net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3
  read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

You can work around the issue by installing a certificate bundle that you trust. I trust Mozilla and curl.