Skip to content

Instantly share code, notes, and snippets.

@sTiLL-iLL
sTiLL-iLL / thepool.js
Last active August 29, 2015 14:05
simple and effective object / worker / connection pool implimentation in javascript
function PoolFactory() {
var createPool = function (options) {
var wrkrs = [], freeWrkrs = [],
opts = options || {},
wCnt = options.maxWorkers || 4,
wrkrPth = options.path || 'whateveryouwant.js';
@sTiLL-iLL
sTiLL-iLL / objProtaddl.js
Created August 26, 2014 09:11
extend, toggleClass, and equals methods
// functional additions to the Object prototype
Object.prototype.extend = function() {
if (arguments.length === 0)
return this;
for (var i = 0; i < arguments.length; i++) {
for (var property in arguments[i]) {
if (arguments[i].hasOwnProperty(property))
@mathisonian
mathisonian / index.md
Last active August 10, 2024 20:59
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@sTiLL-iLL
sTiLL-iLL / XHR.js
Last active February 27, 2023 18:09
XHR and fallback
// simple request with a fallback
function getXHR() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
try {
return new ActiveXObject('MSXML2.XMLHTTP.6.0');
}
@sTiLL-iLL
sTiLL-iLL / brioWifiModule.js
Last active August 29, 2015 14:07
brioWIFImodule.js
define(['knockout', 'jquery'], function (ko, $) {
return function (wifiInfo, wifiNetworks, SSIDList) {
var slf = this, SKT = skt || io.connect(), WifiInfo = wifiInfo || {},
wirelessCollection = ko.observableArray(wifiNetworks) || ko.observableArray([]),
ssidCollection = ko.observableArray(SSIDList) || ko.observableArray([]), Abstract = {
isConnected: false,
BrioSSID: ko.observable(),
BrioPassword: ko.observable(),
BrioSecurityType: ko.observable(999),
@sTiLL-iLL
sTiLL-iLL / KNDmitter.js
Last active March 20, 2025 07:59
Emitter for the browser...
(function () {
'use strict';
function KNDmitter() { }
var proto = KNDmitter.prototype;
var exports = this;
var originalGlobalValue = exports.KNDmitter;
function indexOfListener(listeners, listener) {
var i = listeners.length;
while (i--) {
@sTiLL-iLL
sTiLL-iLL / Signals.js
Last active August 29, 2015 14:10
Signals.js... A fast and efficient event system in javascript.
// SignalsBest2.js 8;]
var Signals = (function() {
'use strict';
var sigCache = {}, singleRtnVal = false,
received = function(eventName, func) {
return wen(eventName, function(evnt) {
return func(evnt);
});
@sTiLL-iLL
sTiLL-iLL / SignalsV2.js
Last active August 29, 2015 14:10
Another version of my "Signals" event system.
// SignalsV2.js
(function () {
'use strict';
function Signals () {};
var exports = this,
@sTiLL-iLL
sTiLL-iLL / kacher.js
Last active March 20, 2025 08:03
kacher.js A basic static resource cache module for node.js
// kacher.js ... this uses my Signals.js event module as a dependency
var signalCaster = require("./signals").Signals,
fs = require('fs'),
url = require("url"),
path = require("path"),
config = {
cache: [],
/**
* Usage: phantomjs scrape.js URL [selector]
* selector defaults to `#content`
*/
var page = require('webpage').create(),
system = require('system');
if (system.args.length < 2 || system.args.length > 3) {