Skip to content

Instantly share code, notes, and snippets.

View himynameisdave's full-sized avatar
✌️
livin' the dream...

Dave Lunny himynameisdave

✌️
livin' the dream...
View GitHub Profile
@himynameisdave
himynameisdave / system-font-stack.scss
Created July 11, 2016 23:05
A font stack that (mostly) relies on the fonts on the users machine/device
$system-font-stack: font-family: system, -apple-system, ".SFNSDisplay-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
@himynameisdave
himynameisdave / getKeys.js
Last active June 30, 2016 18:31
specify an array of keys you want and an array of objs, should return an array of objects with only specified keys
const objects = [
{
a: 'a',
b: 'b',
c: 'c'
},{
a: 'a',
b: 'b',
c: 'c'
},{
@himynameisdave
himynameisdave / sorter.js
Created June 29, 2016 20:37
Sort by a property in an array of objects
// Takes a property name and returns a function to be consumed by .sort
const sorter = (prop) => (a, b) => {
if (a[prop] < b[prop]) return -1;
if (a[prop] > b[prop]) return 1;
return 0;
};
export default sorter;
@himynameisdave
himynameisdave / GoogleHackMasterList.txt
Created June 22, 2016 20:16 — forked from cmartinbaughman/GoogleHackMasterList.txt
The definitive super list for "Google Hacking".
admin account info" filetype:log
!Host=*.* intext:enc_UserPassword=* ext:pcf
"# -FrontPage-" ext:pwd inurl:(service | authors | administrators | users) "# -FrontPage-" inurl:service.pwd
"AutoCreate=TRUE password=*"
"http://*:*@www&#8221; domainname
"index of/" "ws_ftp.ini" "parent directory"
"liveice configuration file" ext:cfg -site:sourceforge.net
"parent directory" +proftpdpasswd
Duclassified" -site:duware.com "DUware All Rights reserved"
duclassmate" -site:duware.com
@himynameisdave
himynameisdave / isMobileSafari.js
Created May 10, 2016 18:54
UA Sniffing for MobileSafari - I did not write this
module.exports = function isMobileSafari() {
return /(iPhone|iPod|iPad).+AppleWebKit/i.test(window.navigator.userAgent) && (function() {
var iOSversion = window.navigator.userAgent.match(/OS (\d)/);
return iOSversion && iOSversion.length>1 && parseInt(iOSversion[1]) < 10;
})();
}
@himynameisdave
himynameisdave / shuffle.js
Last active April 28, 2016 02:49
A shuffle one-liner
export default shuffle = (arr) => arr.sort((a, b) => arr.map(Math.random)[a] - arr.map(Math.random)[b]);
@himynameisdave
himynameisdave / request.js
Created April 13, 2016 19:30
Simple XMLHttpRequest wrapper
var req = function (url, cb) {
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState === 4 && r.statusCode === 200) {
cb(JSON.parse(r.responseText));
}
};
r.open("GET", url, true);
r.send();
};
alert('test');
@himynameisdave
himynameisdave / microservice_song-of-the-week.js
Created March 16, 2016 03:11
Microservice that tweets my most played song each week
module.exports = function songOfTheWeek(hook) {
var req = require("request-promise");
var Twitter = require('twitter');
var lastFmUrl = "http://ws.audioscrobbler.com/2.0/?method=user.getweeklytrackchart&user=himynameisdave9&api_key="+hook.env.sotw_lastfm+"&format=json";
var client = new Twitter({
consumer_key: hook.env.sotw_ckey,
consumer_secret: hook.env.sotw_csecret,
access_token_key: hook.env.sotw_atkey,
access_token_secret: hook.env.sotw_atsecret
});
@himynameisdave
himynameisdave / microservice_last-song.js
Last active March 9, 2016 21:44
Microservice to fetch data about the last song I played from last.fm
module.exports = function lastPlay(hook) {
var req = require("request-promise");
var url = "http://ws.audioscrobbler.com/2.0/?method=user.getRecentTracks&user=himynameisdave9&api_key="+hook.env.lastsong_lastfm_key+"&format=json";
var stringify = function(data) {
return JSON.stringify(data, true, 2);
};
var blackList = ["Hello Internet", "This American Life", "Myke Hurley and CGP Grey"]; // items that we don't want showing up
var isValidArtist = function (artist) {
var validity = blackList.filter(function(dontAdd){
return artist.toLowerCase().indexOf(dontAdd.toLowerCase()) >= 0;