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 / 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 / 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 / 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 / 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 / fiber_test.cpp
Last active August 29, 2015 13:57
Using fiber on Windows
#include "stdafx.h"
#include <windows.h>
PVOID ParentFiber;
VOID WINAPI logicFiber (PVOID pvParam) {
printf("logicFiber\n");
SwitchToFiber(ParentFiber);
}
@whoo24
whoo24 / split_jpg.cs
Created August 12, 2015 10:46
It splits two images from given image file.
using System;
using System.Drawing;
namespace split_jpg {
class Program {
static void Main (string[] args) {
try {
string filename = args[0];
Bitmap src = Image.FromFile(filename) as Bitmap;
int split = 2;
@whoo24
whoo24 / singleton_using_nested_class.cpp
Last active January 14, 2022 01:22
The nested class named FProtection prevents the creation of instances by direct calling the constructor.
#include "stdafx.h"
template <typename T>
class TSingleton {
public:
TSingleton() {}
~TSingleton() {
delete(Instance_);
}
import os
import fnmatch
prefix = "page-"
postfix = ".jpg"
add_num = 1;
digits = 3;
v = []
@whoo24
whoo24 / Floyd.cs
Created November 6, 2016 14:05
floyd algorithm for finding shortestpath
using System;
using System.Collections.Generic;
namespace FloydAlgorithm {
public class Floyd {
public void floyd (int n, Graph W, ref Graph D) {
int i, j, k;
D.CopyFrom(W);
for (k = 0; k < n; k++) {
for (i = 0; i < n; i++) {
@whoo24
whoo24 / Graph.cs
Created November 8, 2016 08:07
Getting minimum spanning tree using Prim algorithm on C#
using System.Collections.Generic;
namespace PrimAlgorithm {
public class Graph<T> {
private List<Node> nodes_ = new List<Node>();
public class Node {
private List<Edge> edges_ = new List<Edge>();
private T context_;