Skip to content

Instantly share code, notes, and snippets.

View cmoore4's full-sized avatar

Sean Moore cmoore4

  • GE Digital
  • New Orleans, LA
View GitHub Profile
@cmoore4
cmoore4 / gist:998126
Created May 29, 2011 20:51
Node.io Scraper
// This is the library that'll handle all of our input tracking and job dispatching
var nodeio = require('node.io');
// The base_url is the site you want to crawl.
// Links is an array of all the links seen as <a> tags, but not yet scraped.
// crawled_links is the array of all the pages already scraped.
var base_url = 'http://reddit.com',
links = [base_url],
crawled_links = [];
@cmoore4
cmoore4 / gist:1289114
Created October 15, 2011 05:52
Javascript Brief Resume
/*
* In Response to: http://tampa.craigslist.org/hil/cpg/2630542650.html
*
*/
var Applicant = function(args){
return {
'name': args.name || 'Jos Shmo',
'skills': args.skills || {'Not': 0, 'The': 1, 'Right': 0, 'Skills': 1},
'address': args.address || {'street': '123 Spaghetti Code Drive', 'city': 'BadCodersVille', 'state': 'CA'},
@cmoore4
cmoore4 / gist:2949471
Created June 18, 2012 17:13
Hello Tumblr
<?php
echo "Hello Tumblr."
?>
@cmoore4
cmoore4 / gist:5025392
Created February 24, 2013 20:12
Simple CSV generator in Scala.
def makeCSV(csvValues: List[String]) = {
csvValues.map(s => "\""+s.replace("\"", "\\\"").replace(",", "\\,")+"\"").mkString(",") + "\n";
}
val csv = List(
List("a", "b", "c", "d"),
List("e", "f", "g", "h"),
List("i", "j", "k", "l")
);
@cmoore4
cmoore4 / gist:5380550
Last active December 16, 2015 04:58
Express JS routes loader prototype
/*
METHOD route controller
GET /index main
GET /users users.getAll
POST /users users.create
GET /users/:id users.getOne
PUT /users/:id users.update
@cmoore4
cmoore4 / gist:5647728
Last active December 17, 2015 17:39
A definition of a REST test.
{
"name": "Example: GET users search",
"documentation": "*Markdown*?",
"createDate": "2013-05-24 10:40:15-6",
"request": {
"method": "GET",
"url": "https://api.example.com/v1/users",
"parameters": "q=(name:Tester McT)&oauth=X123V456",
"body": null,
"headers": [
@cmoore4
cmoore4 / passwordGen.js
Created February 13, 2014 03:35
JS Password Generator
// Use: var myPassword = makePWD(10);
function makePWD(len){
// Characters to include in the generator
var vars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_+=~<>;";
var pwd = '';
for(var i=0; i < len; i++){
var idx = Math.floor(Math.random()*vars.length-1);
pwd += vars.substring(idx,idx+1);
@cmoore4
cmoore4 / trelloToCsv.js
Last active August 29, 2015 13:56
Trello Board Cards to CSV File
(function () {
function JSON2CSV(objArray) {
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
var str = '';
var line = '';
var head = array[0];
for (var index in array[0]) {
var value = index + "";
line += '"' + value.replace(/"/g, '""') + '",';
}
@cmoore4
cmoore4 / docker-compose.yml
Created October 26, 2015 15:40
Docker-Compose Auto-Scale with Nginx Upstreams
nginx:
image: myclient/nginx
environment:
- HOSTHOST=UBUNTU
- PROXY_PORT=8069
links:
- myservice:myservice
ports:
- "80:80"
- "443:443"
@cmoore4
cmoore4 / AngularHttpCacher.js
Created June 10, 2016 16:25
A method, using Angular's promise notify functionality, to immediately restore previous page contents on renavigating to the same page, while simultaneously getting new data and updating the cache.
// These two resources helped me out:
// http://www.webdeveasy.com/interceptors-in-angularjs-and-useful-examples/
// https://code.angularjs.org/1.4.0/docs/api/ng/service/$q
module.factory('httpCacher', ['localStorageService', '$q', '$timeout', '$injector', function(localStorageService, $q, $timeout, $injector) {
var cachePrefix = 'ng_http_cache_';
var cacheExpire = 1000 * 60 * 60 * 8; // 8 Hour Expirey
// http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/