Skip to content

Instantly share code, notes, and snippets.

View nilium's full-sized avatar
🍉
internal screaming intensifies

Noel nilium

🍉
internal screaming intensifies
View GitHub Profile
<?xml version="1.0"?>
<root>
<item>
<name>Control_R to Control_R</name>
<appendix>(+ When you type Control_R only, send Escape)</appendix>
<identifier>remap.nc.controlRToEscape</identifier>
<autogen>__KeyOverlaidModifier__ KeyCode::CONTROL_R, KeyCode::CONTROL_R, KeyCode::ESCAPE</autogen>
</item>
<item>
@nilium
nilium / go
Created December 1, 2014 15:02
#!/bin/sh
# Forwarding utility for go.
# Puts any directory with a .go-root file into the GOPATH then launches go.
__gopath_for_dir__() {
test_goroot="$1/.go-root"
if [[ -f "$test_goroot" ]] ; then
echo "${2:+$2:}$1"
else
@nilium
nilium / read_pool.go
Created December 28, 2014 02:13
Read pool used internally in gork to avoid spawning too many threads due to syscalls from IO (not sure if this is actually a concern) and limit the number of file descriptors in use by gork (this one is).
package gork
import (
"fmt"
"io/ioutil"
"log"
"os"
)
var (
@nilium
nilium / auto-vim-comment.vim
Last active August 29, 2015 14:15
A vim plugin to insert vim: ... : comment lines at the end of a buffer if no such modeline already exists.
" auto-vim-comment.vim
" Noel Cower
"
" A quick plugin to insert a vim settings line comment as the last line of
" a buffer if none is found.
"
" Although it would be possible to insert the settings line comment at the top
" of the buffer, certain languages reserve the first line for special purposes
" (e.g., a hashbang). As such, this plugin does not attempt to do that.
"
@nilium
nilium / go
Created February 26, 2015 18:34
Go wrapper script
#!/bin/sh
#
# Forwarding utility for go.
# Puts any directory with a .go-root file into the GOPATH then launches go.
#
# Assumes you have a go binary already in your path.
#
# Depends on:
# https://github.com/nilium/gopath
# https://github.com/nilium/realpath
@nilium
nilium / make.bash
Last active August 29, 2015 14:24
General purpose make.bash script for building wgo-based Go projects
#!/usr/bin/env bash
# General-purpose build script for wgo workspaces -- by default, builds all
# main root packages and their sub-packages. This sort of thing isn't
# applicable to all projects, especially those with more than just binary
# products.
if ! which wgo >/dev/null ; then
cat <<-EOF 1>&2
wgo not found. Please install wgo and vendor before running make.bash:
type glogWriter func(...interface{})
func (fn glogWriter) Write(d []byte) (n int, err error) {
n = len(d)
if fn != nil {
fn(string(d))
}
return n, err
}
@nilium
nilium / gist:79287
Created March 15, 2009 03:12
Alternate method of handling exceptions in TMonoMethod.Invoke
Rem
bbdoc: Invoke the method. If an exception is passed, its internal pointer must be Null.
returns: A mono object containing the return data, or Null if an exception is thrown.
End Rem
Method Invoke:TMonoObject(obj:TMonoObject, params:Byte Ptr[], exception:TMonoObject)
Return InvokeByPointer(obj._pointer, params, exception)
End Method
Rem
@nilium
nilium / lua_test.bmx
Created March 16, 2009 02:54
Example of calling Lua functions and Lua calling C functions in BlitzMax
' lua_test.bmx
Strict
Import Axe.Lua
' Available to lua
Function lua_KeyHit( lvm@ Ptr )
' Get the number of arguments to the function
IDENTIFIER_REGEX=/[a-zA-Z_]\w*/
TYPENAME_REGEX=/(?ix)
# type shortcut
(?:
( [!#%] | @{1,2} | \$[zw]? )
|
: \s* ([a-zA-Z_]\w*)
)
# pointer