Skip to content

Instantly share code, notes, and snippets.

View liuzxc's full-sized avatar
🎯
Focusing

刘兴起 liuzxc

🎯
Focusing
View GitHub Profile
Something else I found helpful along the way (as I had old stuff installed):
gem uninstall --install-dir /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 rails
@liuzxc
liuzxc / check_purchase_status.rb
Last active August 29, 2015 14:14
Checks the android purchase and consumption status
# -*- encoding : utf-8 -*-
require 'net/http'
require 'json'
module CheckPurchaseStatus
CLIENT_ID = "xxxxxxxxxxxx"
CLIENT_SECRET = "xxxxxxxxxx"
REDIRECT_URIS = "https://xxxxxxxxxx"

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action

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
@liuzxc
liuzxc / 0_reuse_code.js
Created January 14, 2016 02:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@liuzxc
liuzxc / install
Last active March 2, 2016 10:04
Install pip and virtualenv for Ubuntu
$ sudo apt-get install python-pip python-dev build-essential
$ sudo pip install --upgrade pip
$ sudo pip install --upgrade virtualenv
sudo apt-get install redis-server
pip install flower
@liuzxc
liuzxc / load_test_data.sh
Created March 19, 2016 03:36 — forked from clintongormley/load_test_data.sh
Run these commands in your shell to setup the test data for Chapter 5
curl -XPUT 'http://localhost:9200/us/user/1?pretty=1' -d '
{
"email" : "john@smith.com",
"name" : "John Smith",
"username" : "@john"
}
'
curl -XPUT 'http://localhost:9200/gb/user/2?pretty=1' -d '
{
@liuzxc
liuzxc / goto-sublime
Created February 9, 2017 02:45 — forked from kendellfab/goto-sublime
Add mouse click `goto definition` in sublime text 3.
Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User
Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User
Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User
[
{
"button": "button1",
"count": 1,
"modifiers": ["ctrl"],
"press_command": "drag_select",
@liuzxc
liuzxc / consumer.go
Last active January 31, 2018 08:03 — forked from ebenoist/consumer.go
nsq consumer
package main
import (
"errors"
"log"
"os"
"os/signal"
"syscall"
"github.com/nsqio/go-nsq"
@liuzxc
liuzxc / docker-compose.yml
Created January 31, 2018 15:08 — forked from dudleycarr/docker-compose.yml
Docker Compose for nsq, StatsD, Graphite, and Grafana
graphitestatsd:
image: hopsoft/graphite-statsd
expose:
- 80
- 8125/udp
ports:
- 8080:80
nsqlookupd: