Skip to content

Instantly share code, notes, and snippets.

@jesselang
jesselang / verify_utf.adb
Created January 24, 2016 18:06
I wrote this in May of 2010, and don't remember what it does, but better it being forgotten here than on a hard drive.
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Streams.Stream_IO;
use Ada.Streams;
procedure Verify_UTF is
First_Word : constant Stream_Element_Array (1 .. 2) := (16#fe#, 16#ff#); -- http://en.wikipedia.org/wiki/Byte_order_mark
Second_Word : constant Stream_Element_Array (1 .. 2) := (16#00#, 16#22#);
@jesselang
jesselang / example.yml
Created January 23, 2016 04:22
Example ansible playbook to access facts from a group of hosts from another host
---
# Execute using ansible-playbook -i hosts example.yml
- hosts: web
gather_facts: yes
- hosts: db
gather_facts: no # optional; speed optimization
tasks:
- name: Display addresses of all web hosts
- debug: msg={{ hostvars[item].ansible_eth0.ipv4.address }}
@jesselang
jesselang / prune-origin.sh
Created October 23, 2015 20:55
One-liner to keep your origin remote tidy (assuming you only care about branches being merged to master)
git fetch --prune && git branch -r --merged origin/HEAD | sed "s/origin\///" | grep -v 'master\|HEAD' | xargs -n 1 git push --delete origin && git fetch --prune
@jesselang
jesselang / migrate-repo.sh
Last active October 6, 2015 17:58
Migrate a git repo from one instance of Altassian Stash/BitBucket to another
#!/bin/sh
# Script to migrate git repos from one instance of Altassian Stash/BitBucket to another.
# Author: Jesse Lang | http://jesselang.com/
REPO=/tmp/migrate-repo-mirror-${USER}
if [ $# -lt 2 ]; then
echo "usage: migrate-repo.sh <current-url> <new-url>"
exit 1
fi
@jesselang
jesselang / malware_scanner.py
Last active October 6, 2015 17:57
Script to assist in cleaning up one type of injection from PHP malware
#!/usr/bin/env python
# Script to assist in cleaning up one type of injection from PHP malware.
# Author: Jesse Lang | http://jesselang.com/
# Use it with "find" like this:
# $ for FILE in $(find -iname *.php); do python malware_cleanup.py $FILE; done
# This script takes one argument, a file path.
# The file is opened and scanned for a match.
# The user is given the option of cleaning or deleting the file, or doing nothing.
# If repairing the file would result in an empty file, the file is deleted instead.