Skip to content

Instantly share code, notes, and snippets.

@ilyakatz
ilyakatz / primary_key_autoincrement. rb
Created February 5, 2014 19:30
Update the value of the primary key auto increment for a model in rails
klazz = SoftwareMember
klazz .connection.execute("ALTER TABLE #{klazz .table_name} AUTO_INCREMENT = 1000")
@ilyakatz
ilyakatz / active_admin.rb
Created August 12, 2014 17:35
Custom default order order in active_admin
# initializers/active_admin.rb
module ActiveAdmin
class OrderClause
alias_method :initialize_old, :initialize
alias_method :valid_old?, :valid?
alias_method :to_sql_old, :to_sql
def initialize(clause)
if clause.class == String
initialize_old(clause)
Verifying that +katzmopolitan is my Bitcoin username. You can send me #bitcoin here: https://onename.io/katzmopolitan
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFRY6TUBCADgzqFSpV15H77BC574fnzYNl7rFEerbyeK1JIwnkCRvssS/S8ZzGNwgYUn
eMZFT3t9euYAzTx0WgHwhdDUZpRPXsYIfzjz44bXPd4yhJtes12twpj4ZD9RBmbDLnnVpPY1
ZVvk6EICKsy3FuwaQ1t/SxwWJ/w/aVHzTmlvxHuLYsp418Ik+5S+EAg/zB0ME/V89BUNiC/w
tEisE2EZj6JZSXeQrs7YQhZxe5E5HNewBdEvpigvlFUS/Q3aObeFe1lj5M1sGn6Cmrzs8GXy
Q/qWzVuRqjiVy7229Tm2+yARLm87KbbyRWVjdj43ykM1NcDwl/GEau57o6QNuwKUl1KrABEB
AAG0HklseWEgS2F0eiA8aWx5YWthdHpAZ21haWwuY29tPokBMgQQAQgAJgUCVFjpNwYLCQgH
AwIJEFLp7GBMMJSGBBUIAgoDFgIBAhsDAh4BAACvwAf/dv8j/OfJ1IjxQrFvRXv/BxTBZ8UD
99igTFHM8KuYhK/AluOKQZMR34yUNVyGPvO6Iz3+jDeES8d3PoVOOD8y7VKtqwkooXLjFb4m
@ilyakatz
ilyakatz / opsworks.rb
Last active August 29, 2015 14:22
Viewing logs in OpsWorks
require 'aws-sdk-core'
deployments = opsworks.describe_commands(deployment_id: deployment_id)
region = "us-east-1"
opsworks = Aws::OpsWorks::Client.new(region: region)
deployments = opsworks.describe_commands(deployment_id: deployment_id)
deployments[0].collect(&:log_url).compact
@ilyakatz
ilyakatz / gist:1590356
Created January 10, 2012 18:22
see the full real path from the symbolic link
#!/usr/bin/env python
import os,sys
print os.path.realpath(sys.argv[1])
@ilyakatz
ilyakatz / mouseflow_with_rails.rb
Created March 1, 2012 21:45
Mouseflow session support with Rails
require 'net/http'
require 'uri'
class Admin::MouseflowController < ApplicationController
#these are optional if you using authentication and ssl
skip_before_filter :authenticate_login!
def ssl_required?
false
@ilyakatz
ilyakatz / .gitconfig
Created June 26, 2012 15:12
Sample .gitconfig file
[user]
name = YOUR_NAME
email = YOU_EMAIL
[credential]
helper = osxkeychain
[core]
excludesfile = /Users/[YOURNAME]/.gitignore_global
quotepath = false
[help]
autocorrect = 1
@ilyakatz
ilyakatz / pre-commit.bash
Created July 10, 2012 22:25
Disable commits to master
#!/bin/bash
if [[ `git symbolic-ref HEAD` == "refs/heads/master" ]]
then
if [[ ! -f /tmp/master_commit ]]
then
echo "*************************"
echo "CANNOT COMMIT TO MASTER!"
echo "To override this behavior"
echo "touch /tmp/master_commit"
@ilyakatz
ilyakatz / mouseflow.js
Created July 12, 2012 21:39
Safe mouseflow script inclusion
(function () {
var msf_script = document.createElement('script');
msf_script.type = 'text/javascript';
msf_script.src =
('https:' == document.location.protocol ? 'https://' : 'http://') +
'cdn.mouseflow.com/projects/ba141427-dfd0-4d3a-acbe-37df41b6c8e0.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(msf_script, s);
})();