Skip to content

Instantly share code, notes, and snippets.

@thanhtam92
thanhtam92 / 0_reuse_code.js
Last active August 29, 2015 14:02
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
@thanhtam92
thanhtam92 / libcurl_dns.md
Created September 8, 2016 17:39 — forked from deltheil/libcurl_dns.md
libcurl options to control DNS lookup (cache, timeout, resolving time, etc). The short URL for this page is: http://git.io/libcurl-dns.

Easy handle interface

Options

Info

@thanhtam92
thanhtam92 / libevent-v-libuv.md
Created October 27, 2016 02:55 — forked from eddieh/libevent-v-libuv.md
libevent vs libuv

libevent vs libuv

Comparing libevent and libuv. My upfront biased: I want to like libevent. However, I want to objectively compare the two and make an informed decision.

What versions are we comparing?

  • libevent 2.0.22 (Stable) [2014-01-05]
  • libuv 1.8.0 (Stable) [2015-12-15]
@thanhtam92
thanhtam92 / message.hpp
Created February 28, 2017 08:09 — forked from mashiro/message.hpp
zeromq + msgpack
#include <string>
#include <ctime>
#include <msgpack.hpp>
struct message
{
std::string tag;
std::time_t time;
std::string text;
MSGPACK_DEFINE(tag, time, text);
find command:http://www.oreillynet.com/linux/cmd/cmd.csp?path=f/find
find . -maxdepth 1/2/..../n
%to just find them and printout:
find . -maxdepth 1 -name '[!.]*' -size 0 -printf 'Name: %16f Size: %6s\n'
%delete them, may be modified to use
find . -maxdepth 1 -name '[!.]*' -size 0 -printf 'Name: %16f Size: %6s\n' | xargs rm
http://content.hccfl.edu/pollock/unix/findcmd.htm
@thanhtam92
thanhtam92 / zeromq-vs-redis.md
Created January 18, 2018 10:31 — 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:

@thanhtam92
thanhtam92 / CMakeLists.txt
Created May 30, 2018 06:25 — forked from alorence/CMakeLists.txt
2 CMake macros returning the current date (format yyyy-mm-dd) and the current time (hh:mm:ss)
cmake_minimum_required(VERSION 2.8)
# Return the date (yyyy-mm-dd)
macro(DATE RESULT)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" ${RESULT} ${${RESULT}})
elseif(UNIX)
execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
else()
@echo on & @setlocal enableextensions
@echo =========================
@echo Turn off the time service
net stop w32time
@echo ======================================================================
@echo Set the SNTP (Simple Network Time Protocol) source for the time server
w32tm /config /syncfromflags:manual /manualpeerlist:"0.it.pool.ntp.org 1.it.pool.ntp.org 2.it.pool.ntp.org 3.it.pool.ntp.org"
@echo =============================================
@echo ... and then turn on the time service back on
net start w32time
@thanhtam92
thanhtam92 / git branch name prompt
Created August 28, 2018 11:31 — forked from dropmeaword/git branch name prompt
function parse_git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } YELLOW="\[\033[0;33m\]" # Comment in the above and uncomment this below for a color prompt PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w$YELLOW\$(parse_git_branch)\[\033[00m\]\$ "
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
YELLOW="\[\033[0;33m\]"
# Comment in the above and uncomment this below for a color prompt
PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w$YELLOW\$(parse_git_branch)\[\033[00m\]\$ "
@thanhtam92
thanhtam92 / client.cpp
Created September 12, 2018 04:18 — forked from SteveRuben/client.cpp
Multiple streaming in c++ using opencv; OpenCV video streaming over TCP/IP
/**
* OpenCV video streaming over TCP/IP
* Client: Receives video from server and display it
* by Steve Tuenkam
*/
#include "opencv2/opencv.hpp"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>