Skip to content

Instantly share code, notes, and snippets.

@lrvick
lrvick / nfcauth.sh
Created January 28, 2015 06:57
PAM NFC screen unlock helper script
valid_hash=$( cat /home/lrvick/.nfcauth )
challange_hash=$( printf $1 | shasum -a 256 | sed 's/ .*//' )
echo $valid_hash
echo $challange_hash
if [ "$valid_hash" == "$challange_hash" ]; then
echo "unlocked"
killall slock
fi
@lrvick
lrvick / yts.sh
Created January 28, 2015 06:59
Youtube batch browserless search/autoplay script I wrote ages ago. Probably no longer works.
#!/bin/bash
#YouTubeSucker 0.9999999423ish
#your media player and args of choice, must have flv support, mplayer or vlc will do the job
mediap="mplayer -fs"
terms="$*"
if [ "$terms" = "" ] ; then
echo 'Usage: yts.sh [YouTube URL] [search terms]'
fi
@lrvick
lrvick / rsscrawl.py
Created January 28, 2015 09:17
Simple Python RSS crawler using lxml
import lxml.html
urls= (
'http://lrvick.net',
'http://zenhabits.net/',
'http://theoatmeal.com/',
'http://botd.wordpress.com/',
'http://informantpodcast.com/',
'http://moo.com',
)
@lrvick
lrvick / google-oauth.py
Created January 28, 2015 09:18
Python/Flask oAuth authorization example.
from flask import Flask, request, redirect
from rauth.service import OAuth2Service
import simplejson as json
google = OAuth2Service(
name='google',
consumer_key='478110803143-ct2e336q06knns6p7pgnob1msandulj3.apps.googleusercontent.com',
consumer_secret='BGncEz1jPsNAMN7mzqki7zTy',
access_token_url='https://accounts.google.com/o/oauth2/token',
authorize_url='https://accounts.google.com/o/oauth2/auth'
@lrvick
lrvick / happiness.py
Created January 28, 2015 09:20
Python Happiness Calculator. (Don't ask)
present_happiness = 1
trauma_happiness = present_happiness/10
post_trauma_happiness = present_happiness*2
trauma_years = 1
years_left = 43
@lrvick
lrvick / facebook-oauth.py
Created January 28, 2015 09:24
Flask / Python Facebook Graph oAuth Example
#!/usr/bin/python2.6
import os.path
import json
import urllib2
import urllib
import urlparse
import BaseHTTPServer
import webbrowser
APP_ID = '218248774869881'
@lrvick
lrvick / README.md
Last active May 9, 2024 20:15
Basecamp BS - How to deal with a clueless non-technical manager that insists you log every last second of your day in Basecamp.

Basecamp BS

How to deal with a clueless non-technical manager that insists you log every last second of your day in Basecamp.

I used this for a few weeks to randomly fill in Basecamp time logs to free up time to actually do my job. He was actually commented how satisfied he was with the level of detail I was logging. Since he didn't catch on on his own, I finally explained it was all random scripted nonsense to prove the point that micro time-management serves no purpose. He never brought up time logging again

@lrvick
lrvick / leak-recursive.js
Last active April 10, 2018 09:08
iojs/node memory leaks when dealing with promises and infinite loops
// This leaks insane amounts of memory
var fetchCallback = function(resolve, reject) {
resolve({'some':'test'})
}
var fetch = function() {
return new Promise(fetchCallback)
}
@lrvick
lrvick / roll-restart.sh
Last active August 29, 2015 14:17
Rolling CoreOS fleet restart
#!/bin/sh
SERVICE=$1
BRANCH=$2
HEALTH_URL=$3
if [ -z "$HEALTH_URL" ]; then
echo "Syntax: roll-restart someservice somebranch http://localhost:80"
exit
fi
@lrvick
lrvick / bathroom-lock.ino
Created March 26, 2015 20:00
Arduino Bathroom Lock State Server
#include <Wire.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE };
EthernetServer server(80);
const int lockPin = 2;
const int ledPin = 13;