Skip to content

Instantly share code, notes, and snippets.

View Boldewyn's full-sized avatar

Manuel Strehl Boldewyn

View GitHub Profile
@Boldewyn
Boldewyn / cssgrep.sh
Last active March 20, 2023 13:49
cssgrep prints the part of HTML files, that match a given CSS selector. Solution based on this answer on StackOverflow: http://stackoverflow.com/a/14187086/113195
#!/bin/bash
function _usage() {
cat <<USAGE
usage: $(basename $0) PATTERN [FILES]
Print the HTML that matches the CSS selector PATTERN.
USAGE
}
@Boldewyn
Boldewyn / mdshow
Created December 16, 2012 19:38
Show a Markdown file rendered in the browser. The `markdown` program as well as `base64` must be installed. Assumes, that `x-www-browser` is correctly configured.
#!/bin/bash
MDFILE=$1
x-www-browser $(markdown "$MDFILE" | base64 -w0 | \
cat <(echo -n "data:text/html;charset=UTF-8;base64,") -)
@Boldewyn
Boldewyn / install.php
Created September 13, 2021 11:42 — forked from tschoffelen/install.php
A simple PHP script that automatically downloads and unzips the latest version of Wordpress in the current directory (./), so that I don't have to download it and upload it to my server through FTP manually.
<?php
echo '<pre>';
echo '<span style="color:blue">DOWNLOADING...</span>'.PHP_EOL;
// Download file
file_put_contents('wp.zip', file_get_contents('https://wordpress.org/latest.zip'));
$zip = new ZipArchive();
$res = $zip->open('wp.zip');
if ($res === TRUE) {
@Boldewyn
Boldewyn / Proposal for CSS :for() pseudo-class.md
Last active January 21, 2021 19:33
CSS Selectors to Match `label` Elements

CSS Selectors to Match label Elements

<label> elements are notoriously hard to select with CSS in any non-trivial mark-up structure, when the state of their control is to be taken into account. Consider these frequent cases, where it is not possible to reach the label element with CSS selectors, when the corresponding input state is relevant:

1. <label><input> Input inside label</label>

2. <tr>
    <td><input></td>
 Good ol' tables
@Boldewyn
Boldewyn / functions.php
Created July 7, 2020 14:31 — forked from sirbrillig/functions.php
Post file using wp_remote_post in WordPress
<?php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array(
'name' => 'value',
);
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,
);
#!/bin/bash
set -euo pipefail
FIRST="${1:-}"
SECOND="${2:-}"
CURL="curl"
CURL_FLAGS="${CURL_FLAGS:--sSki}"
@Boldewyn
Boldewyn / piwik-update.sh
Created June 16, 2017 22:26 — forked from szepeviktor/piwik-update.sh
Piwik automatic update - bash script
#!/bin/bash
# Start this scipt above the /piwik directory.
# We assume that the webserver runs under www-data.
# download & verify
wget -nv "http://builds.piwik.org/piwik.zip" || exit 1
wget -nv "http://builds.piwik.org/piwik.zip.asc" || exit 2
gpg --verify piwik.zip.asc || exit 3
@Boldewyn
Boldewyn / post-merge
Created March 2, 2017 08:49 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@Boldewyn
Boldewyn / hyperform.js
Last active February 2, 2017 22:23
Hyperform built with Webpack 2
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@Boldewyn
Boldewyn / json.ne
Created January 26, 2017 20:51
A JSON grammar for nearley
@{%
const merge = d => d.join('');
const nth = n => d => d[n];
%}
@builtin "whitespace.ne"
json -> _ object _ {% nth(1) %}
| _ array _ {% nth(1) %}