Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@dockimbel
dockimbel / gist:3435800
Created August 23, 2012 11:34
DLL loading testing program
#include "stdafx.h"
#include <Windows.h>
int (*foo)(int) = NULL;
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE handle = LoadLibraryA("temp.dll");
printf("error: %i\n", GetLastError());
printf("hModule: %i\n", handle);
@dockimbel
dockimbel / r2-rewrite.r
Created March 4, 2013 16:13
Show how to achieve R2 source rewriting suitable for evaluation using R3 interpreter.
REBOL [
Author: "Nenad Rakocevic"
Date: 04/03/2013
Purpose: {
Show how to achieve R2 source rewriting suitable for evaluation
using R3 interpreter.
}
]
@dockimbel
dockimbel / gist:5083375
Last active December 14, 2015 11:59
Show how to achieve R2 source rewriting suitable for evaluation using R3 interpreter.
REBOL [
Author: "Nenad Rakocevic"
Date: 04/03/2013
Purpose: {
Show how to achieve R2 source rewriting suitable for evaluation
using R3 interpreter.
}
Note: "Use it from %Red/ folder"
]
@dockimbel
dockimbel / gist:5640445
Created May 24, 2013 00:07
Output from: readelf -a /usr/lib/libporttime.so.0.0.0
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: ARM
Version: 0x1
Red/System []
int-to-float: func [
n [integer!]
return: [float!]
/local sign shifts less? z
][
sign: 0
shifts: 0
less?: true
@dockimbel
dockimbel / brainfuck.red
Created November 29, 2013 23:08
This is a complete (but not fully tested) implementation of a Brainfuck interpreter in Red language, only using the Parse dialect. The extra verbosity comes from the current lack of built-in reversed input parsing. Once reverse parsing will be implemented in the dialect, the `jump-back` rule should be simplified a lot. Note: this is not meant to…
Red [
Author: "Nenad Rakocevic"
Date: 29/11/2013
]
bf: function [prog [string!]][
size: 30000
cells: make string! size
append/dup cells null size
@dockimbel
dockimbel / dyn-rule.red
Last active December 8, 2016 17:47
Example of dynamic rule creation in Parse dialect using the Red language. The code can be copy/pasted directly into a Red console.
Red [
Author: "Nenad Rakocevic"
Date: 06/12/2013
Note: {
This short Red program demonstrates the use of dynamically built Parse rules.
It parses an imaginary external DSL with variables, and detects if a variable has
been used before been properly declared and initialized.
The detection works by comparing found variables against a list of declared
variables. The list starts empty, and it grows as new variables are collected.
Red [
Title: "Red Android VID sample"
Author: "Nenad Rakocevic"
File: %vid.red
Needs: 'View
Tabs: 4
Rights: "Copyright (C) 2014 Nenad Rakocevic. All rights reserved."
License: {
Distributed under the Boost Software License, Version 1.0.
See https://github.com/dockimbel/Red/blob/master/BSL-License.txt
@dockimbel
dockimbel / unicode.reds
Last active August 29, 2015 13:56 — forked from meijeru/unicode.reds
FIX: typo in 66536 (should be 65536)
Red/System []
utf8-to-codepoint: func [ ; yields an integer >= 0 and < 1114112, or -1
u [c-string!] ; should have length 1 to 4
/local b1 b2 b3 b4
][
either 1 = length? u
[
b1: as-integer u/1
either b1 < 128 [
@dockimbel
dockimbel / JSON.red
Last active April 4, 2017 11:10
JSON toy parser for Red
Red [
Title: "JSON parser"
File: %json.red
Author: "Nenad Rakocevic"
License: "BSD-3 - https://github.com/red/red/blob/master/BSD-3-License.txt"
]
json: context [
quoted-char: charset {"\/bfnrt}
exponent: charset "eE"