Skip to content

Instantly share code, notes, and snippets.

View alsotang's full-sized avatar

alsotang alsotang

View GitHub Profile
@ryanflorence
ryanflorence / universal-module.js
Created September 6, 2011 18:10
Universal JavaScript Module, supports AMD (RequireJS), Node.js, and the browser.
(function (name, definition){
if (typeof define === 'function'){ // AMD
define(definition);
} else if (typeof module !== 'undefined' && module.exports) { // Node.js
module.exports = definition();
} else { // Browser
var theModule = definition(), global = this, old = global[name];
theModule.noConflict = function () {
global[name] = old;
return theModule;
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active November 14, 2024 18:34
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@peterhellberg
peterhellberg / max_parallelism.go
Created June 24, 2013 07:25
Find out the max value for GOMAXPROCS on your machine.
package main
import (
"fmt"
"runtime"
)
func MaxParallelism() int {
maxProcs := runtime.GOMAXPROCS(0)
numCPU := runtime.NumCPU()
@vkz
vkz / escodegen-comments.js
Last active February 6, 2023 17:54
Preserve comments with Esprima + Escodegen combination
// escodegen has a fucked up API for attaching comments
// https://github.com/estools/escodegen/issues/10
var esprima = require("esprima");
var es = require("escodegen");
var ast = esprima.parse(
'//comment here\nvar answer = 42;',
{range: true, tokens: true, comment: true});
// attaching comments is a separate step
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active November 16, 2024 03:35
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example