Skip to content

Instantly share code, notes, and snippets.

View armornick's full-sized avatar

Nick Arnoeyts armornick

  • Belgium
View GitHub Profile
@armornick
armornick / seed.c
Created April 10, 2014 12:42
Seed (self-contained lua host using physfs to grab data from zip file concatenated to executable)
//// seed.c ///////////////////////////////////////////////////////////////////
// seed is a lua executable which loads data and lua code embedded in the
// executable. Specifically, it loads from a zip file concatenated to its
// executable. Initially /init.lua from the zip file is run, and a loader is
// added to package.loaders so that 'require' searches inside the zip file. If
// a module is not found in the archive, then the default loaders are used.
//
// In addition to using 'require', lua files can be loaded with seed.loadfile,
// which is like loadfile except that it gets the file from inside the archive.
// Basic reading of arbitrary files from the archive is supported.
@armornick
armornick / stripfile.lua
Created April 21, 2014 13:25
Utility to convert lua scripts to a C character array to embed scripts in code
---
-- Code copied from Premake-stable (scripts/embed.lua)
---
function iif(cond, iftrue, iffalse)
if cond then return iftrue else return iffalse end
end
local function stripfile(fname)
local f = io.open(fname)
#include <memory>
#include <cstdio>
/////////////////////////////////////////////////////////////////////////////
typedef std::unique_ptr<std::FILE, int (*)(std::FILE *)> unique_file_ptr;
typedef std::shared_ptr<std::FILE> shared_file_ptr;
static shared_file_ptr make_shared_file(const char * filename, const char * flags)
{
@armornick
armornick / Lazarus.bat
Last active August 29, 2015 14:01
Batch script to make Lazarus (more) portable (for Lazarus version 1.2.2 but should be easy to modify)
@echo off
rem
rem from http://forum.lazarus.freepascal.org/index.php/topic,23343.msg139270.html
rem
rem Simple script to relocate lazarus to use the current driveletter as
rem path, and put basic portable app support in lazarus.
rem
rem Assumes lazarus is in drvletter:\lazarus and config in
@armornick
armornick / apputils.pas
Created May 10, 2014 09:36
Free Pascal program to make Lazarus portable (based off the earlier batch script but more versatile)
unit AppUtils;
{$mode objfpc}{$H+}
interface
uses
SysUtils;
function CheckDir(path:string):Boolean;
@armornick
armornick / rreplace.c
Created May 22, 2014 11:05
Replace using POSIX regular expressions
/* replace using posix regular expressions */
/* source: http://www.daniweb.com/software-development/c/code/216955/replace-using-posix-regular-expressions */
#include <stdio.h>
#include <string.h>
#include <regex.h>
int rreplace (char *buf, int size, regex_t *re, char *rp)
{
char *pos;
int sub, so, n;
@armornick
armornick / argparse_test.lua
Created June 5, 2014 09:34
Simple Argument Parser (and dependency-free pretty printer)
local concat, format = table.concat, string.format
-------------------------------------------------------------------------
--- Pretty Printing
-------------------------------------------------------------------------
function extended_tostring(o, qstring)
local otype = type(o)
if otype == "table" then
local result = {}
for k,v in pairs(o) do
@armornick
armornick / matchwords.nim
Created October 14, 2014 08:10
Testing Regular Expressions and Static Builds
# nimrod c --clibdir:. --dynlibOverride:pcre --PassL:-lpcre -d:release matchwords.nim
import re
var patt = re".*[a-zA-Z]+.*"
stdout.write("> ")
var inputs = stdin.readLine
while inputs != "":
@armornick
armornick / mixins.scss
Created November 25, 2014 14:22
Usefull Sass mixins found on the web (SCSS style)
//=======================================================
// Useful SASS Mixins
// src: http://sachagreif.com/useful-sass-mixins/
//=======================================================
//-------------------------------------------------------
// Horizontal Navigation Lists
//-------------------------------------------------------
@mixin navigation-list {
list-style-type:none;
@armornick
armornick / zip-dirs.js
Last active August 29, 2015 14:17
7-zip a whole bunch of directories in a directory
// Module imports
var _ = require('underscore'),
test = require('shelljs').test,
which = require('shelljs').which,
listdir = require('shelljs').ls,
exec = require('shelljs').exec;
// suppress output of commands
require('shelljs').config.silent = true;