Skip to content

Instantly share code, notes, and snippets.

View malkia's full-sized avatar

Dimiter 'malkia' Stanev malkia

View GitHub Profile
@rpetrich
rpetrich / install-sdk
Created May 17, 2010 10:02
iPhone Toolchain installer script
#!/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 ""
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
@drbobbeaty
drbobbeaty / heavySender.cpp
Created December 2, 2010 21:55
Simple ZMQ Transmitter Illustrating Memory Usage
/**
* On my CentOS 5 system this application sent the first 3000 messages
* with a running memory footprint less than 7 MB. In a few minutes, it
* leveled out at 18MB. Based on the sending rate, the maximum data rate
* out of this process should be less than 75kbps -- well below the
* ZMQ_RATE of 10Mbps. While there doesn't seem to be a long-term leak,
* the fact that this application does the first 3000 sends with a memory
* footprint far less than it's terminal value is concerning.
*
* If I change nothing other than the ZMQ_RATE value and change it to
@stevedonovan
stevedonovan / safe_array.lua
Created December 30, 2010 08:20
This defines an array with strict bounds checking. It is also impossible to set any existing index to a nil value, so the array remains free of holes. The table functions will not work on such arrays because they are userdata, giving an extra layer of pro
local function out_of_range(i,n)
if type(i) == 'number' then
if i > 0 and i <= n then return true
else error('out of range',3)
end
else
error 'cannot index array by non-number type'
end
end
diff --git a/win32/win32.c b/win32/win32.c
index 6366d92..4e52d7b 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4115,39 +4115,62 @@ winnt_stat(const WCHAR *path, struct stati64 *st)
{
HANDLE h;
WIN32_FIND_DATAW wfd;
+ WIN32_FILE_ATTRIBUTE_DATA wfa;
@stuartcarnie
stuartcarnie / main.m
Created March 4, 2011 19:59
Demonstrates we can now support limited JIT compilation on recent versions of iOS (assuming Apple approves entitlements at some future point)
//
// main.m
// ProtectTest
// Demonstrates newer versions of iOS now support PROT_EXEC pages, for just-in-time compilation.
//
// Must be compiled with Thumb disabled
//
// Created by Stuart Carnie on 3/4/11.
// Copyright 2011 Manomio LLC. All rights reserved.
//
@AdrienLemaire
AdrienLemaire / ftpplugintex.vim
Created September 21, 2011 12:56
Mupdf hack to open pdf directly to the (sub)*section you're editing from vim in Latex
" Function: OpenPdfToSection
function! OpenPdfToSection()
let g:my_section = substitute(getline(search('\\\(sub\)\?section', 'bn')), '\\\%(sub\)\?section{\([^}]\+\)}', '\1', '')
" some weird trailing space can appear, remove them
let g:my_section = substitute(g:my_section, "^ *", "", "g")
let g:Tex_ViewRuleComplete_pdf = 'mupdf -f "'.g:my_section.'" -r 102 $*.pdf'
call Tex_ViewLaTeX()
" reinitialize the variable to keep <leader>lv working
let g:Tex_ViewRuleComplete_pdf = 'mupdf -r 102 $*.pdf'
endfunction
@etorreborre
etorreborre / gist:1387113
Created November 22, 2011 21:50
An example of a non-terminating compilation with javac
/** from http://www.reddit.com/r/programming/comments/mlbna/scala_feels_like_ejb_2/c31z0co */
interface Pong<T> {}
class Ping<T> implements Pong<Pong<? super Ping<Ping<T>>>> {
static void Ping() {
Pong<? super Ping<Long>> Ping = new Ping<Long>();
}
}
> javac Ping.java
@malkia
malkia / cdef-sample.lua
Created January 12, 2012 20:23
idea: extend luajit's ffi.cdef so that it can return introspection information
-- Something like (ZeroMQ in this case)
return {
typedefs = {
functions = {
zmq_free_fn = { "void", "data", "hint" },
},
structs = {
zmq_pollitem_t = "zmq_pollitem_t"
},
@stevedonovan
stevedonovan / ml.lua
Created February 15, 2012 09:36
Microlight - a really compact set of general Lua functions
-----------------
-- Microlight - a very compact Lua utilities module
--
-- Steve Donovan, 2012; License MIT
-- @module ml
local ml = {}
--- String utilties.
-- @section string