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 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
#!/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
(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
<?php | |
use Predis\Client as PredisClient; | |
include __DIR__ . '/vendor/autoload.php'; | |
function redis() { | |
global $Redis; | |
if ( !isset($Redis) || !$Redis instanceof PredisClient ) { |
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
import json | |
import urllib | |
downloader = urllib.URLopener() | |
# start by getting the full list of videos | |
with open('items.json') as json_data: | |
items = json.load(json_data) | |
# where to save the videos (directory) | |
save_to_dir = './' |
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 | |
/* | |
Plugin Name: Tweak MailChimp Feeds RSS | |
Plugin URI: https://samelh.com/blog | |
Description: Tweak MailChimp RSS Feeds to add the featured image, excerpt and a read more button. | |
Author: Samuel Elh | |
Version: 0.1 | |
Author URI: https://go.samelh.com/buy-me-a-coffee | |
*/ |
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
import React, { Component } from 'react'; | |
import { Text, Linking, Alert } from 'react-native'; | |
export default class Link extends Component | |
{ | |
style = {color: '#008de6'} | |
onPress() | |
{ | |
if ( this.props.confirm ) { |
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 | |
require __DIR__ . '/vendor/autoload.php'; | |
use \DrewM\MailChimp\MailChimp; | |
$mc = new MailChimp('<your-mailchimp-api-key>'); | |
// list ID | |
// When a user unsubscribes from the list, they cannot be subscribed again | |
// via the API, so use a unique list for this mailing purpose |
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 start = +new Date, d, chrono | |
setInterval(function() | |
{ | |
d = new Date( +new Date - start ) | |
chrono = (''+d).match( /\d+:\d+(?= )/g )[0] + ':' + Math.floor(d.getMilliseconds()/100) | |
document.body.innerHTML = chrono.replace(/(\d+)/g, '<span>$1</span>').replace(':', '\'').replace(':', '"') | |
}, 100) |