Skip to content

Instantly share code, notes, and snippets.

@getify
getify / gist:713779
Created November 24, 2010 15:09
loading google analytics using LABjs
<!DOCTYPE html>
<html>
<head>
<title>LABjs Demo</title>
</head>
<body>
<!-- some stuff -->
<script src="/js/LAB.js"></script>
@matthewmccullough
matthewmccullough / git-deletealltags.bsh
Created April 1, 2011 20:29
Script to delete all tags both locally and remotely
for t in `git tag`
do
git push origin :$t
git tag -d $t
done
@coolaj86
coolaj86 / fs.extra.js
Last active May 22, 2022 22:45
fs.copy and fs.move for Node.JS
/*
UPDATE: this has finally been pushed to npm as `fs.extra`
URL: https://github.com/coolaj86/utile-fs/tree/master/fs.extra
*/
(function () {
"use strict";
console.warn('[Deprecated] See https://github.com/coolaj86/utile-fs');
var fs = require('fs')
@dshaw
dshaw / application.js
Created June 8, 2011 17:43 — forked from fabware/application.js
socket.io application and haproxy configuration
var express = require('express');
var redis = require('redis');
const serverType = process.argv[2];
const serverHost = process.argv[3];
const serverPort = parseInt(process.argv[4]);
const redisPort = 6379;
const redisHost = '127.0.0.1';
var chatData = JSON.stringify({
timestamp: (currentDate.getTime() - currentDate.getMilliseconds()) / 1000
, chat: {
employee_id: employeeId
, created_at: chat.created_at
, username: chat.chatname
, message: chat.message
}
});
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active June 9, 2024 23:19
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@logicalparadox
logicalparadox / About.md
Created January 8, 2012 07:01
Designing `loggable` custom error constructors for Node.js.

Custom Errors

I am working on a custom error constructor for my seed project. I had a few objectives in mind when I started.

  • When in production, these errors need to be able to be serialized for logging.
  • When in development, I can easily throw these errors should I need additional feedback on to what is going on.
  • Any addon plugins made can use or extend the custom error type and still satisfy the first two objective with ease.

Screenshot

@Gozala
Gozala / example.js
Created January 29, 2012 03:46
Workaround for lack of "tail call optimization" in JS
// Lack of tail call optimization in JS
var sum = function(x, y) {
return y > 0 ? sum(x + 1, y - 1) :
y < 0 ? sum(x - 1, y + 1) :
x
}
sum(20, 100000) // => RangeError: Maximum call stack size exceeded
// Using workaround
@h3xx
h3xx / wiki-100k.txt
Created March 5, 2012 03:07
Wictionary top 100,000 most frequently-used English words [for john the ripper]
#!comment: This is a list of the top 100,000 most frequently-used English words
#!comment: according to Wiktionary.
#!comment:
#!comment: It was compiled in August 2005 and coalesced into a handy list for
#!comment: use in John the Ripper.
#!comment:
#!comment:
#!comment: Pull date: Sun Jan 15 22:03:54 2012 GMT
#!comment:
#!comment: Sources:
@antirez
antirez / gist:2010867
Created March 10, 2012 08:39
Redis client-side scripting API
Hi client library users / developers, this is what I think is the best approach to expose
EVAL / EVALSHA to the final user:
redis.eval and redis.evalsha -> exposed verbatim without any intermediate layer.
redis.script(... script body ...,arguments) -> use evalsha, revert to eval if the SHA was not definied.
redis.register("foobar","...script body...") -> Creates an entry into
a table with "foobar","script body",pre_computed_SHA so that I can use
directly: