Skip to content

Instantly share code, notes, and snippets.

@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
@RandomEtc
RandomEtc / tile.js
Created November 9, 2010 01:25
shape rendering in nodejs with LearnBoost's node-canvas
// node.js geo polygon map tile rendering!
// requires https://github.com/learnboost/node-canvas and GeoJSON data files
// e.g.
// data from naturalearthdata.com converted to GeoJSON with GDAL's ogr2ogr
// or from datasf.org, reprojected too:
// ogr2ogr -f GeoJSON sfbay.js sfbay.shp -t_srs EPSG:4326
var Canvas = require('./vendor/node-canvas/lib/canvas'),
http = require('http'),
fs = require('fs');
@mathiasbynens
mathiasbynens / appify
Created November 12, 2010 13:46 — forked from subtleGradient/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@erh
erh / test.cpp
Created April 25, 2011 16:21
boost shared_mutex test
// bm.cpp
// g++ test.cpp -lboost_thread-mt && ./a.out
// the ration of XXX and YYY determines
// if this works or deadlocks
int XXX = 20;
int YYY = 10;
#include <boost/thread.hpp>
@mraleph
mraleph / gist:1352731
Created November 9, 2011 19:49
catching memory corruption
static Handle<Value> Stat(const Arguments& args) {
HandleScope scope;
if (args.Length() < 1 || !args[0]->IsString()) {
return THROW_BAD_ARGS;
}
String::Utf8Value path(args[0]->ToString());
if (args[1]->IsFunction()) {
@vmg
vmg / sparc.c
Created November 15, 2011 23:03
Sparks in C
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
int main
(int argc
,char *ac []){int i, count = argc - 1;
double * dvalues=malloc(01- 01+count*
sizeof(double)+1); double mi=DBL_MAX,ran=.0,ma =DBL_MIN,mo;for(i= 00; argc>1
&&i<count;i=i+8-7) {double val = atof(ac[i+1]) ;if(23&&val<mi)mi= val;if(val
@TooTallNate
TooTallNate / README.md
Created November 16, 2011 00:57
A C header file to make your node bindings backwards and forwards compatible that use eio_custom()

node_async_shim.h

Use this header file to conditionally invoke eio_custom() or uv_queue_work(), depending on the node version that the module is being compiled for.

See the usage.cc file for a partial example.

Comments, forks, and improvements are welcome!

@craigds
craigds / mac-development-for-ubuntu-users.rst
Last active May 24, 2021 08:45
Mac development for Ubuntu users

Mac development for Ubuntu users

This is a quick summary of tweaks to make development on a Mac easier for Ubuntu users. These all worked on my Macbook Air with OSX 10.7 Lion.

If you have something to add here, please let me know! http://twitter.com/craigds

1. Install Xcode

@tokumine
tokumine / postgis.py
Created January 21, 2012 00:28
Hacked imposm postgis.py to enable imports to work with PostGIS 2.0
# On OSX, this Imposm file is found at: /Library/Python/2.7/site-packages/imposm/db/postgis.py. YMMV
# Hack basically comments out all the elements relating to modifying the geometry_columns table.
# In PostGIS 2.0 this is a view and handled transparently.
# Copyright 2011 Omniscale (http://omniscale.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@avar
avar / speedtest.sh
Created January 28, 2012 18:33
Basic speedtest.net replacement
#!/bin/sh
cd /tmp
# dd if=/dev/urandom of=100mb-random-file bs=1024 count=$((100*1024))
rm 100mb-random-file
echo "Downloading 100MB from w"
time rsync --rsh=ssh --append --archive --no-group --human-readable --progress w:/tmp/100mb-random-file .
echo "Uploading a 10MB file to w"