Skip to content

Instantly share code, notes, and snippets.

<!doctype>
<html>
<head>
<title>hi</title>
<style>
body, html {
background: #aaa;
font-family: monospace;
var ShoppingCart = function(parent) {
var self = this;
self.parent = parent;
this.state = {
"items": {
"Chicken": 79.99,
"Horse": 1299.99,
class NotEnoughCashError < Exception
end
class Bank
attr_reader :accounts
attr_reader :name
def initialize(name)
@name = name
<html>
<head>
<style>
html, body {
margin: 0;
padding: 0;
}
#wrapper {
file = File.open('/usr/share/dict/words').read
lines = file.lines
$words = lines.map do |word|
word.strip.downcase
end
@mayfer
mayfer / orm.rb
Created October 13, 2015 18:29
Intro to ORMs
require 'pg'
CONN = PG::Connection.new({
host: 'localhost',
user: 'murat',
password: '',
dbname: 'lighthouse_2015_10'
})
<!doctype html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<style>
body, html { padding: 0; margin: 0; }
@mayfer
mayfer / dictionary.rb
Created October 1, 2015 18:25
Block and Enumerable examples
def read_dictionary
words = File.open('/usr/share/dict/words').read
words.each_line do |line|
word = line.chomp.downcase
yield(word)
end
end
require("./config.rb")
require("./file.rb")
class EssayStats
include FileReader
def initialize
@words = read_file(Config::ESSAY_PATH)
end
arr = [45, 234, 56758, 23, 1, 0, 0, 0, 0, 345345, 23]
def find_number(numbers, number)
numbers.each_with_index do |n, i|
if n == number
return i