Skip to content

Instantly share code, notes, and snippets.

View pyk's full-sized avatar
🐈‍⬛
I may be slow to respond.

pyk pyk

🐈‍⬛
I may be slow to respond.
View GitHub Profile

punya satu kategori:

shoes = Category.create(name: "shoes")

terus ada beberapa produk yang dimasukkan ke kategori shoes:

sepatu_a = Product.create(name: "sepatu a")
@pyk
pyk / gist:8815299
Last active August 29, 2015 13:56 — forked from schneems/gist:3079202
## Week 5 Quiz
## 0) Name 3 types of variables in Ruby? Put them in order from least scope to greatest.
local variable (var) , instance variable (@var), class variable (@@var), constant variable (VAR)
## 1) Where do SQL queries belong, the view or controller?
controller
def self.run
# set current working directory
file_path = File.expand_path(__FILE__) # File.join(Dir.getwd, __FILE__))
file_workdir = File.dirname( file_path )
file_logdir = File.join(file_workdir, 'log')
Dir.chdir file_workdir
@@cwd = Dir.getwd
@@name = File.basename($0)
@@hostname = Socket.gethostname
@pyk
pyk / gist:8718360
Last active August 29, 2015 13:55 — forked from schneems/gist:3029994
## 1) What does MVCr stand for?
Model, View, Controller (routes)
## 2) In what file do we store 'r' from MVCr ?
config/routes.rb
@pyk
pyk / gist:8613205
Last active January 4, 2016 11:09 — forked from schneems/gist:3036609
## Week 3 Quiz
## 1) What does ERB stand for?
Embedded Ruby
## 2) What is the name of the place (library) where additional built in Ruby functions can be accessed?
STDlib
# generate using this gems : http://rubygems.org/gems/terminal-table
require "terminal-table"
title = "posts"
properties = ["id", "title", "author_name", "body"]
r = []
r << [1, "I love dogs", "John", "woof"]
r << [2, "cars are great", "Sara", "I think they are"]
@pyk
pyk / active-record-migration-expert.md
Last active August 2, 2021 09:20
become active record migration expert (Rails 4.0.2)

become active record migration expert (Rails 4.0.2)

workflow:

create model

$ rails g model NameOfModel
    invoke  active_record
    create    db/migrate/YYYYMMDDHHMMSS_create_name_of_models.rb
@pyk
pyk / less_converter.rb
Last active January 2, 2016 18:49 — forked from KBalderson/less_converter.rb
Using LESS on Jekyll site . for using intructions see here https://kippt.com/bayu/notes/clips/18862841
module Jekyll
class LessConverter < Converter
safe true
priority :high
def setup
return if @setup
require 'less'
@setup = true
rescue LoadError
@pyk
pyk / installing postgresql 9.3.2 on ubuntu 12.04.md
Created January 3, 2014 18:05
installing postgresql 9.3.2 on ubuntu 12.04 . with error fix: ummet dependencies

installing postgresql 9.3.2 on ubuntu 12.04

$ echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-9.3 postgresql-contrib-9.3

you should succesfully installing postgresql 9.3.2 on your machine.

@pyk
pyk / kenapa-kok-infinite.md
Last active January 1, 2016 07:48
kenapa kok infinite

kenapa kok infinite?

Konsep dasar loop di javascript

# for loop
for (var; kondisi; increment){}

# while loop
while (kondisi){}