Skip to content

Instantly share code, notes, and snippets.

Ozgun Koyun ozgun

Block or report user

Report or block ozgun

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
# To see available batteries run "upower -e"
BATTERY_PERCENTAGE=`upower -i /org/freedesktop/UPower/devices/DisplayDevice |grep percentage |awk -F: '{ print $2}' |awk -F% '{gsub(/ /, ""); print $1 }' |awk -F, '{ print $1 }'`
if [ $((BATTERY_PERCENTAGE)) -lt 10 ]; then
notify-send -u critical -c device -i /usr/share/icons/gnome/48x48/status/battery-low.png "Battery Level Low!" "%$BATTERY_PERCENTAGE"
# Crontab entry:
ozgun / my-vim-plugins.vim
Last active Nov 18, 2016
vim plugins I use
View my-vim-plugins.vim
Plugin 'gmarik/Vundle.vim'
Bundle 'L9'
Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-rails'
Plugin 'vim-ruby/vim-ruby'
View rubysnippets.vim
" Ruby snippets
" Last change: August 6 2007
" Version> 0.1.0
" Maintainer: Eustáquio 'TaQ' Rangel
" License: GPL
" Thanks to: Andy Wokula and Antonio Terceiro for help and patches.
if exists("b:rubysnippets_ignore")
View gist:7a99ee5e759fd8e425ee15615bfeae8c
" An example for a vimrc file.
" Maintainer: Bram Moolenaar <>
" Last change: 2002 May 28
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
View .tmux.conf
# $Id: vim-keys.conf,v 1.2 2010-09-18 09:36:15 nicm Exp $
# vim-keys.conf, v1.2 2010/09/12
# By Daniel Thau. Public domain.
# This configuration file binds many vi- and vim-like bindings to the
# appropriate tmux key bindings. Note that for many key bindings there is no
# tmux analogue. This is intended for tmux 1.3, which handles pane selection
# differently from the previous versions
View 20160318145525_convert_text_to_medium_in_post_and_page_translations.rb
class ConvertTextToMediumInPostAndPageTranslations < ActiveRecord::Migration
def up
change_column :post_translations, :text, :text, :limit => 64.kilobytes + 1
change_column :page_translations, :text, :text, :limit => 64.kilobytes + 1
def down
change_column :post_translations, :text, :text
change_column :page_translations, :text, :text
ozgun / boolean_store_accessor.rb
Last active Jun 1, 2017
Using ActiveRecord::Store to store boolean fields
View boolean_store_accessor.rb
# File: app/models/concerns/boolean_store_accessor.rb
# When we submit a form in order to update a model, a booelan/checkbox field is posted
# as '1' or '0', and if we are using ActiveRecord::Store, posted value is stored in
# database as '1' or '0'. By the help of this module, we store '1' and '0'
# values as `true` or `false`.
# Example usage:
# ```
ozgun / apps_controller.rb
Last active Dec 23, 2015
Nested conrtollers example
View apps_controller.rb
class Admin::AppsController < Admin::BaseController
before_filter :load_app
def index
@apps = App.all
def show
ozgun /
Created Dec 11, 2015
Download last file from remote server with ssh
FILE_TO_DOWNLOAD=`ssh 'ls -Art /tmp/dir |tail -n 1'`
ozgun / cards_controller.rb
Created Dec 9, 2015
Custom Rails Responder for Service Objects
View cards_controller.rb
class Dashboard::Payments::CardsController < ::Dashboard::Payments::BaseController
self.responder = Core::CustomServiceResponder
respond_to :html
before_action :customer_required
def destroy
service =
status_object =[:identifier])
You can’t perform that action at this time.