Skip to content

Instantly share code, notes, and snippets.

✳️
Focused

Alexander F. Rødseth xyproto

✳️
Focused
Block or report user

Report or block xyproto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@xyproto
xyproto / props.go
Created Oct 3, 2018
List user properties with permissionbolt and simplebolt
View props.go
package main
import (
"fmt"
"github.com/coreos/bbolt"
"github.com/xyproto/permissionbolt"
"github.com/xyproto/simplebolt"
"log"
"os"
"path"
View testgo.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
extern char* go_add(char*, char*) __asm__ ("example.main.Add");
char* __go_string_plus(char *a, char *b) {
char *c = malloc((strlen(a) + strlen(b) + 1));
strcat(c, a);
strcat(c, b);
@xyproto
xyproto / GC.md
Last active Aug 1, 2017
Garbage collection is not mandatory in Go
View GC.md

Go

Disable garbage collection:

debug.SetGCPercent(-1)

Trigger garbage collection:

runtime.GC()
@xyproto
xyproto / Makefile
Created Jul 26, 2017
One way of processing shell scripts through the C preprocessor + strip comments. Beware that cpp may do surprising things to shell scripts.
View Makefile
RELEASE ?= 0
%: %.in
@$(eval SHEBANG=$(shell head -1 ${<} | grep -q -F '#!' && echo 1 || echo 0))
@if [ $(SHEBANG) = 1 ]; then \
head -1 $< > $@; \
tail -n +2 $< | sed -e 's/^ *# .*$$//' -e '/^$$/d' -e '/^#$$/d' | cpp -DRELEASE=$(RELEASE) -P >> $@; \
else \
sed -e 's/^ *# .*$$//' -e '/^$$/d' -e '/^#$$/d' $< | cpp -DRELEASE=$(RELEASE) -P > $@; \
fi
@xyproto
xyproto / tag_hash.sh
Created Mar 21, 2017
First attempt at command line for extracting the latest tag's git hash from a PKGBUILD file that uses git
View tag_hash.sh
#!/bin/bash
# Try to extract the latest tag's commit hash
git ls-remote --tags $(grep source= PKGBUILD | cut -d\" -f2 | cut -d\# -f1 | cut -d+ -f2 | sed "s/\$pkgname/$(grep pkgname= PKGBUILD | cut -d= -f2)/g") | tail -1
View postgresdatabase.go
package main
import (
"fmt"
"github.com/xyproto/permissionwrench"
"github.com/xyproto/simplehstore"
)
func main() {
perm, err := permissionwrench.New()
@xyproto
xyproto / test_otto.sh
Last active Jul 28, 2016
Test changes to otto for EcmaScript 5 compliance improvements
View test_otto.sh
#!/bin/sh
git clone https://github.com/robertkrimen/otto
cd otto/otto; go get -d; go build; cd ../..
git clone https://github.com/tc39/test262.git
git clone https://github.com/test262-utils/test262-harness-py.git
python2 test262-harness-py/src/test262.py --command otto/otto/otto --tests test262 > original.log
rm -rf otto
git clone https://github.com/xyproto/otto.git
cd otto/otto; go get -d; go build; cd ../..
python2 test262-harness-py/src/test262.py --command otto/otto/otto --tests test262 > xyproto.log
View main.pony
actor Main
new create(env: Env) =>
env.out.print("dibs!")
View Marshalling two maps with different types to JSON
package main
import (
"fmt"
"log"
"encoding/json"
)
func main() {
mapSI := map[string]int{"x": 2}
@xyproto
xyproto / boltdatabase.go
Last active Nov 6, 2015
Example for creating a Bolt database with a specific filename, and retrieving the Bolt database struct
View boltdatabase.go
package main
import (
"fmt"
"github.com/boltdb/bolt"
"github.com/xyproto/permissionbolt"
)
func main() {
filename := "bolt.db"
You can’t perform that action at this time.