Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@binki
binki / BinkiBinarySearch.hx
Last active February 1, 2017 14:38
Binary search attempt
class BinkiBinarySearch {
/**
Input: `arr` is a sorted array, `sought` is a sought value,
`cmp` a comparer which when called like `cmp(a, b)` returns -1
if `a` comes before `b`, 0 if `a` and `b` are of the same
order, and 1 if `a` comes after `b`.
Returns: -1 if something equivalent to `sought` is not found,
index of any element matching `sought` otherwise.
**/
@binki
binki / output.txt
Created January 31, 2017 03:39
Reading unicode CSV
C:\Users\ohnob>.\readUnicodeCsv.py
勇気
@binki
binki / Program.cs
Created January 25, 2017 20:06
Haxe Interpolated String Example
using System;
using System.Linq;
class Program
{
static void Main(string[] args)
{
intr($"asdf{""}{"bsdf"}"); // Format=asdf{0}{1}, Arguments=“”,“bsdf”
intr($"asdf{""}bsdf"); // Format=asdf{0}bsdf, Arguments=“”
}
@binki
binki / Program.cs
Created January 18, 2017 20:50
VS default C# .net Console app template
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
#!/usr/bin/env python
def something():
pass
def hi():
something()
something()
bye = 5
sigh = 10
@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));
}
@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 {
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:
using System;
using System.Xml.Linq;
class XElementDemo
{
static void Main(string[] args)
{
var tree = new XElement(
"x",
new XAttribute("y", $"uh, {1+4}"),
@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);