Skip to content

Instantly share code, notes, and snippets.

View bingeboy's full-sized avatar
🏠
Working from home

JP McGarrity bingeboy

🏠
Working from home
View GitHub Profile
@bingeboy
bingeboy / input methods
Created May 23, 2013 17:13
CSS Form Elements
/* Custom radio input */
input[type="radio"] {
position:absolute;
clip: rect(0,0,0,0);
clip: rect(0 0 0 0);
}
input[type="radio"] + label::before {
content: url('radio.png');
}
@bingeboy
bingeboy / for loop
Last active December 17, 2015 17:39
JavaScript Proper methods
//data type with length
var x = [1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,6,7,7,10];
var i
,content;
for(i = 0; xlength; i < content; i ++){
console.log(x[i]);
}
@bingeboy
bingeboy / Working with Arrays
Last active December 17, 2015 17:49
JS Arrays
//largest value in array
Array.max = function( array ){
return Math.max.apply( Math, array );
};
//add multiple array values
function addArrayValues(arrayNameHere){
var i
, max
, statTotal = [];
@bingeboy
bingeboy / Merge Arrays Into Object Literal.js
Last active December 17, 2015 23:49
Merge Arrays Into Object Literal
var x = ["blue", "yellow", "red", "green", "brown", "grey", "gray", "orange"];
var y = ["james", "john", "robert", "michael", "william", "david", "richard", "wayne"];
function merge2array(a, b) {
var obj = {};
var l = a.length;
var i;
for (i = 0; i < l; i++) {
obj[a[i]] = b[i];
@bingeboy
bingeboy / package.json
Created June 15, 2013 23:30
Package.json
{
"name": "HackAthon",
"description": "North Festival Hackathon 2013 WBURG BK",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "nodemon app.js",
"debug": "nodemon --debug app.js"
},
"dependencies": {
@bingeboy
bingeboy / app.js
Last active December 18, 2015 19:49
2012 Hackathon Olymipcs Entry
var fs = require('fs')
, http = require('http')
, util = require('util')
, path = require('path')
, Combinatorics = require('./combinatorics.js').Combinatorics
, request = require('request')
, ipContainer = [], url2Test, ipContainer2 = []
, cmb = Combinatorics.permutation(['0','1','8','16','46','74','96','106','109','126','127','186','192','255'], 4);
cmb = cmb.toArray();
@bingeboy
bingeboy / request-with-pipe.js
Created June 28, 2013 05:52
pipe with get call from request... quick and dirty!
//get image with request and pipe it to client.
var http = require('http');
var request = require('/usr/local/share/npm/lib/node_modules/request');
var server = http.createServer(function (req, res) {
request.get('http://www.1up.com/images/Elements/carouselNav.png').pipe(res);
});
server.listen(8000);
@bingeboy
bingeboy / app.js
Created June 29, 2013 22:07
BP for expressjs v3.x
var app = require('express')()
, server = require('http').createServer(app)
, express = require('express')
, http = require('http')
, port = 3000;
/*
* Express : Configure
@bingeboy
bingeboy / list of 58,110 words
Created June 30, 2013 21:22
Words, Dictionary.
aardvark
aardwolf
aaron
aback
abacus
abaft
abalone
abandon
abandoned
abandonment
// Ever needed to escape '\n' as '\\n'? This function does that for any character,
// using hex and/or Unicode escape sequences (whichever are shortest).
// Demo: http://mothereff.in/js-escapes
function unicodeEscape(str) {
return str.replace(/[\s\S]/g, function(character) {
var escape = character.charCodeAt().toString(16),
longhand = escape.length > 2;
return '\\' + (longhand ? 'u' : 'x') + ('0000' + escape).slice(longhand ? -4 : -2);
});
}