Skip to content

Instantly share code, notes, and snippets.

View ozgun's full-sized avatar

Ozgun Koyun ozgun

View GitHub Profile
sec1 = "(1) toplama"
sec2 = "(2) çıkarma"
sec3 = "(3) çarpma"
sec4 = "(4) bölme"
puts sec1
puts sec2
puts sec3
puts sec4
@ozgun
ozgun / sinatra-testing-with-sessions.rb
Created May 31, 2011 07:29
sinatra-testing-with-sessions
# Middleware: my_app.rb
class MyApp < Sinatra::Base
enable :sessions
get '/testing' do
puts env['rack.session'].inspect
'testing'
end
end
@ozgun
ozgun / my_app_spec.rb
Created May 31, 2011 08:57
sinatra-testing-with-sessions
it "tests something..." do
sess = {'warden.user.user.key' => [User, User.first.id]}
encoded = [Marshal.dump(sess)].pack("m*")
get "/testing", {}, {'HTTP_COOKIE' => "rack.session=" + encoded}
end
<div style="background-color: green; width:500px; height: 500px">Text</div>
@ozgun
ozgun / gist:1141681
Created August 12, 2011 08:13
cucumber - pickle - paths
# eg: I am on the advertisers ad campaign's the ad's edit page
when /^the (.+?) #{capture_model}(?:'s)? #{capture_model}(?:'s)? (.+?) page$/
polymorphic_path [$1.to_sym, model($2), model($3)], :action => $4
# eg: I am on the advertisers the ad campaign's the ad's page
when /^the (.+?) #{capture_model}(?:'s)? #{capture_model}(?:'s)? page$/
polymorphic_path [$1.to_sym, model($2), model($3)]
# eg: I am on the advertisers the ad's edit page
when /^the (.+?) #{capture_model}(?:'s)? (.+?) page$/
@ozgun
ozgun / xml
Created August 16, 2011 12:13
xml
<html_code><![CDATA[<a href="http://example.com" target="_blank"><img src="http://kozgun.net/images/screenshots/0000/0025/sopar-0.1-800_thumb.png" hspace="0" vspace="0" border="0" id="htmlbannerinstance"/></a>]]></html_code>
@ozgun
ozgun / splash_screen.rb
Created August 17, 2011 11:53
blueprints for splash screens
SplashScreen.blueprint do
image { File.open(File.join(Rails.root, "features", "assets", "images", "splash_screen.jpg")) }
end
@ozgun
ozgun / globalize3_fix_for_rails_3_2.rb
Created January 25, 2012 12:38
globalize3 fix for rails 3.2
module ActiveRecord
module ModelSchema
module ClassMethods
def compute_table_name
base = base_class
if self == Globalize::ActiveRecord::Translation #globalize3
tbl_name = "translations"
elsif superclass == Globalize::ActiveRecord::Translation #globalize3
tbl_name = "#{self.parent.table_name.singularize}_translations"
elsif self == base
@ozgun
ozgun / tinymce.yml
Created July 10, 2012 08:12
tinymce.yml
mode: "textareas"
theme: "advanced"
#skin: "o2k7"
#skin_variant: "silver"
editor_selector: "mceEditor"
language: "tr"
#content_css : "/stylesheets/tinymce.css"
plugins:
- inlinepopups
- preview
# http://www.broadcastingadam.com/2012/07/advanced_caching_part_2-using_strategies/
# Step 3: Caching Views Generated from Arrays
# missing "}"
class Post
def cache_key
Digest::MD5.hexdigest "#{maximum(:updated_at).try(:to_i)}-#{count}"
end
end