Skip to content

Instantly share code, notes, and snippets.

View JanDintel's full-sized avatar

JanDintel

View GitHub Profile
@savethefails
savethefails / RubyScope.rb
Last active December 12, 2019 21:18
I found keeping track of 'self' in Ruby Classes to be exhausting, so I created this handy example illustrating when self changes, where instance variables are stored, and against which self methods are executed.
class RubyScope
# `self` is the RubyScope Class
# (i.e. an Instance of RubyScope MetaClass)
@variable_type = 'class instance variable'
# Methods are defined in a class, but executd on an instance
# Created on self: "RubyScope", Executed on self: "any instance of RubyScope"
def initialize
# `self` is an Instance of RubyScope Class
@variable_type = 'instance variable'
@madis
madis / gist:4650014
Created January 27, 2013 19:40
Testing CORS OPTIONS request with curl
curl \
--verbose \
--request OPTIONS \
http://localhost:3001/api/configuration/visitor \
--header 'Origin: http://localhost:9292' \
--header 'Access-Control-Request-Headers: Origin, Accept, Content-Type' \
--header 'Access-Control-Request-Method: GET'
# http://nils-blum-oeste.net/cors-api-with-oauth2-authentication-using-rails-and-angularjs/#.UQJeLkp4ZyE
@NARKOZ
NARKOZ / whitespace.rake
Created August 30, 2011 01:31
Whitespaaaaaaaace! WHITESPAAAAAAAACE!
# requires BSD sed
namespace :whitespace do
desc 'Removes trailing whitespace'
task :cleanup do
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
do sed -i '' 's/ *$//g' "$f";
done}, {:verbose => false}
puts "Task cleanup done"
end