Skip to content

Instantly share code, notes, and snippets.

@joshbetz
joshbetz / Todo.txt to Omnifocus
Created October 22, 2011 21:40
Import todo.txt file to Omnifocus
set p to "<Path to todo.txt>"
set l to paragraphs of (do shell script "grep . " & p)
do shell script ">" & p
tell app "OmniFocus" to tell document 1
repeat with v in l
make new inbox task with properties {name:v}
end repeat
end tell
@joshbetz
joshbetz / possibly_related_posts.php
Created September 14, 2012 22:25
Suggest posts on 404 pages
@joshbetz
joshbetz / pretty-code-editor.php
Created September 18, 2012 16:31
Add basic <tab>ing ability
<?php
class Pretty_Code_Editor {
function __construct() {
add_action( 'admin_print_styles', array( $this, 'editor_styles' ) );
add_action( 'admin_print_footer_scripts', array( $this, 'tabs' ) );
}
function editor_styles() { ?>
@joshbetz
joshbetz / UnfullscreenAll.scpt
Created October 7, 2012 23:12
AppleScript for unfullscreening apps (only works with apps that support AppleScript)
tell application "System Events"
repeat with p in (every process whose visible is true)
try
my setFullScreen(displayed name of p, 0, true)
end try
end repeat
end tell
(*
Sets the fullscreen status for either the front window or all windows of the specified, *AppleScript-enabled* application.
@joshbetz
joshbetz / .zshrc
Last active December 10, 2015 19:19
A version of ssh-copy-id for the .bashrc file on your Mac.
ssh-copy-id() {
USER=$(whoami)
USAGE="Usage: `basename $0` [-i FILE] user@host"
FILE="$HOME/.ssh/id_rsa.pub"
if [ $# -lt 1 ]; then
echo "$USAGE"
fi
@joshbetz
joshbetz / Hazel-secure-files.applescript
Last active December 12, 2015 00:49
Secure files with Hazel
-- Set password and file name
set itemPath to quoted form of (POSIX path of theFile)
set passwd to do shell script "openssl rand -base64 32"
set hash to do shell script "openssl sha1 " & itemPath & " | awk -F'= ' '{print $2}'"
-- set file name
tell application "Finder"
set file_name to name of theFile
set file_name to text 1 thru ((offset of "." in file_name) - 1) of file_name
set file_ext to name extension of theFile
@joshbetz
joshbetz / nav_walker_nav_menu.php
Last active December 12, 2015 01:08
WordPress nav menu without lists.
<?php
class v12_Walker_Nav_Menu extends Walker_Nav_Menu {
function __construct() {
add_filter( 'wp_nav_menu_args', array( __CLASS__, 'items_wrap' ) );
}
/**
* @see wp_nav_menu()
@joshbetz
joshbetz / wordpress.pp
Created June 8, 2013 03:14
Puppet script to configure a server to serve WordPress
Exec { path => "/bin:/usr/bin:/usr/local/bin:/usr/sbin" }
stage { 'pre': before => Stage['main'] }
class { 'pre': stage => pre }
class pre {
exec { 'apt-get update': }
}
package { 'nginx': ensure => present }
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@joshbetz
joshbetz / hidden_posts.php
Last active December 31, 2015 18:59
Hide a limited number of specified posts from the homepage in WordPress.
<?php
/**
* Plugin Name: Hidden Posts
* Description: Hide posts on the home page.
* Version: 0.1
*/
/**
* Hidden Posts
*