Skip to content

Instantly share code, notes, and snippets.

View govindak's full-sized avatar

Govinda Khatiwada govindak

View GitHub Profile
@govindak
govindak / wp.sh
Created October 6, 2015 16:37 — forked from bgallagh3r/wp.sh
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from, then deletes itself!
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
defaults delete ~/Library/Preferences/com.teamviewer.teamviewer9.plist
defaults delete ~/Library/Preferences/com.teamviewer.teamviewer9.Machine.plist
sudo defaults delete /Library/Preferences/com.teamviewer.teamviewer9.plist
rm -f ~/Library/Preferences/com.teamviewer.teamviewer9.plist
rm -f ~/Library/Preferences/com.teamviewer.teamviewer9.Machine.plist
sudo rm -f /Library/Preferences/com.teamviewer.teamviewer9.plist
<?php
//usage:
//url_title($title);
if ( ! function_exists('url_title'))
{
/**
* Create URL Title
*
<?php
/** maxmind geoip integration in php */
function get_real_ip() {
$ipaddress = '';
if(empty($_REQUEST['ip']) && @$_REQUEST['ip']==""){
if (@$_SERVER['HTTP_CLIENT_IP'])
$ipaddress = @$_SERVER['HTTP_CLIENT_IP'];
else if(@$_SERVER['HTTP_X_FORWARDED_FOR'])
$ipaddress = @$_SERVER['HTTP_X_FORWARDED_FOR'];
else if(@$_SERVER['HTTP_X_FORWARDED'])
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id ) {
$current_admin_user = wp_get_current_user();
if ( isset( $_POST['first_name'] ) ){
$user = new WP_User( $user_id );
$user_roles = $user->roles;
$user_role = array_shift($user_roles);
if($user_role!="administrator"){
update_user_meta($user_id, 'asso_admin', $current_admin_user->ID);
}else{
<?php
// Magento: Getting categroy from product
$categoryIds = $_product->getCategoryIds();
if(count($categoryIds) ){
$firstCategoryId = $categoryIds[0];
$_category = Mage::getModel('catalog/category')->load($firstCategoryId);
echo $_category->getData('categorysecondimage');
}