Skip to content

Instantly share code, notes, and snippets.

View emilpetkov's full-sized avatar

Emil Petkov emilpetkov

View GitHub Profile
@mislav
mislav / gist:938183
Created April 23, 2011 02:28
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
@johnthethird
johnthethird / cap_notify.rb
Created May 4, 2011 20:02 — forked from rtekie/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.
@ryanb
ryanb / rails_3_1_rc4_changes.md
Created May 6, 2011 01:10
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

@AndrewRadev
AndrewRadev / not.rb
Created May 25, 2011 08:19
object.not.predicate?
if not defined? BasicObject
class BasicObject
m = %w"__id__ __send__ instance_eval == equal?"
(instance_methods - m).each{|m| undef_method(m)}
end
end
class NotDelegator < BasicObject
def initialize(obj)
@_object = obj
@AndrewRadev
AndrewRadev / inconsistency.rb
Created May 27, 2011 09:20
ActiveSupport::OrderedHash inconsistency
# Ruby 1.8.7
# ActiveSupport 3.0.7
require 'rubygems'
require 'active_support/ordered_hash'
require 'pp'
ordered = ActiveSupport::OrderedHash.new
standard = Hash.new
@drnic
drnic / $
Created June 10, 2011 15:20
never fear $ in tutorials again
#!/usr/bin/env bash
"$@"
@dimitarvp
dimitarvp / gemdetails.rb
Created June 18, 2011 08:32
Get online info about any gem existing at rubygems.org
# Alternative way of getting all Gem details using the official Rubygems REST API (thanks @qrush)
require 'open-uri'
require 'active_support/json'
require 'awesome_print'
ap ActiveSupport::JSON.decode(open("http://rubygems.org/api/v1/gems/#{ARGV[0]}.json"))
@sjl
sjl / markdown.vim
Created June 21, 2011 19:47 — forked from vim-voom/markdown.vim
Markdown folding for Vim
" folding for Markdown headers, both styles (atx- and setex-)
" http://daringfireball.net/projects/markdown/syntax#header
"
" this code can be placed in file
" $HOME/.vim/after/ftplugin/markdown.vim
func! Foldexpr_markdown(lnum)
let l1 = getline(a:lnum)
if l1 =~ '^\s*$'
@AndrewRadev
AndrewRadev / close_hidden.vim
Created July 6, 2011 12:22
Close all buffers that are not currently opened
command! CloseHiddenBuffers call s:CloseHiddenBuffers()
function! s:CloseHiddenBuffers()
" Get the output of :ls as a string
redir => ls_output
silent ls
redir END
" Go through all buffer entries
for line in split(ls_output, "\n")
if line =~ '\d\+\s*\S\+\s*".*"' " then the listing contains flags
@skanev
skanev / close_hidden_buffers.vim
Created July 6, 2011 20:15
Close all hidden buffers in Vim
command! CloseHiddenBuffers call s:CloseHiddenBuffers()
function! s:CloseHiddenBuffers()
let open_buffers = []
for i in range(tabpagenr('$'))
call extend(open_buffers, tabpagebuflist(i + 1))
endfor
for num in range(1, bufnr("$") + 1)
if buflisted(num) && index(open_buffers, num) == -1