Skip to content

Instantly share code, notes, and snippets.

View benthepoet's full-sized avatar

Ben Hanna benthepoet

View GitHub Profile
@benthepoet
benthepoet / lisp.c
Created March 27, 2019 13:23
Recursive S-expression parsing
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sprite.h"
#define GAME_FILE "config/game.lisp"
enum NodeType {
@benthepoet
benthepoet / lisp.c
Created March 24, 2019 20:14
Parsing S-expression
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define DATA_FILE "data.lisp"
struct Node {
char *data;
struct Node *next;
@benthepoet
benthepoet / Export.ps1
Created March 14, 2019 01:57
Parsing XML to CSV
Add-Type -AssemblyName System.Xml.Linq
$reader = [System.Xml.XmlReader]::Create("./magnified.xml")
$reader.ReadStartElement("response")
$reader.ReadStartElement("row")
$csv = @()
while(!$reader.EOF) {
(defmacro do-until-eof (line &body body)
`(loop for ,line = (read-line *standard-input* nil :eof)
until (eq ,line :eof)
do ,@body))
@benthepoet
benthepoet / Main.elm
Created June 25, 2018 12:12
SVG Drag and Drop
module Main exposing (main)
import Array exposing (Array)
import Html exposing (Html)
import Json.Decode as Decode
import Svg
import Svg.Attributes as Attributes
import Svg.Events as Events
@benthepoet
benthepoet / Main.elm
Last active June 7, 2018 03:24
Firebird Admin Layout
module Main exposing (main)
import Html exposing (Html)
import Html.Attributes as Attributes
main : Html msg
main =
Html.div [ Attributes.class "container" ]
[ Html.div [ Attributes.class "row header"]
[ Html.h2 [] [ Html.text "Firebird Admin" ]
@benthepoet
benthepoet / Main.elm
Created June 6, 2018 20:00
Ctrl-Enter Form Event
module Main exposing (main)
import Html exposing (Html)
import Html.Events as Events
import Json.Decode as Decode
type alias KeyUpEvent =
{ ctrlKey : Bool
, key : String
@benthepoet
benthepoet / threaditjs-ramda-transform.js
Last active October 13, 2017 18:22
ThreadItJS transform performed using Ramda
// Build the pipelines
const isRoot = where({ parentId: isNil });
const isNotRoot = complement(isRoot);
const assembleLookup = (accumulator, current) => {
const key = current.parentId;
const lookup = compose(append(current), propOr([], key));
return assoc(key, lookup(accumulator), accumulator);
};
@benthepoet
benthepoet / Main.elm
Created July 26, 2017 02:13 — forked from anonymous/Main.elm
Form Event Bubbling
module Main exposing (..)
import Html exposing (Html, beginnerProgram, div, form, textarea)
import Html.Attributes exposing (name)
import Html.Events exposing (on)
import Json.Decode as Json
import Dict exposing (Dict)
type alias Model =
@benthepoet
benthepoet / qunit.teamcity.js
Last active December 27, 2015 22:59 — forked from kir/qunit.teamcity.js
A modified version of the QUnit Team City output. Needed to add a special variable to track the beginning and end of a module because testSuiteFinished were being misplaced or duplicated. Needed to escape the test names in order to use apostrophes. Also added a snippet that sets up window.console.log() as a blank function when it's not present. …
(function (QUnit) {
if (!window.console) {
window.console = {
log: function () { }
};
}
var tcEscape = function (str) {
str = str ? str.toString() : "";