Skip to content

Instantly share code, notes, and snippets.

View matutter's full-sized avatar

Mat Utter matutter

View GitHub Profile
@matutter
matutter / Calculator.java
Created September 2, 2014 19:48
java calc example: This is an example of java.swing.* usage. Non-GUI features are intentionally poorly implemented. Don't plagiarizer.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Calculator extends JFrame implements ActionListener {
int cols = 6;
JPanel[] row = new JPanel[cols];
JButton[] button = new JButton[20];
String[] buttonString = {"7", "8", "9", "+",
@matutter
matutter / LangDefine.h
Created August 31, 2014 16:50
Reusable lexical tokenizer
#include <string>
#include <vector>
#include <regex>
#include <iostream>
/* affinity levels ergo, same level of presidence */
#define _OPERATOR_PLUS 0xf0
#define _OPERATOR_MINU 0xf1
#define _OPERATOR_MULT 0xf2
#define _OPERATOR_DIVI 0xf3
@matutter
matutter / cmp.cpp
Created August 30, 2014 21:58
Common Language parser idea
void Tokenize(string s, langDef l) {
unsigned int cursor = 0;
unsigned int offset = 0;
string chunk = "";
while (cursor + offset < s.length()){
Token token("");
Identity hint;
@matutter
matutter / C# persist
Created July 11, 2014 02:57
persistence is very easy in c#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace settings
@matutter
matutter / pMonitor.py
Created June 20, 2014 03:37
a process utility for logging and restarting apps.
import subprocess
import select
import time
import sys
#no-nonsense python utility for app testing
#pythons subprocess class is really weird...
class pMonitor:
pM_proc = False
pM_path = False
@matutter
matutter / useless cacher
Created June 14, 2014 20:48
Created a node FS pre-cacher, my node was already optimized... 1 tick slower
/*
var images = new pre.cache_request('./resources/images/','*', true, function(cache) {
handler.locals.cache = cache
})
pre.directoryCache( [images] )
if( local.cache[pathto+file] != undefined ) {
res.writeHead(200, {'content-type':mime})
@matutter
matutter / simple_IPC.js
Created June 13, 2014 03:06
IPC in nodeJS
try {
var proc = cp.spawn('execs/a.out',['param1','param2'], null );
proc.stdout.setEncoding('utf-8');
proc.stdin.setEncoding('utf-8');
var writeBuffer = []
, artificial_latency = 50
, writeCRON = setInterval(function(){
if( /*proc.connected &&*/ writeBuffer.length ) {
proc.stdin.write( writeBuffer[0] + '\n')
@matutter
matutter / gist:12f569954e8132c2c4e8
Created May 31, 2014 18:45
Install sublime with PPA
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer
@matutter
matutter / JSON to form creator
Created May 17, 2014 02:32
dynamic JSON to form creation, much to expland on
function generateTemplate(doc) {
var name = doc.name
var page = doc.page
var content = doc.content
var id = doc._id
var form = ''
form += '<generate>'
form += '<div class="page-header"><h1>' + name + '<small>' + page + '</small></h1><button class="btn btn-gen">Save</div>'
form += '<label>Post title</label><input class="form-control" type="text" name="title">'