Skip to content

Instantly share code, notes, and snippets.

import sys,traceback,json,threading
import twitter,util
class Stream():
def __init__(self):
self.listeners = []
t = threading.Thread(target=self.stream)
t.start()
def __add__(self, listener):
@firstspring1845
firstspring1845 / mikutter_anime_icon.rb
Created April 29, 2014 07:25
某氏の動かしてるbotの機能をmikutterプラグイン化したものです、anime_iconとリプライを貰うと用意したアイコンにランダムで変更します。 プラグインと同じディレクトリにiconディレクトリを作成しその中に入れてください
# -*- coding: utf-8 -*-
Plugin.create :mikutter_anime_icon do
require 'base64'
on_mention do |s,ms|
ms.each do |m|
if Time.now - m.message[:created] < 5 then
if m.message.to_s.split[1] == 'anime_icon' then
dir = File.expand_path(File.join(File.dirname(__FILE__), "icon"))
subdir = ['.','..']
#-*- coding: utf-8 -*-
Plugin.create :text do
on_mention do |s,ms|
ms.each do |m|
if Time.now - m.message[:created] < 5 then
if m.message.to_s =~ /.*text / then
Service.primary.post(:message => m.message.to_s.gsub(/.*text /,''))
end
@firstspring1845
firstspring1845 / gist:fcf2bfadb613a3fdf845
Created May 10, 2014 18:15
mikutterでフォロイーのふぁぼふぁぼとか受信するモンキーパッチ pluginの中に適当な.rbファイルとして突っ込んだら機能すると思います
class Service
def streaming(method = :userstream, *args, &proc)
twitter.__send__(method, {'include_followings_activity' => true}, &proc)
end
end
@firstspring1845
firstspring1845 / mikutter_dig_up.rb
Created May 13, 2014 13:46
掘り返されたツイートを既にRTしててRTできない、そんなあなたに、RTを取り消してやり直すmikutterプラグインです
#-*- coding: utf-8 -*-
Plugin.create :dig_up do
command(:dig_up,
name: '掘り返し',
condition: Plugin::Command[:HasOneMessage],
visible: true,
role: :timeline) do |opt|
message = opt.messages.first
(Service.primary.twitter/'statuses/show').json(:id => message.id, :include_my_retweet => true).next do |m|
@firstspring1845
firstspring1845 / field.rb
Last active August 29, 2015 14:03
適当ライフゲーム
class Field
def initialize(x,y)
@x = x
@y = y
@m = x.times.map{[false]*y}
end
def get_size
[@x,@y]
end
@firstspring1845
firstspring1845 / block.rb
Last active August 29, 2015 14:03
ブロックを使わないといけないツイッターつらい
# -*- coding: utf-8 -*-
Plugin.create :block do
command(:block,
name: 'ブロックする',
condition: Plugin::Command::CanReplyAll,
visible: true,
icon: nil,
role: :timeline) do |opt|
package net.firsp.amber.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class FuncUtil {
public static <A,B> ArrayList<B> map(Collection <A> data, MapFunction<A,B> func){
@firstspring1845
firstspring1845 / kq_user.py
Created August 11, 2014 19:58
ユーザーSNのリストをKrileQueryに変換するスクリプト
a = ['user == "{0}"'.format(s.strip()) for s in open('user.txt')]
b = 'from all where \n' + ('|\n').join(a)
open('query.txt','w').write(b)
@firstspring1845
firstspring1845 / mash.py
Last active August 29, 2015 14:05
Python用にRubyのHashie::Mashっぽいの
class mash(object):
def __init__(self, dic={}):
dic = {str(k): v if v.__class__ != dict else mash(v) for (k, v) in dic.items()}
super(mash, self).__setattr__('_dic', dic)
#self.name
def __getattr__(self, name):
return self._dic[name]
#self.name = value