Skip to content

Instantly share code, notes, and snippets.

@JesseKPhillips
JesseKPhillips / processTests.d
Created April 3, 2013 05:35
Unittests pulled from std.process (DLang)
import std.process2;
import std.stdio, std.array;
void main(string[] args) { write(args.join("\0")); }
unittest
{
import std.ascii;
auto x = executeShell("echo wyda");
// @@@ This fails on wine
@JesseKPhillips
JesseKPhillips / osmpbfexample.d
Last active November 30, 2017 19:55
This gives a very basic parsing of osm.pbf files.
/**
* Explaination comments taken from:
* http://wiki.openstreetmap.org/wiki/PBF_Format#Design
*
* This gives a very basic parsing of osm.pbf files. The purpose was several
* fold.
*
* - Read PBF files
* - Learn the file layout
* - Verify the bytes match
@JesseKPhillips
JesseKPhillips / SaveRestoreProperties.d
Last active January 4, 2016 12:29
This shows that hiding implementation behind a function and provide a very simple client interface. As per a conversation on reddit: http://www.reddit.com/r/programming/comments/1w2xpl/selfreferential_functions_and_the_design_of/cey8y4v
import std.stdio;
@safe:
void main() {
Foo foo;
foo.Option.Val2 = "bye";
myFun(foo);
foo.DoSomeDebugging();
}
@JesseKPhillips
JesseKPhillips / gist:9147869
Created February 22, 2014 02:46
Scala traits as D interface... maybe.
import std.stdio;
interface Flying {
@property string flyingMessage();
final void fly() {
writeln(flyingMessage);
}
}
interface Swimming {
#!/usr/bin/dmd -run
// Solution to Project Euler problem 61
// For a more readable version, see 061.rb
// Author: David J. Oftedal.
import std.stdio, std.math, std.algorithm, std.string, std.conv, std.c.stdlib, std.range;
// The ABC formula for solving quadratic equations (where the solutions are real numbers).
// Restrict to integer solutions.
@JesseKPhillips
JesseKPhillips / noloops.d
Last active August 29, 2015 14:13
Translation to D of the Java 8 No more loops post
// Original: http://www.deadcoderising.com/java-8-no-more-loops/
import std.algorithm;
import std.range;
import std.typecons;
private struct Article {
private immutable string title;
private immutable string author;
private immutable string[] _tags;
@JesseKPhillips
JesseKPhillips / DividendWorksheet2014.d
Last active August 29, 2015 14:16
Provides the sequence of events for the USA 2014 Qualified Dividend and Capital Gain Tax Worksheet.
/**
* Provides the sequence of events for the USA 2014 Qualified Dividend and Capital Gain Tax Worksheet.
*
* This is license under Boost 1.0:
* http://www.boost.org/LICENSE_1_0.txt
*
* Do not rely on this software being correct, do yourself a favor and
* review the the logic.
*
* It relys on cmdln.interact found on github:
auto test(T)(T lhs) {
auto t = new Test!T;
t.lhs = lhs;
import std.typecons : Tuple;
return Tuple!(Test!T , "lhs", Test!T, "verify")(t, t);
}
class Test(T) {
T lhs;
@JesseKPhillips
JesseKPhillips / wrapStructTest.d
Created November 11, 2015 23:11
Provides testing of wrapping a structure into Range interfaces
// Based on: http://he-the-great.livejournal.com/49174.html
import std.range;
import exp = std.experimental.typecons;
interface InputRange(E) {
@property E front();
void popFront();
@property bool empty();
}
@JesseKPhillips
JesseKPhillips / mystory.md
Last active November 18, 2016 00:31
mkUSAgreatAgain: My letter to the president

Dear President Elect,

I expect that you'll get a large number of requests for help, many of which will be to help others and not the author. That is one of the great things about persons, it isn't just about themselves, instead life should be better for all. But the United States of America was great, not for what it did, but instead for what it could not do. I want to make my suggest toward fixing the government.

The founders, as flawed as they were, did two great things to the government. They made the government open/transparent and granted it powers. Consider what the government is doing and see if you can find that power granted in the Constitution; if it isn't there or you find it isn't clear, draft a modification to the Constitution so that it can be written and people can see that power exists.

Consider also that the Constitution does not specify a partisan government, yet is it fair to say that the country had more than two choices (Clinton and Trump)? Either we need the Constitution to specify a