Instantly share code, notes, and snippets.

View README.md

This is a workaround for Twitter search API being limited to only tweets from the past week.

Open Twitter on your favourite browser, open dev-tools, then go to console.

Make sure you are on Twitter search page, searching for your mentioned handle or hashtag or whatever.

Enter the code, it will only capture the handles but you can alter it to capture more data of your choosing.

It will attempt to adjust the page scroll to reach the bottom, in order to load more tweets, until you reach the end.

View chrono.js
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)
View php-send-email-mailchimp-yt.php
<?php
require __DIR__ . '/vendor/autoload.php';
use \DrewM\MailChimp\MailChimp;
$mc = new MailChimp('<your-mailchimp-api-key>');
$list_id = 'fb05b906b8'; // list ID
$email_address = 'test@example.com'; // where to send
View Link.js
View mc-feed.php
<?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
*/
View download_videos.py
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 = './'
View api.php
<?php
use Predis\Client as PredisClient;
include __DIR__ . '/vendor/autoload.php';
function redis() {
global $Redis;
if ( !isset($Redis) || !$Redis instanceof PredisClient ) {
View attachDomEvent.js
(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 ) {
View alexa.py
#!/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)
View geoiplookup.php
<?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)
*/