Skip to content

Instantly share code, notes, and snippets.

@ukutaht
ukutaht / HW1_part1
Created March 31, 2013 00:05
BerkleyX CS169.1x Homework Solutions
def palindrome?(str)
letters = str.downcase.scan(/\w/)
letters == x.reverse
end
def count_words(str)
word_count = Hash.new(0)
str.downcase.scan(/\w+/).each do |word|
word_count[word] += 1
end
@ukutaht
ukutaht / Bank Teller
Created April 28, 2013 09:18
Small logic snippets
# Bank Teller Project
def add_account(name, password, accounts)
accounts = {'name'=>name,'password'=>password,'balance'=>0}
return accounts
end
def get_balance(accounts)
return accounts['balance']
end
@ukutaht
ukutaht / board.rb
Last active December 23, 2015 18:29
Sudoku solver
class Board < Array
def initialize(board_string)
super
end
def boxes
triplets = self.flatten.each_slice(3).to_a
temp = triplets.each_slice(3).to_a
almost_there = temp.transpose
@ukutaht
ukutaht / scraper.rb
Created September 25, 2013 20:47
Command line tool for scraping Hackernews.
require 'nokogiri'
require_relative 'utils'
require 'open-uri'
class Scraper
def initialize(path)
@doc = Nokogiri::HTML(File.open(path))
end
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the Socrates website.
Enter them in the console to make sure it works and then save
your results here.
/*1. Use basic selectors (id, class, element) to choose an element on the page.
Use the .css() method to alter at least two CSS properties of this element. */
$(".span9").css("color", "pink")
@ukutaht
ukutaht / index.html
Last active December 25, 2015 19:09 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@ukutaht
ukutaht / zoo.js
Last active December 25, 2015 19:18 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
function Animal(name, legs) {
this.name = name;
this.legs = legs;
};
@ukutaht
ukutaht / app.js
Last active December 25, 2015 19:49
Javascript form validation
$(document).ready(function(){
$(document).on("submit","form", function(event){
event.preventDefault();
var email = $("form").find("#email").val();
var password = $("form").find("#password").val();
var errors = checkEmailErrors(email).concat(checkPasswordErrors(password));
if (errors.length === 0){
@ukutaht
ukutaht / carousel.js
Created October 17, 2013 22:21 — forked from ksolo/carousel.js
Image Carousel
" Based on
runtime colors/ir_black.vim
let g:colors_name = "grb256"
hi pythonSpaceError ctermbg=red guibg=red
hi Comment ctermfg=darkgray
hi StatusLine ctermbg=darkgrey ctermfg=white