Skip to content

Instantly share code, notes, and snippets.

Willington Vega wvega

View GitHub Profile
@wvega
wvega / attendees.js
Last active Feb 10, 2019
Extract Meetup member information from event's Attendees page
View attendees.js
Array.prototype.slice.apply(document.getElementsByClassName('member-item')).map((attendee) => {
return attendee.querySelector('a').href.replace('https://www.meetup.com/WordPressMedellin/members/', '').replace('/', '') + "," + attendee.querySelector('h4').innerText
}).join("\n")
@wvega
wvega / wvega-850-eventbrite-api-workarounds.php
Created Dec 19, 2016
Workarounds to make Eventbrite API WordPress plugin work on 32bit systems
View wvega-850-eventbrite-api-workarounds.php
<?php
// Additions to main functions.php file - eventbrite 32bit php problems - referenced from http://wvega.com/850/getting-eventbrite-api-wordpress-plugin-to-work-on-systems-with-32-bit-builds-of-php/
function wvega_850_filter_event_permalink( $url ) { // eg. http://mysite.com/events/july-test-drive-11829569561
if ( function_exists( 'eventbrite_is_event' ) && eventbrite_is_event() ) {
$url = sprintf( '%1$s/%2$s/%3$s-%4$s/',
esc_url( home_url() ), // protocol://domain
sanitize_title( get_queried_object()->post_name ), // page-with-eventbrite-template
sanitize_title( get_post()->post_title ), // event-title
@wvega
wvega / fix-hidden-files-memory-stick.sh
Created Oct 3, 2016
Oneliner used to remove the hidden flag from files and directories in the current directory
View fix-hidden-files-memory-stick.sh
ls -lO | grep hidden | tr -s " " | cut -d " " -f 10- | awk '{ system(sprintf("chflags nohidden \"%s\"", $0)) }'
@wvega
wvega / wp-debug-util.php
Last active Apr 7, 2018
Utility functions for debugging WordPress websites
View wp-debug-util.php
<?php
function wp_debug_util_get_hook_handlers( $hook_name ) {
global $wp_filter;
$hook_handlers = array();
foreach ( $wp_filter[ $hook_name ] as $priority => $handlers ) {
foreach ( $handlers as $handler ) {
if ( is_array( $handler['function'] ) && is_callable( $handler['function'] ) && is_object( $handler['function'][0] ) ) {
@wvega
wvega / jquery.timepicker-1.3.2-custom.min.js
Created May 11, 2016
A modified version of jQuery Timepicker 1.3.2 (See issue #50)
View jquery.timepicker-1.3.2-custom.min.js
/**
* jQuery Timepicker - v1.3.2 - 2016-05-10
* http://timepicker.co
*
* Enhances standard form input fields helping users to select (or type) times.
*
* Copyright (c) 2016 Willington Vega; Licensed MIT, GPL
*/
"undefined"!=typeof jQuery&&!function(a,b){function c(a,b,c){return new Array(c+1-a.length).join(b)+a}function d(){if(1===arguments.length){var b=arguments[0];return"string"==typeof b&&(b=a.fn.timepicker.parseTime(b)),new Date(0,0,0,b.getHours(),b.getMinutes(),b.getSeconds())}return 3===arguments.length?new Date(0,0,0,arguments[0],arguments[1],arguments[2]):2===arguments.length?new Date(0,0,0,arguments[0],arguments[1],0):new Date(0,0,0)}a.TimePicker=function(){var b=this;b.container=a(".ui-timepicker-container"),b.ui=b.container.find(".ui-timepicker"),0===b.container.length&&(b.container=a("<div></div>").addClass("ui-timepicker-container").addClass("ui-timepicker-hidden ui-helper-hidden").appendTo("body").hide(),b.ui=a("<div></div>").addClass("ui-timepicker").addClass("ui-widget ui-widget-conte
@wvega
wvega / custom-meta-query.php
Created Mar 17, 2016
Code used to create SQL clauses for meta queries using custom tables (Draft)
View custom-meta-query.php
<?php
$regions_query = new WP_Meta_Query( $query_object->query['_regions_query'] );
$regions_clauses = $regions_query->get_sql( 'post', $this->db->posts, 'ID', $query_object );
$regions_clauses['join'] = str_replace( $this->db->postmeta, AWPCP_TABLE_AD_REGIONS, $regions_clauses['join'] );
$regions_clauses['join'] = preg_replace( "/mt(\d+)/", 'listing_regions\1', $regions_clauses['join'] );
$regions_clauses['join'] = str_replace( 'post_id', 'ad_id', $regions_clauses['join'] );
$regions_clauses['where'] = str_replace( $this->db->postmeta, AWPCP_TABLE_AD_REGIONS, $regions_clauses['where'] );
@wvega
wvega / snippet-from-class-freemius.php
Created Dec 7, 2015
Alternative implementation for _find_caller_plugin_file() (2nd Attempt).
View snippet-from-class-freemius.php
<?php
private function _find_caller_plugin_file() {
$bt = debug_backtrace();
$backtrace_entries_count = count( $bt );
$active_plugins = get_option( 'active_plugins' );
$active_plugins_paths = array();
$plugin_file = null;
foreach ( $active_plugins as $i => $relative_path ) {
View snippet-from-class-freemius.php
<?php
private function _find_caller_plugin_file() {
$bt = debug_backtrace();
$abs_path_lenght = strlen( ABSPATH );
$backtrace_entries_count = count( $bt );
$plugin_file = null;
for ( $i = 1; $i < $backtrace_entries_count; $i++ ) {
if ( false !== strpos( substr( fs_normalize_path( $bt[ $i ]['file'] ), $abs_path_lenght ), '/freemius/' ) ) {
@wvega
wvega / data-to-binary-string.py
Created Dec 4, 2015
Convert a binary file into a binary string and back
View data-to-binary-string.py
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 Jul 30, 2015
Implementation of Pippin's WP Session for AWPCP
View 0001-Use-Pippin-s-WP_Session-in-AWPCP.patch
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 +++++++++++
You can’t perform that action at this time.