Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am adhipg on github.
  • I am adhipg (https://keybase.io/adhipg) on keybase.
  • I have a public key whose fingerprint is 5E62 8E26 72D6 C581 8F6F 33F5 AFB8 5A15 777F 6EF7

To claim this, I am signing this object:

{
"491289025" : "ijinshan-kappmarket://",
"301521403" : "fb103361823069955://",
"492178411" : "ils492178411://",
"346142396" : "fb234434003713://",
"310633997" : "whatsapp://",
"370614765" : "com.condenet.newyorker://",
"325058491" : "rnmddisco://",
"382952264" : "epichttp://",
"477048487" : "predictwind://",
@adhipg
adhipg / .gitignore
Created January 22, 2015 14:04
Ignore everything but a certain subdirectory
*
!.gitignore
!/wp-content
/wp-content/*
!/wp-content/themes
/wp-content/themes/*
!/wp-content/themes/raison-winetrust/
@adhipg
adhipg / colorYourProgress.js
Created December 25, 2009 18:28
Colour Your Progress
function colorThem ( domElement ) {
var green = parseInt ( ( domElement.text() / 100 ) * 255 );
var red = 255 - green;
greenString = green.toString ( 16 );
redString = red.toString ( 16 );
if ( greenString.length == 1 ) greenString = '0' + greenString;
if ( redString.length == 1 ) redString = '0' + redString;
<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAEX95M5gKl7Nn_i4Mzl1TAhT4b5KCiYFj3ZfOJov1Qpq4YsRyghTrgMf7VDdXUg9oULkwfWhrlOumiQ" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(29.427394,-98.624654), 15);
# Reset the panels in GNOME:
gconftool --recursive-unset /apps/panel
rm -rf ~/.gconf/apps/panel
pkill gnome-panel
@adhipg
adhipg / wordpress-update-posts-url.sql
Created March 10, 2011 06:57
SQL to update the posts table when we migrate websites from one site to another. Corrects the URLs of the attachments
UPDATE wp_posts SET post_content = REPLACE (post_content, 'oldlink', 'newlink');
@adhipg
adhipg / gist:1162478
Created August 22, 2011 14:16
MySQL Date to JavaScript Date
function getJavaScriptDate(timestamp) {
var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
var parts=drink.post_date.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
}
@adhipg
adhipg / format_dates.php
Created September 12, 2011 11:10
Format a set of dates (timestamps) into a format like 1, 2, 3 Jan, 13 Feb, 15 Mar 2011
<?php
function formatDates( $dates ) {
$output = '';
$month = '';
$year = '';
sort( $dates, SORT_NUMERIC );
foreach ( $dates as $date ) {
@adhipg
adhipg / gist:1217103
Created September 14, 2011 17:01
Creating short URLs/hashes
<?php
function getHash( $n = '' ) {
if( $n == '' ) {
$n = rand();
}
$codeset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$base = strlen($codeset);