Skip to content

Instantly share code, notes, and snippets.

(module
(export "main" (func $main))
;; Create memory with at least 1 page of 64k of memory
(memory $mem 1)
(func $main (result i32 i32)
;; write some data to an arbitrary memory location
i32.const 0xcafe ;; address
i32.const 42 ;; memory to write
(module
;; Create a function that returns a single value
(func $main (result i32)
i32.const 42
)
;; Export that function so the test harness can find it
(export "main" (func $main))
)
@bryanburgers
bryanburgers / dbus-promise.js
Last active February 13, 2017 16:38
Use promises with node-dbus 1.0.0.
'use strict';
const Promise = require('bluebird');
const DBus = require('dbus');
const Bus = require('dbus/lib/bus');
const Interface = require('dbus/lib/interface');
Promise.promisifyAll(Bus.prototype);
Promise.promisifyAll(Interface.prototype);
@bryanburgers
bryanburgers / tmux-date
Last active May 3, 2024 18:09
Format the date how I like it, for use in the status bar of tmux
#!/bin/bash
# Format the current date in a way that clearly shows local time and UTC time,
# for use in a tmux status bar.
# Examples:
# tmux-date (with computer set to America/Chicago timezone)
# 2016-01-11 / 08:55 -06:00 / 14:55Z
# TZ="Australia/Victoria" tmux-date
# 2016-01-12 / 01:55 +11:00 / 2016-01-11T14:55Z
@bryanburgers
bryanburgers / git-deploy.sh
Created December 29, 2015 19:55
Take a selection of branches, merge them all together, and force-push them to a remote repo
#!/bin/bash
set -e
current_branch="$(git symbolic-ref HEAD 2>/dev/null)"
short_current_branch=${current_branch#refs/heads/}
date=$(date --iso-8601 --date="-1 month")
options=()
//
// UserAgent.swift
//
import Foundation
class UserAgent {
static func getUserAgent() -> String {
let bundleDict = NSBundle.mainBundle().infoDictionary!
let appName = bundleDict["CFBundleName"] as! String
@bryanburgers
bryanburgers / formattingtest.php
Last active January 27, 2021 18:00
Forcing four-digit years on IntlDateFormatter::SHORT
<?php
$d = new DateTime("2012-10-11");
function unalteredFormat($date, $locale) {
$fmt = new IntlDateFormatter(
$locale,
IntlDateFormatter::SHORT,
IntlDateFormatter::NONE);
$fmtted = $fmt->format($date);
@bryanburgers
bryanburgers / generate-ios-images.sh
Created August 27, 2015 01:41
Generate all of the png images necessary for an iOS app from a source SVG file, using Inkscape to render them.
#!/bin/bash
sizes=('29' '29@2' '29@3' '40' '40@2' '40@3' '60@2' '60@3' '76' '76@2')
IFS='@'
for size in "${sizes[@]}"
do
read -ra parts <<< "$size"
base=${parts[0]}
@bryanburgers
bryanburgers / template.html
Created May 14, 2015 02:30
Group adjacent blocks of the same type together.
{!--
> Awesome. Just had an Ah-ha! moment. Build small blocks, then add
> multiple Block fields to a channel with specific blocks in.
-- @JayHealy, https://twitter.com/JayHealey/status/598668322301837312
--}
{cf_page_content}
@bryanburgers
bryanburgers / .bashrc
Last active August 29, 2015 14:14
Recent changes to my .bashrc file
# ...
# Open up WAMP's Apache httpd.conf in Sublime, so I can add a vhost
alias vhosts='/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe /c/wamp/bin/apache/apache2.4.2/conf/httpd.conf'
# Restart WAMP's Apache to pick up vhost changes
alias apacherestart='NET STOP wampapache && NET START wampapache'
# Edit the hosts file
alias hosts='vi /c/Windows/System32/drivers/etc/hosts'