Skip to content

Instantly share code, notes, and snippets.

View sheabunge's full-sized avatar
😴

Shea Bunge sheabunge

😴
View GitHub Profile
<?php
const ACTION_NAME = 'shea_ajax_example';
$handler = function () {
check_ajax_referer( ACTION_NAME );
wp_send_json_success( 'it works!' );
};
@sheabunge
sheabunge / wp-loop.php
Last active March 18, 2020 08:45
WordPress loop generator function, as described at https://wpscholar.com/blog/creating-better-wordpress-loop/
<?php
/**
* Simplifies the WordPress loop.
*
* @param WP_Query|WP_Post[] $iterable
*
* @return Generator
*/
function wp_loop( $iterable = null ) {
@sheabunge
sheabunge / flashget.sh
Created September 29, 2016 12:55
Shell script for retrieving flash videos from Linux cache. Tested on Ubuntu.
#!/usr/bin/env bash
pids=$(ps ax | grep -iE 'chrome|firefox|vivaldi' | grep -i flash | awk '{ print $1 }')
for pid in $pids
do
file -L /proc/$pid/fd/* | grep -iE 'video|media|mp4|flash' | cut -f 1 -d ':'
done
@sheabunge
sheabunge / flashget
Last active March 19, 2016 06:44
Bash script for retrieving flash videos from Firefox/Chrome cache
#!/usr/bin/env bash
for process in chrome firefox
do
pid=$(ps ax | grep -i $process | grep -i flash | cut -f 1 -d ' ')
file -L /proc/$pid/fd/* | grep -iE 'video|media|mp4|flash' | cut -f 1 -d ':'
done
@sheabunge
sheabunge / Getting Started with Drupal and Drush.md
Last active January 25, 2016 12:21
Getting Started with Drupal and Drush

Getting Started with Drupal and Drush

As part of participating in Google Code-In this year, I am introducing myself to Drupal, as an excersise to see how it works and what it offers as an alternative to WordPress for building content managed websites. As part of this process, I am learning how to install Drupal on an Ubuntu-powered web server running nginx and PHP 7.

To make installing and managing Drupal much easier, we will be shell interface for Drupal known as Drush. Drush is an incredibly useful tool, allowing you to perform a number of various tasks from the command line as a faster and more efficient alternative to using the graphical web based administration.

Setting up the server

First step is to install a web server for Drupal to run on. The first component of this is nginx, a fast and effecient server which can integrate with PHP. It is avaliable in the default Ubuntu repostories and can be installed like so:

sudo apt install nginx

@sheabunge
sheabunge / autoload.php
Last active October 9, 2024 00:31
Basic PHP class autoloader that follows the WordPress coding standards for class names and class filenames
<?php
namespace Shea\Example_Plugin;
/**
* Enable autoloading of plugin classes in namespace.
*
* @param $class_name
*/
function autoload( $class_name ) {
@sheabunge
sheabunge / gist:de7e69eb6d81ad804b26
Last active August 29, 2015 14:15
Not eXactly C line following code
/******************** Line Follow ********************/
task LineFollow()
{
OnFwd(L_MOTOR, POWER);
while(true)
{
if(SENSOR_A_BLACK)
{
if(SENSOR_B_WHITE)
@sheabunge
sheabunge / dl-file.php
Last active August 29, 2015 14:07 — forked from hakre/dl-file.php
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+
@sheabunge
sheabunge / feedly.css
Created February 23, 2014 02:52
Tweaks for Feedly on smaller screens. Use with something like Stylish.
body.home {
top: 0 !important;
margin: 0 auto;
max-width: 100%;
}
#feedlyTabs {
padding-right: 55px !important;
padding-left: 10px !important;
max-width: 200px;
@sheabunge
sheabunge / hello-world.ahk
Created January 26, 2014 06:53
"Hello World" in different programming languages
MsgBox Hello World!