Skip to content

Instantly share code, notes, and snippets.

View matutter's full-sized avatar

Mat Utter matutter

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / test.cpp
Last active August 29, 2015 14:06
current tutoring document
#include <iostream>
#include <string>
using namespace std;
int good_search( int ary[], int size, int item );
int main(int argc, char const *argv[])
{
int some_array[] = {1,3,4,5,123,2,123,0,515,13,41,3,12321};
@matutter
matutter / multiplicity_and_collection.cpp
Created September 18, 2014 18:30
Multiplicity&collections .cpp example
#include <string> // for string :: iterator
#include <fstream> // for file stuff
#include <cstdlib> // for atoi
#include <vector> // for vectors
#include <cstring> // for c_str
#include <iostream> // for cout/in
using namespace std;
class myclass
@matutter
matutter / TokenProviderNFA.h
Last active August 29, 2015 14:06
an NFA engine
using namespace std;
class TokenProviderNFA {
private:
void MoveTo_Space(string::iterator * cursor, string *s) {
while( ++*cursor != s->end() && !isspace(**cursor));
}
void MoveToNext(string::iterator * cursor, const char n, string * s) {
while (*cursor != s->end() && **cursor != n)
++*cursor;
@matutter
matutter / nfa_.h
Created September 22, 2014 20:10
nfa_NP
#ifndef ushort
#define ushort unsigned short
#endif
using namespace std;
/* 6 bytes */
typedef struct state {
ushort From;
char On;
ushort To;