This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stick this in your home directory and point your Global Git config at it by running: | |
# | |
# $ git config --global core.attributesfile ~/.gitattributes | |
# | |
# See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details | |
*.c diff=cpp | |
*.h diff=cpp | |
*.c++ diff=cpp | |
*.h++ diff=cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tekin@anikulapo:~/projects/crowd.fm$ rake stats | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Controllers | 922 | 777 | 30 | 123 | 4 | 4 | | |
| Helpers | 190 | 159 | 0 | 23 | 0 | 4 | | |
| Models | 1266 | 978 | 26 | 151 | 5 | 4 | | |
| Libraries | 2691 | 2051 | 23 | 250 | 10 | 6 | | |
| Integration tests | 1112 | 883 | 26 | 3 | 0 | 292 | | |
| Functional tests | 2219 | 1957 | 28 | 18 | 0 | 106 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def SomeAuthController < ApplicationController | |
def twitter_auth | |
request_token = twitter_consumer.get_request_token(:oauth_callback => twitter_callback_credentials_url) | |
session['twitter_request_token'] = request_token.token | |
session['twitter_request_secret'] = request_token.secret | |
redirect_to request_token.authorize_url | |
end | |
def twitter_callback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AssociationDefaultAttributes | |
def create(attrs, &block) | |
super(default_attributes.merge(attrs), &block) | |
end | |
def build(attrs={}, &block) | |
super(default_attributes.merge(attrs), &block) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
has_many :events, :extend => AssociationDefaultAttributes do | |
def default_attributes | |
{ :venue => proxy_owner.default_venue } | |
end | |
end | |
end | |
module AssociationDefaultAttributes | |
def create(attrs, &block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Ian Moss aka oceanician : http://twitter.com/oceanician | |
# First Published: https://gist.github.com/1009253 | |
# modulus is your friend! this works because of the way ruby | |
# modulus behaves when the dvidend is negative. | |
def friday_after(date) | |
date +(5 -date.cwday) % 7 | |
end | |
# Returns all the Fridays between today and the date specified. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install the facebook_api gem first | |
require 'rubygems' | |
require 'facebook_api' | |
FacebookApi.configure do |config| | |
config.api_key = 'API_KEY_HERE' | |
config.secret_key = 'SECRET_KEY_HERE' | |
end | |
event_info = {:name => 'Event name', :start_time => Time.now.to_i}.to_json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AF: | |
code: AF | |
name: Afghanistan | |
AL: | |
code: AL | |
name: Albania | |
DZ: | |
code: DZ | |
name: Algeria | |
AS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@credit_card = ActiveMerchant::Billing::CreditCard.new(params[:credit_card]) | |
@billing_address = Address.new(params[:address]) | |
@payment = @order.payments.create(:credit_card => @credit_card, :address => @billing_address) | |
if @payment.success? | |
redirect_to complete_order_url(@order) | |
elsif @payment.requires_authentication? | |
# A view with an iframe from which the user is redirected to the authentication page | |
render :action => 'three_d_iframe' | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% form_tag new_order_payment_path(@order), :id => 'reload_frame', :target => '_top', :method => 'get' do %> | |
<%= hidden_field_tag :verification_failed, true %> | |
<noscript> | |
<p>Verification failed, click the button below to try again.</p> | |
<%= submit_tag 'Try again' %> | |
</noscript> | |
<% end %> | |
<% javascript_tag do %> | |
window.onload=function(){ | |
document.getElementById('reload_frame').submit(); |
NewerOlder