Skip to content

Instantly share code, notes, and snippets.

View vicapow's full-sized avatar

Victor vicapow

View GitHub Profile
CREATE TABLE IF NOT EXISTS openclipart_issues(
clipart INTEGER NOT NULL
, reporter INTEGER DEFAULT NULL
, PRIMARY KEY(clipart, reporter)
, FOREIGN KEY(reporter) REFERENCES openclipart_users(id)
, FOREIGN KEY(clipart) REFERENCES openclipart_clipart(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB;
INSERT INTO openclipart_issues(clipart, reporter)
var a = Object.create({foo:"bar"})
Object.keys(a) // returns []
a.prototype // returns undefined
a.__proto__ // returns {foo:"bar"} but nonstandard. the object could have a __proto__ property with a different value
Object.getPrototypeOf(a) // returns {foo:"bar"}

how to be kind to your future self and others

avoid if statement hell.

this:

if(thing){
 if(someThingElse){
var Person = function(a){
if(a) return { friends : 2 }
return 1
}
// true or false, new Person(true) instanceof Person
// true or false, new Person(false) instanceof Person
@vicapow
vicapow / multireturn.js
Created May 28, 2013 22:17
multiple return statements
// good
function example1() {
if(someCondition) return thing1
else if (someOtherCondition) return thing2
else return thing3
}
// bad
function example2() {
var image1 = {
width : 12
, height : 12
, data :
[ 'ffffff', 'ffff8a', '898943', '4343cb', 'cacaf3', 'f3f3fb', 'fafbfb', 'fbfbf3', 'f3f3e8', 'e9e9f0', 'f1f1ff', 'ffffff'
, 'fffffe', 'fefe6e', '6e6e01', '000005', '030286', '8686e9', 'eaebd7', 'd6d7e0', 'dfdfec', 'ededf4', 'f5f5ff', 'ffffff'
, 'ffffff', 'ffffc0', 'bfbf31', '343573', '7b7da3', 'a7a8f0', 'f2f3e0', 'e9ebe1', 'ecede5', 'e6e7fc', 'fcfcff', 'ffffff'
, 'ffffff', 'ffff91', '8b8b97', 'a6a960', '959d9e', 'bec098', '9596bf', 'e1e5a3', 'c7cce6', 'e9eafb', 'fbfbff', 'ffffff'
, 'fffffa', 'fafaa7', 'a4a55d', '61639f', 'bdbd66', '767311', '1a1675', '84839d', 'b3b1e3', 'e5e5fb', 'fbfcfc', 'fcfcf9'
, 'fafad6', 'd8d8e1', 'e5e4d4', 'cdd1bc', '435b5d', '10253b', '182048', '0010a3', '233ff5', 'f0f4ee', 'f2f1e9', 'eaeafe'
<html>
<head>
<style type="text/css">
body {
font: 10px sans-serif;
}
.ball{
fill: steelblue;

code review

  • don't forgot closing and opening <html> and <body> tags.
  • keep proper indentation of html and js code.

bad

<body>
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body, html {
margin: 0;
overflow: hidden;
}
.block{