Skip to content

Instantly share code, notes, and snippets.

@jmaicher
jmaicher / 1.template.html
Last active February 5, 2017 14:32
Express fragment dependencies with tailor
<html>
<head>
<!-- ... -->
<script>
// stub implementation in case the shell fragment fails to resolve
define("shell", function() { return stub; });
</script>
</head>
<body>
<fragment src="shell.example.com"></fragment>
FROM ubuntu:xenial-20160525
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 575159689BEFB442
RUN echo "deb http://download.fpcomplete.com/ubuntu xenial main"|tee /etc/apt/sources.list.d/fpco.list
RUN apt-get update
RUN apt-get install -y stack
RUN useradd -m -d /home/docker docker
USER docker
export default function endlessContainer() {
'ngInject';
return {
restrict: 'A',
scope: {
'endlessContainer': '&'
},
link: function (scope, element, attrs) {
element.bind('scroll', function() {
require "tco"
require "rmagick"
img = Magick::Image::read(ARGV[0]).first
img.each_pixel do |pixel, col, row|
c = [pixel.red, pixel.green, pixel.blue].map { |v| 256 * (v / 65535.0) }
pixel.opacity == 65535 ? print(" ") : print(" ".bg c)
puts if col >= img.columns - 1
end
@jmaicher
jmaicher / gist:5a5230e2a7699d4fd30b
Created May 9, 2015 10:17
(De-)serialize Plain Old Python Objects (POPOs) with Django Rest Framework
# encoding: utf-8
from __future__ import absolute_import, unicode_literals
import logging
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
log = logging.getLogger(__name__)
@jmaicher
jmaicher / mutate.py
Last active August 9, 2016 20:59
Mutation testing: Hacking python ASTs for fun and profit
import ast, _ast, copy
class Mutator(ast.NodeTransformer):
MUTATIONS = [
# (FromOp, ToOp)
(_ast.Or, _ast.And),
(_ast.And, _ast.Or)
]
def mutate(self, root, mutation):
@jmaicher
jmaicher / index.html
Last active August 29, 2015 13:57
Example: Nested hammer.js instances
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<style>
#foo, #bar { background-color: rgba(1,1,1,.5); }
#foo { height: 100px; padding: 100px; }
#bar { height: 100px; }
</style>
@jmaicher
jmaicher / 2014.clj
Created January 3, 2014 11:52
Produce the number 2014 without any numbers in your source code. Not very short, but whatever :-) http://codegolf.stackexchange.com/questions/17005/produce-the-number-2014-without-any-numbers-in-your-source-code
(let [ I-WISH (fn [x] (* x (mod (int \#) (int \!))))
YOU-A (fn [x] (reduce + (map int x)))]
(I-WISH (YOU-A [\H \A \P \P \Y \N \E \W \Y \E \A \R \) \)])))
@jmaicher
jmaicher / Database.scala
Last active December 27, 2015 16:49
Problem with play 2.2.1 and play-slick 0.5.0.8 when using the cake pattern as seen in the computer-database sample.
package lib.data
import play.api.db.slick.Config.driver.simple._
// Inspired by: http://bit.ly/HL0y7u
private[data] trait DAO extends ReviewersComponent with ProposalsComponent with ValuationsComponent {
val Reviewers = new Reviewers
val Proposals = new Proposals
val Valuations = new Valuations
}
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
Builder.load_string('''
<MyContainer>:
MyWidget: