Skip to content

Instantly share code, notes, and snippets.

@sturadnidge
sturadnidge / steamGetFloatValue.js
Created January 1, 2016 17:28
Gets the float value of a Steam inventory item
'use strict';
/*jshint node:true */
// npm install lodash colors minimist request sync-request
var _ = require('lodash'),
colours = require('colors/safe'),
parseArgs = require('minimist'),
request = require('request'),
requestSync = require('sync-request'),
@sturadnidge
sturadnidge / steamSaleWatch.js
Created March 13, 2015 11:07
Watch for discounts on Steam games!
'use strict';
// npm install cheerio colors moment optimist
// builtins
var http = require('http'),
// 3rd party
cheerio = require('cheerio'),
colors = require('colors/safe'),
moment = require('moment'),
@sturadnidge
sturadnidge / uuidGen.js
Created October 25, 2014 15:38
Generate a UUID... use node-uuid if you can though.
function uuidGen() {
var uuid = 'xxxxxxxxxxxxyxxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g,
function(c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
return uuid;
}
@sturadnidge
sturadnidge / hexGen.js
Created October 25, 2014 15:24
Generates a random 6 digit hex
// nice one paul irish + friends
// http://www.paulirish.com/2009/random-hex-color-code-snippets/
function hexGen() {
return Math.floor(Math.random()*16777215).toString(16)
}
@sturadnidge
sturadnidge / steamMarketWatch.js
Last active January 1, 2016 16:02
Watches an item in the Steam market place and highlights it if price drops below desired value
'use strict';
// npm install colors moment optimist
// builtins
var http = require('http'),
// 3rd party
colors = require('colors/safe'),
moment = require('moment');
@sturadnidge
sturadnidge / loungeWatch.js
Last active August 29, 2015 14:07
CSGO Lounge Match Watcher
'use strict';
// npm install cheerio moment optimist
var http = require('http'),
cheerio = require('cheerio'),
moment = require('moment'),
argv = require('optimist')
.usage('\nCheck csgolounge match stats every 30 secs.\n\nUsage: $0')
.demand(['d', 'i', 'm'])
@sturadnidge
sturadnidge / keybase.md
Created October 5, 2014 09:54
keybase.io validation

Keybase proof

I hereby claim:

  • I am sturadnidge on github.
  • I am stu (https://keybase.io/stu) on keybase.
  • I have a public key whose fingerprint is D119 6CCC 1CA6 35C7 ADA2 FB55 1528 858E 6E7D 4E0B

To claim this, I am signing this object:

@sturadnidge
sturadnidge / db.js
Last active August 29, 2015 14:03
Generic MongoDB lib for use with Express 4 apps
'use strict';
var db,
MongoClient = require('mongodb').MongoClient;
var database_name = checkExists(process.env.MONGODB_DATABASE) ? process.env.MONGODB_DATABASE : 'test',
env_user = process.env.MONGODB_USER,
env_pass = process.env.MONGODB_PASSWORD,
env_host = checkExists(process.env.MONGODB_HOST) ? process.env.MONGODB_HOST : 'localhost',
env_port = checkExists(process.env.MONGODB_PORT) ? parseInt(process.env.MONGODB_PORT, 10) : 27017;
@sturadnidge
sturadnidge / netlogon-to-srv-host
Last active July 17, 2020 04:15
awk one liner to convert netlogon.dns to dnsmasq srv-host format
# if the 4th field is 'SRV', then strip trailing dots, set the output field separator to comma and print accordingly
awk '$4 ~ /SRV/ {gsub(/\.( |$)/, " "); OFS = ","; print "srv-host=" $1,$8,$7,$5,$6}' netlogon.dns
@sturadnidge
sturadnidge / cdh4-httpfs-gateway
Last active December 26, 2015 00:09
Build out an HttpFS gateway. Assumes you have a Sun JDK installed and JAVA_HOME set for root.
# Add Cloudera RPM-GPG-KEY and repo
rpm --import http://archive.cloudera.com/cdh4/redhat/6/x86_64/cdh/RPM-GPG-KEY-cloudera
rpm -ivh http://archive.cloudera.com/cdh4/one-click-install/redhat/6/x86_64/cloudera-cdh-4-0.x86_64.rpm
# note: if you want to install a specific version,
# modify /etc/yum.repos.d/cloudera-cdh4.repo accordingly.
# For example, if you want to install 4.2.1, use the following baseurl:
# baseurl=http://archive.cloudera.com/cdh4/redhat/6/x86_64/cdh/4.2.1/
# Install CDH4 httpfs Base