Skip to content

Instantly share code, notes, and snippets.

@albertstartup
albertstartup / getWordOccurences.js
Created August 1, 2015 02:22
get an array of arrays which hold a string and number of occurences
function getWordOccurences() {
var textNodes;
function getTextNodes() {
var walker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_TEXT,
null,
false
);
var express = require('express');
var app = express();
app.get('/yes', function (req, res) {
res.send('thanks!');
console.log('student got it, stop vib');
});
app.get('/no', function (req, res) {
res.send('thanks!');
MIDDLEFINGER="🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 🖕 "
PS1="\n \n$MIDDLEFINGER \n \n \n💰 \W\\ 💰 "
export PS1
@albertstartup
albertstartup / instawhen.js
Created December 31, 2015 03:42
know exactly when a photo was instagramed
// the page url must be instagram.com/p/
var node = document.getElementsByClassName("_379kp")[0]
var date = new Date(node.attributes["datetime"].value)
node.innerText = date.toLocaleString()
@albertstartup
albertstartup / cat.js
Created January 2, 2016 05:57
append to a tumblr post from the command line
var Q = require('q');
var tumblr = require('tumblr.js');
var fs = require('fs');
var _ = require('underscore');
// Customize these. Ill give instructions soon. Or ping me for help.
var tumblrClient = tumblr.createClient({
consumer_key: '',
consumer_secret: '',
token: '',
# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.
@albertstartup
albertstartup / user-data.sh
Created June 8, 2016 05:26 — forked from shanestillwell/user-data.sh
Amazon User Data script
#!/bin/bash
### BEGIN INIT INFO
# Provides: ec2-run-user-data
# Required-Start: $network $local_fs $remote_fs $syslog $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Run EC2 user-data scripts
# Description: On first boot of EC2 instance, runs user-data if it starts with #!
@albertstartup
albertstartup / user-data.sh
Last active July 4, 2016 01:28
aws user-data to change ssh port
#!/bin/bash
sudo perl -pi -e 's/^#?Port 22$/Port 443/' /etc/ssh/sshd_config
sudo service ssh restart
@albertstartup
albertstartup / get_latest_for_regions.py
Created June 17, 2016 22:53
Python script to get latest ec2 spot instance price for g2.8xlarge
import boto3
from datetime import datetime
from dateutil.tz import tzutc
from operator import itemgetter
from functools import partial
from pipe import Pipe
def get_region_history(region):
remove_windows = partial(filter, lambda item: item['ProductDescription'] != 'Windows')
@albertstartup
albertstartup / steps.sh
Last active December 26, 2017 21:18
aws gpu, ubuntu 16.04, nvidia driver 367, cuda 8,
# Required downloads:
# NVIDIA-Linux-x86_64-367.27.run
# cuda_8.0.27_linux.run
# cudnn-8.0-linux-x64-v5.0-ga.tgz
sudo apt-get install build-essential
sudo apt-get install linux-image-extra-`uname -r`
sudo ./NVIDIA-Linux-x86_64-367.27.run
./cuda_8.0.27_linux.run --extract=`pwd`/extracts
sudo ./extracts/cuda-linux64-rel-8.0.27-20733550.run