Skip to content

Instantly share code, notes, and snippets.

View zackn9ne's full-sized avatar

zackn9ne zackn9ne

  • earth, New York
View GitHub Profile
@zackn9ne
zackn9ne / 0_reuse_code.js
Created May 2, 2014 13:48
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
PSQL CHECKING COMMANDS
1. $psql
2. =# \l List All The DB's
2. =# \c dbname CHANGE TO IT
3. dbname=# \d List All The Relations
4. dbname=# SELECT * FROM relation_of_your_choice;
@zackn9ne
zackn9ne / database.yml
Created May 12, 2014 00:07
Most Basic Rails DB YML
default: &default
adapter: postgresql
pool: 5
timeout: 5000
development:
<<: *default
database: first_rails
<h1>Sign Up</h1>
<%= form_for @user do |f| %>
<% if @user.errors.any? %>
<div class="error_messages">
<h2>Form is invalid</h2>
<ul>
<% for message in @user.errors.full_messages %>
<li><%= message %></li>
<% end %>
@zackn9ne
zackn9ne / dealing_with_arrays.rb
Last active August 29, 2015 14:01
Parse json files in Ruby
http://www.ruby-doc.org/core-2.1.1/Enumerable.html#method-i-zip
add value to an array
users['Neel'][:favorite_numbers].push(64) or
users['Neel'][:favs] << 64
add user to array
users['Jane'] = {:github => "janeplural", :nums => [58,48,44]}
.zip
@zackn9ne
zackn9ne / gist:6c3fbd0aff180f8feef3
Created May 28, 2014 14:49
Rails 4 Private Controller
class UsersController < ApplicationController
def create
@user = User.new(user_params)
# ...
end
private
def user_params
@zackn9ne
zackn9ne / basic_ruby_loop.rb
Last active August 29, 2015 14:01
Basic ruby loop
colors = ["blue","green","seafoam"]
colors.each do |color|
puts "I love #{color.upcase}!"
end
even more simple...
[1, 2, 3].each do |item|
puts("Iterating over #{item}...")
end
@zackn9ne
zackn9ne / module.rb
Created June 9, 2014 13:48
basic module ex
module AnimalBodilyFunctions
def bark
puts "now i am currently barking deal with it..."
end
end
class DogBlueprint
include AnimalBodilyFunctions
attr_accessor :breed, :name
" Powerline on
set rtp+=/usr/local/lib/python2.7/site-packages/powerline/bindings/vim/
" Always show statusline
set laststatus=2
" Use 256 colours (Use this setting only if your terminal supports 256 colours)
set t_Co=256