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
// run this with "node hello_world.js" | |
console.log("Hello World", __dirname); |
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
<!-- demonstrating event bubbling --> | |
<html> | |
<head> | |
<title>arceegee</title> | |
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> | |
<style> | |
body { margin: 0; } | |
#bubble { background: #ffa; width: 200px; height: 200px; } |
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
# no *, / or % allowed | |
def divide(number, divisor) | |
result = 0 | |
while number >= divisor | |
number -= divisor | |
result += 1 |
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 CreateTeachers < ActiveRecord::Migration | |
def change | |
create_table :teachers do |t| | |
t.string :name | |
end | |
end | |
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
require 'active_record' | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Base.establish_connection( | |
:adapter => "postgresql", | |
:host => 'localhost', | |
:username => 'murat', | |
:password => '', | |
:database => 'lighthouse_2015_05', |
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 'pg' | |
CONN = PG::Connection.new({ | |
host: 'localhost', | |
user: 'murat', | |
password: '', | |
dbname: 'lighthouse_2015_05' | |
}) | |
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
var = "asdhasd" | |
numbers = [ | |
[1, 2, 3], | |
[4, 5, 6], | |
] | |
# WRONG |
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
html, body { | |
} | |
.error { | |
background: #faa; | |
color: #a00; | |
} | |
.container { |
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 Session | |
def [](key) | |
cookie = request.cookies["rack.session"] | |
output = decrypt(cookie) | |
return output["user_id"] | |
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
# Homepage (Root path) | |
enable :sessions | |
helpers do | |
def current_user | |
begin | |
@current_user = User.find(session["user_id"].to_i) | |
# @current_user = User.find(response.cookies["user_id"].to_i) | |
rescue | |
@current_user = nil |