- Don't write all your new code on the production machine!
- Use a VCS!
- Document your functions using DocBlocks!
- Document your API (at least LIST the endpoints)... I have to decipher the meaning from your code, and that isn't really clear
- Use a single identifier as the primary ID in the API for a resource (ie don't return a list of group ids for listing groups and then expect the group name as the identifying parameter for modifying a group)
- Use a consistent model for representing the same data model in different endpoints!
- Don't concatenate fields in the API results unless there is a good reason to (e.g first name and last name)
- Don't expose the underlying database logic. This is leaky abstraction, especially when you do it inconsistently!!
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
site = ARGV[0] | |
doc = Nokogiri::HTML(open("http://www.alexa.com/siteinfo/#{site}")) | |
data = [] | |
doc.css('ul')[4].css('li.geo_percentages').each_with_index do |raw,i| |
#!/usr/bin/env ruby | |
# Alexa Rank | |
# Retrieves the Alexa rank for domain(s) | |
# 2011-09-19 # bcoles@gmail.com | |
## | |
verbose = true | |
version = "0.1" | |
# Usage |
/** | |
* Minimum set up for a revealing module pattern jQuery plugin | |
* | |
* This is a bare plugin that uses the revealing module pattern to attach | |
* public and private vars and methods to a jQuery selector. | |
* | |
* Example: | |
* | |
* $('#menu').collapsible().init(); | |
* $('#menu').collapsible().open(); |
set -o verbose | |
set -o errexit | |
echo '* Create and initialize a repository.' | |
git init gitflow-tutorial | |
cd gitflow-tutorial/ | |
git flow init -d | |
echo '* Develop a Feature' |
Years ago, some smart folks that worked on JS engines realized that not all JS that's loaded into a page/app initially is needed right away. They implemented JIT to optimize this situation.
JIT means Just-In-Time, which means essentially that the engine can defer processing (parsing, compiling) certain parts of a JS program until a later time, for example when the function in question is actually needed. This deferral means the engine is freer to spend the important cycles right now on the code that's going to run right now. This is a really good thing for JS performance.
Some time later, some JS engine devs realized that they needed to get some hints from the code as to which functions would run right away, and which ones wouldn't. In technical speak, these hints are called heuristics.
So they realized that one very common pattern for knowing that a function was going to run right away is if the first character before the function
keyword was a (
, because that usually m
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func dump_interface_array(args interface{}) { | |
val := reflect.ValueOf(args) | |
fmt.Println(val.Kind()) |
function( d ) { | |
// Create a copy of this date object | |
var target = new Date(d.valueOf()); | |
// ISO week date weeks start on monday | |
// so correct the day number | |
var dayNr = (d.getDay() + 6) % 7; | |
// Set the target to the thursday of this week so the |
var _vent = require('./vent.js').shared(); | |
_vent.trigger('blah'); |
package main | |
//https://github.com/GoogleCloudPlatform/google-cloud-go/issues/720#issuecomment-320798620 | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"time" |