Skip to content

Instantly share code, notes, and snippets.

View molily's full-sized avatar

Mathias Schäfer molily

View GitHub Profile
@molily
molily / code.js
Created December 2, 2015 08:51
JavaScript flamewars
var treeWalker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
while (treeWalker.nextNode()) {
var node = treeWalker.currentNode;
node.nodeValue = node.nodeValue.replace(/(F|f)ramework/g, '$1lamewar');
}
@molily
molily / README.md
Last active December 2, 2015 09:19
Helpers for testing React / Redux smart components (Jasmine expectations)

In smart components, we’re exporting the original React component class and the Connect wrapper class.

  • There is a test for the smart component class that checks whether mapStateToProps and mapDispatchToProps generate and pass through the expected props.
  • There is another, more conventional test for the dumb component class that tests the rendered DOM tree.

The tests helpers here are used for the smart test.

@molily
molily / bem.sass
Last active August 29, 2015 14:26
BEM helper mixins for Sass
// Mixins for generating Block Element Modifier (BEM) class names.
// See https://css-tricks.com/snippets/sass/bem-mixins/
// They can be nested to produce meaningful classes.
// To create a descendant selector like `.block--modifier .block__element`
// the block needs to be repeated. For example:
// +block(some-block)
//
// +element(some-element)
// color: red
//
@molily
molily / gulpfile.es6
Last active August 29, 2015 14:26
Building a custom D3 with Smash and Gulp
import path from 'path';
import fs from 'fs';
import { Readable } from 'stream';
import es from 'event-stream';
import gulp from 'gulp';
import smash from 'smash';
const SRC_DIR = path.resolve('./src');
const JAVASCRIPTS_SRC_DIR = path.join(SRC_DIR, JAVASCRIPTS_DIR);
@molily
molily / filter.txt
Last active June 7, 2022 05:13
SVG filter: White drop shadow
<filter id="dropshadow" x="0" y="0" width="200%" height="200%">
<feColorMatrix in="SourceAlpha" type="matrix"
values="-1 0 0 0 1, 0 -1 0 0 1, 0 0 -1 0 1, 0 0 0 1 0"
result="matrix"/>
<feGaussianBlur in="matrix" stdDeviation="2" result="blur"/>
<feComposite in="SourceGraphic" in2="blur" operator="over"/>
</filter>
@molily
molily / _accessible-hide.sass
Created February 23, 2015 16:12
Accessible info tooltip
@charset 'UTF-8'
// Hide and show content accessibly. The content is visually hidden, but
// screen readers and other assistive technology should still read it.
// http://snook.ca/archives/html_and_css/hiding-content-for-accessibility
@mixin accessible-hide
position: absolute
// Without any top/right/bottom/left declaration, the element would be
// positioned at its position in the normal flow. This may cause scrollbars
// so we move it to top/left position of the containing block.
@molily
molily / util.coffee
Last active August 29, 2015 14:06
Custom memoizer
util =
# This is faster than working with `arguments`
# \u001E is a ASCII Record Separator
stringify2: (a, b) ->
"#{a}\u001E#{b}"
stringify3: (a, b, c) ->
"#{a}\u001E#{b}\u001E#{c}"
stringify4: (a, b, c, d) ->
"#{a}\u001E#{b}\u001E#{c}\u001E#{d}"
@molily
molily / fullscreen.coffee
Last active August 29, 2015 13:57
My Attempt on the Fullscreen API
# https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
# http://msdn.microsoft.com/en-us/library/ie/dn265028(v=vs.85).aspx
# https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
# https://developer.apple.com/library/safari/documentation/WebKit/Reference/ElementClassRef/Element/Element.html#//apple_ref/javascript/instm/Element/webkitRequestFullScreen
# http://updates.html5rocks.com/2011/10/Let-Your-Content-Do-the-Talking-Fullscreen-API
# See also https://github.com/sindresorhus/screenfull.js for a more complete library.
doc = document
@molily
molily / apps-berlin-js.md
Last active October 7, 2015 19:48
Slides of the apps.berlin.js meetups

The apps.berlin.js meetup

apps.berlin.js is a Berlin.js spin-off with a special focus on JavaScript-driven web applications (“HTML5 apps”), desktop browser apps as well as mobile apps and games written in JavaScript. Here you can find the slides and additional links of all past talks. Please fork this Gist to add more info!

First meetup on May 10th 2012