Skip to content

Instantly share code, notes, and snippets.

View hendra's full-sized avatar

Hendra Nicholas hendra

View GitHub Profile
@hendra
hendra / gist:d32715cfa031e3a3c9a1afbf130cf19d
Last active December 13, 2019 15:00 — forked from tommydunn/gist:6f885cc3efbd505e327a
Setting up Atom for Rails development
brew install caskroom/cask/brew-cask
brew cask install atom
apm install linter # Base linter
apm install linter-ruby
apm install linter-scss-lint
apm install linter-coffeelint
apm install linter-rubocop
apm install linter-haml
@hendra
hendra / cloudflare-update-record.sh
Created June 13, 2019 16:51 — forked from 4ft35t/cloudflare-update-record.sh
Cloudflare API v4 Dynamic DNS Update in Bash
#!/bin/sh
# CHANGE THESE
auth_email="user@example.com"
auth_key="c2547eb745079dac9320b638f5e225cf483cc5cfdda41" # found in cloudflare account settings
zone_name="example.com"
record_name="www.example.com"
# MAYBE CHANGE THESE
ip=$(curl -s http://ipv4.icanhazip.com)
@hendra
hendra / db.rake
Created April 23, 2019 08:34 — forked from khalilgharbaoui/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6
# Benefits of: https://gist.github.com/e12e/e0c7d2cc1d30d18c8050b309a43450ac
# And fixes of: https://gist.github.com/joelvh/f50b8462611573cf9015e17d491a8a92
namespace :db do
desc 'Dumps the database to backups'
task dump: :environment do
dump_fmt = ensure_format(ENV['format'])
dump_sfx = suffix_for_format(dump_fmt)
backup_dir = backup_directory(Rails.env, create: true)
@hendra
hendra / install-rbenv.sh
Created December 6, 2018 13:35 — forked from njh/install-rbenv.sh
Install/update rbenv
# Download rbenv
if [ ! -d ~/.rbenv ]; then
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
fi
cd ~/.rbenv
git reset --hard
git pull origin master
@hendra
hendra / skcluster.rb
Created August 17, 2018 13:58 — forked from stympy/skcluster.rb
Sidekiq cluster control script and systemd service
#!/usr/bin/env ruby
require 'sidekiq'
require 'sidekiq/cli'
# Default to running one process per core
def process_count
return ENV['SK_PROCESS_COUNT'].to_i unless ENV['SK_PROCESS_COUNT'].to_i == 0
case RbConfig::CONFIG['host_os']
@hendra
hendra / gist:bece1aca00db9b5b72fc86a8b3a58f53
Created August 15, 2018 04:36 — forked from luckydev/gist:b2a6ebe793aeacf50ff15331fb3b519d
Increate max no of open files limit in Ubuntu 16.04 for Nginx
# maximum capability of system
user@ubuntu:~$ cat /proc/sys/fs/file-max
708444
# available limit
user@ubuntu:~$ ulimit -n
1024
# To increase the available limit to say 200000
user@ubuntu:~$ sudo vim /etc/sysctl.conf
@hendra
hendra / gist:9490915377f3523a08c0a88493b636d9
Created August 8, 2018 18:43 — forked from carlos8f/gist:3557993
how to raise file descriptor limits on mac os x
$ ulimit -n
2560
$ sudo su
$ echo "limit maxfiles 10000000 10000000" >> /etc/launchd.conf
(now restart mac os)
$ ulimit -n
10000000
@hendra
hendra / fix-libv8-mac.txt
Created August 8, 2018 08:35 — forked from fernandoaleman/fix-libv8-mac.txt
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
@hendra
hendra / OS X network optimize.txt
Last active March 5, 2020 11:06 — forked from snoby/OS X network optimize.txt
OSX Sierra Network & System Performance Tweaks
#
# Reboot into recovery mode (cmd +r ) and in the terminal
#
nvram boot-args="serverperfmode=1 ncl=262144"
#reboot
#
# In regular mode
@hendra
hendra / bench_rails_memory_usage.rb
Created June 30, 2018 09:44 — forked from brianhempel/bench_rails_memory_usage.rb
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0