Skip to content

Instantly share code, notes, and snippets.

View matutter's full-sized avatar

Mat Utter matutter

View GitHub Profile
@matutter
matutter / install_antlr4.sh
Created April 7, 2017 19:01
Installs antlr4 on linux
#!/bin/bash
export ANTLR4_JAR=antlr-4.7-complete.jar
if ! type -p java; then
# Install Java 8
echo "Installing Java 8"
sudo add-apt-repository ppa:webupd8team/java
sudo apt updatee; sudo apt install oracle-java8-installer
@matutter
matutter / tmux_auto.sh
Last active March 30, 2017 12:43
Automatically connect to tmux session
##
# Check for TMUX session, create or attach "remote" session if connected through
# ssh or create or attach "local" session if connected through other means
HOST_SESSION_NAME="local"
SSH_SESSION_NAME="remote"
SESSION_NAME=$HOST_SESSION_NAME
if [ ! -n "$TMUX" ]; then
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
SESSION_NAME=$SSH_SESSION_NAME
fi
@matutter
matutter / example.makefile
Created March 17, 2017 15:44
A makefile to make all intermediate objects and compile the a main executable
##
# Sources are expected to be layed out like so
# .
# ├── makefile
# └── src
# ├── hashing
# │   ├── hash.c
# │   └── hash.h
# └── main.c
#
@matutter
matutter / winston.test.js
Last active September 24, 2016 18:25
Trying to get winston to log into home path with a ~
// winston.version === '2.2.0'
var winston = require("winston")
var fs = require("fs")
var path = require("path")
function tryLog(filename, msg) {
var logger = new winston.Logger()
logger.add(winston.transports.File, {
filename: filename,
level : 'verbose',
@matutter
matutter / nanomake.sh
Last active March 30, 2017 14:08
Includes all .nanorc files from /usr/share/nano
#!/bin/bash
# include all .nanorc files from /usr/share/nano
NANORC=~/.nanorc
SOURCE=/usr/share/nano
echo "# from nanomake.sh" > ${NANORC}
echo "set tabsize 2" >> ${NANORC}
echo "set tabstospaces" >> ${NANORC}
ls ${SOURCE} | grep .nanorc | while read FILE; do
@matutter
matutter / Dockerfile
Last active March 28, 2016 00:07
dependencies for server
FROM alpine:latest
MAINTAINER matutter
RUN apk --no-cache add nodejs
RUN apk --no-cache add git
RUN mkdir /home/www
WORKDIR /home/www
ADD package.json
@matutter
matutter / PureJavaJarExtract.java
Created June 2, 2015 02:19
Extract resources from a jar from jar
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication23;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@matutter
matutter / cpuTimer.cpp
Last active August 29, 2015 14:12
CPU speed, requires c++11 or c++0x
#include <chrono>
#include <iostream>
#include <unistd.h>
class Timer {
private:
static inline unsigned long long CPUCycleCounter(void) {
unsigned long long int x;
__asm__ volatile (".byte 0x0F, 0x31" : "=A" (x));
@matutter
matutter / JCommand.hpp
Created December 24, 2014 18:34
C++ UDP Json tryParse object
/*
from: https://github.com/matutter/AirRocks-FlightController
JCommand -
SHOULD be the main JSON parsing type
WILL be exception safe
boost causes hangs and weird assemlber errors, v8 embedding is worse...
i NEED c++11 support... next time its going to be an Intel Edison
*/
#ifndef JSON_COMMAND_T
@matutter
matutter / fastFib.at2
Created December 6, 2014 07:41
ATROBOTS fastest Fibonacci
#def N
#def F
#def I
#def FP
#def TMP
mov N 20
;non recursive fib
!fib
cmp N 1