Skip to content

Instantly share code, notes, and snippets.

View firmanm's full-sized avatar

Firman M firmanm

  • Jakarta
View GitHub Profile
@firmanm
firmanm / setup.md
Created January 16, 2020 08:26 — forked from MyklClason/rails_guide.md
AWS Cloud9 Rails Setup (and migration from c9.io) for Rails 5.2

Overview

Warning: This guide intended for Rails 5.2, and may be incompletefor Rails 6 setup. This guide will be updated once Rails 6.1 comes out.

This is direction for Migration from c9.io to AWS Cloud9, after you follow the cloud9 migration directions and created a workspace, keeping in mind the Workspace settings Section below.

Be sure you are using the right version of rails. You may need to remove rails and rail-ties and install rails 5.2.

@firmanm
firmanm / gist:f13baa9f31a97e20441e5a8eb506c91e
Created June 25, 2018 01:11 — 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
@firmanm
firmanm / attachinary_setup.md
Created October 25, 2017 06:41 — forked from ssaunier/attachinary_setup.md
Attachinary Setup in Rails 5

Attachinary Setup

First add the following gems to your Gemfile:

# Gemfile
gem "attachinary"
gem "jquery-fileupload-rails"
gem "coffee-rails"
@firmanm
firmanm / deploy-static-site-heroku.md
Created October 23, 2017 13:11 — forked from wh1tney/deploy-static-site-heroku.md
How to deploy a static website to Heroku

Gist

This is a quick tutorial explaining how to get a static website hosted on Heroku.

Why do this?

Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.

Basic Assumptions

@firmanm
firmanm / gist:9474d492d9d9abb4494af6e45e4a9f38
Created April 15, 2017 09:42 — forked from jimmyeisenhauer/gist:2795771
Drop and Rebuild Heroku database
heroku pg:reset SHARED_DATABASE --confirm fasterfaster
heroku run rake db:migrate
heroku run console
Rails.cache.clear
heroku restart
- manually add one record to test
- run performance test
@firmanm
firmanm / spree-api-rest-examples.md
Created December 14, 2016 03:04 — forked from jcowhigjr/spree-api-rest-examples.md
Spree API REST Examples

Products

index of products 25 first

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products.json

Show a product

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products/706676762.json

Modify a product

curl -i -X PUT -H "X-Spree-Token: YOUR_TOKEN_ID" -d "product[name]=Headphones" http://0.0.0.0:3000/api/products/706676762.json

@firmanm
firmanm / gist:0acd94242339ad4d5fb1c31bb6d9c0a2
Created September 29, 2016 07:41 — forked from bkimble/gist:1365005
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@firmanm
firmanm / gist:c091cd5e092b11c57cc6676de1870108
Created September 16, 2016 07:32 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@firmanm
firmanm / bench_rails_memory_usage.rb
Created August 9, 2016 06:08 — 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
@firmanm
firmanm / gist:9f7ad00c46a6255e53d71a8e1e897012
Created August 5, 2016 10:23 — forked from sebboh/gist:f1dfe4f096746c45f3e9ea06a09743a0
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

This method does not add your OAuth token to Gemfile.lock. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying.

  1. Generate an OAuth token from GitHub