Skip to content

Instantly share code, notes, and snippets.

#include <fstream>
#include <iostream>
#include <sys/time.h>
//#include <tbb/tbb.h>
using namespace std;
//using namespace tbb;
#define ROWS 4096
#define COLS 4096
@zguangyu
zguangyu / zeromq-vs-redis.md
Created April 18, 2018 15:18 — forked from hmartiro/zeromq-vs-redis.md
Comparison of ZeroMQ and Redis for a robot control platform

ZeroMQ vs Redis

This document is research for the selection of a communication platform for robot-net.

Goal

The purpose of this component is to enable rapid, reliable, and elegant communication between the various nodes of the network, including controllers, sensors, and actuators (robot drivers). It will act as the core of robot-net to create a standardized infrastructure for robot control.

Requirements:

@zguangyu
zguangyu / queue.v
Created September 16, 2016 16:47
verilog queue
module queue(clk, trig, q, write_en);
parameter BUFF_SIZE=20;
input clk;
input trig;
output reg [7:0] q = 0;
output reg write_en;
reg [8*BUFF_SIZE:1] buff=0;
reg [15:0] buff_size = 0;
@zguangyu
zguangyu / serial.cpp
Created January 24, 2015 11:59
C++ serial port reader
#include <cstring>
#include <cerrno>
#include <cstdio>
#include <iostream>
#include <deque>
#include <vector>
#include <thread>
#include <mutex>
#include <chrono>
@zguangyu
zguangyu / 0_reuse_code.js
Last active August 29, 2015 14:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@zguangyu
zguangyu / select_multi.ec
Created November 14, 2014 13:39
ECPG Select Multiple lines into an array
#include <stdio.h>
int main()
{
int i;
EXEC SQL BEGIN DECLARE SECTION;
int db_tar_id[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO stars;
import re
import json
ori = '[1-5,8]'
m = re.search(r'([0-9]+)-([0-9]+)', s)
s = ''
for i in range((m.groups()[0]), (m.groups()[1])+1):
s += str(i)+','
l = re.sub(r'[0-9]+-[0-9]+,', s, '[1-5,8]')
@zguangyu
zguangyu / gist:9ec4fe8508a17ca0192d
Last active August 29, 2015 14:04
create a dir and create a file in it
#include <linux/stat.h>
#include <linux/types.h>
#include <fcntl.h>
int main()
{
mkdir("foo", 0755);
int a = open("foo/bar", O_RDWR | O_CREAT, 0644);
return 0;
}
@zguangyu
zguangyu / links.py
Created May 10, 2014 15:00
Generate igem Asia teams' links as html
@zguangyu
zguangyu / cowsay.pl
Last active December 24, 2015 16:39
#!/usr/bin/perl
##
## Cowsay version 4.0 (c) 2013 Guangyu Zhang
## (c) 1999-2000 Tony Monroe.
##
use Text::Tabs qw(expand);
use Text::Wrap qw(wrap fill $columns);
use Text::CharWidth qw(mbswidth);