Skip to content

Instantly share code, notes, and snippets.

View ZanderBrown's full-sized avatar
🤦‍♂️
broke it

Zander ZanderBrown

🤦‍♂️
broke it
View GitHub Profile
// The number needs to be parsed from a string
static int
read_int (GDataInputStream *stream)
{
g_autoptr (GError) error = NULL;
g_autofree char *string = NULL;
gint64 num = -1;
string = g_data_input_stream_read_upto (stream, " \n", 2, NULL, NULL, &error);

When making a GtkBox in Vala you can be as formal/informal as you like

Formal

Gtk.Box box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);

I know you mean Gtk.Box

var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
@ZanderBrown
ZanderBrown / php die helpfully.php
Created March 8, 2018 13:27
PHP shutdown function useful for debugging
register_shutdown_function(function() {
$e = error_get_last();
if($e !== null) {
gc_mem_caches();
$str = 'E(' . $e['type'] . '): ' . $e['message'] . PHP_EOL;
$line = 1;
$pad = strlen((string) $e['line'] + 2) + 3;
$fh = fopen($e['file'], 'r');
while (($buffer = fgets($fh)) !== FALSE) {
if ($line >= $e['line'] - 2 && $line <= $e['line'] + 2) {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZanderBrown
ZanderBrown / plan.md
Created November 6, 2017 17:28
'Microflasher', micro:bit uploader for Linux environments

Plan

DBus Server:

  • Monitors folder
  • Installed as service
  • Copies to all connected m:b

LXPanel plugin (for Raspbian):

  • Connects to server
  • Shows notifications for events as tooltips (ala lxplug-ejecter)
@ZanderBrown
ZanderBrown / README.md
Created May 31, 2017 17:51
GNOME Wiki Dark Theme

Don't get me wrong the new GNOME Wiki theme is beautiful but rather bright.

Either add this as user CSS or add to Stylish

@ZanderBrown
ZanderBrown / README.md
Created April 27, 2017 21:11
Unity LowGFX Toggle

A simple tool to enable disable Unity LowGFX mode.

Inspired whist reading this and a blatent copy of this

As i don't have access to the required Unity version this is compleatly untested

@ZanderBrown
ZanderBrown / microchat.py
Created October 1, 2016 20:16
A chat system using the Micro:Bit for communication
from microbit import *
import radio
uart.init()
radio.on()
uart.write("\r\nWelcome\r\n")
while True:
input = uart.readline()
if input is not None and len(input) > 0:
uart.write(str(input,'utf-8'))