Skip to content

Instantly share code, notes, and snippets.

View wilkie's full-sized avatar
☠️
screaming into the void

wilkie wilkie

☠️
screaming into the void
View GitHub Profile
@wilkie
wilkie / A.cpp
Created July 19, 2011 07:27
This shows the fallacy of a virtual function. (in C++, but same logic applies to D or C#)
#include <stdio.h>
// This is the implementation of the class
// The functions go in order a(), b(), then c()
// The constructor or compiler will build a vtable as [&a, &b, &c]
class A {
public:
A();
virtual void a() {
@wilkie
wilkie / whitespace.rb
Created September 18, 2011 01:10
Proof of concept trailing whitespace visualizer (idea by @jackiekircher)
module Whitespace
def self.trollify path, code
code.chomp!.gsub!(/([ \t]+)$/) do |match|
"; Whitespace::annoy(#{match.length})"
end
code.gsub!(/\brequire_relative\s*\(?\s*(.+?)\s*\)?;?$/) do |match|
"Whitespace::require_relative #{$1}, binding(), '#{path}'"
end
code
@wilkie
wilkie / Piratey.java
Created September 19, 2011 20:48
This is how pirates use Strings and void methods.
import java.util.Scanner;
import java.util.Random;
class Piratey {
public static void main(String args[]) {
String name;
Scanner input = new Scanner(System.in);
System.out.print("Enter in your first name: ");
@wilkie
wilkie / gist:1454348
Created December 10, 2011 02:35
Djehuty Layout
IO
- buffer
- stream
- file
- directory
- wavelet
- image
- audio
- socket
http://www.qwantz.com/index.php?comic=2135
88_88 staring intently tarantula
88‿88 smiling tarantula
88ᴗ88 SMILING tarantula
88Д88 angered tarantula
@wilkie
wilkie / new_expressions.d
Created May 16, 2012 07:51
Some weird obscure D syntax.
/+
Inner classes contain a hidden field that contains a reference to the
instance of the outer class. D has a special 'new' expression that can
be used to create instances of inner classes and attach them to outer
class instances.
+/
// Using printf
extern(C) int printf(char*, ...);
@wilkie
wilkie / parser.js
Created July 4, 2012 17:23
Example recursive-descent parser in js for a simple cfg
// Parses the following CFG (assuming the only characters are '(' and ')')
// A -> B | ""
// B -> ( B ) | ( )
function parseA(tokens) {
if (tokens[0].length === 0) {
// A -> ""
return true;
}
@wilkie
wilkie / framework.md
Created October 6, 2012 22:57
An Infrastructure to Promote Sustainable Coding

An Infrastructure to Promote Sustainable Coding

We have long promoted the idea of the re-usability of our code. After an era of writing for our machines instead of ourselves, we discovered that human literacy was preferred over performance. From this notion, we developed higher level languages that started to abstract and even completely obscure the underlying machine. A beautiful era emerged where the Turing machine was our model, and humans our audience.

However, these methods of human expression are not compatible. Although they all express and run upon the same theoretical basis, they cannot collaborate effectively. This is due, ironically, to the constraints set upon the languages at the machine level. For instance, {Rust, D, Java} implies a garbage collector to allow object expressions that ignore allocations and to better analyze the lifetimes of these objects. When the language constrains the type of garbage collector policy, this constrains the languages that can be used together.

However, it is

@wilkie
wilkie / reply.txt
Created October 13, 2012 17:30
reply
My reply to http://laurasanders.net/a-primer-on-sexism-in-the-tech-industry-by-an-actual-girl/
Thank you for writing this article. I do appreciate your comments on the original article, and pointed out some problems I had not seen at first.
However, just as he is clearly over-generalizing, you may be under-generalizing. The systemic oppression of women in this field is indeed strong
and undermines female involvement. Let me go through your points.
1. It's true. The article does not tackle sexism directly. http://rarlindseysmash.com/index.php?n=1313531468 is an article about sexism. Written
by a woman. Uses facts and citations.
Does he need to define the words? Unfortunately yes. You tell a white-male-techy that they are using 'privilege' and they'll respond 'I've never
@wilkie
wilkie / 0-description.md
Created October 26, 2014 02:11
This shows you how to handle simple, dynamic colored versions of svg files in ruby + sinatra.

This is an example of how to present a route in Sinatra that returns a colored version of an existing svg. This assumes the first line is the line, which is what inkscape produces. Just drop in any svg, and it will give you one where it is colored in with the given color.

/dynamic/foo.svg returns the normal image.

/dynamic/foo.svg?color=red gives you a red image.

/dynamic/foo.svg?hue=150&sat=50&light=50 gives you a slightly green version of the image.

/dynamic/foo.svg?hex=fff gives a white version of the image.