Skip to content

Instantly share code, notes, and snippets.

View dmthuc's full-sized avatar
💭
I may be slow to respond.

Dao Minh Thuc dmthuc

💭
I may be slow to respond.
  • TikTok PTE
  • Singapore
View GitHub Profile
@dmthuc
dmthuc / gcc-10-debian-buster.sh
Created August 11, 2021 09:17 — forked from s3rvac/gcc-10-debian-buster.sh
Steps to build GCC 10 on Debian Buster.
#!/bin/bash
#
# Steps to build GCC 10 on Debian Buster.
#
set -e -x
# Install all dependencies.
export DEBIAN_FRONTEND=noninteractive
apt update
@dmthuc
dmthuc / server.sh
Created November 4, 2019 10:37
All command related to testing server
curl -d "@/home/daominhthuc/hello.txt" -X POST http://localhost:8080
@dmthuc
dmthuc / fcgi_cpp_example_with_official_fcgi_library.cpp
Last active September 18, 2024 21:23
Fast CGI example in C++ using official fcgi library
/*
using official fcgi++ library
Reference to fcgi protocol at https://tools.ietf.org/html/rfc3875#section-6.2.1
Build: g++ main.cpp -lfcgi++ -lfcgi -o main
Spawn: spawn-fcgi -a 127.0.0.1 -p 9105 -n -- main
*/
#include <iostream>
#include <string>
#include <thread>
@dmthuc
dmthuc / thuc_fcgi.conf
Created December 18, 2018 09:41
virtual host fcgi configuration with separate access log and error log
/etc/nginx//conf.d/nginx.conf
server {
listen 9106;
error_log /var/log/nginx/thuc_test_fcgi.log;
access_log /var/log/nginx/thuc_test_fcgi_access.log;
location / {
include fastcgi_params;
@dmthuc
dmthuc / trie.cpp
Created December 18, 2018 04:00
Simple Trie implementation in C++
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <cassert>
using namespace std;
@dmthuc
dmthuc / http_post.c
Created October 4, 2018 09:36
HTTP Post with curl
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
/* In windows, this will init the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);
@dmthuc
dmthuc / http_get_with_curl.cpp
Created October 4, 2018 09:29
Example of HTTP get with C curl library
/* Get bit-coin exchange rate */
#include <iostream>
#include <memory>
#include <string>
#include <stdexcept>
#include <curl/curl.h>
using namespace std;
struct Curl_global
{
@dmthuc
dmthuc / git.sh
Last active December 26, 2018 04:15
Git command
# Update submodule for module that have been initialized
git submodule update --recursive --remote --merge
# Pull submodule data for new clone
git submodule update --init
# Update submodule for module that haven't been initialized
git submodule update --init --recursive
# Git push to branch
git push -u origin branch-name
# Git push to delete a branch
git push origin --delete port_websession_stats2_to_take_input_data_from_clickhouse
@dmthuc
dmthuc / valgrind_command.sh
Last active July 24, 2019 04:37
Valgrind mem check, gdb run with command
valgrind --leak-check=full ./main arg1
# Stat with:
gdb executable
# Run with argument
r arg1 arg2
@dmthuc
dmthuc / date_usage.cpp
Last active July 25, 2018 09:59
boost::gregorian::date usage:
#include <iostream>
#include <string>
#include <fstream>
#include <cassert>
#include "boost/date_time/gregorian/gregorian.hpp"
using namespace std;
using namespace boost::gregorian;
int main() {
date d(from_undelimited_string(string{"20180101"}));