Skip to content

Instantly share code, notes, and snippets.

View matutter's full-sized avatar

Mat Utter matutter

View GitHub Profile
@matutter
matutter / complete_sink.rb
Created October 19, 2014 06:39
complete_sink.rb determines if a given vertex is a sink for all other vertices
=begin
:mat utter, 10/18/2014
=end
class Graph
def initialize()
@graph = Hash.new(false)
@visit = Hash.new(false)
end
def add(key,val)
@visit [key] = false
@matutter
matutter / inside_cyclic.rb
Last active August 29, 2015 14:07
inside_cyclic.rb given a directed or undirected graph check if given element is in a cyclic structure
=begin
:mat utter, 10/18/2014
=end
class Graph
def initialize()
@graph = Hash.new(false)
@visit = Hash.new(false)
@target = false
end
def add(key,val)
@matutter
matutter / rsa.rb
Last active August 29, 2015 14:07
An RSA encryption example, written in ruby
=begin
You are given RSA Public Key (391, 3).
What is your decryption exponent?
What is the encoding of M = 41?
=end
puts
puts
def gcd(a, b)
@matutter
matutter / cleanJunk.sh
Created October 5, 2014 01:03
From https://gist.github.com/Ek0n/f46370ee820f63862194: but without gcalc witch isn't a default app.
sudo apt-get remove pistore wolfram-engine oracle-java8-jdk debian-reference-en leafpad scratch smartsim epiphany-browser gnome-icon-theme gnome-themes-standard-data gtk2-engines gvfs-backends gvfs-fuse zenity gpicview java-common libraspberrypi-doc libraspberrypi-dev gstreamer1.0-alsa gstreamer1.0-libav gstreamer1.0-omx gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-x lxde lxde-core libraspberrypi-bin wpagui wpasupplicant dosfstools idle idle3 pypy-upstream python-picamera python-pifacecommon python-pifacedigitalio python-rpi.gpio python-tk python3-picamera python3-pifacedigitalio python3-pifacedigital-scratch-handler python3-pifacecommon python3-rpi.gpio python3-numpy python3-tk alsa-utils timidity xpdf minecraft-pi python-minecraftpi penguinspuzzle sonic-pi omxplayer dillo netsurf-gtk desktop-base lightdm lxappearance lxde-common lxde-icon-theme lxinput lxpanel lxpolkit lxrandr lxsession-edit lxshortcut lxtask lxterminal obconf openbox raspberrypi-artwork weston
@matutter
matutter / cycles.c
Created October 3, 2014 23:49
complete cycles counter
#define PRSET1__ t1 = CPUCycleCounter();
#define PRSET2__ t2 = CPUCycleCounter();
#define PRDIFF__ t2 - t1
unsigned long long t1 =0, t2 =0;
static inline unsigned long long CPUCycleCounter(void) {
unsigned long long int x;
__asm__ volatile (".byte 0x0F, 0x31" : "=A" (x));
return x;
}
@matutter
matutter / pointers.cpp
Created September 24, 2014 20:53
c++ pointers
#include <iostream>
using namespace std;
/* prototype */
void show( double **A );
void add( double **A, double **B, double **C );
@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;
@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 / 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 / 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};