Skip to content

Instantly share code, notes, and snippets.

View automaticalldramatic's full-sized avatar
🦊
this is a useless feature

riz automaticalldramatic

🦊
this is a useless feature
View GitHub Profile
@caseyamcl
caseyamcl / come-on-really.md
Created February 19, 2015 18:20
Ahhhhhhhhh!!!!

HOLY GAWD PEOPLE..

  • 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|
@bcoles
bcoles / alexa-rank.rb
Created September 19, 2011 04:16
Alexa Rank - Retrieves the Alexa rank for domain(s)
#!/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
@wilvandertuin
wilvandertuin / pasz.js
Created January 10, 2012 19:34
Bare jQuery plugin using revealing module pattern
/**
* 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();
@peterdeweese
peterdeweese / gitflow-tutorial.sh
Created December 10, 2012 16:05
Gitflow Tutorial
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'

Parens And Performance

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

@ryochack
ryochack / 20140316-205912.go
Created March 16, 2014 13:28
golang reflection: interface of array
package main
import (
"fmt"
"reflect"
)
func dump_interface_array(args interface{}) {
val := reflect.ValueOf(args)
fmt.Println(val.Kind())
@dblock
dblock / getWeek.js
Created July 13, 2011 22:49
get week of the year in JavaScript
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
@benhowdle89
benhowdle89 / foo.js
Last active March 13, 2021 12:22
Easy Singleton instances using Browserify
var _vent = require('./vent.js').shared();
_vent.trigger('blah');
@salrashid123
salrashid123 / server.go
Last active August 3, 2021 09:34
Google cloud logging consolidated logging in golang
package main
//https://github.com/GoogleCloudPlatform/google-cloud-go/issues/720#issuecomment-320798620
import (
"fmt"
"log"
"net/http"
"time"