Skip to content

Instantly share code, notes, and snippets.

@kristi
kristi / latest-amazon-linux-2.tf
Last active March 12, 2019 23:13
terraform - latest amazon linux 2 ami
data "aws_ami" "latest_amazon_linux_2" {
most_recent = true
filter {
name = "name"
values = ["*amzn2-ami-hvm*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
@kristi
kristi / install-adoptopenjdk.sh
Created March 12, 2019 04:25
Install AdoptOpenJdk
#!/usr/bin/env bash
set -ex
cd /tmp
VERSION="8u202-b08"
VERSION_WITHOUT_DASH="${VERSION/-/}"
TARBALL="OpenJDK8U-jre_x64_linux_hotspot_${VERSION_WITHOUT_DASH}.tar.gz"
CHECKSUM="b3f9934c6fc83fb2e76a4ded31367e5312013e27d36eac82a6fe1423aae394ce"
brew list -1 | while read line; do brew unlink $line; brew link $line; done
for x in sqlite openssl readline; do brew unlink $x; brew link --force $x; done
@kristi
kristi / template.go
Created January 16, 2014 09:23
A template for parsing integers from Stdin. InputParser struct uses embedding (go-flavored inheritance, see http://golang.org/doc/effective_go.html#embedding ) While it may be simpler to use multiple calls to fmt.Scan or fmt.Scanf, Scan is slow for really large arrays. Don't mix Scan calls with the bufio.Reader because the Reader is buffered so …
package main
import (
"fmt"
"strings"
"io"
"bufio"
"os"
"strconv"
)
@kristi
kristi / back 10 seconds
Last active January 2, 2016 02:09 — forked from nicwolff/back 10 seconds
set isPlaying flag even if document is not playing
if application "VLC" is running then
tell application "VLC"
step backward
end tell
end if
property step : 10
if application "QuickTime Player" is running then
tell application "QuickTime Player"
set playerPosition to (current time of front document) - step
set movieDuration to duration of front document
@kristi
kristi / auto-restart
Created September 4, 2011 20:39
auto-restart passenger
#!/bin/bash
# Restarts passenger after any *.py *.html or *.po files are saved
#
# Requires inotify-tools
appDir="/home/user/site.com/appname"
siteDir=$(dirname "$appdir")
# Make sure app directory exists
@kristi
kristi / missing.py
Created September 1, 2011 16:07
find missing natcomm facebook members
#!/usr/bin/env python
import codecs
import json
import urllib2
tcomm_id = '105089836262253'
natcomm_id = '134083046643371'
# Get token from
# https://developers.facebook.com/tools/explorer
# or create a fb app (https://developers.facebook.com/apps)
@kristi
kristi / get_fb_app_token
Created September 1, 2011 16:00
get facebook app access token
#!/usr/bin/env python
import urllib2
app_id='123abc'
app_secret='987fed'
def get_app_access_token(app_id, app_secret):
app_login_url = 'https://graph.facebook.com/oauth/access_token?client_id={app_id}&client_secret={app_secret}&grant_type=client_credentials'.format(app_id=app_id, app_secret=app_secret)
@kristi
kristi / bookmarklet
Created August 29, 2011 05:59
Bookmarklet: See all Facebook group posts
javascript:(function(){var%20t=0;function%20moar(){var%20e=document.querySelectorAll(%22a.pam%22);if(e.length%3E0){e[0].onclick();var%20e=document.querySelectorAll(%22input.stat_elem%22);for(var%20i=0;i%3Ce.length;i=i+1){e[i].click();}}else{t=setInterval(expand,3000);}}function%20expand(){var%20e=document.querySelectorAll(%22input.stat_elem%22);for(var%20i=0;i%3Ce.length;i=i+1){e[i].click();}if(e.length==0){clearInterval(t);}}t=setInterval(moar,1500);})();
@kristi
kristi / Z example commit message
Created August 14, 2011 21:27
customize git commit message
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: src/taikonome/Taikonome.as
# modified: taikonome.as3proj
#