Skip to content

Instantly share code, notes, and snippets.

View audstanley's full-sized avatar
📡
Send me a message on aprs: KM6LZF

Richard Stanley audstanley

📡
Send me a message on aprs: KM6LZF
View GitHub Profile
@audstanley
audstanley / Node Array of object population
Created January 6, 2016 22:28
wont return the objects in the array
var obj = [ {"username":"audstanleybot"} ];
var newObj = '{"username":"audstanleybot2"}';
function addToObj(anObj) {
return anObj.push(newObj);
}
console.log(addToObj(obj));
/**
* Created by audstanley on 01/06/16.
*/
//need to change the path in jsonObj to /home/pi/slackberrypiratebot/json/botlist.json
module.exports = function(robot)
{
robot.respond(/\/[Rr][Ee][Mm][Oo][Vv][Ee]\s+@(\S+)?/, function(res)
{
var role = 'admin';
// console.log(res);
/**
* Created by audstanley on 01/06/16.
*/
//need to change the path in jsonObj to /home/pi/slackberrypiratebot/json/botlist.json
module.exports = function(robot)
{
robot.respond(/\/[Rr][Ee][Mm][Oo][Vv][Ee]\s+@(\S+)?/, function(res)
{
var role = 'admin';
// console.log(res);
@audstanley
audstanley / movieLookUP.js
Created January 8, 2016 02:23
A simple movie Query.
function getMovie(movieData) {
var movie = require('node-movie');
movie('Alien', '1979', function (err, data) {
console.log(data.Poster);
//res.send(data.Poster);
return movieData = data;
});
}
process.nextTick(getMovie);
module.exports = function(robot) {
return robot.hear(/\{.?(movie):.?"(.*?)",?.?(year):.?"(.*?)",?.?(opt):.?"(.*?)".?}/, function(res) {
console.log("Got input, using " + res.match[2] + " for the title, and " + res.match[4] + " for the year.");
var movie = require('node-movie');
var title = res.match[2];
var year = res.match[4];
request({'uri' : 'http://' + 'admin' + ':' + 'password2' + '@localhost:8080/gui/token.html'}, function(error, response, body) {
var regex = new RegExp('<div id=(?:\'|")token(?:\'|")[^>]+>(.*)</div>');
var matches = regex.exec(body);
var ourToken = matches[1];
console.log(response.body);
request({'uri' : 'http://' + 'admin' + ':' + 'password2' + '@localhost:8080/gui/?token=' + ourToken + '&action=add-url&s=' + lastTorrent, 'cookie': response.headers['set-cookie'].GUID}, function(error, more) {
console.log(more.body);
});
jf.writeFileSync('/home/audstanley/slackberrypiratebot/json/output.json', response);
var Promise = require('bluebird');
var bhttp = require('bhttp');
var session = bhttp.session({ headers: {"user-agent": "MyCustomUserAgent/2.0"} });
// Our new session now automatically has a cookie jar, and also uses our preset option(s).
Promise.try(function(){
return session.get("http://admin:password2@localhost:8080/gui/"); // Assume that this site now sets a cookie
}).then(function(response){
var regex = new RegExp('<div id=(?:\'|")token(?:\'|")[^>]+>(.*)</div>');
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
@audstanley
audstanley / gist:4750dd466b8634d8bc9b6fd07f2860c2
Last active December 17, 2016 21:22
getExternalIpAddress.sh
sudo su;
sudo echo "0/10 * * * * root curl ifconfig.me > /home/pi/myIp.txt" >> /etc/;
exit;
sudo echo -e "\n\nnetwork={\n ssid=\"coast-wifi\"\n proto=RSN\n key_mgmt=WPA-EAP\n pairwise=CCMP\n auth_alg=OPEN\n eap=PEAP\n identity=\"user\"\n password=\"password\"\n}" >> /etc/wpa_supplicant/wpa_supplicant.config;