Skip to content

Instantly share code, notes, and snippets.

View justsml's full-sized avatar
🔥
#BLM

Dan Levy justsml

🔥
#BLM
View GitHub Profile
@justsml
justsml / virustotal_upload
Last active November 9, 2015 00:59 — forked from luca-m/virustotal_upload
Upload a sample to VirusTotal and pretty print the report. All in a handy alias.
#!/bin/bash
# Upload a sample to VirusTotal and pretty print the report. All in a handy alias.
#
# Dependecies:
#
# * python > 2.7
# * pip install Pygments==1.4
# * curl
# * VirusTotal API key
@justsml
justsml / disable-transparent-hugepages
Last active November 23, 2015 18:44
Copy into `/etc/init.d/disable-transparent-hugepages` -- from https://docs.mongodb.org/manual/tutorial/transparent-huge-pages/
#!/bin/sh
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
@justsml
justsml / identify-os.sh
Created November 23, 2015 19:04
helper script - returns Linux Standard Base distribution name
#!/bin/bash
#Author: Dan Levy <Dan@DanLevy.net>
#Credits: docker - https://github.com/docker/docker/blob/master/hack/install.sh
command_exists() {
command -v "$@" > /dev/null 2>&1
}
lsb_dist=''
dist_version=''
@justsml
justsml / test.js
Last active January 8, 2016 01:46 — forked from dhigginbotham/adobeAnalyticsInspection.js
sometimes I need to know what vars/events/props are getting sent off to omniture / sitecatalyst / adobe analytics or whatever they renamed themselves to again :neckbeard: I got the awesome list of params from http://www.cheatography.com/dmpg-tom/cheat-sheets/adobe-analytics-omniture-sitecatalyst-parameters/pdf/
var tap = require('tap');
var locationify = require('..');
tap.test('full URLs', function (t) {
t.similar(locationify('https://github.com/justsml#top'), {
host: 'github.com',
hash: '#top',
path: '/justsml',
});
// call t.end() when you're done
@justsml
justsml / Easy QueryString Parameter Overrides.md
Last active January 23, 2016 05:53
Safer Way to Manipulate a QueryString and Return Modified URL

HOWTO: Easy QueryString Parameter Overrides

A Safer Way to Manipulate a QueryString and Return Modified URL

Demo/Example URL Transform

# Example 1 - Update current query's `tab` value
Starting URL:        https://github.com/justsml?tab=repositories
Transform W/: {tab: 'activity'}
@justsml
justsml / fun-with-bluebird-promise-patterns.js
Last active February 4, 2016 02:15 — forked from domenic/not-bad-code.js
Avoiding explicit promise construction antipattern. Added bluebird.js secret sauce.
// Promises are great, but bluebird covers :allthethings
var Promise = require('bluebird');
var appContext = {ready: false, error: false};
const INVALID_CTX = {ready: false, error: true, message: 'App or User not initialized'};
// Bluebird-ify around `fetch` API
function getUser(username) {return Promise.resolve('users/' + username + '.json').then(fetch);}
function initApp(username) {
// Use bluebird to do some real-world-ish code:
#/bin/bash
set -e
# Tested on Mac OSX
# Local IP changes on every network you connect to (via dhcp)
export LOCAL_IP=`ifconfig en0 | grep 'inet ' | awk '{ print $2; }' 2>/dev/null`
# This is the 'Bridge' (virtual switch) from virtualbox - only visible from your local PC
export BRIDGE_IP=`ifconfig vboxnet0 | grep 'inet ' | awk '{ print $2; }' 2>/dev/null`
export DOCKER_HOST_IP=`docker-machine ip default`
@justsml
justsml / screenshot-capture-selection.sh
Created March 28, 2016 22:29
Linux/Debian Clone of Mac OSX 'Capture Screen Region' feature (map to similar Cmd+Ctrl+Shift+4)
#!/bin/bash
# Clone of Capture Screen Region on Mac OSX (map to similar Cmd-Ctrl-Shift-4)
# *** Requirements ***
# shutter - `apt-get install shutter`
# copyq - download from https://github.com/hluk/CopyQ/releases
shutter --select --no_session --exit_after_capture --output=/tmp/screenshot-surrent.png
copyq write image/png - < /tmp/screenshot-surrent.png && copyq select 0
rm /tmp/screenshot-surrent.png
var ctx = {};
var _ = require('lodash');
var assert = require('assert');
var Promise = require('bluebird');
var mongodb = Promise.promisifyAll(require('mongodb'));
var MongoClient = Promise.promisifyAll(mongodb.MongoClient);
var Collection = Promise.promisifyAll(mongodb.Collection);
const MONGO_BOOLEAN_TYPE = { 'type': 'Boolean', default: null };
const MONGO_NUMBER_TYPE = { 'type': 'Number', default: null };
@justsml
justsml / Dockerfile
Created April 10, 2016 18:38
Example Dockerfile which ADD's (remote HTTPS) Shell Enhancements
FROM node:5.10.1
MAINTAINER Dan Levy <Dan@DanLevy.net>
EXPOSE 3000
ADD https://raw.githubusercontent.com/justsml/system-setup-tools/master/home-scripts/.bashrc /root/.bashrc
ADD https://raw.githubusercontent.com/justsml/system-setup-tools/master/home-scripts/.bash_aliases /root/.bash_aliases
COPY . /app/
WORKDIR /app
CMD ["npm", "start"]