Skip to content

Instantly share code, notes, and snippets.


syafiq faiz syafiqfaiz

View GitHub Profile
cgoldberg /
Last active Jan 8, 2021
download and install latest geckodriver for linux or mac (selenium webdriver)
# download and install latest geckodriver for linux or mac.
# required for selenium to drive a firefox browser.
json=$(curl -s
if [[ $(uname) == "Darwin" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("macos"))')
elif [[ $(uname) == "Linux" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64"))')
justjanne / Price
Last active Oct 27, 2020 — forked from kylemanna/price.txt
Server Price Breakdown: DigitalOcean, Amazon AWS LightSail, Vultr, Linode, OVH, Hetzner, Scaleway/
View Price

Server Price Breakdown: DigitalOcean, Amazon AWS LightSail, Vultr, Linode, OVH, Hetzner, Scaleway/



Provider Type RAM Cores Storage Transfer Network Price
briankung /
Last active Dec 29, 2020
Using pry-rails with Docker

First, add pry-rails to your Gemfile:

gem 'pry-rails', group: :development

Then you'll want to rebuild your Docker container to install the gems

mcshakes / Rails C error.
Created Oct 14, 2016
Running into RVM and readline issues
View Rails C error.
$ rails c
Running via Spring preloader in process 7916
/Users/edmac/.rvm/gems/ruby-2.3.1/gems/activesupport- `require': dlopen(/Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle
Reason: image not found - /Users/edmac/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin14/readline.bundle
Fixed with:
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
syafiqfaiz /
Last active Jan 21, 2021
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
    • the database is restored
Aerlinger / fg_find_or_create.rb
Last active Feb 3, 2017
find_or_create with factory girl
View fg_find_or_create.rb
module FactoryGirl
def self.find_or_create(resource_name, attributes = {}, &block)
clazz = resource_name.to_s.classify.constantize
model = clazz.find_by(attributes) ||, attributes)
yield(model) if block_given? && model.new_record?
View database_cleaner.rb
RSpec.configure do |config|
config.before(:suite) do
config.before(:each) do
DatabaseCleaner.strategy = :transaction
config.before(:each, js: true) do
jonathanmoore / gist:2640302
Created May 8, 2012
Get the share counts from various APIs
View gist:2640302

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.


henrik / luhn_checksum.rb
Created Nov 30, 2011
Luhn checksum/check digit generation in Ruby.
View luhn_checksum.rb
class Luhn
def self.checksum(number)
digits = number.to_s.reverse.scan(/\d/).map { |x| x.to_i }
digits = { |d, i|
d *= 2 if i.even?
d > 9 ? d - 9 : d
sum = digits.inject(0) { |m, x| m + x }
mod = 10 - sum % 10
mod==10 ? 0 : mod