Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@binki
binki / output.txt
Created November 3, 2016 04:09
globs match backslashes on unix
ohnobinki@gibby ~/testthings/dir1/dir2\asdf\stilldir2 $ touch foo\\bar\\baz.txt
ohnobinki@gibby ~/testthings/dir1/dir2\asdf\stilldir2 $ busybox ash -c 'echo foo*.txt'
foo\bar\baz.txt
ohnobinki@gibby ~/testthings/dir1/dir2\asdf\stilldir2 $
@binki
binki / Program.cs
Last active January 18, 2017 18:33
Play with C# string interpolation
using System;
namespace FormattablePlay
{
class Program
{
static void Main(string[] args)
{
var stringVar = "plant";
Append($"SELECT * FROM blah b WHERE b.Thing = {stringVar}");
ohnobinki@gibby ~ $ cat blah.js
#!/usr/bin/env node
console.log('hi');
ohnobinki@gibby ~ $ ./blah.js
hi
ohnobinki@gibby ~ $ cat blah2.js
console.log('hi');
ohnobinki@gibby ~ $ ./blah2.js
./blah2.js: 行 1: 予期しないトークン `'hi'' 周辺に構文エラーがあります
./blah2.js: 行 1: `console.log('hi');'
ohnobinki@gibby ~ $ cat blah.js
#!/usr/bin/env node
console.log('hi');
ohnobinki@gibby ~ $ ./blah.js
hi
ohnobinki@gibby ~ $ cat blah2.js
console.log('hi');
ohnobinki@gibby ~ $ ./blah2.js
./blah2.js: 行 1: 予期しないトークン `'hi'' 周辺に構文エラーがあります
./blah2.js: 行 1: `console.log('hi');'

Mercurial supports nested quoting contexts:

ohnobinki@gibby ~/dcx-ridik-variable-substitution $ t="{'a{'b{pad('x', 2, ',', True)}'}'}"; echo "${t}"; hg log -l1 --template "${t}"; echo
{'a{'b{pad('x', 2, ',', True)}'}'}
ab,x

It also supports “weirdly quoted strings”, as I call them:

@binki
binki / github-fluid-moz-stylish.css
Last active August 15, 2016 15:16
Fix GitHub requiring horitontal scrolling/not being fluid
@namespace url(http://www.w3.org/1999/xhtml);
/*
* With this style, github README pages become fluid and no longer
* require horizontal scrolling to read: http://imgur.com/pyruCm0
*
* Without, lots of annoying horizontal scrolling: http://imgur.com/wofNtra
*/
@-moz-document domain("github.com") {
/* -*- c-file-style: "linux" -*- */
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main(int argc, const char *const argv[])
{
struct stat statbuf;
if (argc < 2)
@binki
binki / Program.cs
Created July 29, 2016 15:03
C# static initializers don’t care about inheritance
// Apparently, accessing a static member of a subclass does not initialize
// the static members of the base class unless you explicitly cause this to
// happen.
using System;
namespace StaticInitializationInheritance
{
class Program
{
@binki
binki / Program.cs
Created July 28, 2016 13:47
Fun with C# expressions and maybe a way to SQL?
using System;
using System.Linq;
using System.Linq.Expressions;
namespace ExpressionsFun
{
static class Program
{
static void Main(string[] args)
{
@binki
binki / Program.cs
Created July 25, 2016 18:39
MEF only supports generic type closure using nongeneric type as generic type parameters
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
namespace MefGenericExportImports
{
[Export]
public class Program
{
[Import]