Skip to content

Instantly share code, notes, and snippets.

View andyjeffries's full-sized avatar

Andy Jeffries andyjeffries

View GitHub Profile
@andyjeffries
andyjeffries / user.rb
Created May 3, 2014 11:06
ARC before_filter example for David Tolsma
class User < ActiveRestClient::Base
before_filter do |name, request|
request.headers["Authorization"] = request.get_params[:authorization]
end
get :find, "/users/:id"
end
@andyjeffries
andyjeffries / Gemfile
Created June 16, 2014 09:26
Rails 4.1 Default Files
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
@andyjeffries
andyjeffries / example.rb
Created May 6, 2015 08:32
Example ARC for Abel
require "faraday"
class Customer < ActiveRestClient::Base
base_url "http://requestb.in"
ActiveRestClient::Base.faraday_config do |faraday|
faraday.adapter(:net_http)
faraday.options.timeout = 20
faraday.headers['User-Agent'] = "ActiveRestClient/#{ActiveRestClient::VERSION}"
end
require 'autotest/redgreen'
require 'autotest/timestamp'
module Autotest::Growl
def self.growl title, msg, img, pri=0, sticky=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
Autotest.add_hook :ran_command do |at|
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require 'spec/autorun'
require 'spec/rails'
Spec::Runner.configure do |config|
# If you're not using ActiveRecord you should remove these
# lines, delete config/database.yml and disable :active_record
## main file
<div id="eula_table_id">
<%= render :partial => "config/eula_list" %>
</div>
<div class="form-row">
<%= link_to_remote "Add new end user license agreement",
{ :update => "eula_table_id", # you may not need this :update parameter
:before => "$('#add-user-spinner').show();" +
class IO
def encrypted_read(filename)
puts filename
end
alias_method :non_encrypted_read, :read
alias_method :read, :encrypted_read
end
#>> IO.read('a')
require 'openssl'
require 'digest/sha1'
class Test
def self.decrypt(content, password)
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
cipher.decrypt
cipher.key = Digest::SHA1.hexdigest(password)
cipher.update(content)
cipher.final
[MacBook] [2009-06-18 13:24:10] [14502] [FATAL] /!\ FAILSAFE /!\ 18/06/2009
Status: 500 Internal Server Error
Expected /Users/andy/Sites/fdj-production/app/helpers/cms/component_helper.rb to define Cms::ComponentHelper
/Users/andy/Sites/fdj-production/vendor/rails/activesupport/lib/active_support/dependencies.rb:426:in `load_missing_constant'
/Users/andy/Sites/fdj-production/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
/Users/andy/Sites/fdj-production/vendor/rails/activesupport/lib/active_support/inflector.rb:361:in `constantize'
/Users/andy/Sites/fdj-production/vendor/rails/activesupport/lib/active_support/inflector.rb:360:in `each'
/Users/andy/Sites/fdj-production/vendor/rails/activesupport/lib/active_support/inflector.rb:360:in `constantize'
/Users/andy/Sites/fdj-production/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb:162:in `constantize'
/Users/andy/Sites/fdj-production/vendor/rails/actionpack/lib/actio
class Vehicle
cattr_accessor :name
end
class Car < Vehicle
end
Car.name = "John"
#=> "John"