Skip to content

Instantly share code, notes, and snippets.

View paracycle's full-sized avatar

Ufuk Kayserilioglu paracycle

View GitHub Profile
@paracycle
paracycle / async_query_test.rb
Created April 3, 2021 19:46
Rails 7 Async Query
# frozen_string_literal: true
require "bundler/inline"
gemfile(false) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "activerecord", github: "rails/rails"
gem 'benchmark-ips'
045187663187b475992e14e7a90c31ae9242973ec075dd252e27dc663db11de58926316eaadd4e7bbee9a31adcabf5fdf2c070b5957900b77baaabd43705e7282a;atesgoral
@paracycle
paracycle / testfile.rb
Created February 21, 2015 12:05
Test Gist
def hello
"world"
end
puts "hello #{hello}"
### Keybase proof
I hereby claim:
* I am paracycle on github.
* I am ufuk (https://keybase.io/ufuk) on keybase.
* I have a public key whose fingerprint is E873 99AE 418B 02F8 E23A F5D6 A2A0 E7D7 D418 DEBB
To claim this, I am signing this object:
@paracycle
paracycle / bin_numbers.json
Created February 17, 2014 13:57
Kredi Kartlari Bin Numaralari
[
{"binNumber": "400684", "bankName": "ING Bank A.Ş.", "cardBrand": "Bonus", "bankCode": "099"},
{"binNumber": "401622", "bankName": "YAPI ve KREDİ BANKASI A.Ş.", "cardBrand": "World", "bankCode": "067"},
{"binNumber": "401738", "bankName": "GARANTİ BANKASI A.Ş.", "cardBrand": "Bonus", "bankCode": "062"},
{"binNumber": "402275", "bankName": "ASYA KATILIM BANKASI A.Ş.", "cardBrand": "Asya", "bankCode": "208"},
{"binNumber": "402276", "bankName": "ASYA KATILIM BANKASI A.Ş.", "cardBrand": "Asya", "bankCode": "208"},
{"binNumber": "402277", "bankName": "FİNANSBANK A.Ş.", "cardBrand": "CardFinans", "bankCode": "111"},
{"binNumber": "402278", "bankName": "FİNANSBANK A.Ş.", "cardBrand": "CardFinans", "bankCode": "111"},
{"binNumber": "402280", "bankName": "ASYA KATILIM BANKASI A.Ş.", "cardBrand": "Asya", "bankCode": "208"},
{"binNumber": "402458", "bankName": "TÜRK EKONOMİ BANKASI TEB A.Ş.", "cardBrand": "Bonus", "bankCode": "032"},
@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)|
@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 / 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
- { 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 / 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;