Skip to content

Instantly share code, notes, and snippets.

@elvinio
elvinio / recordtemp.py
Created March 28, 2016 01:52
Records the temperature readout from the hardware sensor in a linux env.
#!/usr/bin/python
import subprocess
import time
temp = [3, 8, 13, 18, 23, 28, 33, 38, 43, 51, 56, 61, 66, 71, 76, 81, 86, 91, 147, 153, 159, 165, 171, 240, 246, 252, 258, 264]
f = open('temp', 'w')
while True:
output = subprocess.check_output(["sensors", "-u"])
lines = output.split("\n")
@elvinio
elvinio / pulse.cpp
Created March 22, 2016 06:49
UDP Time pulse receiver. gcc -std=c++11 pulse.cpp -o pulse
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
void die(char *s)
{
@elvinio
elvinio / UDP_Time_Pulsor.cpp
Last active March 22, 2016 06:49
gcc -std=c++11 pulse.cpp -o pulse.
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
void die(char *s)
{
#include <iostream>
using namespace std;
int main() {
int **seq;
int N, Q;
cin >> N;
cin >> Q;
//cout << N << " " << Q;
@elvinio
elvinio / latency.plt
Last active April 5, 2016 01:13
Plots timediff in nanosecond in gnuplot
set grid xtics
set grid ytics
set xtics rotate
set yrange[-96000:-122000]
set format x '%.0f'
set format y "%.f"
set xtics 60
set ytics 5000
set border 3
plot "apr/pd" using (($1/1000000000-1459440000)/60):($3/1000)
@elvinio
elvinio / clock_gettime.py
Created March 14, 2016 10:05
Return clock_gettime in python by invoking librt system call
#!/usr/bin/python
import ctypes, os
class timespec(ctypes.Structure):
_fields_ = [
('tv_sec', ctypes.c_long),
('tv_nsec', ctypes.c_long)
]
librt = ctypes.CDLL('librt.so.1', use_errno=True)
@elvinio
elvinio / ntpq output
Created March 11, 2016 15:29
ntpq output
> $ ntpq
ntpq> rv
associd=0 status=c018 leap_alarm, sync_unspec, 1 event, no_sys_peer,
version="ntpd 4.2.6@1.2089-o Fri May 28 01:20:53 UTC 2010 (1)",
processor="x86_64", system="Darwin/15.3.0", leap=11, stratum=16,
precision=-20, rootdelay=0.000, rootdisp=132.675, refid=STEP,
reftime=00000000.00000000 Mon, Jan 1 1900 6:55:25.000,
clock=da8d5e4f.827cbf7f Fri, Mar 11 2016 23:10:07.509, peer=0, tc=10,
mintc=3, offset=0.000, frequency=60.953, sys_jitter=0.001,
clk_jitter=0.001, clk_wander=0.025
@elvinio
elvinio / Vector_vs_Array.cpp
Created January 15, 2016 07:37
Compare the memory allocation performance of vector vs array in C++
// Example program
#include <iostream>
#include <string>
#include <vector>
#include <sys/time.h>
class Widget{
public:
int id;
Widget(){
#!/usr/bin/python
from struct import *
with open('cap','rb') as f:
data = f.read(24)
globalHeader = unpack('IHHiIII',data)
print globalHeader
data = f.read(16)
while data != "":
packetHeader = unpack('IIII', data)
@elvinio
elvinio / FIX44
Last active April 7, 2016 14:30
FIX 4.4 tags, description and values
1|Account|String|Account mnemonic as agreed between buy and sell sides, e.g. broker and institution or investor/intermediary and fund manager.<br /><br />|Execution Report, Order Cancel Reject, New Order Single, New Order List, Order Cancel Request, Order Cancel Replace Request, Order Status Request, Quote Request, Quote, Quote Cancel, Quote Status Request, Mass Quote Acknowledgement, Mass Quote, Bid Request, Registration Instructions, Registration Instructions Response, New Order Cross, Cross Order Cancel Replace Request, New Order Multileg, Multileg Order Cancel Replace, Trade Capture Report, Order Mass Status Request, Quote Request Reject, Quote Status Report, Quote Response, Position Maintenance Request, Position Maintenance Report, Request For Positions, Request For Positions Ack, Position Report, Trade Capture Report Ack, Assignment Report, Collateral Request, Collateral Assignment, Collateral Response, Collateral Report, Collateral Inquiry, Collateral Inquiry Ack
2|AdvId|String|Unique identifier of adv