Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@binki
binki / launchTurboCoffee.js
Last active December 28, 2016 16:12
Launch a URI on Windows with JScript host
var objShell = WScript.CreateObject('WScript.Shell');
objShell.Run('http://turbo.coffee');
@binki
binki / Test.hx
Created December 28, 2016 21:21
Haxe coalesce macro
import haxe.macro.Expr;
class Test {
static function main() {
var x = 2;
var y = 53;
var z = 43;
x = null;
trace(coalesce(x, y, z));
y = null;
@binki
binki / InterpolatedMacroPlay.hx
Created December 29, 2016 23:00
Haxe: investigating string interpolation and macros
// Haxe’s macro support makes for a golden opportunity for building
// program metadata during compiletime. I think it would be very cool
// to be able to preprocess itnerpolated strings so that text can be
// extracted and analyzed separately (NLS?) or, e.g., to do JavaScript-style
// tagged string stuff/C#-style FormattableString stuff like automatically
// escaping expressions when building HTML, etc.
//
// However, it looks to me like right now macros are given CStrings
// which don’t even let you know if the string will be interpolated
// or not.
@binki
binki / InterpolatedMacroPlay2.hx
Last active December 30, 2016 19:00
More interpolated string macro fun
// Haxe’s macro support makes for a golden opportunity for building
// program metadata during compiletime. I think it would be very cool
// to be able to preprocess interpolated strings so that text can be
// extracted and analyzed separately (NLS?) or, e.g., to do JavaScript-style
// tagged string stuff/C#-style FormattableString stuff like automatically
// escaping expressions when building HTML, etc.
//
// However, it looks to me like right now macros are given CStrings
// which don’t even let you know if the string will be interpolated or
// not. And MacroStringTools.formatString() seems insufficient…
@binki
binki / Program.cs
Last active January 2, 2017 17:18
csharp attributes allow arrays
using System;
using System.Reflection;
class Program
{
static void Main(string[] args)
{
foreach (var value in typeof(MyClass).GetCustomAttribute<MyAttribute>().Values)
{
Console.WriteLine(value);
using System;
using System.Xml.Linq;
class XElementDemo
{
static void Main(string[] args)
{
var tree = new XElement(
"x",
new XAttribute("y", $"uh, {1+4}"),
import haxe.ds.StringMap;
import haxe.macro.Expr;
import haxe.macro.Printer;
class XmlLiteral {
public static function main() {
// See https://gist.github.com/binki/9d09ea0ae8ea43788505af08844dae79
// It would be cool if the following:
@binki
binki / cxx.php
Last active January 5, 2017 18:22
I can’t get PHP to look like C++ xD
<?php
class NotStream {
public function write($s) {
echo $s;
return $this;
}
}
class std {
@binki
binki / MoreLiteral.hx
Last active January 6, 2017 17:13
Haxe: how to expand arbitrary interpolated strings in macros
import haxe.macro.Expr;
import haxe.macro.MacroStringTools;
import haxe.macro.Printer;
class MoreLiteral {
static function main() {
var x = 2;
trace(Util.xpand(34));
}
#!/usr/bin/env python
def something():
pass
def hi():
something()
something()
bye = 5
sigh = 10