Skip to content

Instantly share code, notes, and snippets.

View obihann's full-sized avatar

Jeffrey Hann obihann

View GitHub Profile
@obihann
obihann / organize.sh
Created August 18, 2014 13:49
Organize Images by Size
#!/bin/sh
for f in *.jpeg
do
BASE=$(basename "$f" .jpg)
mv "$f" "$BASE.jpg"
done
for f in *.jpg
do
@obihann
obihann / check-zeb.sh
Created August 25, 2014 18:31
TT++ MUD Log Check
#!/bin/sh
COUNT=$(cat /home/jeff/Shared/zeb.html | grep "#SESSION 'zeb' DIED." -c)
NOW=$(date +%s)
L_ERROR=$(cat /var/log/check-zeb-down)+3600
if (( $COUNT >= 1 && $L_ERROR <= $NOW )); then
date
curl --request POST https://api.pushover.net/1/messages.json --data "token=SECRET_TOKEN&user=SECRET_USER&message=Zeb is linkdead!&priority=1"
echo -e $NOW > /var/log/check-zeb-down
@obihann
obihann / generate.php
Last active August 29, 2015 14:15
Creating a secure session token
<?php
header('Content-Type: application/json');
session_start();
define("SESSION_SALT", "lowsaltdiet");
$sessionKey = hash("sha512", SESSION_SALT . session_id());
$post_data = array(
'session' => session_id(),
@obihann
obihann / main,go
Created February 19, 2015 18:04
Go Composition
package main
import (
"encoding/json"
"fmt"
"log"
)
type (
AStruct struct {
@obihann
obihann / conflicts.md
Last active August 29, 2015 14:22
look for merge conflicts

Search for merge conflicts by using grep and the pattern '>>>>' which is common to VCS systems such as Git, SVN, and Perforce.

Default use recursively searches based on your current folder:

$ ./conflicts.sh
Checking for conflicts in *
I've got 99 problems but merge conflicts ain't 1  :)

Alternatively you can specify a specific folder

@obihann
obihann / default-readme.md
Last active August 29, 2015 14:24
Default readme

GitHub tag GitHub issues GoDoc API Docs Coverage Status Build Status Dependency Status GitHub license

#Default Readme

@obihann
obihann / sticky-panes.md
Last active March 1, 2018 12:45
tmux `sticky` panes

TMUX sticky panes

Step 1

Create the session that will manage the nested/sticky panes

  • create new session named shared

      $ tmux new -s shared
    
  • rename current window

@obihann
obihann / main.hs
Last active September 25, 2015 12:21
Multiples of 3 and 5
-- If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
-- Find the sum of all the multiples of 3 or 5 below 1000.
rec_sum [] = 0
rec_sum (x:xs) = x + rec_sum xs
nums = [(x::Integer) | x <- [1..999], x `mod` 3 == 0 || x `mod` 5 == 0]
total = rec_sum nums
main = do
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
#!/bin/bash
apt-get install --yes lsb-release
DISTRIB_CODENAME=$(lsb_release --codename --short)
DEB="puppetlabs-release-${DISTRIB_CODENAME}.deb"
DEB_PROVIDES="/etc/apt/sources.list.d/puppetlabs.list" # Assume that this file's existence means we have the Puppet Labs repo added
if [ ! -e $DEB_PROVIDES ]
then
# Print statement useful for debugging, but automated runs of this will interpret any output as an error