Skip to content

Instantly share code, notes, and snippets.

@wvega
wvega / data-to-binary-string.py
Created December 4, 2015 16:27
Convert a binary file into a binary string and back
import struct
def data_to_binary_string(input_filename):
binary_string = ''
file = open(input_filename, 'rb')
bytes = file.read(1024)
while len(bytes):
binary_string = binary_string + ''.join(['{0:0>8b}'.format(ord(b)) for b in bytes])
@wvega
wvega / 0001-Use-Pippin-s-WP_Session-in-AWPCP.patch
Created July 30, 2015 22:36
Implementation of Pippin's WP Session for AWPCP
From 6557efdb0d8c840614706e9f6cb1921128bed363 Mon Sep 17 00:00:00 2001
From: Willington Vega <wvega@wvega.com>
Date: Fri, 12 Jun 2015 19:51:26 -0500
Subject: [PATCH] Use Pippin's WP_Session in AWPCP.
https://pippinsplugins.com/storing-session-data-in-wordpress-without-_session/
---
another-wordpress-classifieds-plugin/awpcp.php | 9 +-
.../includes/sessions/class-session-manager.php | 178 ++++++++++++++++
.../includes/sessions/class-session.php | 119 +++++++++++
@wvega
wvega / customization-guide.md
Last active August 29, 2015 14:25
AWPCP's Customization Guide (draft)

AWPCP Customization Guide

Introduction

This document describes the general layout of the Another WordPress Classifieds Plugin directory as well as the contents of most of the files and directories inside. The instructions provided here assume that you are an expert in PHP coding, understand HTML very well, and are comfortable with the WordPress PHP API. If you feel that your skills aren’t up to par in these areas, you should consider hiring help for your project on a forum such as Upwork.

CUSTOMIZATION WARNING: Beyond the help provided here, customizations to the plugin are something that you do on your own and without further support from the AWPCP team. We can’t provide support on any custom changes you make to the plugin—you must be comfortable in debugging techniques and tools to find and fix issues on your own. Any bugs you find in the plugin must be reproducible with the core, unmodified plugin in order to be considered issues we can address.

Before altering plugin files

<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
require_once('wp-blog-header.php');
require_once('wp-includes/load.php');
// ----------------------------------------------------
@wvega
wvega / install-ffmpeg.sh
Created December 17, 2014 15:06
Instructions to install FFMPEG from sources in CentOS 6
#!/bin/bash
# Based on https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
# Remove ffmpeg-related packages
yum remove ffmpeg SDL alsa-lib celt enca ffmpeg-libs flac fontconfig fribidi gsm lame-libs libICE libSM libXdamage libXext libXfixes libXi libXtst libXxf86vm libass libasyncns libcdio libdc1394 libogg liboil libraw1394 librtmp libsndfile libtheora libusb1 libv4l libva libvorbis mesa-dri-drivers mesa-dri-filesystem mesa-dri1-drivers mesa-libGL mesa-private-llvm openal-soft openjpeg-libs pulseaudio-libs schroedinger speex x264-libs xvidcore
# Compile ffmpeg from sources, as explained in https://trac.ffmpeg.org/wiki/CompilationGuide/Centos.
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
@wvega
wvega / jquery-ui-daterange.js
Created September 17, 2014 00:19
A(nother) daterange jQuery UI plugin (WIP)
$.fn.daterange = function( options ) {
$( this ).each( function() {
var element = $( this ),
settings = $.extend( {}, $.fn.daterange.defaultOptions, options ),
startDateField = $( settings.startDateField ),
endDateField = $( settings.endDateField ),
startDate = settings.startDate || null,
@wvega
wvega / remove-irrelevant-translations-modifications.sh
Created September 10, 2014 01:30
Remove modifications to translations files that don't add or remove strings.
#!/bin/bash
#
# Remove modifications to translations files that don't add or remove strings.
#
# The removed modifications are those that affect the translation date and the
# numbers of the lines where existing strings appear. That information is not
# relevant during development and will only pollute the commit history.
#
# TODO: Try to achieve the same using only git.
# HINT: git diff -G
@wvega
wvega / gist:cf5668af5f03ec3060ba
Created August 9, 2014 18:01
Updated function pre_set_site_transient_update_plugins_filter for EDD_SL_Plugin_Updater 1.2
<?php
/**
* Check for Updates at the defined API endpoint and modify the update array.
*
* This function dives into the update API just when WordPress creates its update array,
* then adds a custom API call and injects the custom plugin data retrieved from the API.
* It is reassembled from parts of the native WordPress plugin update code.
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
*
@wvega
wvega / functions.php
Last active August 29, 2015 14:02
Categories List Walke wrapper function for WEN Team (AWPCP's Issue #833)
<?php
function wen_shortcode_awpcp_list_categories( $atts ) {
// unused
extract( shortcode_atts( array(
'type' => 'page',
'value' => '1',
'input' => 'id',
), $atts ) );
@wvega
wvega / class-wen-categories-list-walker.php
Last active August 29, 2015 14:02
Categories List Walker for WEN Team (AWPCP's Issue #833)
<?php
if ( ! class_exists( 'Walker' ) ) {
require_once( ABSPATH . '/wp-includes/class-wp-walker.php' );
}
if ( class_exists( 'Walker' ) ) {
class WEN_CategoriesListWalker extends Walker {