Skip to content

Instantly share code, notes, and snippets.

View joshterrill's full-sized avatar

Josh Terrill joshterrill

View GitHub Profile
var express = require("express"),
http = require("http"),
async = require("async"),
sockjs = require("sockjs"),
uuid = require("uuid"),
url = require("url"),
redis = require("redis"); // for pubsub and to persist data if your app restarts
var app = express(),
redisClient = redis.createClient(),
@joshterrill
joshterrill / meteorRandomRouter
Created March 15, 2014 20:30
generates a random url and redirects to it, displaying publicScreen
Meteor.startup(function() {
var auto;
auto = Cookie.get('autosubscribe');
if (auto) {
return Router.go('publicScreen', {
_id: auto
});
}
});
@joshterrill
joshterrill / ip_list.txt
Last active August 29, 2015 14:02
a small bash script that loops through all of the ip's in a file and blocks them using iptables
1.1.1.1
2.2.2.2
3.3.3.3
@joshterrill
joshterrill / tweet.js
Created August 8, 2014 22:22
tweet.js example for phantom js
// Get twitter status for given account (or for the default one, "PhantomJS")
var page = require('webpage').create(),
system = require('system'),
twitterId = "PhantomJS"; //< default value
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
console.log(msg);
};
@joshterrill
joshterrill / datepickerNoFocus.js
Last active August 29, 2015 14:16
code that allows the datepicker() to focus first without showing the calendar UI until input field is clicked
function cwUtil_focusDateInput(name) {
var selectedInput = $("[name='" + name + "']");
$(selectedInput).focus();
$(selectedInput).on("click", function() {
$(this).datepicker();
$(this).focus();
});
}
@joshterrill
joshterrill / mailer.sh
Created June 17, 2015 10:35
Bash log mailer
# sendmail -t "joshterrill.dev@gmail.com" < mail.txt
# To: joshterrill.dev@gmail.com
# From: jobs@pig-1-102828
# Subject: Sent from a terminal!
# Thanks for the message!
DATE=`date +%d-%m-%y`
ps aux > /var/www/html/mailerlog/$DATE.txt
sendmail -t "joshterrill.dev@gmail.com" < /var/www/html/mailerlog/$DATE.txt
@joshterrill
joshterrill / valid-file-name.js
Created June 30, 2015 22:11
valid filename regex
var str = '// \\ / \ _ - . ( ) () &&& !@#$%^&*)*_+=this is a test #$^*#<><>[][]{}{}{}{)(*#@';
var result = str.replace(/_|#|\\|\/|-|\.|\ |\(|\)|\&|\@|\!|\$|\%|\^|\*|\+|\=|\[|\]|\{|\}|\'|\"|\<|\>|\?|/g,'');
console.log(result);
// thisisatest

Keybase proof

I hereby claim:

  • I am joshterrill on github.
  • I am joshterrill (https://keybase.io/joshterrill) on keybase.
  • I have a public key whose fingerprint is 25FA 836A E958 18A3 EF6A E79F B3B3 908C 7ED7 608F

To claim this, I am signing this object:

@joshterrill
joshterrill / balance.sol
Last active August 19, 2016 01:36
30 days of Solidity - Day 1: Balance contract
contract Balance {
uint public balance;
}
@joshterrill
joshterrill / Payroll.sol
Last active April 30, 2018 12:36
Payroll solidity contract example
contract Payroll {
// define variables
address public CompanyOwner;
uint employeeId;
// create Employee object
struct Employee {
uint employeeId;
address employeeAddress;