Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@media print {
h2, h3, h4, h5, h6 { break-after: avoid-page; }
img, svg, table, canvas { break-inside: avoid; }
a::after { content: " (" attr(href) ")"; }
}
<?php
function spintax($text) {
$max = substr_count($text, '}');
$i = 0;
$currentPos = 0;
while ($currentPos < strlen($text) && ($endPos = strpos($text, '}', $currentPos)) !== false) {
if ($i++ > $max) break;
<?php
// Small hackable Mustache inspired templating
function alaMustache($template, array $values = []){
$pattern = '/{{(?<BOOLEAN>#|\^)\s*(?P<KEY>[\w\.-]+)\s*}}(?P<BLOCK>.*?)({{\/\s*\2\s*}})/ms';
$template = preg_replace_callback($pattern, function (array $matches) use ($values) {
if ($matches['BOOLEAN'] === '#') {
if (array_key_exists($matches['KEY'], $values) && !empty(trim($values[$matches['KEY']]))) {
return $matches['BLOCK'];
html{
filter: invert(1) hue-rotate(.5turn);
}
// extending https://raw.githubusercontent.com/dcodeIO/node.js-closure-compiler-externs/master/process.js
// use together with
// @externs_url https://gist.githubusercontent.com/mathiasrw/a5696b591b439e55c052e9399028a274/raw/f878549e25646d0c9b2e5191b9c455ac2f662a0c/Closure%2520compiler%2520node%2520externs.js
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@mathiasrw
mathiasrw / npm-audit.sh
Created May 19, 2018 19:02
Get commands to fix npm audit
npm audit | ggrep -oP '(?<=# Run..).+(?=..to resolve)'
@mathiasrw
mathiasrw / hash160-to-base58.go
Created January 25, 2018 09:48
Convert hash160 hex strings to bitcoin bae58 address
package main
import (
"bufio"
"encoding/hex"
"fmt"
"github.com/btcsuite/btcutil/base58"
"log"
"os"
)
#!/usr/bin/env node
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(data) {
process.stdout.write(data);
});
@mathiasrw
mathiasrw / IotaSeed.sh
Created December 3, 2017 00:53
Generate IOTA seed
env LC_CTYPE=C tr -dc "A-Z0-9" < /dev/urandom | fold -w 81 | head -n 1 > myIotaSeed.txt
jQuery('#details-module').hide();
jQuery('#viewissuesidebar').hide();
jQuery('.command-bar').hide();
jQuery('#page').replaceWith(jQuery('.content'));
jQuery('.issue-view').css('overflow-y','visible');