Skip to content

Instantly share code, notes, and snippets.

Avatar

Tekin Süleyman tekin

View GitHub Profile
@tekin
tekin / .gitattributes
Last active Jan 4, 2021
An example .gitattributes file that will configure custom hunk header patterns for some common languages and file formats. See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details.
View .gitattributes
# 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
View keybase.md

Keybase proof

I hereby claim:

  • I am tekin on github.
  • I am tekin (https://keybase.io/tekin) on keybase.
  • I have a public key whose fingerprint is FB9F BD4D 775C E14B F481 1BB1 4AB5 9526 95A5 5C7E

To claim this, I am signing this object:

View gist:2643351
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 |
@tekin
tekin / some_auth_controller.rb
Created Sep 3, 2011
example code for doing OAuth with Twitter using the oauth gem.
View some_auth_controller.rb
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
View association_default_attributes.rb
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
View gist:1173659
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)
@tekin
tekin / weekends.rb
Created Jun 6, 2011 — forked from alterisian/weekends.rb
Weekends left til the end of summer
View weekends.rb
# 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.
View gist:558672
# 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
View gist:231969
AF:
code: AF
name: Afghanistan
AL:
code: AL
name: Albania
DZ:
code: DZ
name: Algeria
AS:
View payments_controller.rb
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