Skip to content

Instantly share code, notes, and snippets.

View seyhunak's full-sized avatar
🏆
Polyglot Programmer

Seyhun Akyürek seyhunak

🏆
Polyglot Programmer
View GitHub Profile
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
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "[email protected]"
@from = "[email protected]"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end
@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
@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 / page_inject.coffee
Created May 10, 2012 06:52 — forked from ntreadway/page_inject.coffee
Simple page inject for JQuery Mobile and Rails Partials
# Used to dynamically add a rails page view when using Jquery Mobile
# Author Nick Treadway @nicktea
@insert_page = (id, content) ->
page = $("<article id="+id+" data-role='page' data-url="+id+" data-add-back-btn='true'>" + content + "</article>")
page.appendTo('body')
$('a' + '#' + id).click ->
$.mobile.changePage(page, {transition: "slide"})
# Use (your-view.haml)
@seyhunak
seyhunak / gist:2602279
Created May 5, 2012 13:09 — forked from anonymous/gist:14120
Google Analytics Image Request Builder
require 'net/http'
class GoogleAnalytics
BASE_URL = "http://www.google-analytics.com/__utm.gif?"
def self.create_url(request, options)
params = {}
raise(ArgumentError, "Can't create GA URL without an urchin code") unless params[:utmac] = options.delete(:ga_code)
raise(ArgumentError, "Can't create GA URL without a page URI") unless params[:utmp] = options.delete(:page_uri)
utmdt = options.delete(:description) || "-" # page description
@seyhunak
seyhunak / rails-export-csv.rb
Created April 9, 2012 15:05 — forked from bcalloway/rails-export-csv.rb
Use FasterCSV to export an ActiveRecord object in Rails
### /config/environment.rb
config.gem 'fastercsv'
### /config/routes.rb
map.connect '/users/export', :controller => 'users', :action => 'export'
### /app/models/user.rb
# find all students and pass to controller export action for export to csv
def self.find_students
find_by_sql("select students.firstname, students.lastname, students.grade, students.homeroom, students.phone, students.email, students.relationship, users.firstname, users.lastname, accounts.school from students, users, accounts where students.user_id = users.id and accounts.id = users.account_id")
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@seyhunak
seyhunak / edit.html.erb
Created February 22, 2012 20:34 — forked from daz/edit.html.erb
twitter-bootstrap-rails ERB template
<%= render :partial => 'form' %>
@seyhunak
seyhunak / on_update.task.rb
Created February 15, 2012 12:51 — forked from peterc/on_update.task.rb
Rake task to automatically run something (i.e. specs) when code files are changed
# Rake task to automatically run something (i.e. specs) when code files are changed
# By Peter Çoopér
#
# Motivation: I couldn't get autotest to run on my Sinatra project for some reason but realized
# it didn't require overengineering. Just detect when a file is changed and then re-run the specs!
#
# Examples:
# # rake on_update "rake"
# # rake on_update "spec spec/user_spec.rb"
#