Skip to content

Instantly share code, notes, and snippets.

@0xnbk
0xnbk / autofollow.php
Created September 13, 2010 06:29
Twitter autofollow script (PHP)
<?php
// Twitter Auto-follow Script by Dave Stevens - http://davestevens.co.uk
$user = "";
$pass = "";
$term = "";
$userApiUrl = "http://twitter.com/statuses/friends.json";
@0xnbk
0xnbk / .php
Created September 13, 2010 06:30
Get the number of twitter follower in full text (PHP)
<?php
$xml=file_get_contents('http://twitter.com/users/show.xml?screen_name=catswhocode');
if (preg_match('/followers_count>(.*)</',$xml,$match)!=0) {
$tw['count'] = $match[1];
}
echo $tw['count'];
?>
@0xnbk
0xnbk / .py
Created September 13, 2010 06:33
View who doesn’t follow you (Python)
import twitter, sys, getpass, os
def call_api(username,password):
api = twitter.Api(username,password)
friends = api.GetFriends()
followers = api.GetFollowers()
heathens = filter(lambda x: x not in followers,friends)
print "There are %i people you follow who do not follow you:" % len(heathens)
for heathen in heathens:
print heathen.screen_name
@0xnbk
0xnbk / gist:576935
Created September 13, 2010 07:32
Update your Twitter status…using Vim
command -range Twitter
<line1>,
<line2>write ++enc=UTF-8 !curl --data-urlencode status@- --netrc --no-remote-name http://twitter.com/statuses/update.xml
</line2></line1>
@0xnbk
0xnbk / .php
Created September 13, 2010 08:33
Get Your Most Recent Twitter Status (PHP)
<?php
function get_status($twitter_id, $hyperlinks = true) {
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$src = curl_exec($c);
curl_close($c);
preg_match('/<text>(.*)<\/text>/', $src, $m);
$status = htmlentities($m[1]);
if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $status);
@0xnbk
0xnbk / .php
Created September 13, 2010 08:36
Twitter email grabber (PHP)
<?php
$file = file_get_contents("http://search.twitter.com/search?q=gmail.com+OR+hotmail.com++OR+%22email+me%22");
$file = strip_tags($file);
preg_match_all(
"([a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)\b)siU",
$file,
$matches);
print_r($matches);
@0xnbk
0xnbk / .rb
Created September 13, 2010 08:37
Backup your tweets (Ruby)
#! /usr/bin/ruby
require 'rubygems'
require 'json'
require 'net/http'
require 'uri'
class TwitterBackup
def backup(username)
@0xnbk
0xnbk / .php
Created September 13, 2010 08:38
Timeline function (PHP)
<?php
function timespan($time1, $time2 = NULL, $output = 'years,months,weeks,days,hours,minutes,seconds')
{
$output = preg_split('/[^a-z]+/', strtolower((string) $output));
if (empty($output))
return FALSE;
extract(array_flip($output), EXTR_SKIP);
$time1 = max(0, (int) $time1);
$time2 = empty($time2) ? time() : max(0, (int) $time2);
$timespan = abs($time1 - $time2);
@0xnbk
0xnbk / .php
Created September 13, 2010 08:39
Display your Twitter entries on your WordPress blog
<?php include_once(ABSPATH . WPINC . '/rss.php');
wp_rss('http://twitter.com/statuses/user_timeline/15985955.rss', 5); ?>
@0xnbk
0xnbk / culturegridne.1.4.bat
Created September 13, 2010 08:41
Twitter Bot (bat file)
@echo off
rem ==============================
rem test for user input
rem ==============================
if [%1]==[] goto error
if [%2]==[] goto error
rem ==============================
rem set password and user name
rem ==============================
set user=%1