Skip to content

Instantly share code, notes, and snippets.

View seyhunak's full-sized avatar
🏆
Winning The Life

Seyhun Akyürek seyhunak

🏆
Winning The Life
View GitHub Profile
@seyhunak
seyhunak / devise.tr.yml
Created May 29, 2012 11:48 — forked from cihad/devise.tr.yml
Turkish translations for Devise
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
tr:
errors:
messages:
expired: "süresi sona erdi, lütfen yenisini isteyin"
not_found: "bulunamadı"
already_confirmed: "zaten onaylandı, lütfen tekrar giriş yapmayı deneyin"
not_locked: "kilitlenmedi"
not_saved:
@seyhunak
seyhunak / latency.txt
Created June 4, 2012 07:29 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD 150,000 ns 0.15 ms
Read 1 MB sequentially from memory 250,000 ns 0.25 ms
Round trip within same datacenter 500,000 ns 0.5 ms
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "someone@somewhere.com"
@from = "must_be_same_as_smpt_account_login@gmail.com"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end
class HelloWorldController < AbstractController::Base
include AbstractController::Rendering
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::Translation
include AbstractController::AssetPaths
include ActionController::UrlWriter
# Uncomment if you want to use helpers defined in ApplicationHelper in your views
# helper ApplicationHelper
@seyhunak
seyhunak / gist:3016871
Created June 29, 2012 09:17 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@seyhunak
seyhunak / gist:3017305
Created June 29, 2012 10:49 — forked from trevorturk/gist:366598
Automated Heroku Backups
namespace :heroku do
desc "PostgreSQL database backups from Heroku to Amazon S3"
task :backup => :environment do
begin
require 'right_aws'
puts "[#{Time.now}] heroku:backup started"
name = "#{ENV['APP_NAME']}-#{Time.now.strftime('%Y-%m-%d-%H%M%S')}.dump"
db = ENV['DATABASE_URL'].match(/postgres:\/\/([^:]+):([^@]+)@([^\/]+)\/(.+)/)
system "PGPASSWORD=#{db[2]} pg_dump -Fc --username=#{db[1]} --host=#{db[3]} #{db[4]} > tmp/#{name}"
s3 = RightAws::S3.new(ENV['s3_access_key_id'], ENV['s3_secret_access_key'])
@seyhunak
seyhunak / application_controller.rb
Created July 9, 2012 16:39 — forked from gonzedge/application_controller.rb
Rails 3.1 - Adding custom 404 and 500 error pages
class ApplicationController < ActionController::Base
# ...
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: :render_500
rescue_from ActionController::RoutingError, with: :render_404
rescue_from ActionController::UnknownController, with: :render_404
rescue_from ActionController::UnknownAction, with: :render_404
rescue_from ActiveRecord::RecordNotFound, with: :render_404
end
@seyhunak
seyhunak / bijective.rb
Created July 10, 2012 14:46 — forked from zumbojo/bijective.rb
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@seyhunak
seyhunak / devise.rb
Created July 24, 2012 07:31 — forked from seanaedmiston/devise.rb
Devise Omniauthable
...
# ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is
# just :email. You can configure it to use [:username, :subdomain], so for
# authenticating a user, both parameters are required. Remember that those
# parameters are used only when authenticating and not when retrieving from
# session. If you need permissions, you should implement that in a before filter.
# You can also supply a hash where the value is a boolean determining whether
# or not authentication should be aborted when the value is not present.
config.authentication_keys = [ :login ]
@seyhunak
seyhunak / Tweetsheets
Created August 10, 2012 12:29 — forked from johannesnagl/Tweetsheets
Use Twitter directly in your Google Doc, so no one will ever blame you for being social
var CONSUMER_KEY = "<< YOUR KEY HERE >>";
var CONSUMER_SECRET = "<< YOUR SECRET HERE >>";
function getConsumerKey() {
return CONSUMER_KEY;
}
function getConsumerSecret() {
return CONSUMER_SECRET;
}