Skip to content

Instantly share code, notes, and snippets.

View kilianc's full-sized avatar
🇮🇹

Kilian Ciuffolo kilianc

🇮🇹
  • San Francisco, CA
  • 05:51 (UTC -08:00)
View GitHub Profile
@kilianc
kilianc / patch.js
Last active October 3, 2015 07:38
Make you request object able to buffer flying packet after pause() call
require('http').IncomingMessage.prototype.makeBuffered = function () {
var self = this
var unluckyChunks = []
var isPaused = false
var isEnded = false
var originalResume = self.resume
var originalPause = self.pause
var originalEmit = self.emit
var currentEmit = originalEmit
@kilianc
kilianc / jquery.tweenlite.js
Created July 4, 2012 22:49
jquery.tweenlite.js
/*!
* TweenLite jQuery plugin v0.0.1
*
* Copyright (c) 2011 Kilian Ciuffolo, [email protected]
*
* Licensed under the MIT license.
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
/*
Firmata.cpp - Firmata library
Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
See file LICENSE.txt for further informations on licensing terms.
@kilianc
kilianc / continuable.test.js
Last active December 28, 2015 15:38
Testing if I forgot to make each method continuable. I am afraid I may be going insane.
describe('#*', function () {
it('should return a continuable if a callback is not passed', function () {
Object.keys(Db.prototype).forEach(function (functionName) {
var params = introspect(db[functionName])
if (params.pop() === 'callback') {
var fnStr = db[functionName].toString()
var line = f('if (undefined === callback) return this.%s.bind(this, %s)', functionName, params.join(', '))
assert.isFunction(db[functionName](), functionName)
var bufferjoiner = require('bufferjoiner')
/**
* Consumes and buffers a file stream
* @param {ReadStream} fileStream The readable file stream
* @param {Function} callback The done callback
*/
module.exports = function consumeFileStream(fileStream, callback) {
if (undefined === callback) return consumeFileStream.bind(null, fileStream)
@kilianc
kilianc / count.js
Last active December 8, 2018 22:16
Example script for Shorts App
let count = 0
let id = setInterval(() => {
if (count > 10) {
return clearInterval(id)
}
console.log(count++)
}, 1000)
console.log(Promise)