Skip to content

Instantly share code, notes, and snippets.

@drogus
drogus / Rakefile.rb
Created July 26, 2013 10:49
This is the example contents of the Rakefile, which you would use to run active record tasks without using Rails. It assumes using the same directories as rails uses: `db/migrate`, `config/database.yml`.
require 'bundler/setup'
require 'active_record'
include ActiveRecord::Tasks
db_dir = File.expand_path('../db', __FILE__)
config_dir = File.expand_path('../config', __FILE__)
DatabaseTasks.env = ENV['ENV'] || 'development'
@kondei
kondei / AutoHotKey.ahk
Created May 13, 2014 13:24
無変換を使い倒し、あと色々便利化するAutoHotKeyのスクリプト
;「;」を行頭につけるとコメント
;文法は公式ドキュメント(http://www.autohotkey.com/docs/)参照のこと
;windowsの設定でログイン時に自動起動するようにすると楽
;----------------------------------------------------------
;検索関数
;ウェブのアドレスならそれを開く
;ディレクトリアドレスならエクスプローラで開く
;文字列ならGoogle検索
@hopsoft
hopsoft / db.rake
Last active July 5, 2024 14:52
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@Yimiprod
Yimiprod / difference.js
Last active July 13, 2024 15:07
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
@nashirox
nashirox / rails-validates.rb
Last active May 31, 2024 04:11
Rubyのバリデーション用正規表現集
#
# 数字
#
# 全て数値(全角)
/\A[0-9]+\z/
# 全て数値(半角)
/\A[0-9]+\z/
@fleveque
fleveque / s3_folder_upload.rb
Last active November 21, 2022 17:22
Upload folder to S3 recursively with ruby, multi threads and aws-sdk v2 gem, based on http://avi.io/blog/2013/12/03/upload-folder-to-s3-recursively/
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket, :include_folder
attr_accessor :files
# Initialize the upload class
@tamamushi
tamamushi / docker-compose_setup4centos67.md
Last active March 3, 2019 15:16
CentOS6.7にdocker-composeをインストール

CentOS 6.7へのdocker-composeインストールメモ

docker-composeとdocker-engineとCentOSのバージョン関係

docker-compose docker-engine CentOS
1.7.0 1.9.1- 7.0
1.6.2 1.9.1- 7.0
1.5.2 1.7.1- 6.7
function ghq-fzf() {
local selected_dir=$(ghq list | fzf --query="$LBUFFER")
if [ -n "$selected_dir" ]; then
BUFFER="cd $(ghq root)/${selected_dir}"
zle accept-line
fi
zle reset-prompt
}
@masfj
masfj / spotlight-reload.org
Created August 21, 2017 06:37
Spotlightが/Applications内の.appを正しく表示しなくなった時の対応

ターミナル上で以下のコマンドを叩く

sudo mdutil -a -i off
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist 
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist 
sudo mdutil -a -i on
@doitian
doitian / rails-cookie-decrypt.go
Created September 23, 2017 07:30
rails session encrypt