Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@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 / 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 / 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 / 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 / output.txt
Created December 17, 2016 15:14
null trick with maps?
> var x = {}
undefined
> x['null'] = 2
2
> x['undefined'] = 4
4
> y = {parentId: null,}
{ parentId: null }
> x[y.parentId]
2
@binki
binki / pevil.html
Last active December 12, 2016 23:22
Switch input type=password to type=text in the current page.
<p>
Drag this link to your bookmark toolbar to install this bookmarklet: <a href="javascript:(function()%20{var%20o%20=%20document.getElementsByTagName('input'),%20i%20=%200;%20for%20(;%20i%20<%20o.length;%20i++)%20if%20(o[i].type%20==%20'password')%20o[i].type%20=%20'text';%20undefined;})()">pevil</a>
</p>
<p>
Demo: <input type="password" value="password"/>
</p>
#include <stdio.h>
int main(int argc, const char *argv[]) {
return rename(argv[1], argv[2]);
}
@binki
binki / Scriptfile
Created November 21, 2016 15:05
[email protected]’s conditional globbing is weird
ohnobinki@gibby /tmp/.private/ohnobinki/asdf $ mkdir -p a/{b{0,1,2,3},\*\*}/c
ohnobinki@gibby /tmp/.private/ohnobinki/asdf $ find . -name node_modules -prune -or -print
.
./a
./a/**
./a/**/c
./a/b3
./a/b3/c
./a/b2
./a/b2/c
@binki
binki / Program.cs
Last active November 5, 2016 14:51
#csharp7 #tuple #destructuring
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace ValueTupleFun
{
class Program
{
static void Main(string[] args)
{
@binki
binki / Program.cs
Created November 3, 2016 16:12
Remoting—reference versus value/AppDomain remoting
// Inspired by http://stackoverflow.com/q/13729089/429091
using System;
class Program
{
static void Main(string[] args)
{
var appDomain = AppDomain.CreateDomain("Temp AppDomain", null, AppDomain.CurrentDomain.SetupInformation);
try