Skip to content

Instantly share code, notes, and snippets.

@bjconlan
bjconlan / parseUnit
Last active December 20, 2015 14:49
Basic absolute conversions in javascript. Converts a subset of 'http://www.w3.org/TR/css3-values/' in pure javascript. Returns linear measurements in pixels and angles in degrees (perhaps this should be rads...)
var ppi = 96 * window.devicePixelRatio || 1; // 96 = CSS DPI/PPI reference measurement
var absoluteMeasurements = {
px : 1,
pt : 4 / 3,
pc : 12 * (4 / 3),
in : ppi,
cm : ppi / 2.54,
mm : ppi / 25.4,
deg: 1,
grad: 400 / 360,
@bjconlan
bjconlan / Kotlin Spring-Data-Rest Seed
Last active August 22, 2017 03:32
Kotlin spring-data-rest Seed
A very basic kotlin seed that uses spring boot (and the jpa/rest starters)
@bjconlan
bjconlan / httpProvider.js
Created June 18, 2015 14:14
Nodejs implementation of angular $httpProvider
'use strict';
var _ = require('underscore');
var http = require('http');
var https = require('https');
var url = require('url');
var querystring = require('querystring');
/**
* A http client library implementation encapsulating nodes http.request object.
@bjconlan
bjconlan / prelude-customizations.el
Last active May 4, 2021 14:45
Personalized customizations to the default https://github.com/bbatsov/prelude install (.emacs.d/personal)
;; Modules
(require 'prelude-clojure) ;; prelude-modules
(prelude-require-package 'magit) ;; git support
;; Update UI/Editor state
;; Change default font to consolas falling back to dejavue
(require 'cl)
(defun font-candidate (&rest fonts)
"Return existing font which first match."
(find-if (lambda (f) (find-font (font-spec :name f))) fonts))
@bjconlan
bjconlan / test.c
Created September 28, 2015 12:33
SDL 2 tests
#define SDL_MAIN_HANDLED // resolve main symbol not sdl_main
#include <stdio.h>
#include <SDL2/SDL.h>
int main(int argc, char **argv) {
if (SDL_Init(SDL_INIT_VIDEO)) {
printf("SDL_Init Error: %s \n", SDL_GetError());
return 1;
}
@bjconlan
bjconlan / coffee.kt
Created November 22, 2015 04:06
Kotlin Dagger Example
import dagger.Component
import dagger.Module
import dagger.Provides
import javax.inject.Inject
import javax.inject.Singleton
interface Heater {
fun on()
fun off()
}
@bjconlan
bjconlan / plexy.js
Last active July 26, 2016 10:25
Pico8 (Lua subset) hand rolled parser/lexer
function plexy(src) {
const TOKEN = {
STRING: 0,
NUMBER: 1,
LABEL: 2,
SYMBOL: 3,
'...': 4,
'..': 5,
'.': 6,
'==': 7,
@bjconlan
bjconlan / dombuilder.js
Last active August 28, 2018 01:07
Simple dom builder using tuple of [node, children]
// node = {}
// children are a key;
class DOMBuilder {
constructor(document, options = {uri: 'http://www.w3.org/1999/xhtml', tag: 'div'}) {
this.document = document;
this.options = options;
}
buildNode(node) {
@bjconlan
bjconlan / vdomify.html
Last active February 11, 2017 06:30
VDomify builder function example for Inferno which allows JSON persistable template structures
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/inferno/1.0.7/inferno.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/inferno/1.0.7/inferno-component.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/inferno/1.0.7/inferno-create-element.js"></script>
</head>
<body>
<div id="app" />
<script>
// Review Inferno.createElement dep. perhaps Inferno.createVNode would suffice.
@bjconlan
bjconlan / gf.sh
Last active September 13, 2018 06:08
Simple util function for working with multiple git repositories using the same parent folder
#!/usr/bin/env bash
# To have this work on windows (without extension) nicely its easiest
# just to create a bat file which calls `@echo off & bash -c "gf.sh %*"`
REPOS=*/
if [[ -r .gf ]]; then
REPOS=(`cat .gf`)
fi
for REPO in $REPOS; do