Skip to content

Instantly share code, notes, and snippets.

View aeppert's full-sized avatar

Aaron Eppert aeppert

View GitHub Profile
@aeppert
aeppert / bug_free_buddha_comment.py
Created June 20, 2016 19:24 — forked from rsvp/bug_free_buddha_comment.py
Special comment to minimize bugs in any Python or shell code -- Buddhist ASCII Art
# To minimize bugs, include this comment:
#
#
# _oo0oo_
# o8888888o
# 88" . "88
# (| -_- |)
# 0\ = /0
# ___/`---'\___
# .' \| |// '.
@aeppert
aeppert / SSHwithgit2go.go
Created September 12, 2016 04:18 — forked from zchee/SSHwithgit2go.go
Working example with SSH and libgit2/git2go
package main
import (
git "github.com/libgit2/git2go"
"log"
)
func credentialsCallback(url string, username string, allowedTypes git.CredType) (git.ErrorCode, *git.Cred) {
ret, cred := git.NewCredSshKey("git", "/home/vagrant/.ssh/id_rsa.pub", "/home/vagrant/.ssh/id_rsa", "")
return git.ErrorCode(ret), &cred
package main
import (
"errors"
"fmt"
"os"
"strings"
"os/exec"
)
@aeppert
aeppert / cli_to_bin.py
Created December 19, 2016 18:20
Covert a string as a command line argument to binary
#!/usr/bin/python
import sys
def to_bin(st):
return ' '.join(format(ord(x), 'b') for x in st)
def main(argv):
for x in argv[1:]:
print to_bin(x)
#!/usr/bin/python
def chunker(seq, size):
return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))
def word_to_ord(s):
ret = ''
for i in s:
ret += str(ord(i))
return ret
#!/bin/bash
# autossh.x86_64 1.4e-1.el7 @epel
# puppetlabs-stdlib.noarch 4.5.1-2.20150121git7a91f20.el7 @epel
IFS=$'\n'
get_filename() {
local line=$1
echo $i | awk '{
#!/bin/bash
start() {
echo "Starting"
}
stop() {
echo "Stopping"
}
@aeppert
aeppert / durationdiff.go
Created January 12, 2017 21:14
Return the time.Time between passed in time and duration string (m,h,s, etc.)
package main
import (
"fmt"
"time"
)
func getDurationDiff(t time.Time, duration string) (time.Time, error) {
dur, err := time.ParseDuration(fmt.Sprintf("-%s", duration))
if err != nil {
return time.Now(), err
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
#include <sstream>
#include <iostream>
#include <numeric>
#include <string>
#include <iostream>
std::string &righttrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(),
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;