Skip to content

Instantly share code, notes, and snippets.

View wktk's full-sized avatar
🏠
Working from home

wktk

🏠
Working from home
View GitHub Profile
@wktk
wktk / bot_fav.php
Created March 3, 2012 10:18
EasyBotter で TL 上のツイートをふぁぼ
<?php // bot.php
require_once("EasyBotter.php");
$eb = new EasyBotter();
foreach ($eb->getFriendsTimeline() as $tweet){
// $tweet に各ツイートの情報が入ってるので必要なら条件付けをこの辺りで
// 例:
// if (preg_match('/(?:お[き気]に[い入]り|ふぁぼ|fav)/i', $tweet->text)) {}
$response = $eb->_setData("https://api.twitter.com/1/favorites/create/{$tweet->id}.xml");
@wktk
wktk / EasyBotter.php
Created March 12, 2012 21:13
EasyBotter の非推奨 API (Unversioned API 等) 対応
// <?php
/* 既存の "//自動フォロー返し function autoFollow()" を削除 or コメントアウトして
* EasyBotter.php 下部の "//基本的なAPIを叩く" 以下をこのファイルでまとめて上書き
*
* フォロー関連は XML に挫折したので json_decode() 使ってる
*/
// 基本的なAPIを叩く
function _setData($url, $value = array()){
return simplexml_load_string($this->consumer->sendRequest($url, $value, "POST")->getBody());
@wktk
wktk / gist:2318713
Created April 6, 2012 10:30
3 文字以下の取得可能 Twitter ユーザー名を探す
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
my $target = 'http://twitter.com/users/username_available?username=';
my @range = ('a'..'x', '0'..'9', '_', '');
while (1) {
my $str;
@wktk
wktk / op.py
Created May 27, 2012 05:32
( ゚∀゚)o彡゜
# coding: utf-8
import time
status = False
while not time.sleep(0.5):
print "( ゚∀゚)" + ("o彡 " if status else " 彡゚") + "\r",
status = not status
@wktk
wktk / gist:2987858
Created June 25, 2012 10:29
ドメインを TLD からソートするワンライナー
perl -F\. -nae "push@d,join('.',reverse(@F));END{print join('.',reverse(split(/\./)))foreach sort(@d)}" domains.txt
@wktk
wktk / theme.html
Created June 28, 2012 18:12
My Tumblr Theme
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
<head>
<meta charset="utf-8" />
<meta name="description" content="{MetaDescription}" />
<title>{block:PostTitle}{PostTitle} - {/block:PostTitle}{Title}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes" />
<link rel="shortcut icon" href="{Favicon}" />
<link rel="apple-touch-icon" href="{PortraitURL-128}" />
<link rel="alternate" type="application/rss+xml" href="{RSS}" />
@wktk
wktk / tweets.php
Created August 24, 2012 11:00
ツイートを可能な限り遡る
<?php
require './tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => "",
'consumer_secret' => '',
'user_token' => '',
'user_secret' => '',
'curl_ssl_verifypeer' => false,
));
@wktk
wktk / gist:3472845
Created August 26, 2012 00:43
EasyBotter で実行中にフッターを変更する

+: 行追加, -: 行削除

EasyBotter.php
private を解除して bot.php からでも footer を触れるようにする

<?php
// (ry
  private $_replyLoopLimit;
- private $_footer;
+ // private $_footer;
@wktk
wktk / memo.md
Created September 6, 2012 09:13
Twitter API v1.1 メモ
require 'mechanize'
[['username1', 'password1'], ['username2', 'password2']].each do |user|
mech = Mechanize.new
mech.verify_mode = 0
page = mech.get 'http:// ... /oauth'
form = page.form
form.field_with(:name => /mail/i).value = user[0]
form.field_with(:name => /pass/i).value = user[1]
result = form.submit.link_with(:text=> /continue/).click