Skip to content

Instantly share code, notes, and snippets.

@wvega
wvega / mov-to-avi.sh
Created September 28, 2011 21:03
Convert .MOV to .AVI using MEncoder or ffmpeg
# convert MOV to AVI using MEncoder
mencoder ${fl} -o ${fl/mov/avi} -oac mp3lame -ovc lavc
# convert MOV to AVI using ffmpeg
ffmpeg -i ${fl} -sameq -vcodec msmpeg4v2 -acodec pcm_u8 ${fl/mov/avi}
# create audio track
mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile ${fl/mov/mp3} ${fl/mov/avi}
@wvega
wvega / wvega-850-eventbrite-api-workarounds.php
Created December 19, 2016 16:11
Workarounds to make Eventbrite API WordPress plugin work on 32bit systems
<?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 October 3, 2016 21:18
Oneliner used to remove the hidden flag from files and directories in the current directory
ls -lO | grep hidden | tr -s " " | cut -d " " -f 10- | awk '{ system(sprintf("chflags nohidden \"%s\"", $0)) }'
@wvega
wvega / jquery.timepicker-1.3.2-custom.min.js
Created May 11, 2016 04:18
A modified version of jQuery Timepicker 1.3.2 (See issue #50)
/**
* 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 / wordpress-subpages-menu.php
Created August 13, 2011 20:56
Add a subpages menu to WordPress pages
<?php
function subpages() {
global $post;
// Output a link to the parent page, if we are on a subpage
if (!empty($post->post_parent)) {
$title = esc_attr(get_the_title($post->post_parent)) ?>
<p><b>Parent page:</b><br />
<a href="<?php echo get_permalink($post->post_parent); ?>" title="<?php echo esc_attr($title); ?>"><?php echo $title ?></a></p>
@wvega
wvega / custom-meta-query.php
Created March 17, 2016 01:10
Code used to create SQL clauses for meta queries using custom tables (Draft)
<?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 / 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
# a fully-functional Python unittest example where we have a
# Tornado web application that is being tested:
#
# taken from https://groups.google.com/forum/#!topic/python-tornado/hnz7JmXqEKk
# originally posted by Jeremy Whitlock
import tornado.httpserver
import tornado.httpclient
import tornado.ioloop
import tornado.web
  1. (0.5h) Create table for Products, Product Properties, Specific Product Properties (Each Product would be associated with a Listing Category).
  2. (7.5h) Create Product admin screens:
    1. (1.5h) Create Products table.
      1. (1.0h) Create table
      2. (0.5h) Delete Products action.
    2. (1.5h) Create Add/Edit Products action.
      1. Create associated Listing Category id.
    3. (1.0h) Create action to Add/Edit (global) Product Properties.
      1. Associate related Extra Fields to the Product category.
  3. (2.0h) Create action to Add/Edit (specific) Product Properties.
<?php
echo $before_widget . $before_title . $title . $after_title;
echo '<div align="center">';
echo '<form method="post" action="'. url_searchads() .'" onsubmit="if (this.keywordphrase.value == \'Search by keyword\') { this.keywordphrase.value = \'\'; } return true;">';
echo '<input type="hidden" name="a" value="dosearch"/>';
$keywordphrase = stripslashes_deep(awpcp_post_param('keywordphrase'));
if ($instance['show_keyword'] == 1) {