Skip to content

Instantly share code, notes, and snippets.

View lethee's full-sized avatar

lethee lethee

  • Weaveus
  • Seoul, South Korea
View GitHub Profile
@lethee
lethee / main.cpp
Created April 4, 2016 06:56
glib main roop, boot coroutine, blocking loop
// g++ -std=c++11 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include main.cpp -lglib-2.0 -lboost_system -lboost_coroutine -lboost_context -o test
//
#include <iostream>
#include <thread>
#include <chrono>
#include <glib.h>
#include <boost/coroutine/all.hpp>
using namespace std;
@lethee
lethee / env.py
Created March 21, 2016 07:53
Sublime Text 3: Apply NVM environment
# Save this file
# mac - "~/Library/Application Support/Sublime Text 3/Packages/"
# linux - "~/.config/sublime-text-3/Packages/"
# NOTE!
# ~/.nvm/alias/default must contain full version name.
# $ nvm alias default v4.3.5
import os
@lethee
lethee / get.cpp
Created February 15, 2016 06:38
ipv4 ipv6 getaddrinfo instead of gethostbyname
// g++ -Wall -o get get.cpp && ./get ::ffff:192.168.111.8 3000
// g++ -Wall -o get get.cpp && ./get 192.168.111.8 3000
// g++ -Wall -o get get.cpp && ./get www.google.com 80
#include <iostream>
#include <cstdlib>
#include <sys/socket.h>
#include <netdb.h>
#include <cstring>
#include <arpa/inet.h>
@lethee
lethee / time_server.py
Created November 9, 2015 08:46
Python UTC current Time in milleseconds with non-block TCP Server
import socket
import select
import datetime
port = 20001
def main():
serversock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
serversock.setblocking(0)
@lethee
lethee / Dockerfile
Last active August 6, 2023 18:52
progit2-ko-build-docker
FROM ubuntu:14.04
MAINTAINER Seonghwan Lee <lethee@gmail.com>
RUN cd /etc/apt && \
sed -i 's/archive.ubuntu.com/kr.archive.ubuntu.com/g' sources.list
RUN apt-get update
RUN apt-get install -y git curl python
RUN apt-get install -y ruby2.0 ruby2.0-dev
@lethee
lethee / get_active_window_and_exec.py
Last active June 14, 2023 01:51
Get a active window title and its executable path
# pywin32 must be installed
# pip install wmi
import win32gui
import win32process
import win32pdhutil
import wmi
procs = wmi.WMI().Win32_Process()
@lethee
lethee / findMapValue.cpp
Created April 22, 2015 09:38
findMapValue
#define _findMapValue(container, key) (container.end() != find_if(container.begin(), container.end(), [](decltype(container)::value_type it) { return it.first == key; }))
// c++11
@lethee
lethee / gist:3e1686715539483024ea
Created January 28, 2015 01:30
popen example: exec shell command output
bool exec(const std::string &cmd, std::string* out)
{
FILE* pipe = popen(cmd.c_str(), "r");
if (pipe == NULL) {
return false;
}
char buffer[2048];
while (!feof(pipe)) {
if (fgets(buffer, sizeof(buffer), pipe) != NULL) {
@lethee
lethee / .fonts.conf
Created July 16, 2014 11:13
Source Han Sans KR - 본고딕 KR 리눅스 적용
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- $HOME/.config/font-manager/local.conf -->
<fontconfig>
<match>
<test name="family">
<string>sans-serif</string>
</test>
<edit name="family" mode="prepend" binding="same">
@lethee
lethee / func_print.c
Last active August 29, 2015 13:56
automatically-adding-enter-exit-function-logs-to-a-project
// http://stackoverflow.com/questions/2281739/automatically-adding-enter-exit-function-logs-to-a-project
#define KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"