Skip to content

Instantly share code, notes, and snippets.

View nkuln's full-sized avatar

Gant Kulnirundorn nkuln

View GitHub Profile
Date & Time: 7/12/2012 9:01:28 AM
Event Class: File System
Operation: CreateFile
Result: ACCESS DENIED
Path: C:\Users\nkuln\Desktop\APISnapshot_100b\bin\APISnapshot_Service.exe
TID: 164
Duration: 0.0015702
Desired Access: Read Data/List Directory, Execute/Traverse, Read Attributes, Synchronize
Disposition: Open
Options: Synchronous IO Non-Alert, Non-Directory File
@nkuln
nkuln / blogger_snippet.js
Created May 1, 2012 12:11
Adding source code to my blogger account
<script class="brush: js; toolbar: false" type="syntaxhighlighter">
<![CDATA[
System.Threading.Parallel.For(0, maxNum + 1, => IsPrime(x));
]]>
</script>
@nkuln
nkuln / cxa_throw_replace_backtrace.c
Created March 12, 2012 09:18
Override __cxa_throw and prints backtrace when exception is thrown (Linux)
#include <dlfcn.h>
#include <execinfo.h>
typedef void (*cxa_throw_type)(void *, void *, void (*) (void *));
cxa_throw_type orig_cxa_throw = 0;
void load_orig_throw_code()
{
orig_cxa_throw = (cxa_throw_type) dlsym(RTLD_NEXT, "__cxa_throw");
}
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
// ..
struct timeval t;
gettimeofday(&t, NULL);
rfa::common::Int64 now;
now = t.tv_sec;
@nkuln
nkuln / test_mixin.py
Created October 20, 2011 18:00
Playing with Mixin which is basically a multiple inheritance. I was confused before on what the line 'cls = TestMixin' does ..
class TestMixin(object):
member1 = ['gant','from','mixin']
def mixin_method(self):
print 'member 1 from self: %s' % self.member1
cls = TestMixin
print 'member 1 from cls: %s' % cls.member1
class Cat(TestMixin):
member1 = 'meow meow'
@nkuln
nkuln / perf_counter_timer.hpp
Created October 20, 2011 10:36
Example for QueryPerformanceCounter to get current time in Windows C++
//
// PerfCounterTimer:
// To get current time in millisecond, use (1000.0 * GetCurrentTime() / GetFrequency()).
// Practically, you must cache value from GetFrequency() so that you don't need to
// re-query the frequency every time
//
#pragma once
#include <windows.h>
@nkuln
nkuln / gettimestamp_cpp_windows.cpp
Created October 19, 2011 11:00
Demonstrate problem from getting 64-bit timestamp to nanosec in Windows
// Demonstrate problem in GetSystemTimeAsFileTime(..) call
// The time returned is not very precised
//
ULARGE_INTEGER prev_timestamp, timestamp;
prev_timestamp.QuadPart = 0;
for(int i = 0 ; i < 100 ; ++i, prev_timestamp = timestamp){
FILETIME now;
GetSystemTimeAsFileTime(&now);