Skip to content

Instantly share code, notes, and snippets.

View StephanHoyer's full-sized avatar
🏠
Working from home

Stephan Hoyer StephanHoyer

🏠
Working from home
View GitHub Profile
@StephanHoyer
StephanHoyer / gist:bddccd9e159828867d2a
Last active March 29, 2022 11:46
Isomorphic applications with mithril

Attention

This post described how to create an application with mithril 0.2.x. Now that ver 1.0 is out, some things are a little differnent.

The example is updated with the current version of mithril, though.

Isomorphic applications with mithril

var express = require('express');
function base(content) {
return [
'<!doctype html>',
'<html>',
'<head>',
'<link href="/index.css" media="all" rel="stylesheet" type="text/css">',
'<link href="/latin/firasans-bold,firasans-hair,firasans-light,firasans-book,firasans-italic,firamono-bold/fonts.css" type="text/css" rel="stylesheet"/ >',
'<script src="/index.js"></script>',
@StephanHoyer
StephanHoyer / index.js
Created November 7, 2014 15:56 — forked from kamilogorek/index.js
requirebin sketch
var AmpersandState = require('ampersand-state');
var Ingredient = AmpersandState.extend({
props: {
name: 'string'
}
});
var Meal = AmpersandState.extend({
props: {
@StephanHoyer
StephanHoyer / index.js
Created November 7, 2014 15:55
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
@StephanHoyer
StephanHoyer / gist:de107b794c43f28ffd75
Last active August 10, 2023 17:16
SVG Icons with mithril.js

Icons have been part of applications since ages. Also most websites rely on icons. There were several ways to use them. First we used plain files then image sprites to reduce requests. Nowadays everyone uses icon fonts like font-awesome or glyphicons.

They are infinetly scaleable and styleable with css. The downside is they use pseudo elements for displaying. This is not only difficult to handle but also non-optimal for accessibilty.

A famous CSS-Tricks post brings SVG icons into play. The are also scalable and they behave like normal images. But we also want to have a sprite to not load any images seperatly and kill our servers and our sites performance. The proposed version is to create sprites with grunt or gulp using the symbol-trick. It's basically add every icon to a hidden sprite-image and give every icon an id-property.

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  
  <symbol id="beaker" viewBox="214.7 0 182.6 792">
@StephanHoyer
StephanHoyer / oojs.md
Last active October 13, 2015 16:45
Object orientation without new and the in JavaScript

Just saw Douglas Crockfords talk at Craft Conference

http://www.ustream.tv/recorded/46640057

Just tried it and must say, it has a certain beauty in it.

No tangeling with prototypes and this/that fuckup.

var Animal = function(name, legs) {
@StephanHoyer
StephanHoyer / Proposals.md
Last active December 24, 2015 06:19 — forked from it-ony/Proposals.md

Talk proposals for @leipzigjs usergroup

(In a non prioritized order)

  • flow.js - a synchron, asynchron control flow javascript library
  • inherit.js - a js inheritance library
  • xajax - perform cross-domain AJAX requests via iFrame and postMessage
  • query.js - an abstract query language which can be mapped to different query language implementations
  • jscop - static javascript code analyser written in node.js