Skip to content

Instantly share code, notes, and snippets.

@crazy2be
crazy2be / 0ad-patches.diff
Created August 15, 2015 19:11
A bunch of patches for 0ad to improve gameplay based on our own difficulties/annoyances.
Index: binaries/data/mods/public/simulation/components/Foundation.js
===================================================================
--- binaries/data/mods/public/simulation/components/Foundation.js (revision 16918)
+++ binaries/data/mods/public/simulation/components/Foundation.js (working copy)
@@ -33,6 +33,12 @@
this.maxProgress = 0;
this.initialised = true;
+
+ // Give our foundation a small amount of initial health, so that
@crazy2be
crazy2be / .bash_profile
Created September 22, 2015 00:09
Add to .bash_profile to get more useful terminal titles.
# http://askubuntu.com/questions/126737/make-gnome-terminal-show-the-command-running-as-title
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
prompt_prefix()
{
if [ "$USER" != "jmcgirr" ] || [ "$HOSTNAME" != "jmcgirr-ld1" ]; then
echo -n "${USER}@${HOSTNAME}: "
else
echo -n
package main
import (
"os"
"io"
"fmt"
"rpc"
"rpc/jsonrpc"
)
panic:
runtime.panic+0xa4 ~/go/src/pkg/runtime/proc.c:1060
runtime.panic(0x80b2fb8, 0x967ac4a0)
gojs.value_to_javascript+0x4e ~/Src/gojs/_obj/base.cgo1.go:89
gojs.value_to_javascript(0x967ac490, 0x80b32a8, 0x85a02a00, 0x0, 0x0, ...)
gojs.*Context·NewValue+0x67 ~/Src/gojs/_obj/base.cgo1.go:882
gojs.*Context·NewValue(0x967ac490, 0x80b32a8, 0x85a02a00, 0x85a02a00, 0x1, ...)
gojs.*Context·EvaluateScript+0x155 ~/Src/gojs/_obj/base.cgo1.go:-24
gojs.*Context·EvaluateScript(0x967ac490, 0x80d8be8, 0x3, 0x967ac498, 0x80dea4c, ...)
// Given a slice of go-style Values, this function allocates a new array of c-style values and returns a pointer to the first element in the array, along with the length of the array.
func (ctx *Context) newCValueArray(val []*Value) (*C.JSValueRef, C.size_t) {
if len(val) == 0 {
return nil, 0
}
arr := make([]C.JSValueRef, len(val))
for i := 0; i < len(val); i++ {
arr[i] = val[i].ref
}
return &arr[0], C.size_t(len(arr))
@crazy2be
crazy2be / gist:1057936
Created July 1, 2011 05:45
My daily WTF.
func nativecallback_CallAsFunction_go(data_ptr unsafe.Pointer, ctx unsafe.Pointer, obj unsafe.Pointer, thisObject unsafe.Pointer, argumentCount uint, arguments unsafe.Pointer, exception *unsafe.Pointer) unsafe.Pointer {
defer func() {
if r := recover(); r != nil {
*exception = unsafe.Pointer(recover_to_javascript((*Context)(ctx), r))
}
}()
data := (*object_data)(data_ptr)
ret := data.val.Interface().(GoFunctionCallback)(
(*Context)(ctx), (*Object)(obj), (*Object)(thisObject), (*[1 << 14]*Value)(arguments)[0:argumentCount])
func (ctx *Context) newGoValueArray(ptr unsafe.Pointer, size uint) ([]*Value) {
goarr := make([]*Value, size)
for i := uint(0); i < size; i++ {
goarr[i] = ctx.newValue(C.JSValueRef(ptr))
ptr = unsafe.Pointer(4+uintptr(ptr))
}
return goarr
}
func (ctx *Context) newCValueArray(val []*Value) (*C.JSValueRef, C.size_t) {
if len(val) == 0 {
return nil, 0
}
arr := make([]C.JSValueRef, len(val))
for i := 0; i < len(val); i++ {
arr[i] = val[i].ref
}
return &arr[0], C.size_t(len(arr))
}
// native.go
// Have to add this function for native_test.go
func ptrToJSValueRef(ptr unsafe.Pointer) C.JSValueRef {
return C.JSValueRef(ptr)
}
// native_test.go
func PrettyPrintValArr(t *testing.T, values []*Value) {
for _, val := range values {
tlog(t, val)
func (e *Exception) debugString() (str string) {
defer func() {
if r := recover(); r != nil {
stringer, ok := r.(Stringer)
if !ok {
str = "Panic of non-string type when attempting to create string representation."
return
}
str = stringer.String()
return