Skip to content

Instantly share code, notes, and snippets.

@richardtifelt
richardtifelt / bitly.rb
Created May 15, 2009 12:31
Simple bit.ly API class in Ruby
require 'httparty'
class Api::Bitly
include HTTParty
base_uri 'api.bit.ly'
basic_auth 'username', 'password'
format :json
def self.shorten(url)
response = get('/shorten', :query => required_params.merge(:longUrl => url))
SIGN UP
curl -H "Content-Type:application/json" -H "Accept:application/json" \
-d "{\"user\":{\"password_confirmation\":\"12345678\", \"password\":\"12345678\", \"email\":\"test5@test.com\"}}" \
http://your_server.com/users
SIGN IN
curl -H "Content-Type:application/json" -H "Accept:application/json" \
-d "{\"user\":{\"remember_me\":\"0\", \"password\":\"12345678\", \"email\":\"test5@test.com\"}}" \
http://your_server.com/users/sign_in
require 'rubygems'
require 'httparty'
require 'json'
class Party
include HTTParty
base_uri 'messageparty.net'
def post room, message
headers = {
require 'httparty'
class Webservice
CANDIDATE = <<XML
<Candidate xmlns="com.mysite/2010/10/10" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<FirstName>%s</FirstName>
<LastName>%s</LastName>
<Email>%s</Email>
<Gender>%s</Gender>
</Candidate>
@cowboy
cowboy / ba-whatevcache.js
Created November 1, 2010 17:17
whatevCache: a simple localStorage-if-you-got-it, otherwise not-at-all-persistent data object cache.
/*!
* JavaScript whatevCache - v0.2pre - 12/30/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// whatevCache.set( key, value [, ttl ] );
@floehopper
floehopper / wem.rb
Created November 24, 2010 18:23
Use httparty to connect using SSL mutual authentication
require "rubygems"
require "httparty"
class Wem
include HTTParty
debug_output $stderr
ssl_ca_file '/Users/jamesmead/Sites/ssltest/demoCA/ca.crt'
pem File.read('/Users/jamesmead/Sites/ssltest/user/hashblue.pem')
base_uri "https://127.0.0.1/"
def self.wem
@zpao
zpao / README.md
Created June 6, 2011 17:56
autoconf 2.13 homebrew formula

Install

  1. install homebrew
  2. place autoconf.rb into Formula folder: /usr/local/Library/Formula/
  3. run brew install autoconf
@ryanlecompte
ryanlecompte / gist:1283413
Created October 13, 2011 04:50
Providing an ActiveRecord-like before_filter capability to arbitrary Ruby classes
# First the end result of what we want:
class Foo
before_hook :whoa
before_hook :amazing
def test
puts "This is kinda cool!"
end
@madmax
madmax / gist:1474059
Created December 13, 2011 21:54
changing font in textmate 2
1. Open Bundle editor
2. Select Themes -> Themes -> your theme
3. add to settings
fontName = 'Monaco';
fontSize = '12px';
or what you want, enjoy :)
@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet