Skip to content

Instantly share code, notes, and snippets.

@akavel
akavel / cwrap.c
Created December 2, 2011 07:38
sketch for Go wrapper for 8c/6c main()
int main(int argc, char** argv);
void cwrap·runmain() {
char *dummyargv[2] = {"dummyarg0", 0};
main(1, dummyargv);
}
@akavel
akavel / HOWTO TortoiseHg and Github .markdown
Created January 6, 2012 02:35
TortoiseHg and GitHub.com

Read-only access, in short

First,

hg clone http://bitbucket.org/durin42/hg-git HGGIT_PATH

Second, in "mercurial.ini" add:

[extensions]
hggit=HGGIT_PATH\hggit
@akavel
akavel / lua+parser.min.js
Last active September 30, 2015 18:07
Dump of a lua+parser.min.js file from mherkender/lua.js repository
/*
Copyright 2011 Maximilian Herkender
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@akavel
akavel / ascii-table.lua
Created March 14, 2012 17:49
Print ASCII table (using Lua)
-- compact/one-line form (note: all strings in '', so you can run it with: lua -e "..." )
s=' 01234567 89abcdef\n' for y=0,0xf0,0x10 do s=s..('%02x '):format(y) for x=0,0xf do s=s..string.char(y+x):gsub('%c','.') if x==7 then s=s..' ' end end s=s..(' %02x\n'):format(y) end print(s)
-- expanded/pretty-printed form
s=' 01234567 89abcdef\n'
for y=0,0xf0,0x10 do
s=s..('%02x '):format(y)
for x=0,0xf do
s=s..string.char(y+x):gsub('%c','.')
if x==7 then
@akavel
akavel / mg.bat
Last active October 10, 2015 15:47
mg - Tool for easy building Go (http://golang.org) programs out of the main $GOPATH tree (Windows variant). DOWNLOAD: https://gist.github.com/raw/3713260/mg.bat
@echo off
:: "Make Go" v1.06 2013-02-22
:: Tool for easy building Go (http://golang.org) programs out of the
:: main %GOPATH% tree.
:: SOURCE: https://gist.github.com/3713260
::
:: TODO:
:: - add subcommands, especially: install, clean (rmdir /q /s _gopath)
:: - add info that when importing, you must prefix with current dir name
:: OTHER IDEAS:
@akavel
akavel / git.bat
Last active December 14, 2015 14:39
pseudo-"git", using Mercurial + hg-git plugin to cheat on "go get"
@echo off
:: Homepage: https://gist.github.com/akavel/5102393
:: Author: (c) 2013 by Mateusz Czaplinski
:: License: MIT/X11
if "%1"=="clone" goto :clone
if "%1"=="show-ref" goto :showref
if "%1"=="checkout" goto :checkout
goto :unknown
:clone
function throbber()
{
local rs="${1-\n}"
gawk '
BEGIN {RS="'"$rs"'"; ORS=RS; s="/-\\|"}
{print $0}
NR%100==0 {printf(substr(s,(NR/100)%4+1,1)"\b") > "/dev/stderr"}
NR%1000==0 {printf(".") > "/dev/stderr"}
END{print "" > "/dev/stderr"}
'
@akavel
akavel / results.txt
Created August 20, 2013 18:42
convert codepage win1252 to utf8
0x00 0x0000 []byte{0x0}
0x01 0x0001 []byte{0x1}
0x02 0x0002 []byte{0x2}
0x03 0x0003 []byte{0x3}
0x04 0x0004 []byte{0x4}
0x05 0x0005 []byte{0x5}
0x06 0x0006 []byte{0x6}
0x07 0x0007 []byte{0x7}
0x08 0x0008 []byte{0x8}
0x09 0x0009 []byte{0x9}
@akavel
akavel / go-cmd.bat
Created November 6, 2013 11:42
go-cmd.bat
@echo off
setlocal
:: EXAMPLE:
:: set GOPATH=c:\gopath1;c:\gopath2
:::::::: meat ::::::::
set GOROOT=%~dp0