Skip to content

Instantly share code, notes, and snippets.

View viruthagiri's full-sized avatar

Viruthagiri Thirumavalavan viruthagiri

  • Bangalore, India
View GitHub Profile
@viruthagiri
viruthagiri / ssh-socks-proxy.md
Created May 18, 2012 20:22 — forked from vu3rdd/ssh-socks-proxy.md
circumvent Internet censorship
  • You will need a VPS/Unix Shell account on a remote machine sitting in a country with some sane laws.

  • from your local machine, do:

    $ ssh -D 1080 user@host

On your browser (or other applications), go to the network connection settings, select the option to use a proxy and leave everything blank except the SOCKS option, where you fill in hostname as localhost or 127.0.0.1 and port number as 1080 (or whatever you filled in above). That is all!

@viruthagiri
viruthagiri / wp_insert_post_front_end_form.php
Created October 28, 2012 22:15 — forked from clarklab/wp_insert_post_front_end_form.php
This is a sample front-end form using wp_insert_post(). It's quickly stripped out of my production code from Android and Me, and hasn't been tested alone, so please take it with a grain of salt.
<?
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['insert_post'] )) { //check that our form was submitted
$title = $_POST['thread_title']; //set our title
if ($_POST['thread_description']=="") { // check if a description was entered
$description = "See thread title..."; // if not, use placeholder
} else {
$description = $_POST['thread_description']; //if so, use it
@viruthagiri
viruthagiri / functions.php
Created October 31, 2012 23:02 — forked from deadlyhifi/functions.php
WordPress Pagination function
/**
* A pagination function
* @param integer $range: The range of the slider, works best with even numbers
* Used WP functions:
* get_pagenum_link($i) - creates the link, e.g. http://site.com/page/4
* previous_posts_link(' ‚ '); - returns the Previous page link
* next_posts_link(' é '); - returns the Next page link
* http://robertbasic.com/blog/wordpress-paging-navigation/
* Tweaked by tdB ...
*/
<?php
/*
Plugin Name: SO Inspired Badges
Version: 1.2
Plugin URI: http://wordpress.stackexchange.com/questions/71360/bug-in-stackoverflow-styled-badge-system-script
Description: A Stack Overflow inspired plugin which allows users to acquire badges. Badges are created and managed through the standard WordPress Dashboard.
Author: Amanda Duke
Author URI: http://wordpress.stackexchange.com/users/22585/amanda-duke
Copyright (c) 2012
@viruthagiri
viruthagiri / README.markdown
Created November 9, 2012 17:45 — forked from marijn/README.markdown
List of countries in YAML, CSV and TXT format

#List of countries

It's time someone compiled a list of countries to use within a web application. This gist attempts to make a first move at that.

List of nationalities

I've also compiled a list of nationalities

@viruthagiri
viruthagiri / README.markdown
Created November 9, 2012 17:45 — forked from marijn/README.markdown
List of nationalities in YAML, CSV and TXT format

List of nationalities

It's time someone compiled a list of nationalities to use within a web application. This gist attempts to make a first move at that.

##List of countries

I've also compiled a list of countries

@viruthagiri
viruthagiri / custom.js
Created November 17, 2012 05:15 — forked from drewjoh/custom.js
Dynamic (AJAX) loaded Bootstrap Modal (Bootstrap 2.1)
$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
@viruthagiri
viruthagiri / profile.php
Created November 19, 2012 19:11 — forked from anonymous/profile.php
Wordpress front end log in page template with multiple custom meta_key - input, select, dropdown
<?php
global $user_ID, $user_identity, $user_level;
if ($user_ID) {
if($_POST)
{
Index: includes/plugin.auth.php =================================================================== --- includes/plugin.auth.php (revision 608458) +++ includes/plugin.auth.php (working copy) @@ -86,6 +86,10 @@ $user_id = (int) email_exists( $hybridauth_user_profile->emailVerified ); } + // try to guess (reliably) user profile with filters + // this allows for looking at other stuff (such as associated OpenID) + $user_id = apply_filters('wsl_reliably_guess_user', $user_id, $hybridauth_user_profile, $provider); + // try to get user by meta if not if( ! $user_id ){ $user_id = (int) wsl_get_user_by_meta( $provider, $hybridauth_user_profile->identifier ); @@ -146,6 +150,8 @@ 'user_pass' => wp_generate_password() ); + + $userdata = apply_filters('wsl_insert_user', $userdata, $hybridauth_user_profile, $provider); // Create a new user $user_id = wp_insert_user( $userdata ); @@ -176,11 +182,18 @@ $user_age = (int) date("Y") - (int) $hybridauth_user_profile->birthYear; } - update_user_meta ( $user_id, 'wsl_user' , $p
function FormatASINResult($Result){ //main function for single product
$Item = $Result['ItemLookupResponse']['Items']['Item'];
$ItemAttr = $Item['ItemAttributes'];
$ImageSM = $Item['SmallImage']['URL'];
$ImageMD = $Item['MediumImage']['URL'];
$ImageLG = $Item['LargeImage']['URL'];
$lowestNewPrice = $Item["OfferSummary"]["LowestNewPrice"]["FormattedPrice"];
if(isset($Item["OfferSummary"]["LowestUsedPrice"]["FormattedPrice"])) {
$lowestUsedPrice = $Item["OfferSummary"]["LowestUsedPrice"]["FormattedPrice"];
} else {