This file contains 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 lsof -i :<port number> | |
# e.g. sudo lsof -i :8080 |
This file contains 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
# Communicate with GameAnalytics.com to download aggragrated data. | |
# Author: Jesdakorn S. (@thet0ny / http://www.ton.in.th / http://zaqqle.com) | |
require 'rubygems' | |
require 'active_support/core_ext/date' | |
require 'active_support/core_ext/numeric/time' # Date time helper (when use outside Rails) | |
require 'HTTParty' # gem install httparty | |
require 'JWT' # gem install jwt |
This file contains 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 HstoreQuery | |
attr_accessor :klass, :hstore_field, :parent | |
# parent = Game.first.players | |
# a = HstoreQuery.new Player, 'game_values', parent | |
# a.search 'float_money', '>', 9 | |
def initialize(klass, field, parent = nil) | |
self.klass = klass | |
self.hstore_field = field |
This file contains 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
# hstore customized, in the model. | |
# given your h store field is 'data' and the hash key named 'trace' | |
ransacker :trace do |parent| | |
Arel::Nodes::InfixOperation.new('->', parent.table[:data], 'trace') | |
end | |
# Filter some field out when query field selection for ransack from (Still put in your model) | |
def self.ransackable_attributes(auth_object = nil) | |
super - ['id', 'player', 'updated_at'] | |
end |
This file contains 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
start on started network | |
stop on stopping network | |
kill signal INT | |
respawn | |
script | |
export GOROOT=/home/ton/go | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$GOROOT/bin | |
export GOPATH=$GOROOT/gocode |
This file contains 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
Capybara.register_driver :poltergeist_ssl do |app| | |
Capybara::Poltergeist::Driver.new(app, js_errors: false, timeout: 5000, phantomjs_options: ['--ignore-ssl-errors=yes', '--ssl-protocol=any']) | |
end | |
Capybara.default_driver = :poltergeist_ssl |
This file contains 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
As Amazon AMI is a subset of Redhat so most of the tutorials will turn you to `yum` by adding or configuring some repo config file which those repo is old and tutorials are no longer valid. | |
To make it super easy, I would recommend you to use a static build of `ffmpeg` which you can find it at: | |
http://johnvansickle.com/ffmpeg/ | |
Get a latest stable release version (the 3rd or 4th line e.g. 2.5 at the moment of writing) not the 1st - 2nd line which is considerable as a unreleased build and maybe unstable. You can go ahead and copy a download link which correct to your machine CPU architecture e.g. 64bits | |
After that `ssh` to your Amazon EC2 and do: | |
``` |
This file contains 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
cd /var/log | |
sudo mkdir rails | |
sudo chown ec2-user:ec2-user rails | |
# /etc/logroate.conf | |
# Rotate weekly and when reached 52 rotations, notify or remove | |
# compress to .gz with delaycompress (compress will be done on next round of logrotation) | |
# ignore size 0 file | |
# copytruncate so we don't need to restart unicorn. |
This file contains 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 /bin/dd if=/dev/zero of=/var/swap1 bs=1G count=3 #(block size 1G for 3 which is 3GB in total) | |
# or sudo /bin/dd if=/dev/zero of=/var/swap1 bs=1M count=2048 | |
sudo /sbin/mkswap /var/swap1 | |
# Change permission so the swap file is secured. | |
sudo chmod 0600 /var/swap1 | |
# Turn swap on | |
sudo /sbin/swapon /var/swap1 | |
# Add auto (mount/)swapon when instance start | |
sudo vi /etc/fstab |
This file contains 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
mysqldump DATABASE --tables logs --where="created_at < '2015-03-01'" -u XXXX -pXXXXX --host ZZZZZZ.com > data.sql |
OlderNewer