$ rails _3.2.11_ new learnapt-web --database postgresql --skip-test-unit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Class description | |
# goes here. | |
class State < ActiveRecord::Base | |
#-- attributes | |
attr_accessor :id, :name, :slug, :country_id | |
#-- validations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy command to clipboard | |
$ sudo apt-get install xclip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void loadUpdates(boolean loadWordADay) | |
{ | |
try | |
{ | |
if (Util.isNetworkAvailable(this)) | |
{ | |
sendProgress(ProgressMode.UPDATE_STARTED.ordinal()); | |
//-- Update Word of the day | |
if(loadWordADay) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory "User", ["$http","$resource",($http,$resource) -> | |
User = $resource("/roles/:id", {id: "@id"}, {update: {method: "PUT"}}) | |
# Initialize the data using a static method | |
User.init = (data) -> | |
angular.extend this, data | |
# a static method to retrieve User by ID | |
User.get_it = (id) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Authenticate: | |
curl -H 'Content-Type: application/json' \ | |
-H 'Accept: application/json' \ | |
-X POST http://localhost:3000/users/sign_in \ | |
-d "{'user' : { 'email' : '[email protected]', 'password' : 'password'}}" \ | |
-c cookie | |
# Show: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl http://localhost:3000/api/v1/Action -H 'Authorization: Token token="api_key_goes_here"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem install rails | |
Fetching: i18n-0.6.5.gem (100%) | |
Successfully installed i18n-0.6.5 | |
Fetching: multi_json-1.7.9.gem (100%) | |
Successfully installed multi_json-1.7.9 | |
Fetching: tzinfo-0.3.37.gem (100%) | |
Successfully installed tzinfo-0.3.37 | |
Fetching: atomic-1.1.13.gem (100%) | |
Building native extensions. This could take a while... | |
Successfully installed atomic-1.1.13 |
Here's how to install PostgreSQL and have it run automatically at startup, on an Ubuntu 10.04 virtual machine using Vagrant. This took me a while to figure out:
Add the default lucid32 base box to your vagrant, if you haven't already:
host> vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
Now make a new lucid32 virtual machine and install postgresql on it:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://stackoverflow.com/a/5408501 | |
-- PostgreSQL 9.1 and below: | |
SELECT pg_terminate_backend(pg_stat_activity.procpid) | |
FROM pg_stat_activity | |
WHERE pg_stat_activity.datname = 'TARGET_DB' | |
AND procpid <> pg_backend_pid(); | |
-- PostgreSQL 9.2 and above: |
OlderNewer