Skip to content

Instantly share code, notes, and snippets.

View halilim's full-sized avatar

Halil Özgür halilim

View GitHub Profile
@halilim
halilim / homebrew_postgres_recreate.sh
Created November 16, 2014 12:48
PostgreSQL recreate sequence craze - Homebrew Postgres, Y U NO collate tr_TR ?!
gem install lunchy
pg_dumpall > pg_all.sql
# Kill anything that access PostgreSQL before this, e.g. local rails server, pgAdmin etc
sudo lunchy stop homebrew.mxcl.postgresql
mv /usr/local/var/postgres{,.bak}
LC_CTYPE="tr_TR.UTF-8" initdb -E UTF-8 --locale=tr_TR --lc-collate=tr_TR --lc-ctype=tr_TR -D /usr/local/var/postgres/
sudo lunchy start homebrew.mxcl.postgresql
psql -f pg_all.sql -d postgres
# Make sure pg_all.sql is safe and can be restored before this
rm -rf /usr/local/var/postgres.bak
@halilim
halilim / Set Up MongoDB (2.6 and 3) Authentication.md
Last active August 29, 2015 14:13
Set Up MongoDB (2.6 and 3) Authentication

Set Up MongoDB (2.6 and 3) Authentication

  1. Create admin user

    use admin
    db.createUser(
        {
            user: "admin",

pwd: "***",

@halilim
halilim / IntelPowerGadgetMac3.0.1_licence
Created March 16, 2015 23:00
Intel Power Gadget Mac 3.0.1 licence
IMPORTANT - READ BEFORE COPYING, INSTALLING OR USING.
Do not copy, install, or use the "Materials" provided under this license agreement ("Agreement"), until you have carefully read the following terms and conditions.
By copying, installing, or otherwise using the Materials, you agree to be bound by the terms of this Agreement. If you do not agree to the terms of this Agreement, do not copy, install, or use the Materials.
End User License Agreement for the Intel(R) Power Gadget
1. LICENSE DEFINITIONS:
A. "Materials" are defined as the software in source and object code formats, documentation, license key codes and other materials, including any updates and upgrade thereto, that are provided to you under this Agreement.
@halilim
halilim / Capistrano Deployment Notes.md
Last active August 29, 2015 14:22
Capistrano Deployment Notes

Environment

  • Example ~/.bash_profile:
    [[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
    
    export RBENV_ROOT="${HOME}/.rbenv"
    
    if [ -d "${RBENV_ROOT}" ]; then
      export PATH="${RBENV_ROOT}/bin:${RBENV_ROOT}/plugins/ruby-build/bin:${PATH}"
@halilim
halilim / Comodo Essential SSL CA Bundle.md
Last active August 29, 2015 14:26
Comodo Essential SSL CA Bundle

Concatenate the files in the following order:

Root CA Certificate - AddTrustExternalCARoot.crt
Intermediate CA Certificate - COMODORSAAddTrustCA.crt
Intermediate CA Certificate - COMODORSADomainValidationSecureServerCA.crt
Your EssentialSSL Certificate - www_example_com.crt *

(*) Exclude the real certificate "www_example_com.crt" if CA bundle is entered separately.

@halilim
halilim / Paperclip_S3_IAM_user_per_bucket_region.md
Last active September 10, 2015 07:38
Paperclip S3 storage with IAM user per bucket and region support

Amazon

I'm assuming you have already created an Amazon AWS account and an S3 bucket.

  1. Open the [IAM console][1]

  2. Create a group:

    • Groups
    • Create New Group
  • (Enter a name, e.g. user_per_bucket) Next Step
@halilim
halilim / migrations.rb
Last active September 10, 2015 19:44
Bare bones e-commerce Rails models
class CreateTables < ActiveRecord::Migration
def change
create_table :products do |t|
# ...
end
create_table :orders do |t|
# ...
end
create_table :order_items do |t|
t.references :order, index: true, foreign_key: true
@halilim
halilim / digitize_benchmark.rb
Last active November 19, 2015 20:34
Benchmark various digitization methods
require 'benchmark/ips'
def digits_s(n)
n.to_s.chars.map(&:to_i)
end
# http://stackoverflow.com/a/12909952/372654
def digits_divmod(n)
n = n.abs
[].tap do |result|
@halilim
halilim / Chewy_price_filter.rb
Last active November 29, 2015 23:44
A stab at Elastic script filters for a multi-currency price filter
# Assumes gems: Chewy, Money and eu_central_bank
class SearchForm
include ActiveModel::Model
DEFAULTS = { 'currency' => 'TRY' }
attr_accessor :price_min, :price_max, :currency
# ...