Skip to content

Instantly share code, notes, and snippets.

View saiury92's full-sized avatar
🎯
Focusing

Khánh Thiện saiury92

🎯
Focusing
View GitHub Profile
@saiury92
saiury92 / fixup.sh
Created April 27, 2021 09:49 — forked from stepankuzmin/fixup.sh
Git alias for squashing last N commits into it's parents
git config --global alias.fixup "\!f(){ git reset --soft HEAD~${1} && git commit --amend -C HEAD; };f"
git fixup 1 # squashes last commit into it's parent

Typical rails setup with docker+puma+nginx+postgres

Zaid Annas

Devsinc inc. 30/08/2018

Overview

$ benchmark-driver benchmark.yml --rbenv '2.0.0::2.0.0-p648 --disable-gems;2.5.3::2.5.3 --disable-gems;2.6.0-preview3::trunk --disable-gems;2.6.0-preview3+JIT::trunk --disable-gems --jit' -v --repeat-count 24
2.0.0: ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]
2.5.3: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
2.6.0-preview3: ruby 2.6.0dev (2018-10-31 trunk 65474) [x86_64-linux]
2.6.0-preview3+JIT: ruby 2.6.0dev (2018-10-31 trunk 65474) +JIT [x86_64-linux]
Calculating -------------------------------------
2.0.0 2.5.3 2.6.0-preview3 2.6.0-preview3+JIT
Optcarrot Lan_Master.nes 34.548 48.314 54.535 85.690 fps
Comparison:
@saiury92
saiury92 / ssl_puma.sh
Created June 28, 2018 08:13 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@saiury92
saiury92 / gist:fb11b8787e8d5efcae23e8e5c2a5886f
Created March 2, 2018 07:08 — forked from mrtns/gist:78d15e3263b2f6a231fe
Upgrade Chrome from Command Line on Ubuntu
# Install
# via http://askubuntu.com/questions/510056/how-to-install-google-chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
# Update
@saiury92
saiury92 / config_server_with_chef_for_rails.md
Created August 25, 2017 08:28 — forked from francois-blanchard/config_server_with_chef_for_rails.md
Build server with chef for deploy rails app

Configure server for deploy rails app

Objective

Prepare a server for a Rails app with MySQL (percona) + NGINX (passenger)
Deploy rails app in new server with Capistrano v3

For this example we need :

@saiury92
saiury92 / edge_detection.rb
Created January 11, 2017 08:43 — forked from jrobertson/edge_detection.rb
Edge detection with the Sobel operator in Ruby
require 'chunky_png'
class ChunkyPNG::Image
def at(x,y)
ChunkyPNG::Color.to_grayscale_bytes(self[x,y]).first
end
end
img = ChunkyPNG::Image.from_file('engine.png')
@saiury92
saiury92 / promises.md
Created December 10, 2015 01:40 — forked from bricker/promises.md
Promises in Rails callbacks, using after_save and after_commit together.

"Russian-Doll Caching" is great. It embraces the Rails (and Ruby) goal to "make the developer happy". And it does. Not having to worry about cache expiration is superb.

It has its limits, though. If you're trying to avoid any database queries, russian-doll caching will not work for you. If you are trying to represent thousands, or even hundreds, of objects under a single cache fragment, russian-doll caching is not the best option.

We use it whenever it makes sense, but sometimes we just have to bite the bullet and expire a cache fragment manually. When you want to start manually expiring cache on a fairly busy website, you have to start considering race conditions. I recently ran into the following scenario:

class Post < ActiveRecord::Base
  after_save :expire_cache
  
@saiury92
saiury92 / .gitconfig
Created December 9, 2015 09:20 — forked from RajaJaganathan/.gitconfig
my favorites gitconfig options
[user]
name = Raja J
email = raja_j@apple.com
[alias]
aa = add --all
br = branch
ca = commit --amend
cb = checkout -b
cm = commit -a --amend -C HEAD
ci = commit -a -v
@saiury92
saiury92 / provision1404.sh
Created October 28, 2015 04:40 — forked from dakira/provision1604.sh
Basic provisioning for Ubuntu 14.04
#!/bin/bash
apt-get update
apt-get install -y dialog
apt-get -y dist-upgrade
apt-get install -y bash-completion joe-jupp mosh byobu software-properties-common \
php5-fpm php5-gd php5-ldap php5-mysql php5-mcrypt php5-json php5-sqlite \
libapache2-mod-fastcgi \
python-setuptools python-simplejson python-imaging python-mysqldb python-flup \