Skip to content

Instantly share code, notes, and snippets.

View ashfame's full-sized avatar
💭
What parts of our society are best governed by code?

Ashish Kumar ashfame

💭
What parts of our society are best governed by code?
View GitHub Profile
@ashfame
ashfame / shutdown-dropbox-done.sh
Created November 5, 2011 23:41
Shutdown linux (Ubuntu) when Dropbox completes transfer
#!/bin/bash
# By Ashfame
while true
do
# keep checking for idle dropbox status
STATUS=`dropbox status`
if [ $STATUS = 'Idle' ]; then
notify-send "System Shutdown" "System will power off now"
@ashfame
ashfame / gist:1370753
Created November 16, 2011 17:32
Bash script to generate a html file describing all tables in a database
#!/bin/bash
#Change your db username, password & database name
if [ -f ~/Desktop/db_schema.html ]; then
rm ~/Desktop/db_schema.html
fi
for i in `mysql -B -N -uroot -proot dbname -e 'show tables;'`; do
echo "<a href='#$i'>$i</a><br />" >> /tmp/$$.nav.html
@ashfame
ashfame / delete-all-tags.php
Created November 25, 2011 10:11
Delete all tags of a WP install
<?php
/**
* Delete all tags of a WordPress blog
*
* @author Ashfame
*
* Place this file in root of your WordPress install and open it in the browser - domain.com/delete-all-tags.php
*/
@ashfame
ashfame / index.php
Created December 12, 2011 15:44
SugarCRM REST API call examples
<?php
/**
* SugarCRM RESTS API Call examples
*
* REST API Wrapper - https://github.com/asakusuma/SugarCRM-REST-API-Wrapper-Class
*/
?>
<!doctype html>
<head>
<meta charset="utf-8">
@ashfame
ashfame / wpautop-control.php
Created December 31, 2011 09:56
Function to remove wpautop filter for specific post IDs
/**
* Function to remove wpautop filter for specific post IDs
*/
add_action( 'init', 'do_ma_thang' );
function do_ma_thang() {
global $wp_query;
$exclusion = array( 1, 5, 7 ); // add post IDs here
@ashfame
ashfame / example.php
Created January 24, 2012 08:00
Changing postmeta fields programmatically
<pre><?php
require 'wp-load.php';
$postmeta_field_name = 'video_url'; // fill it
echo $query = "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '$postmeta_field_name';";
$data = $wpdb->get_results( $query );
@ashfame
ashfame / svn-commands.sh
Created February 24, 2012 16:58
SVN commands
# Count no of files in repo
svn info -R --xml file:///path/to/rep | grep kind=\"file\"|wc -l
# SVN command to give commit authors list and save it in author-transform.txt
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
@ashfame
ashfame / Best-way-to-wrap-up-your-jQuery-code-for-avoiding-conflicts.js
Created February 27, 2012 10:07
Best way to wrap up your jQuery code for avoiding conflicts
(function($){
// Regular jQuery code inside
$(document).ready(function(){
});
})(jQuery);
@ashfame
ashfame / awesome-wp-config-file.php
Created February 27, 2012 13:30
awesome-wp-config-file
<?php
/**
* Define type of server
*
* Depending on the type other stuff can be configured
* Note: Define them all, don't skip one if other is already defined
*/
define( 'DB_CREDENTIALS_PATH', dirname( ABSPATH ) ); // cache it for multiple use
@ashfame
ashfame / local-config-awesome-wp-config-file.php
Created February 27, 2012 13:34
Local config file to hold db credentials and for defining keys & salts along with the use of awesome wp-config.php file
<?php
/**
* WordPress config file to use one directory above WordPress root, when awesome version of wp-config.php is in use.
*
* Awesome wp-config.php file - https://gist.github.com/1923821
*/
/* WordPress Local Environment DB credentials */