Skip to content

Instantly share code, notes, and snippets.

@sudar
sudar / package-list.txt
Created March 9, 2014 03:13
List of packages that are installed by default in DigitalOcean LAMP image. As of 09-March-2014
$ dpkg --get-selections | grep -v deinstall
acpid install
adduser install
anacron install
apache2-mpm-prefork install
apache2-utils install
apache2.2-bin install
apache2.2-common install
apt install
@sudar
sudar / gist:9749465
Last active August 29, 2015 13:57
Code to prevent users from adding new terms to custom taxonomy in WordPress. More details at http://sudarmuthu.com/blog/prevent-users-from-adding-new-terms-to-custom-taxonomy-in-wordpress/
<?php
add_action( 'pre_insert_term', 'prevent_terms', 1, 2 );
function prevent_terms ( $term, $taxonomy ) {
if ( 'areas' === $taxonomy && !current_user_can( 'activate_plugins' ) ) {
return new WP_Error( 'term_addition_blocked', __( 'You cannot add terms to this taxonomy' ) );
}
return $term;
}
@sudar
sudar / readme.php
Created May 8, 2014 05:59
Code to automatically update version number from readme file in EDD Software licensing addon
<?php
add_filter( 'edd_sl_license_readme_response', function( $response, $download, $readme ) {
$meta_version = get_post_meta( $download->ID, '_edd_sl_version', true );
if ( '' != $readme['stable_tag'] && $meta_version != $readme['stable_tag'] ) {
update_post_meta( $download->ID, '_edd_sl_version', $readme['stable_tag']);
}
return $response;
}, 10, 3 );
?>
[Sat May 31 10:24:44 2014] [error] [client 127.0.0.1] Request header read timeout
@sudar
sudar / svn-to-git.sh
Created August 27, 2014 06:32
SVN to git
#!/bin/bash
################################################################################
# Clone the svn Plugin repo into github
# Author: Sudar <http://sudarmuthu.com>
#
# License: Beerware ;)
#
# Usage:
# ./path/to/clone-from-svn-to-git.sh [-p plugin-name] [-a authors-file] [-u svn-username] [-g github-repo-url]`
@sudar
sudar / wordpress.vim
Created September 8, 2014 16:44
Syntastic Syntax Checker for WordPress
if exists("g:loaded_syntastic_wordpress_phpcs_checker")
finish
endif
let g:loaded_syntastic_wordpress_phpcs_checker = 1
" Use PHP's phpcs checker
runtime! syntax_checkers/php/phpcs.vim
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'wordpress',
@sudar
sudar / gist:d362472ef9b1f6b6ffef
Created February 2, 2015 14:06
vip-quickstart error output
$ v up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2201.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2201 (adapter 1)
This is a test gits.
require 'net/http'
require 'uri'
# /api/v1/:format/new
# /api/v1/:format/gists/:user
# /api/v1/:format/:gist_id
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'),
{ 'files[file1.ab]' => 'CONTNETS',
'files[file2.ab]' => 'contents' })
MouseAdapter handler = new MouseAdapter() {
//Override methods
}
// Get all children of the combobox
Component c[] = combobox.getComponents();
for (int i =0; i < c.length; i++) {
// add event listener to all of the child components
c[i].addMouseListener(handler);
}