gem install rails -v 5.1.2 --no-ri --no-rdoc
rails _5.1.2_ new mysql_lock_wait_timeout_problem
cd mysql_lock_wait_timeout_problem
bundle exec rake db:create
bundle exec rails g model User first_name archived:boolean
bundle exec rails db:migrate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "http://rubygems.org" | |
gem "activerecord", "5.2.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="https://rawgit.com/jquery/jquery/1.12.4/dist/jquery.min.js"></script> | |
<script src="https://rawgit.com/moment/moment/develop/min/moment-with-locales.min.js"></script> | |
<script src="https://rawgit.com/longbill/jquery-date-range-picker/master/dist/jquery.daterangepicker.min.js"></script> | |
<link href="https://rawgit.com/longbill/jquery-date-range-picker/master/dist/daterangepicker.min.css" rel="stylesheet"/> | |
</head> | |
<body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function workon() { | |
echo "export CURRENT_PROJECT=$1" > ~/.current_project | |
cd "$HOME/Documents/work/$1" | |
} | |
[[ -f ~/.current_project ]] && source ~/.current_project | |
[[ $CURRENT_PROJECT ]] && cd ~/Documents/work/$CURRENT_PROJECT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For mysql | |
SET @id:=1 | |
SELECT id, @num:=@num + 1 AS num | |
FROM ( | |
SELECT id FROM email_notifications ORDER BY created_at ASC | |
) AS t | |
HAVING MOD(num, 101) = 0; | |
# For postgresql | |
SELECT id FROM ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE clients ( | |
first_name text, | |
last_name text | |
); | |
INSERT INTO clients (first_name, last_name) | |
(SELECT md5(random()::text) AS first_name, md5(random()::text) AS last_name | |
FROM (SELECT * FROM generate_series(1,1000000) AS id) AS x); | |
# trigram index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get install openjdk-9-jre | |
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.3.0.deb | |
sudo dpkg -i elasticsearch-2.3.0.deb | |
sudo update-rc.d elasticsearch defaults | |
# remove |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dump() { | |
time=$(date '+%H_%M_%S'); | |
date=$(date '+%Y_%m_%d'); | |
database=$1; | |
dumps_dir="$HOME/dumps"; | |
mkdir -p "$dumps_dir/$date"; | |
dumpfile=$dumps_dir/$date/$time"_"$database"_dump".psql.gz | |
pg_dump $database -W -U ontheway --no-privileges --clean --exclude-table=schema_migrations | gzip > $dumpfile; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Concord1 < Module | |
def initialize | |
define_a | |
end | |
def define_a | |
puts self | |
define_method :a do | | | |
puts "a" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install brew | |
# this will also download and install XCode https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12 | |
# xcode-select --install | |
sudo -u $USER /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \ </dev/null | |
brew update --force | |
# fix homebrew permissions (see http://stackoverflow.com/questions/16432071/how-to-fix-homebrew-permissions) | |
# sudo chown -R "$USER":admin /usr/local | |
# mysql56 (mysql57 ) |
NewerOlder