Skip to content

Instantly share code, notes, and snippets.

@derhasi
derhasi / build.sh
Last active October 14, 2019 13:43
#!/usr/bin/env bash
set -e
# Create build commit by pulling the remote branch and copying over the files from the project build
# which contain data in the docroot we usually do not commit.
LAST_COMMIT_INFO=$(git log -1 --pretty="[%h] (%an) %B")
LAST_COMMIT_USER=$(git show -s --format="%an")
LAST_COMMIT_USER_EMAIL=$(git show -s --format="%ae")
CURRENT_REV=$(git rev-parse --abbrev-ref HEAD)
# We store directory values, so we can restore them later.
@edenwaith
edenwaith / CountOpenSafariTabs.scpt
Last active January 7, 2024 13:01
AppleScript: Count the number of open tabs in Safari
-- CountOpenSafariTabs.scpt
-- Author: Chad Armstrong
-- Date: 13 May 2016
-- Description: Count the number of open tabs in Safari
-- To run from CLI: osascript CountOpenSafariTabs.scpt
tell application "Safari"
--Variables
set winlist to every window
@imjasonh
imjasonh / markdown.css
Last active May 24, 2024 22:56
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@fitnr
fitnr / readme.md
Last active December 17, 2018 09:14
Bookmarklet for switching between two versions of a site, say dev and production, or localhost and dev

How to

Change the left_domain_name and right_domain_name variables to reflect your project. If your sites have exactly matching URL schemas (where localhost/my/path is always equivalent to production.com/my/path), you can ignore that big comment block. If not, check it out and rewrite the two functions to fit your setup.

Compress the javascript, say with UglifyJS.

Urlencode the result, say with this tool.

Add javascript: to the front and save it as a bookmark. Depending on your browser, the easiest way to do this might be to make a new bookmark for a random page and then edit both the address and name.

@dlh01
dlh01 / distribute_user.sh
Last active June 27, 2023 20:25
WP-CLI: Add a user to all sites in a network
#!/bin/bash
# Usage: ./distribute_user.sh [username] [role]
ARGS="$@"
echo "Adding user $1 as $2 to all sites"
SITES=$(wp site list --field=url --format=csv)
for site in $SITES
do
@mstoltenburg
mstoltenburg / font-size-range.scss
Last active May 31, 2017 19:35
min-max responsive font size
// Variables
$base-font-size: 16px;
$min-screen-size: 320px;
// Utility functions
/**
* Get font-size in point size (em)
@mrcoles
mrcoles / detect-autoplay.js
Created May 8, 2013 01:25
A script to detect browser support for the autoplay attribute on the HTML5 Audio element.
// Detect autoplay
// ---------------
// This script detects whether the current browser supports the
// autoplay feature for HTML5 Audio elements, and it sets the
// `AUTOPLAY` variable accordingly.
// Used in the Meteor app [PicDinner](http://picdinner.com)
@pjkix
pjkix / css-stats-ack.sh
Created October 5, 2011 21:39
shell script to generate some css file statistics
#!/bin/bash
## v1.0.6
## this script will gernerate css stats
### example output
# CSS STATS
# ----------
# Floats: 132
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",