Skip to content

Instantly share code, notes, and snippets.

@maxjacobson
maxjacobson / script.js
Created September 12, 2012 03:51
Some javascript/jquery(?) to add a class to certain tags in my pinboard linkroll widget so i can make them red
$(function() {
$( '.pin-tag').html(function( index, oldHtml ) {
if(this.outerHTML == '<a class="pin-tag" href="http://pinboard.in/u:maxjacobson/t:max_jacobson">max_jacobson</a>') {
return '<a class="pin-tag extra-hot" href="http://pinboard.in/u:maxjacobson/t:max_jacobson"><strong>max_jacobson</strong></a>'
}
});
});
@maxjacobson
maxjacobson / tictactoe.rb
Created December 11, 2012 03:34
command line tic tac toe
###### some methods #######
def print_board
puts
for i in 0..8
if @the_board[i].nil?
print "#{i+1}"
else
print "#{@the_board[i]}"
end
def is_palindrome? whatsit
str = whatsit.to_s.downcase.gsub(/ |[^\w\d]|\n/, '')
str == str.reverse ? true : false
end
to_check = [
"a man, a plan, a canal: panama",
"Mr. Owl Ate My Metal Worm",
909,
100,
class String
def word_count
self.split(" ").length
end
def char_count
self.chars.to_a.length
end
def contains(word)
self.gsub(/[^\w]/, " ").split(" ").count(word)
end
@maxjacobson
maxjacobson / nodes.rb
Created March 19, 2013 21:45
family tree
class Node
attr_accessor :name, :children
def initialize (name)
@name = name
@children = Hash.new
end
def add_children(*names)
names.each do |name|
@children[name] = Node.new(name)
end
@maxjacobson
maxjacobson / index.html
Created June 2, 2013 00:55
boilerplate jekyll index.thml
---
layout: default
title: Your New Jekyll Site
---
<div id="home">
<h1>Blog Posts</h1>
<ul class="posts">
{&#37; for post in site.posts &#37;}
<li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
@maxjacobson
maxjacobson / index.html
Created June 2, 2013 00:57
boilerplate jekyll index.html
---
layout: default
title: Your New Jekyll Site
---
<div id="home">
<h1>Blog Posts</h1>
<ul class="posts">
{% for post in site.posts %}
<li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
@maxjacobson
maxjacobson / pbj.md
Last active December 18, 2015 01:28
my sorry attempt at describing how to make pbj

PBJ

  1. If you're not in a well-stocked kitchen, abort, abort.
  2. "Retrieve" (look for and pick up in your hands) a "toaster" (a box with slots on top and a "cord" (pronged tail)); we will use this to heat food items in the future, making them more edible
  3. Place it on your "workspace" (a clear flat surface)
  4. Retrieve a "knife" (a hard, sharp tool); look for "handles" (hand-sized loops attached to sliding bins) and open them until you find a knife, then set it down on your workspace
  5. Look along the walls for "electrical sockets" (two slots for the toaster's cord prongs to go into)
  6. If the toaster is near enough to the electrical sockets, insert the cord's prongs into an electrical socket
  7. If not, pick it up and move it closer, then try again
  8. Retrieve a "loaf of bread" (a soft squareish cylinder in a transparent, flimsy bag). There may be more than one bagged item, so use your hands to feel for softness and shape (there's no danger or risk) and choose the one that best matches these critera
@maxjacobson
maxjacobson / maxjacobson_profile.md
Created June 4, 2013 05:05
first draft profile
@maxjacobson
maxjacobson / amazon.sql
Created June 6, 2013 18:53
Modeling Amazon in SQL
-- run while testing:
-- sqlite3 -echo amazon.db < amazon.sql
DROP TABLE dvd;
DROP TABLE review;
-- 1) Create a database with tables and columns that
-- will hold information about DVD's
-- for sale on Amazon
CREATE TABLE dvd (