Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import pika
import uuid
import json
import sample2_pb2 as sample2
import base64
person = sample2.Person()
person.name = "Johan Astborg"
person.id = 1001
@joastbg
joastbg / rpc_client.py
Created August 4, 2016 09:13
RPC - RabbitMQ + Protobuf
#!/usr/bin/env python
import pika
import uuid
import json
import sample2_pb2 as sample2
import base64
person = sample2.Person()
person.name = "Johan Astborg"
person.id = 1001
mvn archetype:generate -DgroupId=se.gautr.testing \
-DartifactId=signals \
-Dversion=1.0-SNAPSHOT
@joastbg
joastbg / fib.m
Created June 2, 2016 13:39
Fibonacci sequence in state-space form - Octave (MATLAB)
%% Fibonacci sequence in state-space form
% Define the state-space system parameters:
A = [0 1; 1 1]; % State transition matrix
B = [0; 1]; C = [1 1]; D = 1; % Input, output, feed-around
% Set up the input signal, initial conditions, etc.
x0 = [0;0]; % Initial state (N=2)
Ns = 13; % Number of sample times to simulate
u = [1, zeros(1,Ns-1)]; % Input signal (an impulse at time 0)
@joastbg
joastbg / Heap.java
Created April 21, 2016 21:32
Heap (rev 2)
// Programvaruutveckling i Grupp, Spike 01 - 1/19/2007
public class Heap {
public static void main(String[] args) {
Integer[] intArray;
MinHeap<Integer> myHeap = new MinHeap<Integer>();
import java.awt.*;
import se.lth.cs.ad.drawing.*;
public class BSTVisualizer {
private DrawingArea canvas;
// diameter of nodes;
private final static int DIAMETER = 20;
// horizontal distance between nodes on same level
/
public class HeapEntry<E> {
E element; // element associated with this HeapEntry object
int index; // index of this HeapEntry object in the array
// representing the heap.
HeapEntry(E element) {
this.element = element;
}
#include <iostream>
#include <string>
#include <cstring>
#include <bitset>
#include <cmath>
// Convert the 32-bit binary encoding into hexadecimal
int binary_to_hex(std::string &binary)
{
std::bitset<32> set(binary);
@joastbg
joastbg / ellipse.html
Created February 25, 2016 21:27
Ellipse SVG
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="500" width="500">
<defs>
<marker id="arrow" markerWidth="10" markerHeight="10" refx="0" refy="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,0 L0,6 L9,3 z" fill="#000" />
</marker>
</defs>
@joastbg
joastbg / fft.py
Last active February 23, 2016 13:35
Settings for creating nice plots
import numpy as np
from scipy import fftpack
import matplotlib.pyplot as plt
from matplotlib import rcParams
from matplotlib import use
#import matplotlib as mpl
use('pgf')
def figsize(scale):