Skip to content

Instantly share code, notes, and snippets.

View whoo24's full-sized avatar

Wooyeong Choe whoo24

  • Oslo, Norway
View GitHub Profile
@whoo24
whoo24 / regex-parse-pair.cpp
Created January 21, 2014 16:09
split blanket using c++ tr1 regex. output is below. {pa,tt} {e, rn}
#include "stdafx.h"
#include <regex>
#include <iostream>
#include <exception>
int _tmain(int argc, _TCHAR* argv[])
{
std::string source = "{pa,tt}, {e, rn}";
try
{
std::regex pattern("\\{.*?\\}", std::regex_constants::ECMAScript);
@whoo24
whoo24 / rename.py
Last active December 27, 2015 08:59
rename files
import os
import glob
files = glob.glob("C:\\path\\*.exe")
for file in files:
os.rename(file, file.replace(".exe", ".com"))
@whoo24
whoo24 / callback_sample1.lua
Created August 29, 2013 06:07
LuaExpat sample
--package.cpath = package.cpath..';'..'C:\\devel\\luaexpat-1.2.0\\luaexpat-1.1.win32-lua51'
require("lxp")
sample_text = "<elem1>text<elem2>inside text</elem2>more text</elem1>"
local count = 0
callbacks = {
StartElement = function(parser, name)
io.write( string.rep(" ", count), "+", name, "\n" )
@whoo24
whoo24 / client.cpp
Created June 24, 2013 07:15
Basic Winsock Program
#include "stdafx.h"
#include <WinSock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "Ws2_32.lib")
void run_client()
{
WSADATA wsaData;
WSAStartup( MAKEWORD(2,2), &wsaData );
@whoo24
whoo24 / func2table.cpp
Created May 6, 2013 09:26
테이블에 함수를 포인터에 넣어놓고 문자열을 이용해 호출하는 코드
#include <map>
#include <string>
#include <functional>
#include <iostream>
using namespace std;
template <class T>
class Delegator
{
public:
@whoo24
whoo24 / AccessJsonRawData.cs
Last active April 25, 2018 10:18
LitJson simple samples
string json_text = @"
{
""album"" : {
""name"" : ""The Dark Side of the Moon"",
""artist"" : ""Pink Floyd"",
""year"" : 1973,
""tracks"" : [
""Speak To Me"",
""Breathe"",
""On The Run""
@whoo24
whoo24 / classTemplate.lua
Created April 30, 2013 09:23
Implement of class in Lua
classTemplate = {
new = function(self, func, o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o;
end
}
@whoo24
whoo24 / tuple.lua
Last active December 16, 2015 19:49
Lua tuple by table and tail-call.
function tuple(arg) -- arg is table.
local n_arg = #arg
if n_arg == 0 then
return nil;
end
if n_arg == 1 then
return arg[1];
end
@whoo24
whoo24 / float2byte
Last active December 15, 2015 22:39
C# float to byte
float value = 100.001f;
byte[] FloatToByte = System.BitConverter.GetBytes(value);
float ByteToFloat = BitConverter.ToSingle(FloatToByte, 0);
@whoo24
whoo24 / Editor\CanvasWindow.cs
Last active April 5, 2016 12:37
UnityEditor.EditorWindow 클래스 확장 Extending UnityEditor.EditorWindow class
using UnityEngine;
using UnityEditor;
using System;
public class CanvasWindow : EditorWindow {
[MenuItem("Canvas/Show")]
public static void ShowWindow()
{
CanvasWindow window = (CanvasWindow)EditorWindow.GetWindow(typeof(CanvasWindow));