Skip to content

Instantly share code, notes, and snippets.

View jancbeck's full-sized avatar

Jan Beck jancbeck

View GitHub Profile
@jancbeck
jancbeck / safari_reading_list_2_pocket_html.py
Created August 30, 2023 16:04
Takes a Safari exported reading list JSON and converts to Pocket's export format
from datetime import datetime
from bs4 import BeautifulSoup
# Create a BeautifulSoup object with the basic HTML structure
html_structure = '''
<!DOCTYPE html>
<html>
<head>
<title>Reading List</title>
</head>
@jancbeck
jancbeck / new-uberspace.sh
Last active March 16, 2022 08:17
Setup Uberspace 7
# switch to zsh shell
# https://manual.uberspace.de/en/basics-shell.html
chsh --shell /bin/zsh
# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# remove existing .zshrc
rm -rf .zshrc
@jancbeck
jancbeck / wp-role-bodyclass.php
Last active January 15, 2022 19:34
WordPress: Add user role class to body tag
<?php
// Add role class to body
function add_role_to_body($classes) {
foreach (wp_get_current_user()->roles as $user_role) {
$classes[] = 'role-'. $user_role;
}
return $classes;
});
add_filter('body_class','add_role_to_body');
git clone --bare git@github.com:jancbeck/dotfiles.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
@jancbeck
jancbeck / redis.php
Created October 2, 2015 16:29
Redis Cache for Kirby. Requires Predis.
<?php
namespace Cache\Driver;
use Cache\Driver;
/**
* Redis
*
* @package Kirby Redis
@jancbeck
jancbeck / package.json
Created May 10, 2018 11:28
Dynamically search and replace server logs when they change. Uses gulp.js and node
{
"name": "process-log",
"version": "1.0.0",
"description": "Dynamically search and replace server logs when they change",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"logs"
@jancbeck
jancbeck / functions.php
Created April 8, 2017 08:36
Uses the "New Customer" email template by WooCommerce when a new user is created via the WP Job Manager. Add to your themes functions.php
<?php
function wp_job_manager_notify_new_user( $user_id, $password ){
global $wp_version;
$wc_emails = WC_Emails::instance();
if ( empty($wc_emails)) {
return;
}
@jancbeck
jancbeck / password-protect.php
Created September 27, 2016 15:41
Automatically password protect all new custom post types in WordPress
<?php
add_filter( 'wp_insert_post_data', function( $data, $postarr ){
if ( 'book' == $data['post_type'] && 'auto-draft' == $data['post_status'] ) {
$data['post_password'] = wp_generate_password();
}
return $data;
}, '99', 2 );
@jancbeck
jancbeck / install.md
Last active February 2, 2017 09:39
Documenting the process of setting up my local environment for web design and development (OS X 10.9 Mavericks)

User Home Directory

Restore home folder from backup. You better have a backup.

Important files and folders:

  • ~/.bash_profile
  • ~/.ssh/
  • ~/Library/Preferences/

Keybase proof

I hereby claim:

  • I am jancbeck on github.
  • I am jancbeck (https://keybase.io/jancbeck) on keybase.
  • I have a public key ASBC8CHbwPT11Jz5cP_InKjVuD8YZTxpWsJGqPTkiBWy6go

To claim this, I am signing this object: