Skip to content

Instantly share code, notes, and snippets.

View matutter's full-sized avatar

Mat Utter matutter

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / shortestpath2.rb
Last active August 29, 2015 14:07
shortestpath.rb Finds the shortest path given tuples to represent the graph. For directed and directed.
=begin
:mat utter, 10/19/2014
=end
class Graph
def initialize()
@graph = Array.new
end
def add(key,val)
@graph.push( [key,val] )
@matutter
matutter / DijkstrasShortestPath.rb
Last active August 29, 2015 14:07
DijkstrasShortestPath.rb
require 'matrix'
=begin
:mat utter, 10/19/2014
=end
class Graph
From = 0
To = 1
Length = 2
def initialize()
@graph = Array.new
@matutter
matutter / basicRational.rb
Last active August 29, 2015 14:08
An example class of cartisian graphs and rational numbers. although rational numbers is really just a class x > delegate(float) with a hat.
# mat utter 10/25/2014
# ...arrays of fractions - find the sum of an array.. is this an integral number class or not? Your directions are very unclear.
class Rational2
def initialize( n = 0 )
@num = n.to_f
@roundTo = 100
end
def +(other)
return Rational2.new( @num + other )
@matutter
matutter / asm.c
Last active August 29, 2015 14:08
Flex file, AT-ASM to AT-ROM
/*
Mat Utter 10/27/2014
compiler design, Confer
*/
/*
line comments begin with a semicolon (';')
a ".msg" precompiler directive is allowed prior to any labels or code.
It may contain a message of up to 70 characters beginning after