This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
'use strict'; | |
Object.prototype.attachDomEvent = function(eventName, callback) | |
{ | |
eventName = eventName.replace(/^on/g, ''); | |
if ( window.addEventListener ) { | |
this.addEventListener(eventName, callback, false); | |
} else if ( window.attachEvent ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import urllib, sys, re | |
xml = urllib.urlopen('http://data.alexa.com/data?cli=10&dat=s&url=%s'%sys.argv[1]).read() | |
try: rank = int(re.search(r'<POPULARITY[^>]*TEXT="(\d+)"', xml).groups()[0]) | |
except: rank = -1 | |
print 'Your rank for %s is %d!\n' % (sys.argv[1], rank) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get the user country code with package | |
* | |
* Requires geoiplookup package installed | |
* @link http://manpages.ubuntu.com/manpages/trusty/man1/geoiplookup.1.html | |
* @param $ip user IP string | |
* @param $args Array (optional parameters) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// prevent direct access, only index.php can include this file | |
defined ( 'STRIPE_SECRET_KEY' ) || exit ( 'Direct access not allowed' . PHP_EOL ); | |
use \Stripe\Stripe; | |
use \Stripe\Customer; | |
use \Stripe\Charge; | |
Stripe::setApiKey(STRIPE_SECRET_KEY); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get client IP | |
*/ | |
function whatismyip() { | |
if (isset($_SERVER['HTTP_CLIENT_IP'])) | |
$ipaddress = $_SERVER['HTTP_CLIENT_IP']; | |
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) | |
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hashScrollFix = function() { | |
var hash = location.hash | |
, menu = $('.main-navi.fixed') // your fixed menu selector | |
, itm; | |
// I added menu.position().top >= 0 because I fade my menu to above viewport | |
// with a negative top position | |
if ( menu.is(':visible') && menu.position().top >= 0 ) { | |
itm = $(hash); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @link https://github.com/bainternet/PHP-Hooks | |
*/ | |
function hooks() { | |
global $hooks; | |
if ( !isset($hooks) || !($hooks instanceof \Hooks) ) { | |
$hooks = new \Hooks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @link https://samelh.com/blog/2016/12/22/add-custom-fields-bbpress-profile/ **/ | |
// add field to bbP profile edit | |
add_action( "bbp_user_edit_after_contact", "se_add_city_field" ); | |
function se_add_city_field() { | |
// a random selection of cities | |
$cities = array( "Seoul", "Mexico City", "Amsterdam", "Mumbai", "Agadir", "Egypt" ); | |
// selected city, if any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( defined('BM_CUSTOM_LOAD') && isset($BM_Loader) && method_exists($BM_Loader, "init") ) { | |
if ( true /* my custom preferences */ ) { | |
$BM_Loader->init(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Smarty plugin | |
* ------------------------------------------------------------- | |
* Type: modifier | |
* Name: relative_date | |
* Version: 1.1 | |
* Date: November 28, 2008 | |
* Author: Chris Wheeler <[email protected]> |