Skip to content

Instantly share code, notes, and snippets.

View webercoder's full-sized avatar
🌴

Mike Weber webercoder

🌴
  • Sydney, Australia
  • 08:05 (UTC +10:00)
View GitHub Profile
@webercoder
webercoder / wp-author-import-auto-select.js
Created June 4, 2012 20:33
Auto-select authors for posts during WordPress import. They must already be assigned to the project. Enable jQuery in a plugin or functions.php, and paste this in the browser console.
(function($){
$('#authors li').each(function(key, value) {
var name = $(this).children('strong').first().html();
var re = /\s\([^\)]+\)/gi;
name = name.replace(re, '');
$(this).find('select').first().children('option').each(function(){
if ($(this).html() == name) {
console.log('Comparing ' + $(this).html() + ' to ' + name + ".\n");
$(this).attr('selected', 'selected');
@webercoder
webercoder / cookie-warning.js
Last active July 27, 2021 18:15
Simple, opt-in cookie warning template for GDPR. (Warning: may not be sufficient to meet legal requirements 🤷‍♂️)
@webercoder
webercoder / srcset-generator.sh
Last active December 30, 2020 15:39
Create several sizes of an image for use with the HTML srcset attribute.
#!/bin/bash
function usage {
cat << EOM
Usage: $0 filename size [quality, default: 75] [count, default: 3]
For example:
$0 rad.jpg 1024 75 3
@webercoder
webercoder / index.html
Created August 7, 2013 07:49
A CodePen by Mike Weber. Social Icons with Font Awesome - Horizontal list with font-awesome icons.
<div class="container">
<div class="row">
<div class="span10 offset1">
<div class="social-icons">
<h1>Horizontal Social Icon List</h1>
<ul>
<li><a href="https://twitter.com"><i class="icon-twitter"></i></a></li>
<li><a href="https://facebook.com"><i class="icon-facebook"></i></a></li>
<li><a href="https://instagram.com"><i class="icon-instagram"></i></a></li>
<li><a href="https://pinterest.com"><i class="icon-pinterest"></i></a></li>
#!/bin/bash
# Array with expressions
expressions=("guuuuuuuuuurrrrrrrrrrrr" "cluck cluck cluck" "click" "tick tock")
voices=("Karen" "Diego" "Sara" "Thomas" "Victoria")
# Seed random generator
RANDOM=$$$(date +%s)
# Get random expression...
@webercoder
webercoder / make-number-puzzle.js
Created March 2, 2019 01:01
make-number-puzzle.js
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
function makePuzzle(rows = 5, columns = 5, max = 20) {
const find = getRandomInt(max);
console.log(`Find the number ${find}`);
const puzzle = [];
for (let i = 0; i < rows; i++) {
puzzle[i] = [];
@webercoder
webercoder / copy-iphone-photos.go
Created January 3, 2017 05:29
Recursively find iPhone photos in a directory and copy them to another
package main
import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
@webercoder
webercoder / mtg-resize.sh
Last active January 10, 2016 04:04
Takes MTG CCGHQ XLHQ images, strips the border, and adds a border size of your chosing. Tested with only the unglued basics.
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "Illegal number of parameters"
echo "Usage: $0 directory [border-size]"
exit
fi
if [ ! -z $2 ]; then
border=$2
else
border=65
Moved to https://github.com/weberwithoneb/reddit-random-number-bot/
@webercoder
webercoder / convert_xml_to_json.js
Last active December 20, 2015 07:39
node.js script to convert XML to JSON. Saves a file called converted.json to the input file's directory. Usage: node convert_js_to_json.js filename.xml [pretty]
var xml2js = require("xml2js");
var fs = require("fs");
var path = require("path");
if (process.argv.length < 2)
throw new Exception("Usage: node " + process.argv[1] + " filename [pretty]");
var filename = process.argv[2];
var pretty = (process.argv[3] && process.argv[3] == "pretty" ? true : false);
var outputDirectory = path.dirname(filename) || __dirname;