Skip to content

Instantly share code, notes, and snippets.

# must have log module loaded
# working to regex out the timestamps and repeat posts
ssh your.znc.server "tail -f ~/.znc/users/your_user_name/moddata/log/#channel.log" | while read line ; do echo $line | say ; done
@nicovalencia
nicovalencia / raf-polyfill.js
Created August 20, 2012 20:39
requestAnimationFrame polyfill
/**
* Request Animation Frame Polyfill
* Authored by Erik Möller
* http://my.opera.com/emoller/blog
*
* Polyfills requestAnimationFrame and cancelAnimationFrame
* for ms/mox/webkit/o vendor prefixes.
*
* Will fallback to setTimeout for non-supportive browsers.
*/
var _writeHead = res.writeHead; // Store the original function
res.writeHead = function(statusCode, headers) {
res.writeHead = _writeHead; // Put the original back
if (statusCode === 401) {
// Change a 401 statusCode to a 403 in order to prevent browser's BASIC AUTH dialog from appearing.
// This allows the Backbone app's login page to handle the credentials.
_writeHead.call(res, 403, headers);
} else {
res.writeHead(statusCode, headers); // Call the original
}
@nicovalencia
nicovalencia / onerror.js
Last active August 29, 2015 13:58
Chrome dev tools source map auto-linking for unhandled Q.js rejection stack traces
var q = require('q');
if (debug) {
q.onerror = function(err) {
console.log(err); // auto-links source map refs in stack trace
};
}
somePromiseThatThrowsAnError
.then(function() { /* do stuff */ })
# Use to proxy commands through a proxy server:
Host your_destination_name
HostName your.destination
ProxyCommand ssh -i ~/.ssh/your_key -A -q your_user@your.proxy nc -q0 your.destination 22
ForwardAgent yes
(function () { var root = $(document.getElementsByTagName('body')); var watchers = []; var f = function (element) { if (element.data().hasOwnProperty('$scope')) { angular.forEach(element.data().$scope.$$watchers, function (watcher) { watchers.push(watcher); }); } angular.forEach(element.children(), function (childElement) { f($(childElement)); }); }; f(root); console.log(watchers.length); })();
/*
* Example directory/file structure:
*
* app
* |-- components/
* | └-- user-profile/
* | |-- user-profile.js
* | |-- user-profile-directives.js
* | └-- user-profile-services.js
* └-- main.js
@nicovalencia
nicovalencia / injector.js
Created October 31, 2014 17:38
injector angular
function createInjector(modulesToLoad) {
var INSTANTIATING = {},
providerSuffix = 'Provider',
path = [],
loadedModules = new HashMap(),
providerCache = {
$provide: {
provider: supportObject(provider),
factory: supportObject(factory),
service: supportObject(service),
@nicovalencia
nicovalencia / http-backend-decorator.js
Last active August 29, 2015 14:10
Add global timeout to Angular $http
/**
* @monkeypatch
* $http gives us no way to add a global timeout default. This is critical
* for triggering the YOUR_FAULT_TOLERANCE module to handle timeouts after
* a reasonable amount of time:
*
* @upgrade instructions
* Ensure that arguments[x] is overriding the timeout property of the
* $httpBackend provider's constructor.
*
var items = [{
content: 'hotdog 1'
}, {
content: 'hotdog 2'
}, {
content: 'hotdog 3'
}, {
content: 'hotdog 4'
}, {
content: 'hotdog 5'