Skip to content

Instantly share code, notes, and snippets.

View kafaichoi's full-sized avatar
🍃

KaFai kafaichoi

🍃
View GitHub Profile
@kafaichoi
kafaichoi / answer_for_quiz1_rail.md
Last active August 29, 2015 14:01
My answer for the quiz in the lesson 1 of Rails
  1. Why do they call it a relational database? Relational database are usually consisted of different tables which are related to other table by foreign key. And Foreign key in one table is the primary key of a record in another table. We can easily make a query base on different criteria on different table by joining the table.

2.What is SQL? SQL stands for Structured Query Language. It is a Domain Specific Language for managing data in RDBMS

  1. There are two predominant views into a relational database. What are they, and how are they different? They are the data and schema views. Data view displays like a spreadsheet. A schema view descripts the column names and the value type of each column.

  2. In a table, what do we call the column that serves as the main identifier for a row of data? We're looking for the general database term, not the column name.

Quiz: Lesson 3
1. What's the difference between rendering and redirecting? What's the impact with regards to instance variables, view templates?
They both complete a request but redirect will tell the client (browser) to send a brand-new request to a new URL. Therefore, no instance variable from previous action triggering the redirect will be available to the redirected view template . For rendering, the instance variable from the action will be avaiable for the view template being rendered.
2. If I need to display a message on the view template, and I'm redirecting, what's the easiest way to accomplish this?
flash[:notice]
3.If I need to display a message on the view template, and I'm rendering, what's the easiest way to accomplish this?
<p>This is deprecated, in future versions you may need to <code>bundle binstub rails</code> to work around a system/bundle conflict.<br>
/home/kafai/.rvm/gems/ruby-2.0.0-p481/gems/paratrooper-0.0.1/lib/paratrooper.rb:1:in <code>require': cannot load such file -- heroku (LoadError)<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481/gems/paratrooper-0.0.1/lib/paratrooper.rb:1:in</code>'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in <code>require'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in</code>block (2 levels) in require'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in <code>each'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in</code>block in require'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in <code>each'<br>
@kafaichoi
kafaichoi / gist:823266d43a04a902b468
Created September 5, 2014 08:37
Curl for nested json request
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user":{"fullname":"Bob Chan","email":"[email protected]","password":"password"}}' http://localhost:3000/api/users
@kafaichoi
kafaichoi / gist:a6f8bda444da4e3a5886
Created September 17, 2014 06:39
Setting Up test build for Ionic App for HockeyApp
Register in HockeyApp
-Android
1. cordova build --release android
2. keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
3. jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name
4. zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk
5. upload apk file to HockeyApp
-IOS
1. cordova build --release ios
@kafaichoi
kafaichoi / gist:aac9865ae19fa20666c7
Last active August 29, 2015 14:07
CQL create table
CREATE TABLE shake_magnitudes (
event_id int,
user_id int,
recorded_at timestamp,
magnitude float,
PRIMARY KEY (event_id, user_id, recorded_at)
)
WITH CLUSTERING ORDER BY (user_id ASC, recorded_at ASC);
:e. :edit . at current working directory
:sp. :split . in split at current working directory
:vs. :vsplit . in vertical split at current working directory
:E :Explore at directory of current file
:Se :Sexplore in split at directory of current file
:Vex :Vexplore in vertical split at directory of current file
% create a new file
d create a new directory
R rename the file/directory under the cursor
@kafaichoi
kafaichoi / install.sh
Created May 16, 2016 13:21 — forked from chaos-ad/install.sh
Installing erlang in ubuntu
#!/bin/bash
# installing erlang on ubuntu's
VERSION="R15B01"
sudo apt-get install build-essential libncurses5-dev openssl libssl-dev
sudo mkdir -p /opt/erlang/
curl -O https://raw.github.com/spawngrid/kerl/master/kerl && chmod a+x kerl
sudo mv kerl /opt/erlang/
@kafaichoi
kafaichoi / upgrade-postgres-9.3-to-9.5.md
Created June 6, 2016 03:34 — forked from johanndt/upgrade-postgres-9.3-to-9.5.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main