Skip to content

Instantly share code, notes, and snippets.

View bewildergeist's full-sized avatar

Dan Okkels Brendstrup bewildergeist

View GitHub Profile
@barneycarroll
barneycarroll / README.md
Last active April 20, 2021 15:13
Run a Mithril application with Amok!

Amok is a live editing tool for javascript development. It is beyond awesome. It is the future of javascript development.

Mithril is a javascript framework for building brilliant applications.

This simple test case shows how we can use Amok's event handlers to trigger redraws as and when code is dynamically recompiled in the browser. It's a little taste of the awesome to come.

To use this demo:

  1. Install Amok
  2. You'll need Node
@webcss
webcss / mithril-touch.js
Last active May 26, 2020 15:34
mithril-touch, consume touch and mouse events evenly with mithril
/*****************************************
/* DOM touch support module
/*****************************************/
if (!window.CustomEvent) {
window.CustomEvent = function (event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
};
@greystate
greystate / open-hours.json
Created January 23, 2015 12:52
I'll just let this sit here for eternal scrutiny... :-)
{
"fieldsets": [
{
"alias": "contactInfo",
"disabled": false,
"properties": [
{
"alias": "value",
"value": "Lukket"
},
@leekelleher
leekelleher / 01-umbraco-xml-cache-json-namespaced.xml
Last active March 16, 2016 10:19
Umbraco: Converting and namespacing the JSON data to XML (for use with XSLT/XPath)
<root id="-1">
<HomePage id="1234" parentID="-1" level="1" creatorID="1" sortOrder="0" createDate="2014-12-16T00:00:00" updateDate="2014-12-16T00:00:00" nodeName="Home" urlName="home" path="-1,1156" isDoc="" nodeType="1111" creatorName="admin" writerName="admin" writerID="1" template="0" nodeTypeAlias="HomePage">
<archetypeLinks><![CDATA[{"fieldsets":[{"properties":[{"alias":"linkUrl","value":"http://www.example.com/"},{"alias":"linkLabel","value":"Website"}],"alias":"externalLink","disabled":false},{"properties":[{"alias":"linkUrl","value":"http://www.example2.com/"},{"alias":"linkLabel","value":"Webshop"}],"alias":"externalLink","disabled":false}]}]]></archetypeLinks>
<json:archetypeLinks xmlns:json="http://pimpmyxslt.com/json">
<fieldsets>
<properties>
<alias>linkUrl</alias>
<value>http://www.example.com/</value>
</properties>
<properties>
@sjl
sjl / ext.vim
Created December 15, 2014 18:58
ways to run external commands in vim
" run command
" no stdin
" output displayed in "Press enter to continue" style
" current buffer untouched
:!uptime
" run command
" pipe range of text to command on stdin
" output replaces the range in the current buffer
:RANGE!grep foo
@barneycarroll
barneycarroll / animator.js
Last active June 11, 2021 05:06
A factory for decorating Mithril modules / views / elements with incoming and outgoing animations.
var animating = false;
// Define an animator consisting of optional incoming and outgoing animations.
// alwaysAnimate is false unless specified as true: false means an incoming animation will only trigger if an outgoing animation is also in progress.
// forcing dontClone to true means the outward animation will use the original element rather than a clone. This could improve performance by recycling elements, but can lead to trouble: clones have the advantage of being stripped of all event listeners.
function animator( incoming, outgoing, alwaysAnimate, dontClone ){
// The resulting animator can be applied to any number of components
return function animate( x, y, z ){
var config;
var parent;
@abjerner
abjerner / Contour.md
Created December 3, 2014 18:29
Quick guide to insert Contour <script> tags at the bottom of the page rather than in context.

Open /umbraco/plugins/umbracoContour/views/Form.cshtml and look for the following line:

@Html.Partial(FormViewResolver.GetScriptView(Model.FormId), Model)

Replace it with these lines:

List temp = HttpContext.Current.Items["ContourScripts"] as List;
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="xsl:template[@match]">
<xsl:text>@* Sorry, can't do that in Razor :( *@</xsl:text>
</xsl:template>
<xsl:template match="xsl:value-of[starts-with(@select, '$currentPage/')]">
@lelandrichardson
lelandrichardson / ko-convenience.js
Created March 5, 2014 01:11
Knockout.js Custom Utility Bindings
(function (ko, handlers, unwrap, extend) {
"use strict";
extend(handlers, {
href: {
update: function (element, valueAccessor) {
handlers.attr.update(element, function () {
return { href: valueAccessor() };
});
}
},
@kgiszewski
kgiszewski / gist:8863822
Last active March 11, 2020 14:12
Archetype Template Use Cases
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Archetype.Models;
@using Archetype.Extensions;
@{
Layout = null;
}
//use case #1 - Covers a single Archetype
@foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("a1"))
{