Skip to content

Instantly share code, notes, and snippets.

View zainalmustofa's full-sized avatar
🎯
Focusing

zainal mustofa zainalmustofa

🎯
Focusing
View GitHub Profile
@zainalmustofa
zainalmustofa / areas.json
Last active September 10, 2018 17:07
test.json
{
"items": {
"countries": [
{
"id": 192,
"name": "Aceh",
"cities": [
{
"id": 2252,
@zainalmustofa
zainalmustofa / mysql.database.yml
Last active October 4, 2016 03:10
Sample config/database.yml from Ruby On Rails. Postgres, MySQL, and SQLite
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
default: &default
@zainalmustofa
zainalmustofa / err-src.js
Created September 27, 2016 01:29
Handle image not found (404, 500)
// on folder app/directives
"use strict";
angular.module('myApp').directive('errSrc', [function() {
return {
link: function(scope, element, attrs) {
element.bind('error', function() {
if (attrs.src != attrs.errSrc) {
attrs.$set('src', attrs.errSrc);
}
@zainalmustofa
zainalmustofa / spin.rb
Created August 18, 2016 04:19
Create ASCII spining in the console
def spin_it(fps=10)
chars = %w[⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷] #you can change with your style
delay = 1.0/fps
iter = 0
spinner = Thread.new do
while iter do # Keep spinning until told otherwise
print chars[(iter+=1) % chars.length]
sleep delay
print "\b"
end

http://guides.rubyonrails.org/getting_started.html

Rails Guides Getting Started Notes

rails new -h see all app builder switches

File/Folder Purpose

app/ Contains the controllers, models, views and assets for your application. You'll focus on this folder for the remainder of this guide.
config/ Configure your application's runtime rules, routes, database, and more. This is covered in more detail in Configuring Rails Applications
config.ru Rack configuration for Rack based servers used to start the application.

@zainalmustofa
zainalmustofa / zsh.md
Created February 10, 2016 04:55 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
@zainalmustofa
zainalmustofa / Ruby on Rails Helpers: h, j, l and t.txt
Last active August 31, 2015 07:18
Ruby on Rails Helpers: h, j, l and t
Ruby on Rails Helpers: h, j, l and t
There are four one-char Rails helpers that seasoned developers use all the time for their simplicity and expressiveness:
h, alias for html_escape
h is a helper for escaping HTML tag characters.
Reference: http://api.rubyonrails.org/classes/ERB/Util.html#method-c-html_escape
## show Briefs [/api/member/briefs/{id}]
### show Briefs for buyer [GET]
+ Parameters
+ id (required, number, `1`) ... Numeric `id` of the Note to perform action with. Has example value.
+ Request (application/json)
{
"user_id" : "2",
"auth_token": "A4nvpgims6Go_j8CfWU8"