Skip to content

Instantly share code, notes, and snippets.

View d-led's full-sized avatar

Dmitry Ledentsov d-led

View GitHub Profile
@d-led
d-led / horror.cpp
Created July 13, 2012 12:39
a --do not modify the comments or format-- horror code
#include <iostream>
#define B(l,a) __##l##E##__
#define _O_ ((1<<2>>1<<1)-2)
#define _h_ 7-3
#define _C_ (7/_h_)
#define _r_ ((1<<0)+0x00a/2+_C_)
#define _a_ ((1<<5)-_r_)
#define _p_ { void _(){} namespace
#define printf(_0_) squeak(_O_,B(LIN,!)-_a_); _
@d-led
d-led / inspect.lua
Created July 13, 2012 12:40
a recursive Lua table inspector
local insp={}
assert( type(insp)=="table" )
function InspectValue(value,history,indent,inside)
res=""
for vkey,vvalue in pairs(value) do
local vvtype=type(vvalue)
res=res..(string.rep(" ",indent)..tostring(vkey).." ["..tostring(vvalue).."]").."\n"
if not history[vvalue] then
@d-led
d-led / recursivememo.cpp
Created July 13, 2012 12:41
automatic memoization with slightly mod. recursive functions
//original post: http://slackito.com/2011/03/17/automatic-memoization-in-cplusplus0x/
//a BOOST way of doing it: http://www.boost.org/doc/libs/1_49_0/libs/flyweight/example/fibonacci.cpp
#include <iostream>
#include <functional>
#include <map>
#include <time.h>
//maahcros
#define TIME(__x) init=clock(); __x; final=clock()-init; std::cout << "time:"<<(double)final / ((double)CLOCKS_PER_SEC)<<std::endl;
@d-led
d-led / horror.cpp
Created September 5, 2012 19:16
a --do not modify the comments or format-- horror code v2
#include <iostream>
#define B(l,a) __##l##E##__
#define _O_ ((1<<2>>1<<1)-2)
#define _h_ 7-3
#define _C_ (7/_h_)
#define _r_ ((1<<0)+0x00a/2+_C_)
#define _a_ ((1<<5)-_r_)
#define _p_ { void _(){} namespace
#define printf(_0_) squeak(_O_,B(LIN,!)-_a_); _
@d-led
d-led / navigate.lua
Created October 4, 2012 07:56
usage of pugilua to view xml in a less verbose format
require('pugilua')
local function printattributes(node)
local res=''
local a=node:first_attribute()
while a.valid do
if #res>0 then res=res..',' end
res=res .. a.name .. '=' .. a.value
a=a:next_attribute()
end
@d-led
d-led / vcproj2filelist.lua
Created October 4, 2012 08:40
filter vcproj files into a lua table
require('pugilua')
local doc=pugi.xml_document()
local res=doc:load_file [[..\pugilua.vcproj]]
print('Parsed: '..res.description)
assert(res.valid)
local text='{\n'
local query1=doc:root():select_nodes('/VisualStudioProject/Files/Filter/File | /VisualStudioProject/Files/File')
local n=query1.size
@d-led
d-led / vcxproj2filelist.lua
Created October 4, 2012 08:41
filter vcxproj files into a lua table
require('pugilua')
local doc=pugi.xml_document()
local res=doc:load_file [[..\pugilua.vcxproj]]
print('Parsed: '..res.description)
assert(res.valid)
local text='{\n'
local query1=doc:root():select_nodes('/Project/ItemGroup/ClCompile | /Project/ItemGroup/ClInclude')
local n=query1.size
@d-led
d-led / luabridge_error_vs2012.txt
Created October 4, 2012 19:13
luabridge build error
1>------ Build started: Project: pugilua, Configuration: Release Win32 ------
1> pugilua.cpp
1> pugilua_lib.cpp
1>..\..\..\LuaBridge\LuaBridge.h(1505): error C2953: 'luabridge::FuncTraits<R(__cdecl *)(void),D>' : class template has already been defined
1> ..\..\..\LuaBridge\LuaBridge.h(1082) : see declaration of 'luabridge::FuncTraits<R(__cdecl *)(void),D>'
1>..\..\..\LuaBridge\LuaBridge.h(1518): error C2953: 'luabridge::FuncTraits<R(__cdecl *)(P1),D>' : class template has already been defined
1> ..\..\..\LuaBridge\LuaBridge.h(1095) : see declaration of 'luabridge::FuncTraits<R(__cdecl *)(P1),D>'
1>..\..\..\LuaBridge\LuaBridge.h(1531): error C2953: 'luabridge::FuncTraits<R(__cdecl *)(P1,P2),D>' : class template has already been defined
1> ..\..\..\LuaBridge\LuaBridge.h(1108) : see declaration of 'luabridge::FuncTraits<R(__cdecl *)(P1,P2),D>'
1>..\..\..\LuaBridge\LuaBridge.h(1544): error C2953: 'luabridge::FuncTraits<R(__cdecl *)(P1,P2,P3),D>' : class template has already been defi
@d-led
d-led / vs2008topremake4.lua
Created November 14, 2012 09:12
scan directory for VS 2008 solutions and try to create a premake4 script
local dir=assert(require 'pl.dir')
local path=assert(require 'pl.path')
assert(require('pugilua'))
local function getsourcefiles(dir,d)
local text='{\n'
------------------------
local query1=d:root():select_nodes('/VisualStudioProject/Files/Filter/File | /VisualStudioProject/Files/File')
local n=query1.size
for i=0,n-1 do
@d-led
d-led / asyncfrequencymeter.cs
Created November 15, 2012 20:14
Asynchronously read a Field from an object repeatedly
using System;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
namespace rxtest
{
class FrequencyMeter
{
Random rand = new Random();
public int Hz