Skip to content

Instantly share code, notes, and snippets.

@smd686s
smd686s / routes.rb
Created February 3, 2012 15:06
Get Parent Resource in Rails Router
root :to => 'application#index'
resources :attractions, :shopping, :accomodations, :restaurants, :events do
collection do
get 'type' => "#{parent_resource.collection_scope}#index"
end
member do
get 'type' => "#{parent_resource.member_scope}#show"
end
end
@smd686s
smd686s / Gemfile
Created May 12, 2012 16:29
Goliath.io with Grape and MongoDB
gem 'mongo'
gem 'em-mongo'
gem 'bson_ext'
gem 'goliath'
gem 'grape'
body = MultipartBody.new(:field1 => 'test', :field2 => 'test2')
http = EventMachine::HttpRequest.new('http://example.com').post(
:head => {'content-type' => "multipart/form-data; boundary=#{body.boundary}"},
:body => body.to_s
)
# Or with a file part included
part1 = Part.new('name', 'content', 'file.txt')
@smd686s
smd686s / auth.rb
Created December 2, 2012 15:34
Attempt at authorization with goliath
#!/usr/bin/env ruby
require 'rubygems'
require 'goliath'
require 'warden'
require 'digest/sha1'
require 'pp'
Warden::Strategies.add(:password) do
def valid?
@smd686s
smd686s / Gemfile
Last active October 27, 2016 02:16
Use Strong Parameters in a Grape API without Rails
gem "actionpack", "~> 4.0.0"
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/julienschmidt/httprouter"
"net/http"
)
func main() {
@smd686s
smd686s / server.go
Last active August 29, 2015 14:17 — forked from elithrar/server.go
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
sudo aptitude install libx11-dev libesd0-dev libgtk2.0-dev libgtk1.2-dev