Skip to content

Instantly share code, notes, and snippets.

View Havvy's full-sized avatar

Ryan Scheel Havvy

  • Work is not programming related
  • Washington, USA
View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
// These are also the same function as below, with slightly different syntax.
function new (constructor, args) {
var binding = Object.create(constructor.prototype);
var retval = constructor.apply(binding, args);
if (retval === null || typeof retval !== 'object') {
return binding;
}
return retval;

101 - The player agreement

  1. A player is a person who follows this rule.
  2. A player may only join before the game begins or at the beginning of a round.
  3. All players must always abide by all the rules that are in effect, in the order in which they were put in effect.
  4. The rules in the Initial Set are in effect whenever the game begins.
  5. The Initial Set consists of Rules 101-115.

102 - Definition: Rounds

  1. The game starts at the beginning of the first round.
  2. During a round, players take turns in alphabetical order.
@ashnur
ashnur / bookmarlet.js
Last active December 27, 2015 09:59
Open npm package url in a new tab from its github page.
javascript:(function(){ var w=window.open(''); var r=document.createElement('script'); r.textContent = 'var x=new XMLHttpRequest;x.onload = function(){window.location.href=\'https://npmjs.org/package/\'+JSON.parse(atob(JSON.parse(x.responseText).content.replace(/\\n/g,\'\'))).name}; x.open(\'GET\',(\'https://api.github.com/repos'+window.location.pathname+'/contents/package.json\').replace(/([^:])[\/][\/]+/g,\'$1/\'));x.send()'; w.document.body.appendChild(r) }())
@Havvy
Havvy / id_rsa.pub
Created November 7, 2013 18:58 — forked from anonymous/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChecVDc+Ydwqnri7ikD5fPFgPsY0xuD/XLYD9piJqWLQKyogEhWZqMoQ/eZEfRPuRjaoHfZ+9vjl29LSQgqSApamgANSefw6jpJw/AvVFcAe/fBn44x8tHWSrV0iTR4MSjEPnupnIALa1qq/MTcbmcGnuLKSj8VvjVXHiw1THk7ErjHV5P5lXvurw+KFznxiwqgx2NsWZAPEEhFPb+C2v/w/W+fQ7jZTq7AqYG1AHp/wOpG7dHDmgXxx3x5T1t6xMG1eMlsfhwBwgULCFGElv7Mgwglx+SkMtGKuEjSK2MKML/9nPIV0UPMWoBfYbQTJK5rDfS0ib6MtCgkI+TOmHN ryan.havvy@gmail.com
@Havvy
Havvy / JS-Styles.md
Last active August 29, 2015 14:13
Style Guides

Whitespace

  • I prefer projects to be four space indents, though you can convince me to use tabs if we're starting a project together.
  • Opening brackets do not belong on their own line.
  • Spaces go on both sides of operators, always.
  • Spaces never go on the inside of parenthesis except for curly braces of single line functions.
  • That said, single line function expressions/declarations should be avoided. Mostly their usecase is IRC.

Semicolons

@bobbygrace
bobbygrace / trello-css-guide.md
Last active May 15, 2024 16:01
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

@Havvy
Havvy / mibbit.db.json
Last active June 30, 2016 07:44
Factoids for Havvy's bots.
{"key":"u"}
{"key":"HM 3"}
{"key":"havvy","val":"false profit"}
{"key":"havvy","val":"false profit"}
{"key":"Loser","val":"fag"}
{"key":"HM02","val":""}
{"key":"Lord_Diamond","val":"God"}
{"key":"Ryan","val":"Sollux IRL"}
{"key":"Moltres","val":"Volleyball"}
{"key":"vein","val":"ebola"}

Programmers have a tendency to write functions that take types that are too generic for what the functions actually want.

The most common form of this is called Boolean Blindness where a function takes boolean arguments that don't actually say what they want. An example that comes to mind is widget.paint(true);. It's impossible to say what that boolean parameter does without looking up the documentation. The general solution is to either take an enum (short for enumeration) or an approximation thereof. It'd look something like widget.paint(WidgetPaintMode.Immediate);.

In generic this is called Primitive Obsession. Functions that take integers, booleans, strings, and other highly general types. And the solution is to create a more specialized type, either by wrapping the type in a wrapper or creating a new type type to represent the concept, ideally making it impossible to represent impossible values.

Programmers also have an error handling strategy where they return a type that represents *either