Skip to content

Instantly share code, notes, and snippets.

View annalinneajohansson's full-sized avatar
🐱

Anna annalinneajohansson

🐱
  • Frontwalker Group AB
  • Sweden
  • 10:05 (UTC +02:00)
View GitHub Profile
@annalinneajohansson
annalinneajohansson / dropbox-autostart.sh
Last active August 29, 2015 14:20
Bash script to autostart dropbox daemon if it exists with a delay set in seconds. Usage $ dropbox <time in seconds>.
#!/bin/bash
## How long to delay the start of Dropbox
DELAY=$1
## If no delay is set default to 10 seconds
: ${DELAY:=10}
## If dropbox exists then start it
if type "dropbox" > /dev/null; then
echo "Starting Dropbox in ${DELAY} seconds..."
@annalinneajohansson
annalinneajohansson / superstart.css
Created April 26, 2015 07:06
CSS for Firefox addon SuperStart
#sites,
#folder {
font-family: "Ubuntu Mono",monospace;
}
.site-title-text {
font-weight:400!important;
}
#folder {
padding: 1em 0 3em;
@annalinneajohansson
annalinneajohansson / new_gist_file_0
Last active August 29, 2015 14:18
Search and replace string apple with orange in php files recursively in the directory you're in. From https://glassonionblog.wordpress.com/2013/02/04/search-n-replace-text-in-multiple-files-recursively/
find . -name "*.php" -print | xargs sed -i 's/apple/orange/g'
#!/usr/bin/env python
import os
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
from paramiko.config import SSHConfig
cfgdir = os.getenv("HOME")+"/.ssh"
cfgfile = cfgdir+"/config"
@annalinneajohansson
annalinneajohansson / clean_url.php
Last active August 29, 2015 14:16
Add defer to enqueued javascripts in WordPress
<?php
// clean_url can be used in versions prior to 4.1
add_filter( 'clean_url', function( $url ) {
if( is_admin() ) {
return $url;
}
if ( FALSE === strpos( $url, '.js' ) ) {
return $url;
@annalinneajohansson
annalinneajohansson / do-update.php
Last active August 29, 2015 14:16
Do Automatic Updates
<?php
/*
Plugin Name: Do Automatic Updates
Plugin URI:
Description: Do automatic updates on everything; themes, plugins, translations and core (both minor and major updates).
Author: Anna Johansson
Version: 1
Author URI: http://annalinneajohansson.com
*/
@annalinneajohansson
annalinneajohansson / auto_core_update_email.php
Created February 26, 2015 08:12
Change the recipient email for auto_core_update_email
<?php
function hip_filter_auto_update_email( $email ) {
$email['to'] = '[email protected]';
return $email;
}
add_filter( 'auto_core_update_email', 'hip_filter_auto_update_email', 1 );
@annalinneajohansson
annalinneajohansson / pinboard-hearts-wp.php
Last active August 29, 2015 14:15
Seriously... Can anyone see why my do_settings_sections fails to print? I'm blind, appearantly. *scratches head* #wordpress #do_settings_sections
<?php
define( 'MENU_SLUG', 'pinboard-hearts-wp' );
add_action( 'admin_menu', 'pinbheartswp_admin_menu', 10 );
function pinbheartswp_admin_menu() {
/*
add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function);
*/
add_options_page( __('Pinboard &hearts; WordPress Options', 'pinbheartswp' ), __('Pinboard &hearts; WP', 'pinbheartswp' ), 'manage_options', MENU_SLUG, 'pinboard_hearts_wordpress_options' );
}
@annalinneajohansson
annalinneajohansson / force-lowercase.sh
Created February 9, 2015 20:16
Make all the files in the current directory lower case
#!/bin/bash
for i in * ; do mv $i `echo $i | tr [A-Z] [a-z]` ; done
@annalinneajohansson
annalinneajohansson / current-desktop.sh
Last active February 8, 2020 02:50
Match the first character of $desktop
#!/bin/bash
desktops=$(wmctrl -d | awk '{ print $2":"$10 }')
for desktop in $desktops
do
# example output of $desktop: -Work or *Leisure
if [[ $(echo $desktop | cut -c1-1) = '*' ]]; then
echo $desktop | cut -c3-
fi
done