Skip to content

Instantly share code, notes, and snippets.

@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active July 14, 2024 19:27
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@hoffstein
hoffstein / Default (Windows).sublime-keymap
Created July 18, 2011 15:08
Sublime Text 2 script to open the current file's parent directory in Windows Explorer
[
{ "keys": ["ctrl+shift+e"], "command": "open_folder_in_explorer" }
]
@sentientmonkey
sentientmonkey / pluralize.js
Created September 22, 2011 23:23
Pluralize for Javascript
Number.prototype.plural = function(){
if(this > 1 || this == 0){
return true;
} else {
return false;
}
}
String.prototype.pluralize_rules = function(){
return [[new RegExp('$', 'gi'), 's']];
@gabesmed
gabesmed / distance.py
Created February 14, 2012 11:43
great circle distance in python
"""Distance helpers."""
import math
EARTH_CIRCUMFERENCE = 6378137 # earth circumference in meters
def great_circle_distance(latlong_a, latlong_b):
"""
@neuronix
neuronix / gist:2016071
Created March 11, 2012 11:20
Rendering dynamic parameters in a dust.js helper
// Handy function to render dynamic parameters in a dust.js helper
function renderParameter(name, chunk, context, bodies, params) {
if (params && params[name]) {
if (typeof params[name] === "function") {
var output = "";
chunk.tap(function (data) {
output += data;
return "";
}).render(params[name], context).untap();
return output;
@sgillies
sgillies / geo_interface.rst
Last active July 9, 2024 15:21
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction

@lossyrob
lossyrob / install-gdal
Last active August 10, 2017 18:53
Script to install GDAL on Ubuntu 12.04 LTS
# Install subversion
sudo apt-get -y install subversion
# Install g++
sudo apt-get -y install g++
# Install Hierarchical Data Format library
# NOTE: This library is not necessarily needed, but was required
# in order for this to compile against a clean Ubuntu 12.04 LTS system.
# I didn't need it on a clean EC2 Ubuntu 12.10 instance, so
@progrium
progrium / gist:5734609
Last active October 14, 2019 07:15
Let unprivileged processes easily restart/reload Nginx without sudo or setuid hacks
# run this as root
while [ 1 ]; do echo | nc -l -U /tmp/reload_nginx && /etc/init.d/nginx reload; done
# or as an upstart job
script
echo | nc -l -U /tmp/reload_nginx && /etc/init.d/nginx reload
end script
respawn
# now any process can run this or do the equivalent with sockets to trigger reload
// Needed in AndroidManifest:
<!-- Permission for using NFC hardware -->
<uses-permission android:name="android.permission.NFC"/>
<!-- Forcing device to have NFC hardware -->
<uses-feature android:name="android.hardware.nfc" android:required="true"/>
<!-- Registering app for receiving NFC's TAG_DISCOVERED intent -->
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
@kissgyorgy
kissgyorgy / get_next_primary_key.py
Last active January 11, 2022 09:49
Django: Get next primary key for object.
from djangobb_forum.models import Post
from django.db.models import Max
# id__max is None if there are no Posts in the database
id_max = Post.objects.all().aggregate(Max('id'))['id__max']
id_next = id_max + 1 if id_max else 1