Skip to content

Instantly share code, notes, and snippets.

View BjornW's full-sized avatar

BjornW BjornW

View GitHub Profile
@BjornW
BjornW / correct_is_home.php
Created November 9, 2010 15:49
Trying to fix WordPress' is_home functionality with custom post types [DOES NOT WORK]
/**
* Makes sure the context is correct and set ordering to use custom fields
*
* Courtesy of Matt Wiebe's SD_Register_Post_Type class
* http://somadesign.ca
*
* @access public
* @return void
*/
function context_fixer()
@BjornW
BjornW / gist:1235290
Created September 22, 2011 16:41
remkus-edited
/**
* Adds a body class 'not-logged-in' for guests.
*
* We use this because X
*
* @author Remkus de Vries
* @link http://remkusdevries.com/when-sharing-wordpress-related-code-snippets-i-can-haz-standards-please/
* @param array $classes Existing body classes
* @return array Amended body classes
*/
@BjornW
BjornW / RandomStringTask.php
Created January 24, 2012 16:32
A first attempt at writing a Phing Task
<?php
require_once "phing/Task.php";
class RandomStringTask extends Task {
/**
* The length of the random string
*/
private $length = 32;
@BjornW
BjornW / check-extensions.php
Created May 9, 2012 13:18
Check which PHP extensions are loaded
<?php
$extensions = get_loaded_extensions();
if( is_array($extensions) && sizeof($extensions) ) {
natcasesort($extensions);
foreach($extensions as $ext) {
echo "$ext <br />";
}
}
?>
@BjornW
BjornW / solarize.sh
Created May 13, 2012 15:13 — forked from codeforkjeff/solarize.sh
shell script for setting gnome-terminal color palette to use Solarized theme
#!/bin/sh
#
# Shell script that configures gnome-terminal to use solarized theme
# colors. Written for Ubuntu 11.10, untested on anything else.
#
# Solarized theme: http://ethanschoonover.com/solarized
#
# Adapted from these sources:
# https://gist.github.com/1280177
# http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@BjornW
BjornW / noise.sh
Last active February 3, 2024 06:02 — forked from rsvp/noise.sh
noise : relaxing ambient Brown noise generator (cf. white noise) | Linux bash script using sox | CogSci notes
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-10-04
#
# _______________| noise : ambient Brown noise generator (cf. white noise).
#
# Usage: noise [minutes=59] [band-pass freq center=1786] [wave]
# ^minutes can be any positive integer.
# Command "noise 1" will display peak-level meter.
#
# Dependencies: play (from sox package)
@BjornW
BjornW / removeSpammers.php
Created October 23, 2012 20:02
Remove spammers from Mediawiki in combination with PHPMyAdmin export as php array function. Build a query to determine the users to remove and export the user_ids.
<?php
/** Hack to remove spammers, based on removeUnusedAccounts.php by **/
/** BjornW <burobjorn@burobjorn.nl> **/
/** Original header info follows **/
/**
* Remove unused user accounts from the database
* An unused account is one which has made no edits
*
* This program is free software; you can redistribute it and/or modify
@BjornW
BjornW / say-time.sh
Created November 1, 2012 13:01
Speaking time
#!/bin/bash
# depends on speech dispatcher http://packages.ubuntu.com/precise/speech-dispatcher
# use crontab to run this script automatically every X times when you want to know the time
current=`date --date="now" +%H:%M`;
spd-say --pitch -90 --rate -30 --voice-type male1 "The current time is: $current"
@BjornW
BjornW / mkdir_by_file
Created September 8, 2013 10:28
Create multiple directories based on file input. Each line is one directory to create. In this case used to create a directory per site.
#!/bin/bash
# quick & dirty script to create multiple directories
# Load a file with one site per line
list=$(<sites.txt)
# add the list of sites to an array
myarray=( $list )
# for every site in the array create a directory