Skip to content

Instantly share code, notes, and snippets.

View malkia's full-sized avatar

Dimiter 'malkia' Stanev malkia

View GitHub Profile
function DeleteArrayElements( array, index, count )
-- Deletes one or more (count) array elements from the specified index.
-- Returns an undo function, which if called would revert the operation.
local deletedElements = {}
assert( index >= 1 and index <= #array, "index=" .. index .. " must be >= 1 and <= " .. #array .. " (#array)" )
assert( count >= 1 and count <= #array - index + 1, "count=" .. count .. " must be >= 1 and <= " .. #array - index + 1 .. " (#array - index + 1) where #array=" .. #array .. " and index=" .. index)
for i = 0, count - 1 do
#!/bin/sh
SDK=`dirname $0`
SCRIPT=`basename $0`
SDKPARENT=`dirname $SDK`
PLATFORM=`uname -sp`
if [ "$PLATFORM" = "Darwin i386" -o "$PLATFORM" = "Darwin x86_64" ]; then
echo "iPhone Toolchain installer script by rpetrich"
echo ""
#include <stdio.h>
char hex( char h )
{
signed char xa = '0' - h;
signed char xb = h - ('9' + 1);
signed char ya = ('A' - 1) - h;
signed char yb = h - ('F' + 1);
signed char za = ('a' - 1) - h;
signed char zb = h - ('f' + 1);
;; Lispworks 6.00 required and p4 executable
;; Tested only under Vista 64 bit with Lispworks Professional 32-bit
;;
(defpackage "P4BEE" (:use "CL"))
(in-package "P4BEE")
(eval-when (:compile-toplevel :load-toplevel :execute)
(let ((dir (or *compile-file-truename* *load-truename* *default-pathname-defaults*)))
(format t "*compile-file-truename* = ~A~&" *compile-file-truename*)
(format t "*load-truename* = ~A~&" *load-truename*)
@malkia
malkia / nan.c
Created March 17, 2011 03:47
This examples show how floating point numbers that are NaN are always different even if they are the same binary identity
#include <stdio.h>
/*
malkia ~/p $ gcc nan.c
nan.c: In function ‘print_range’:
nan.c:15: warning: format ‘%p’ expects type ‘void *’, but argument 2 has type ‘unsigned int’
nan.c:15: warning: format ‘%p’ expects type ‘void *’, but argument 3 has type ‘unsigned int’
nan.c:15: warning: format ‘%p’ expects type ‘void *’, but argument 4 has type ‘unsigned int’
malkia ~/p $ ./a.out
[0x7f800001 .. 0x7fffffff], total of 0x7fffff (8388607)
@malkia
malkia / em.bat
Created March 22, 2011 19:05
My batch file that starts emacs. It's located in c:\emacs-22.3\bin
@start /B /MAX %~dp0\emacs -g 216x69+0+0 %*
@malkia
malkia / wraplib
Created April 1, 2011 13:49
The goal is to wrap the ffi symbols and new ones in one table
local ffi = require( "ffi" )
local function wraplib( lib, options )
local function LOG(...)
if options.verbose then
print(...)
end
end
return setmetatable (
{},
LuaJIT 2.0.0-beta6 -- Copyright (C) 2005-2011 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 fold cse dce fwd dse narrow loop abc fuse
>
1
2
__index: importing from library <userdata: 0x0004f2e0>
into table <table: 0x0004f398>
the symbol curl_easy_init = cdata<void **()>: 0x00043820
@malkia
malkia / test.cs
Created April 26, 2011 19:39
some test
// x64
//
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
namespace GenericSpeedTest
{
@malkia
malkia / fileinfo.c
Created August 15, 2011 22:41
Low level directory reading on Windows
#include <windows.h>
#include <stdio.h>
// to compile:
// cl fileinfo.c setargv.obj
void fileinfo(const char*name);
int main( int argc, const char* argv[] )
{
int i;