$ psql -U postgres
### CREATION w/o Password
$ createuser
# fill shit in
$ createdb <databasename>
$ psql -U postgres
$ alter user <username>;
# ALTER USER
$ rails new <name> -T -d postgresql
# makes new project with no tests and postgresql database
### create new column in database model
$ rails generate migration add_column_to_<modelname> <column>:<class>
$ rake db:migrate
### drop a table from the database
$ rails c
$ ActiveRecord::Base.connection.drop_table :your_table_name
### using heroku
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
# Some cool stuff | |
begin | |
# code | |
rescue #error message | |
# code to what next | |
retry # if you want to run begin again | |
end |
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
### find things in your table | |
Model.find_by_<key>(value) # Limits 1 | |
Model.where(:key => value) # No limit, returns all | |
example = Model.find_by_<key>(key) | |
example.key = 'value' # this will return the key/value and update it | |
### find/create by | |
Model.find_or_create_by_<key>(key) |
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
YAML::ENGINE.yamler = 'syck' |
$ curl -u 'USER:PASS' https://api.github.com/user/repos -d '{"name":"REPO"}'
$ git remote add origin [email protected]:USER/REPO.git
$ git push origin master
Start manually:
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Stop manually:
$ pg_ctl -D /usr/local/var/postgres stop -s -m fast
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
require 'net/http' | |
require 'open-uri' | |
require 'awesome_print' | |
require 'nokogiri' | |
LINK = "http://www.ozbargain.com.au/live" | |
html = open(LINK).read | |
noko = Nokogiri::HTML(html) |
Edit file on Instance
$ vi /usr/lib/ec2-ami-tools/lib/ec2/amitools/util.rb
Change to this method
def gen_ident()
(0...19).map{(65+rand(26)).chr}.join
end
OlderNewer