Skip to content

Instantly share code, notes, and snippets.

View binki's full-sized avatar

Nathan Phillip Brink binki

View GitHub Profile
@binki
binki / undelayed-expansion-ridik.cmd
Last active February 29, 2016 16:13
Undelayed expansion use case?
SETLOCAL
CALL test.cmd
IF ERRORLEVEL 1 (
SET TESTRET=1
) ELSE (
: # Do something with some envvars that test.cmd set that
: # we want to protect our own cmd code from.
)
: # Rely on undelayed expansion semantics to communicate variables
: # out of the SETLOCAL/ENDLOCAL :-D. Though, I suspect that if
@binki
binki / -
Created February 6, 2016 02:55
ohnobinki@gibby ~ $ cd UseMef/
ohnobinki@gibby ~/UseMef $ mono ./UseMef.exe
Plugin SomePlugin
ohnobinki@gibby ~/UseMef $ rm SomePlugin.dll
ohnobinki@gibby ~/UseMef $ mono ./UseMef.exe
ohnobinki@gibby ~/UseMef $ make
mcs /o:'SomePlugin.dll' /t:library SomePlugin.cs /r:UseMef.exe
ohnobinki@gibby ~/UseMef $ mono ./UseMef.exe
Plugin SomePlugin
#!/usr/bin/env python
import datetime
class Job(object):
def __init__(self, mean_hours, dates):
self.mean_hours = mean_hours
self.dates = dates
def parse_date(s):
diff --git a/configure.in b/configure.in
index 67acee0..dc98c90 100644
--- a/configure.in
+++ b/configure.in
@@ -43,22 +43,20 @@ AC_ARG_WITH([localdir],
withval="/usr/pkg"
elif test -d /opt/lib ; then
withval="/opt"
- else
- with_extra_libdir="no"
#!/usr/bin/env python
import csv, io
with io.StringIO() as os:
writer = csv.writer(os)
writer.writerow(['hi', 'bye'])
writer.writerow(['there', 'here'])
# You would figure out how to pass this to your email system
print(os.getvalue())
@binki
binki / .gitignore
Last active January 4, 2016 15:40
Some code which requires either C99/C11.
*.exe
*.o
blah-c11
@binki
binki / faker.sql
Last active December 29, 2015 18:38
T-SQL flow control: `DECLARE` with default is like `SET`, labels inside of constructs
DECLARE @done BIT = 0;
IF 1=0
BEGIN
faker:
PRINT 'x';
SET @done = 1;
END
DECLARE @not BIT = @done;
PRINT @not;
IF @done = 0
@binki
binki / encapsulation_try1.py
Last active December 16, 2015 07:53
Encapsulation enforcement in python? weakref required
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import abc
# Define an abstract class for our public interface.
class Human(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def eat(self):
@binki
binki / banner.json
Created October 30, 2015 21:39
banner.p as JSON rather than a python2 pickle
[[[" ", 95]], [[" ", 14], ["#", 5], [" ", 70], ["#", 5], [" ", 1]], [[" ", 15], ["#", 4], [" ", 71], ["#", 4], [" ", 1]], [[" ", 15], ["#", 4], [" ", 71], ["#", 4], [" ", 1]], [[" ", 15], ["#", 4], [" ", 71], ["#", 4], [" ", 1]], [[" ", 15], ["#", 4], [" ", 71], ["#", 4], [" ", 1]], [[" ", 15], ["#", 4], [" ", 71], ["#", 4], [" ", 1]], [[" ", 15], ["#", 4], [" ", 71], ["#", 4], [" ", 1]], [[" ", 15], ["#", 4], [" ", 71], ["#", 4], [" ", 1]], [[" ", 6], ["#", 3], [" ", 6], ["#", 4], [" ", 3], ["#", 3], [" ", 9], ["#", 3], [" ", 7], ["#", 5], [" ", 3], ["#", 3], [" ", 4], ["#", 5], [" ", 3], ["#", 3], [" ", 10], ["#", 3], [" ", 7], ["#", 4], [" ", 1]], [[" ", 3], ["#", 3], [" ", 3], ["#", 2], [" ", 4], ["#", 4], [" ", 1], ["#", 7], [" ", 5], ["#", 2], [" ", 2], ["#", 3], [" ", 6], ["#", 4], [" ", 1], ["#", 7], [" ", 3], ["#", 4], [" ", 1], ["#", 7], [" ", 5], ["#", 3], [" ", 2], ["#", 3], [" ", 5], ["#", 4], [" ", 1]], [[" ", 2], ["#", 3], [" ", 5], ["#", 3], [" ", 2], ["#", 5], [" ", 4], ["#", 4], [" ", 3], ["
@binki
binki / banner.py
Created October 30, 2015 21:30
banner.p as a python literal rather than a pickle
banner = [[(' ', 95)], [(' ', 14), ('#', 5), (' ', 70), ('#', 5), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 6), ('#', 3), (' ', 6), ('#', 4), (' ', 3), ('#', 3), (' ', 9), ('#', 3), (' ', 7), ('#', 5), (' ', 3), ('#', 3), (' ', 4), ('#', 5), (' ', 3), ('#', 3), (' ', 10), ('#', 3), (' ', 7), ('#', 4), (' ', 1)], [(' ', 3), ('#', 3), (' ', 3), ('#', 2), (' ', 4), ('#', 4), (' ', 1), ('#', 7), (' ', 5), ('#', 2), (' ', 2), ('#', 3), (' ', 6), ('#', 4), (' ', 1), ('#', 7), (' ', 3), ('#', 4), (' ', 1), ('#', 7), (' ', 5), ('#', 3), (' ', 2), ('#', 3), (' ', 5), ('#', 4), (' ', 1)], [(' ', 2), ('#', 3), (' ', 5), ('#', 3), (' ', 2), ('#', 5), (' ', 4), ('#', 4), ('