Skip to content

Instantly share code, notes, and snippets.

View shellexample.sh
#!/bin/bash
helpFunction()
{
echo ""
echo "Usage: $0 -a parameterA -b parameterB -c parameterC"
echo -e "\t-a Description of what is parameterA"
echo -e "\t-b Description of what is parameterB"
echo -e "\t-c Description of what is parameterC"
exit 1 # Exit script after printing help
@pacozaa
pacozaa / tleparser.py
Created Oct 28, 2016
Parses a NORAD two line element set into a Python dictionary.
View tleparser.py
def parse_tle_number(tle_number_string):
split_string = tle_number_string.split('-')
if len(split_string) == 3:
new_number = '-' + str(split_string[1]) + 'e-' + str(int(split_string[2])+1)
elif len(split_string) == 2:
new_number = str(split_string[0]) + 'e-' + str(int(split_string[1])+1)
elif len(split_string) == 1:
new_number = '0.' + str(split_string[0])
else:
raise TypeError('Input is not in the TLE float format')
@pacozaa
pacozaa / letsencrypt.md
Created Oct 24, 2016 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth
View letsencrypt.md

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@pacozaa
pacozaa / PosPrinter.java
Created Jun 5, 2016 — forked from dulichan/PosPrinter.java
COM port printer writing java example
View PosPrinter.java
package app.posmachine.machine;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.comm.CommPortIdentifier;
import javax.comm.SerialPort;
public class PosPrinter {
@pacozaa
pacozaa / compass+pid+motors.js
Created Mar 22, 2016
Compass PID controller integration with motors using Johnny-Five.io
View compass+pid+motors.js
var five = require('johnny-five');
var board = new five.Board();
var motorRight;
var motorLeft;
var compass;
var PID = require('pid-controller');
var heading = 0;
var headingSetpoint = 0;
var Kp = 5;
@pacozaa
pacozaa / gist:e625ac9b1f4447c8e7df
Created Feb 21, 2016 — forked from fajrif/gist:1265203
git clone specific tag
View gist:e625ac9b1f4447c8e7df
git clone <repo-address>
git tag -l
git checkout <tag-name>
git branch -D master
git checkout -b master
@pacozaa
pacozaa / gist:78b602244990cd261523
Created Jan 31, 2016 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
View gist:78b602244990cd261523
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
function base64ArrayBuffer(arrayBuffer) {
var base64 = ''
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var bytes = new Uint8Array(arrayBuffer)
var byteLength = bytes.byteLength
@pacozaa
pacozaa / nodejs-tcp-example.js
Created Nov 19, 2015 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
View nodejs-tcp-example.js
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');