Skip to content

Instantly share code, notes, and snippets.

View gkatsev's full-sized avatar

Gary Katsevman gkatsev

View GitHub Profile
@gkatsev
gkatsev / gist:4fb70d255b08ae5ce1d3
Last active August 29, 2015 14:01
In case you weren't sure what this function does.
/**
* Update the player duration
*/
updateDuration = function(playlist) {
// update the duration
player.duration(totalDuration(playlist));
};
@gkatsev
gkatsev / triforce.sh
Created May 6, 2014 22:55
Using [zelda](https://www.npmjs.org/package/zelda), cross npm link all projects with all other projects. Just clone all your node modules into the same folder, cd into that folder and run the script below.
for i in *; do
if [ -d "$i" ]; then
cd $i;
if [ -f "package.json" ]; then
zelda ../;
fi;
cd ..;
fi;
done
@gkatsev
gkatsev / gist:10492585
Created April 11, 2014 19:01
Trying to install flex-sdk 4.6.0-0 with the version being specified in `package.json`.
0 info it worked if it ends with ok
1 verbose cli [ '/Users/gkatsevman/.nvm/v0.10.24/bin/node',
1 verbose cli '/Users/gkatsevman/.nvm/v0.10.24/bin/npm',
1 verbose cli 'install',
1 verbose cli 'flex-sdk' ]
2 info using [email protected]
3 info using [email protected]
4 verbose readDependencies using package.json deps
5 verbose cache add [ 'flex-sdk', null ]
6 verbose cache add name=undefined spec="flex-sdk" args=["flex-sdk",null]
test('patchCanPlayType patches canplaytype with our function, conditionally', function() {
var oldAV = vjs.ANDROID_VERSION,
video = document.createElement('video'),
canPlayType = vjs.TEST_VID.constructor.prototype.canPlayType,
patchedCanPlayType,
unpatchedCanPlayType;
vjs.ANDROID_VERSION = 4.0;
vjs.Html5.patchCanPlayType();
<title>backbone-nested amd require</title>
<script data-main="amd-require.js" src="../vendor/requirejs/require.js"></script>
function readTep(evt) {
var three;
taps.push((new Date()).getTime());
taps = taps.slice(-3);
if (taps.length === 3) {
three = taps.reduce(function(p, c, i) {
return p && Math.abs(c - (taps[i - 1] || c)) < 50;
}, true);
if (three) {
@gkatsev
gkatsev / gist:6528315
Created September 11, 2013 19:08
log shows only `foo`.
var http = require('http');
var server = http.createServer(function(req, res) {
console.log('foo');
res.end('foo');
}, function(req, res) {
console.log('bar');
res.end('bar');
});
server.listen(5555);
function foo(id) {
var deferred = q.defer();
bar(id)
.then(function(obj) {
var anotherDeferred = q.defer();
log('fail');
@gkatsev
gkatsev / module.js
Last active December 20, 2015 06:28
define(function(require, exports, module) {
var $ = require('jquery');
});
@gkatsev
gkatsev / toggleable.js
Created July 25, 2013 20:26
A toggleable object.
var Toggleable = function(a, b) {
this._a = a;
this._b = b;
};
Toggleable.prototype.valueOf = function() { return this._a; };
Toggleable.prototype.toggle = function() {
if (this.valueOf() == this._a) {