Skip to content

Instantly share code, notes, and snippets.

View shovon's full-sized avatar
💻
Working on my own projects

Sal Rahman shovon

💻
Working on my own projects
View GitHub Profile
@mpneuried
mpneuried / pubsub.coffee
Last active December 10, 2015 23:28
Simple namespaced Pub/Sub coffee class to use as extendable module for NodeJS and the browser.
# # PubSub
#
# Is a small helper to simply realize a pub/sub pattern to a coffee class.
#
# A namespaceing of the topics is also included.
# This means you can subscribe to `a` and also get the `a.b`. But if you subscribe to `a.b` you will not get a `a`.
#
# **required module**: `underscore`
#
class PubSub
@shovon
shovon / thin-fonts.sh
Created January 17, 2013 01:19
Font rendering on Mac OS X is ugly. This single line should fix it.
# Fix font rendering on Mac OS X.
$ defaults -currentHost write -globalDomain AppleFontSmoothing -int 0
@Acconut
Acconut / gist:5383324
Last active December 16, 2015 05:19
Hoodie on Windows and Linux

Hoodie on Windows and Linux

This guide will help you to use hoodie on windows and linux.

Before we start you'll need following dependencies installed:

  • node
  • npm
  • git
  • couchdb
@shovon
shovon / gist:5728555
Last active December 18, 2015 04:49
Pretty print git logs. Better than gitk.
# Create a git alias that will pretty-print your git logs. Much better than
# firing up `gitk`.
#
# From https://coderwall.com/p/euwpig#comment_3248
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
# And then, you should be able to view the logs like so:
git lg
(function() {
'use strict';
var indexOf = function(list, needle) {
if (list.indexOf) return list.indexOf(needle);
for (var i = 0, n = list.length; i < n; i++) {
if (list[i] === needle) return i;
}
return -1;
};
@darkyen
darkyen / decoder.cpp
Created July 12, 2012 13:13
C++ ffmpeg decoder
/*
* encoder.cpp
*
* Created on: Jul 12, 2012
* Author : Abhishek Hingnikar
* @TODO: remove the file deps.
* ADD STREAM DEPS so that u can buffer output.
* Structure
* @JSAPI
* ffmpeg{
@dsherret
dsherret / WeakCache.ts
Last active September 27, 2018 23:53
A weak cache with support for ES5.
export class WeakCache<T extends object, U> {
private readonly cacheItems: WeakDictionary<T, U>;
constructor() {
if (typeof WeakMap !== "undefined")
this.cacheItems = new WeakMap<T, U>();
else
this.cacheItems = new Es5WeakMap();
}
@raganwald
raganwald / generate-balanced-parentheses.es6
Last active March 1, 2019 03:13
A generator function that enumerates all finite balanced parentheses strings
// memoizes ordinary functions
const memoized = (fn, keymaker = JSON.stringify) => {
const lookupTable = new Map();
return function (...args) {
const key = keymaker.call(this, args);
return lookupTable[key] || (lookupTable[key] = fn.apply(this, args));
}
};
@glslioadmin
glslioadmin / TEMPLATE.glsl
Last active July 5, 2019 00:55
GLSL.io Transition (v1)
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D from, to;
uniform float progress;
uniform vec2 resolution;
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
gl_FragColor = mix(texture2D(from, p), texture2D(to, p), progress);
@travisjeffery
travisjeffery / person.js
Created May 7, 2012 02:33
Empty a Model's Collection With Mongoose
var mongoose = require("mongoose")
, assert = require("assert")
, async = require("async")
, Person
async.series([
function(callback){
mongoose.connect("mongodb://localhost/mydb")
mongoose.connection.on("open", callback)
},