Skip to content

Instantly share code, notes, and snippets.

View paracycle's full-sized avatar

Ufuk Kayserilioglu paracycle

View GitHub Profile
@paracycle
paracycle / rails_admin.tr.yml
Created June 7, 2012 13:57
Rails Admin Turkish translation
tr:
admin:
home:
name: "Anasayfa"
pagination:
previous: "« Önceki"
next: "Sonraki »"
truncate: "…"
misc:
filter_date_format: "dd/mm/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
@paracycle
paracycle / sluggenerator.cs
Created November 30, 2012 18:24 — forked from onebeatconsumer/sluggenerator.cs
Slug Generator - C# - String Extension Method
/// <summary>
/// Generates a permalink slug for passed string
/// </summary>
/// <param name="phrase"></param>
/// <returns>clean slug string (ex. "some-cool-topic")</returns>
public static string GenerateSlug(this string phrase)
{
var s = phrase.RemoveAccent().ToLower();
s = Regex.Replace(s, @"[^a-z0-9\s-]", ""); // remove invalid characters
s = Regex.Replace(s, @"\s+", " ").Trim(); // single space
@paracycle
paracycle / Gemfile
Last active December 17, 2015 09:59 — forked from ethnt/Gemfile
How to use Sidekiq with Padrino on Heroku. This config enables you to run sidekiq inside your "web" dyno (See https://coderwall.com/p/fprnhg for details)
# ...
gem 'sidekiq'
gem 'slim'
gem 'unicorn'
# ...
@paracycle
paracycle / .powrc
Created May 29, 2013 15:50 — forked from nbibler/gist:5307941
A .powrc file that respects .rvmrc, .ruby-version and .ruby-gemset files.
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
fi
if [ -f ".ruby-version" ]; then
rvm use `cat .ruby-version`
fi
@paracycle
paracycle / convert.sql
Created July 29, 2013 19:50
Convert and merge WhatsApp databases from iPhone format to Android
-- Clear tables
DROP TABLE chat_list;
DROP TABLE messages;
-- Create new tables
CREATE TABLE chat_list (_id INTEGER PRIMARY KEY AUTOINCREMENT, key_remote_jid TEXT UNIQUE, message_table_id INTEGER);
CREATE TABLE messages (_id INTEGER PRIMARY KEY AUTOINCREMENT, key_remote_jid TEXT NOT NULL, key_from_me INTEGER, key_id TEXT NOT NULL, status INTEGER, needs_push INTEGER, data TEXT, timestamp INTEGER, media_url TEXT, media_mime_type TEXT, media_wa_type TEXT, media_size INTEGER, media_name TEXT, latitude REAL, longitude REAL, thumb_image TEXT, remote_resource TEXT, received_timestamp INTEGER, send_timestamp INTEGER, receipt_server_timestamp INTEGER, receipt_device_timestamp INTEGER, raw_data BLOB, media_hash TEXT, recipient_count INTEGER, media_duration INTEGER, origin INTEGER);
-- Attach Android and iPhone databases
ATTACH 'msgstore.db' AS android;
- { bin: 413226, banka_kodu: 10 , banka_adi: T.C. ZİRAAT BANKASI A.Ş. , type: VISA , subtype: PLATINUM , virtual: false , prepaid: false }
- { bin: 444676, banka_kodu: 10 , banka_adi: T.C. ZİRAAT BANKASI A.Ş. , type: VISA , subtype: CLASSIC , virtual: false , prepaid: false }
- { bin: 444677, banka_kodu: 10 , banka_adi: T.C. ZİRAAT BANKASI A.Ş. , type: VISA , subtype: GOLD , virtual: false , prepaid: false }
- { bin: 444678, banka_kodu: 10 , banka_adi: T.C. ZİRAAT BANKASI A.Ş. , type: VISA , subtype: PLATINUM , virtual: false , prepaid: false }
- { bin: 453955, banka_kodu: 10 , banka_adi: T.C. ZİRAAT BANKASI A.Ş. , type: VISA , subtype: CLASSIC , virtual: false , prepaid: false }
- { bin: 453956, banka_kodu: 10 , banka_adi: T.C. ZİRAAT BANKASI A.Ş. , type: VISA , subtype: GOLD , virtual: false , prepaid: false }
- { bin: 454671, banka_kodu: 10 , banka_adi: T.C. ZİRAAT B
@paracycle
paracycle / tckn_validator.rb
Created August 27, 2013 12:26
Rails TCKN validator
class TcknValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless validate_tckn(value)
record.errors.add(attribute, options[:message] || :invalid)
end
end
protected
def validate_tckn(tckn)
digits = tckn[0..8].each_char.map(&:to_i).each_with_index
@paracycle
paracycle / sidekiq.cap
Created September 18, 2013 13:50
sidekiq capistrano v3 tasks
namespace :load do
task :defaults do
set :sidekiq_timeout , -> { 10 }
set :sidekiq_role , -> { :app }
set :sidekiq_pid , -> { "#{current_path}/tmp/pids/sidekiq.pid" }
set :sidekiq_processes , -> { 1 }
set :rbenv_map_bins , fetch(:rbenv_map_bins).concat(%w(sidekiq sidekiqctl))
end
end
@paracycle
paracycle / validation.rb
Last active January 2, 2016 16:39
TCKN - VKN validation
def self.validate_tckn(tckn)
return false if invalid_value?(tckn, 11)
digits = tckn[0..-3].each_char.map(&:to_i).each_with_index
# Accumulate the check for both the last digit and the one-from-last
# digit in the same loop. So reduce takes a two element array as memo
# and returns the updated two element array at each iteration.
first, last =
digits.reduce([0, 0]) do |memo, (digit, idx)|