Skip to content

Instantly share code, notes, and snippets.

@sudar
sudar / package-list.txt
Created Mar 9, 2014
List of packages that are installed by default in DigitalOcean LAMP image. As of 09-March-2014
View package-list.txt
$ 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 Aug 29, 2015
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/
View gist:9749465
<?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
Code to automatically update version number from readme file in EDD Software licensing addon
View readme.php
<?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 );
?>
View sample.log
[Sat May 31 10:24:44 2014] [error] [client 127.0.0.1] Request header read timeout
View svn-to-git.sh
#!/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 Sep 8, 2014
Syntastic Syntax Checker for WordPress
View wordpress.vim
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 Feb 2, 2015
vip-quickstart error output
View gist:d362472ef9b1f6b6ffef
$ 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)
View example_gist_create.rb
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' })
View JComboBoxTest.java
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);
}
You can’t perform that action at this time.