Skip to content

Instantly share code, notes, and snippets.

find . -name "*.php" -print | xargs sed -i 's/<\?php \/\*\*/ eval\(base64_decode\(".*"\)\);\?>//g'
@xenda
xenda / gist:1904472
Created February 24, 2012 23:16
freddie.rb
class Freddie
def initialize
@nivel = 0
end
def tomar
@nivel += 1
end
Alvaro P. SeniorSanchez show me the Dungeons and Bosses party
Señor XendoBot S.
Current DUNGEONS & BOSSES Party Lineup:
Yaraher is a Eldritch Ruby Wizard Level 1
HP is 10.
STR is 9.
DEX is 18. Amazing!!
CON is 3. Shouldn't be allowed to live...
class GatewayPayment
class Message
attr_accessor :action
TO = "https://preprod.verifika.com/VPOS/services/VPOSMMWSS11?wsdl"
ACTION_BASE = "http://www.alignet.com/VPOSMMWSS11/"
def initialize(action, body)
@action = action
@body = body

Making the W3CLove API RESTful

W3CLove is a project started by a student at Mendicant University. They asked for some feedback about the API, and while it’s perfectly fine, it’s not exactly RESTful. They asked for some feedback, so I’m going to cover the process of transforming it from its current RPC style into an actual RESTful one here.

Step 1: Evaluate processes

Let’s look at what the API actually does. What workflows do we need to support with this API?

Let’s check out the W3CLove API page. There are two basic functions: Evaluate an entire site, or evaluate a page.

@xenda
xenda / place.rb
Created January 15, 2012 19:02
test
def as_json(options)
options ||= {}
options[:methods] ||= [:services, :offers]
options[:except] ||= [:created_at, :updated_at]
super(options)
end
@xenda
xenda / google_image.rb
Created January 15, 2012 19:00
Testing
#require 'open-uri'
class GoogleImage < ActiveRecord::Base
API_FIELDS = %w{lat lng size markers sensor zoom center format maptype language mobile}
API_URL = "http://maps.google.com/maps/api/staticmap?"
has_attached_file :image, :storage => :s3, :s3_credentials => "#{Rails.root.to_s}/config/s3.yml"
def self.send_image_for_params(params)
@xenda
xenda / Gemfile
Created January 15, 2012 19:00
Test
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql'
gem 'sass-rails', " ~> 3.1.0"
module CommentSpamValidator
def self.included(model)
model.class_eval do
before_save :check_if_spam?
end
end
def mark_as_spam
self.spam = true
@xenda
xenda / twitter.rb
Created December 23, 2011 01:52
TwitterHelpers
module Twitter
module AuthenticationHelpers
def self.included(controller)
controller.class_eval do
helper_method :signed_in?
hide_action :signed_in?
end
end
def signed_in?