Skip to content

Instantly share code, notes, and snippets.

View northamerican's full-sized avatar
🚲

Chris Bitsakis northamerican

🚲
View GitHub Profile
Array.prototype._index=function(a){var b;if(a<0){b=this.length;return b+a}return a};Array.prototype.at=function(a){return this[this._index(a)]};Array.prototype.map=function(a){var c,b;return([].splice.apply(this,[0,this.length-0].concat(b=(function(){var f,e,d;d=[];for(f=0,e=this.length;f<e;f++){c=this[f];d.push(a(c))}return d}).call(this))),b)};Array.prototype.clone=function(){return this.dup()};Array.prototype.dup=function(){return this.slice(0,this.length)};Array.prototype.each=function(b){var a,c;for(a=0,c=this.length;0<=c?a<c:a>c;0<=c?a++:a--){b(this[a],a)}return this};Array.prototype.deleteAt=function(a){a=this._index(a);if(a>=this.length){return}return this.splice(a,1)};Array.prototype.deleteIf=function(b){var a;return this.replace((function(){var d,c;c=[];for(a=0,d=this.length;0<=d?a<d:a>d;0<=d?a++:a--){if(!b(this[a],a)){c.push(this[a])}}return c}).call(this))};Array.prototype.reject=function(a){var b;b=this.length;this.deleteIf(a);if(b===this.length){return}return this};Array.prototype.isEmpty=functi
@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@thunder9
thunder9 / rb-range.js
Created September 7, 2012 14:06
A Ruby-like "range" for JavaScript
// A Ruby-like "range" for JavaScript
// https://github.com/thunder9
//
// Require: https://github.com/thunder9/rb-enumerable.js
(function (global) {
if (!global.RubyLike.enumerable || !global.RubyLike.Enumerator) {
throw Error('rb-enumerable.js required');
}
@leostratus
leostratus / webkit-pseudo-elements.md
Created September 21, 2012 01:44
Webkit Pseudo-Element Selectors (Shadow DOM Elements)

An ongoing project to catalogue all of these sneaky, hidden, bleeding edge selectors as I prepare my JSConf EU 2012 talk.

Everything is broken up by tag, but within each the selectors aren't particularly ordered.

I have not tested/verified all of these. Have I missed some or got it wrong? Let me know. - A

A friendly reminder that you may need to set this property on your target/selected element to get the styling results you want:

-webkit-appearance:none;

@mharsch
mharsch / gist:5188206
Last active February 8, 2024 02:43
serve HLS (HTTP Live Streaming) content from node.js

HLS streaming from node

Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.

loosely based on https://gist.github.com/bnerd/2011232

// loosely based on https://gist.github.com/bnerd/2011232
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory
/**
* Assign a value to the delimited key in the given object. The inverse of `_.lookup`
*
* @example
*
* var myObj = {};
*
* _.assign(myObj, 'foo.bar', 'baz'); // myObj = { foo: { bar: 'baz' }}
*
* @param {Object} obj the object to assign to
@joshuabaker
joshuabaker / getTweetHTML.js
Last active December 23, 2015 09:09
Switches tweet entities, from a Twitter API response, into anchor links, returning HTML ready for display. Built for use with https://github.com/joshuabaker/twitter-proxy
var getTweetHTML = function(tweet)
{
var i, item, entities = {}, html = tweet.text, target;
for (i in tweet.entities.hashtags)
{
item = tweet.entities.hashtags[i];
entities[item.indices[0]] = [item.indices[1], '<a href="https://twitter.com/search?q=%23' + item.text + '" target="_blank">#' + item.text + '</a>'];
}
@rjacoby
rjacoby / gist:46f7ceb900f97b0cc8f4
Created July 31, 2014 17:43
Facebook STOP! console code
__d("Chromedome", ["fbt"], function(a, b, c, d, e, f, g) {
f.start = function(h) {
if (h.off || top !== window ||!/(^|\.)facebook\.com$/.test(document.domain))
return;
var i = h.stop || "Stop!", j = h.text || "This is a browser feature intended for developers. If someone told you to copy-paste something here to enable a Facebook feature or \"hack\" someone's account, it is a scam and will give them access to your Facebook account.", k = h.more || g._("For more information, see {url}.", [g.param("url", 'https://www.facebook.com/selfxss')]);
if ((window.chrome || window.safari)&&!h.textonly) {
var l = 'font-family:helvetica; font-size:20px; ';
[[i, h.c1 || l + 'font-size:50px; font-weight:bold; ' + 'color:red; -webkit-text-stroke:1px black;'], [j, h.c2 || l], [k, h.c3 || l], ['', '']].map(function(r) {
setTimeout(console.log.bind(console, '\n%c' + r[0], r[1]));
});
@addyosmani
addyosmani / package.json
Last active May 29, 2024 15:54
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",