Skip to content

Instantly share code, notes, and snippets.

Avatar

Ozgun Koyun ozgun

View GitHub Profile
@ozgun
ozgun / delete_app.rb
Last active Dec 23, 2015
Service & Status Objects
View delete_app.rb
class Core::DeleteApp < Core::ServiceBase
attr_reader :user, :app
def initialize(user, app)
@user = user
@app = app
end
# Her service object'te sadece bir tane public method var o da `call` methodu.
# `call` methodu bir status object dondurur, bu status object `Error` veya `Success` status object olsun.
View embed_vimeo.html
<iframe src="https://player.vimeo.com/video/37382619" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <p><a href="https://vimeo.com/37382619">Dark Secrets - Hacking Team commercial</a> from <a href="https://vimeo.com/waveaudio">Wave Audio</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
@ozgun
ozgun / auth_helper_methods.rb
Created Jun 24, 2015
Ruby: module_function
View auth_helper_methods.rb
module AuthHelperMethods
# Call callback_url method from inside another class as below:
#
# AuthHelperMethods.callback_url('a', 'b', 1)
#
def callback_url(base_url, provider, app_id)
[base_url, "/members/auth/#{provider}/callback/#{app_id}"].join
end
@ozgun
ozgun / bump_push_and_release.sh
Created Jun 24, 2015
Ruby gems: Bump & Push & Release to gemfury
View bump_push_and_release.sh
# In order to make this script work, gemfury gem needs
# to be added to my_gem.gemspec as development dependency.
cd ~/Projects/my_gem
gem bump --version patch --push && bundle exec rake build && bundle exec fury push pkg/`ls -tr pkg |tail -1` --as user
@ozgun
ozgun / responders_notlar.md
Last active Aug 29, 2015
responders, Rails 4.2, responders gem
View responders_notlar.md

responders, Rails 4.2, responders gem 2.0.2

responders gem'i ile gelen en.yml dosyasında update/alert ve create/alert için mesajlar commentlenmiş durumda, o yüzden aşağıdaki gibi bir flash.en.yml dosyası oluşturulup projenin config/locales/ dizinine kopyalanır.

en:
  flash:
    actions:
@ozgun
ozgun / custom_service_responder.rb
Created Jun 23, 2015
Custom Responder for Service Objects
View custom_service_responder.rb
module MyModule
# This responder can be used with service objects.
#
# result = MyService.new.call
# respond_with result, location: -> { payments_cards_path }
#
# Assumption: When we call the service, we get a status/response object which responds to `success?` method.
# If response is successful, then the response object also responds to `data` method. If response is a
# failure, the response object responds to `error` method.
View custom_responder.rb
module MyModule
class CustomResponder < ActionController::Responder
include Responders::FlashResponder
include Responders::HttpCacheResponder
def has_errors?
case controller.action_name
when 'destroy'
resource.destroyed? ? false : true
else
View instructsions.md

Stop unicorn.

On the server:

$ /etc/init.d/unicorn stop

Drop & re-create database

On the server, in mysql client:

@ozgun
ozgun / unicorn.rb
Created Mar 25, 2015
unicorn config
View unicorn.rb
worker_processes 2
preload_app true
timeout 30
app_name = "myapp"
app_dir = "/home/ozgun/#{app_name}"
working_directory "#{app_dir}/current"
listen "#{app_dir}/shared/tmp/unicorn.sock", :backlog => 64
#listen "/tmp/unicorn.sock", :backlog => 64
View fonts.txt
$ ls -lh app/assets/fonts/
total 3,7M
-rwxrwxr-x 1 ozgun ozgun 20K Haz 23 12:21 glyphicons-halflings-regular.eot
-rwxrwxr-x 1 ozgun ozgun 62K Haz 23 12:21 glyphicons-halflings-regular.svg
-rwxrwxr-x 1 ozgun ozgun 41K Haz 23 12:21 glyphicons-halflings-regular.ttf
-rwxrwxr-x 1 ozgun ozgun 23K Haz 23 12:21 glyphicons-halflings-regular.woff
-rwxrwxr-x 1 ozgun ozgun 67K Haz 30 19:49 inconsolata-bold.eot
-rwxrwxr-x 1 ozgun ozgun 106K Haz 30 19:49 inconsolata-bold.svg
-rwxrwxr-x 1 ozgun ozgun 66K Haz 30 19:49 inconsolata-bold.ttf
-rwxrwxr-x 1 ozgun ozgun 33K Haz 30 19:49 inconsolata-bold.woff
You can’t perform that action at this time.