Skip to content

Instantly share code, notes, and snippets.

View hendra's full-sized avatar

Hendra Nicholas hendra

View GitHub Profile
@hendra
hendra / rails_cors
Created March 18, 2020 03:49
rails cors
# Be sure to restart your server when you modify this file.
# Avoid CORS issues when API is called from the frontend app.
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
# Read more: https://github.com/cyu/rack-cors
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
@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 / syntax-specific-settings.yml
Last active April 14, 2019 01:50
syntax-specific settings
// Settings in here override those in "Default/Preferences.sublime-settings",
// and are overridden in turn by syntax-specific settings.
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"indent_to_bracket": true,
"indent_to_bracket": true,
"block_caret": true,
"match_brackets_angle": true,
"move_to_limit_on_up_down": 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