Skip to content

Instantly share code, notes, and snippets.

View annalinneajohansson's full-sized avatar
🐱

Anna annalinneajohansson

🐱
  • Frontwalker Group AB
  • Sweden
  • 00:55 (UTC +02:00)
View GitHub Profile
@bhwebworks
bhwebworks / Embed Gists with a URL
Last active October 14, 2023 14:38
Add to functions.php or a mu-plugin
/**
* Embed Gists with a URL
*
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*
@jakeasmith
jakeasmith / mysqldump.sh
Last active June 28, 2021 20:07
A quick snippet for doing a compressed mysql dump with a pv to monitor progress
mysqldump [database] | pv | gzip -c > [file].sql.gz
@gistwebdev
gistwebdev / vhost
Last active February 3, 2023 05:19
Script to create apache2 virtual hosts
#!/bin/bash
#
# Display usage info
vhost-usage() {
cat <<"USAGE"
Usage: vhost [OPTIONS] <name>
-h|--help this screen
-pub to create the webhost root in ~/www/name/public/
-url to specify a local address, default is http://name.local
@bainternet
bainternet / gist:5186104
Created March 18, 2013 10:00
delete all post revisions and all associated meta , comments, attachments and taxonomies
<?php
add_action('wp_footer','cleanup_revisions');
function cleanup_revisions(){
global $wpdb;
$sql = "SELECT `ID`
FROM ($wpdb->posts)
WHERE `post_type` = 'revision'
ORDER BY `ID` DESC";
$results = $wpdb -> get_results($sql,'ARRAY_N');
if($results){
@bainternet
bainternet / tax_cpt_filter_class.php
Created February 6, 2013 13:29
Simple class to add custom taxonomy dropdown to a custom post type admin edit list
<?php
if (!class_exists('Tax_CTP_Filter')){
/**
* Tax CTP Filter Class
* Simple class to add custom taxonomy dropdown to a custom post type admin edit list
* @author Ohad Raz <admin@bainternet.info>
* @version 0.1
*/
class Tax_CTP_Filter
{
@spivurno
spivurno / gw-multi-page-navigation.php
Last active February 4, 2022 09:48
Gravity Wiz // Gravity Forms // Multi-page Form Navigation
<?php
/**
* Gravity Wiz // Gravity Forms // Multi-page Navigation
*
* Adds support for navigating between form pages by converting the page steps into page links or creating your own custom page links.
*
* @version 2.1
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/multi-page-navigation/
#!/bin/bash
album=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "album"|egrep -v "album"|egrep -v "array"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
artist=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$`
title=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
echo $artist " - " $album " - " $title;
@daltonrooney
daltonrooney / file-upload-handler.php
Created February 4, 2012 13:29
Multi-file WordPress uploads from the front-end
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@martg0
martg0 / pyrss2gen-example.py
Created February 11, 2010 15:57
PyRSS2Gen example
"""
example of the usage of pyrss2gen library.
URL: http://www.dalkescientific.com/Python/PyRSS2Gen.html
"""
import datetime
import PyRSS2Gen
rss = PyRSS2Gen.RSS2(
title = "Andrew's PyRSS2Gen feed",