Skip to content

Instantly share code, notes, and snippets.

@Fryie
Fryie / search.js
Created June 13, 2014 12:05
CSS Search
// Modified from http://redotheweb.com/2013/05/15/client-side-full-text-search-in-css.html
// you'll need to add type='text/css' to the style tag in the HTML for this to work in IE<9
(function() {
var addslashes = function(str) {
return (str + '')
.replace(/[\\"']/g, '\\$&')
.replace(/\u0000/g, '\\0');
};
@emilbjorklund
emilbjorklund / breakpoints_via_css.html
Created April 24, 2012 16:03
Width detection via sneaky CSS rules
<!DOCTYPE html>
<!--[if IE 8]> <html lang="sv-SE" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="sv-SE" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Breakpoint detection test</title>
<style type="text/css" media="screen">
@media screen and (min-width: 320px) {
#page:after {
content: 'smallest'; /* represent the current width-bracket */
module curved_triangle(r, pitch, separation, gap) {
assign(num_steps = 36)
assign(top_d = pitch - 2 * separation)
assign(bottom_d = triangle_tip_width)
assign(delta = top_d - bottom_d)
assign(d_incr = delta / (num_steps-1))
assign(b_incr=116/(num_steps - 1))
render()
for (i=[0:(num_steps-2)]) {
hull() {
// Pin for the LED
int LEDPin = GREEN_LED;
int speakerPin = P1_1;
// Pin to connect to your drawing
int button1N = 4;
int button2N = 5;
// This is how high the sensor needs to read in order
// to trigger a touch. You'll find this number
// by trial and error, or you could take readings at
@dy
dy / saveAs.js
Created March 18, 2017 21:37
Open data-uri in new window
function saveAs(arrayBuffer, fileName, mime) {
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(window.TEMPORARY, arrayBuffer.byteLength, function(fs) {
fs.root.getFile(fileName, {create: true}, function(fileEntry) {
fileEntry.createWriter(function(writer) {
var dataView = new DataView(arrayBuffer);
var blob = new Blob([dataView], {type: 'font/opentype'});
writer.write(blob);
writer.addEventListener('writeend', function() {
ngOnInit() {
this.filteredRoutes$ = from(this.routes).pipe(
concatMap((route) => {
// handle if nothing is in canActivate
if (!route.canActivate || !route.canActivate.length) {
// create an object that has the route and result for filtering
return of({ route, result: true });
}
return from(route.canActivate).pipe(
const RE_YEAR = re`(?<year>[0-9]{4})`;
const RE_MONTH = re`(?<month>[0-9]{2})`;
const RE_DAY = re`(?<day>[0-9]{2})`;
const RE_DATE = re`${RE_YEAR}-${RE_MONTH}-${RE_DAY}`;
const matchObj = RE_DATE.exec('1999-12-31');
const year = matchObj.groups.year; // 1999
const month = matchObj.groups.month; // 12
const day = matchObj.groups.day; // 31
@ivenmarquardt
ivenmarquardt / lazy-evaluation.js
Last active May 18, 2018 20:37
Lazy evaluation, lazy getters, eta reduction, function composition, implicit thunks through deferred type
// Lazy Getters
/* What enables Tail Recursion Modulo Cons in Javascript is a thunk in Weak Head Normal Form.
An expression in weak head normal form has been evaluated to the outermost data constructor,
but contains sub-expressions that may not have been fully evaluated. In Javascript only thunks
can prevent sub-expressions from being immediately evaluated. */
const cons = (head, tail) => ({head, tail});
@pudgereyem
pudgereyem / _hidden-scrollbar.sass
Created October 13, 2016 12:43
Hidden Scrollbar
/*
* Hidden scrollbar
*/
::-webkit-scrollbar
width: 0px
::-webkit-scrollbar-track-piece
background-color: transparent
-webkit-border-radius: 6px
@qwtel
qwtel / createTween.js
Last active November 6, 2018 18:18
rxjs5 tweening helper function. Creates a tween observable that emits samples from an easing function via requestAnimationFrame.
import { Observable } from 'rxjs/Observable';
/**
* Creates an observable that emits samples from an easing function on every animation frame
* for a duration `d` ms.
*
* The first emitted value will be a sample form the easing function at `t = 0`,
* and the last emitted value is guaranteed to be the easing function at `t = d`.
*
* It can be used with any of [Robert Penner's easing functions](http://robertpenner.com/easing/),