Skip to content

Instantly share code, notes, and snippets.

View pdxjohnny's full-sized avatar
🐢
Rolling Alice...

John Andersen pdxjohnny

🐢
Rolling Alice...
View GitHub Profile
@pdxjohnny
pdxjohnny / in_path.sh
Created July 21, 2015 15:46
Function for checking if something is in the path
#!/bin/bash
in_path () {
IS_IN_PATH=1
if [ -n "$1" ]
then
command -v $1 >/dev/null 2>&1 || { IS_IN_PATH=0; }
fi
return ${IS_IN_PATH}
}
@pdxjohnny
pdxjohnny / index.html
Created July 21, 2015 21:56
Stratus with websockets
<!DOCTYPE html>
<html>
<head>
<title>tornado WebSocket example</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</head>
<body>
<div class="container">
<h1>tornado WebSocket example</h1>
@pdxjohnny
pdxjohnny / -
Created July 22, 2015 18:26
Crontab on reboot
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
@pdxjohnny
pdxjohnny / app.py
Created July 22, 2015 19:10
Python webserver to handle gitlab web hooks
"""
File: gitlab_webhooks/app.py
Author: John Andersen
Description: A webserver to receive json web hooks from gitlab_webhooks
The hooks are dealt with by calling the corresponding function in
hooks.py. For example a push is received so the function push in
hook.py is called and passed the hook data.
Crontab line to run on reboot
@reboot /usr/bin/python /path/to/gitlab_webhooks/app.py 9898
@pdxjohnny
pdxjohnny / irc_client.py
Created July 23, 2015 19:28
Use of python irc
#! /usr/bin/env python
import sys
import ssl
import thread
import argparse
import itertools
import irc.client
__connection__ = False
@pdxjohnny
pdxjohnny / .bashrc
Created July 24, 2015 23:11
functions to make a video a gif
vid2images() {
mplayer -ao null $1 -vo jpeg:outdir=${1}_images
}
images2gif() {
convert ${1}_images/* ${1}_unoptimized.gif
convert ${1}_unoptimized.gif -fuzz 10% -layers Optimize ${1}.gif
}
gifit() {
@pdxjohnny
pdxjohnny / doc.py
Created August 13, 2015 15:57
python access docstring
"""
This is my docstring
John Andersen
"""
import sys
def main():
print sys.modules[__name__].__doc__
@pdxjohnny
pdxjohnny / log.go
Created August 28, 2015 21:19
Redirect stdout to websocket in go, great for logging in gomobile
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"time"
@pdxjohnny
pdxjohnny / SimpleHTTPServerWithUpload.py
Last active March 18, 2016 23:25
Update of UniIsland/3346170 SimpleHTTPServer with upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
#!/bin/bash
PRODUCT_NAME="someproject"
@pdxjohnny
pdxjohnny / bashrc
Created September 3, 2015 05:37
Bashrc
# Go path
export GOPATH=$HOME/Documents/go
mkdir -p $GOPATH/bin
export PATH=$PATH:$GOPATH/bin
TF_ALIAS=fuck alias fuck='eval $(thefuck $(fc -ln -1)); history -r'
export PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '