Skip to content

Instantly share code, notes, and snippets.

View yuiseki's full-sized avatar
🍻
I want to drink

yuiseki yuiseki

🍻
I want to drink
View GitHub Profile
# -*- coding:utf-8 -*-
import sys
import traceback
import datetime
from dateutil.parser import parse
import pytz
import json
import tweepy
uuid = require 'node-uuid'
hex1str = uuid.v4().replace(/-/g, "")
hex1buf = new Buffer(hex1str, "hex")
hex2str = uuid.v4().replace(/-/g, "")
hex2buf = new Buffer(hex2str, "hex")
result = new Array()
for i in [0...hex1buf.length]
r = hex1buf[i] ^ hex2buf[i]
result.push r
@yuiseki
yuiseki / gist:3689764
Created September 10, 2012 08:57
ALAssetsLibraryの取り扱い方法メモ
// AssetsLibrary.frameworkを追加し、
// .hで@property (nonatomic, strong) ALAssetsLibrary *library;とか宣言しておく
// 以下は、カメラロール内のある時点以降の画像をすべてUITableViewに表示しようとしている例
-(void)initAssetsLibrary
{
// TODO 保存時刻古い順でソートしたい → AssetsLibrary標準のAPIではできない
static dispatch_once_t pred = 0;
dispatch_once(&pred, ^{
self.library = [[ALAssetsLibrary alloc] init];
@yuiseki
yuiseki / gist:3338120
Created August 13, 2012 08:09
UIImageViewにタコメーター風の円弧描画 by CoreGraphics
// 与えられた正方形のImageViewと1から0のパーセント値に対して、タコメーター風の円弧を描くメソッド
- (void)drawArcToUIImageView:(UIImageView *)targetImageView withPercntage:(CGFloat)percnt
{
targetImageView.layer.needsDisplayOnBoundsChange=YES;
UIGraphicsBeginImageContext(targetImageView.frame.size);
struct CGContext *context = UIGraphicsGetCurrentContext();
CGPoint arcCenter = CGPointMake(targetImageView.frame.size.width/2, targetImageView.frame.size.height/2);
CGFloat outerRadius = (targetImageView.frame.size.width/2.0f)-1.0f;
CGFloat innerRadius = (targetImageView.frame.size.width/2.0f)-4.0f;
@yuiseki
yuiseki / ustreamdump.sh
Created June 12, 2012 13:56
Ustreamチャンネル名を指定するとrtmpdumpしてくれるシェルスクリプト ref: http://qiita.com/items/53194a24f0dff50ebdde
if [ $# -ne 1 ]; then
echo "usage: ustreamdump.sh channenName"
exit 1
fi
chid=$(wget http://api.ustream.tv/json/channel/${1}/getInfo?key=yourDevKey -q -O -|grep -Po '"id":[0-9]*?,'|grep -Po '[0-9]*')
if [ ! ${chid} ]; then
echo "api error, channelName: ${1}"
exit 1
fi
@yuiseki
yuiseki / gist:2893297
Created June 8, 2012 03:09
ustream録画rtmpdump
rtmpdump -v -r “rtmp://flash83.ustream.tv:1935/ustreamVideo/5883040/streams/live” -a "ustreamVideo/5883040" -y "streams/live" -f “LNX 10,1,58,3” -o `date +%s`.flv --stop 10
@yuiseki
yuiseki / EnableGoogleWebHistory.user.js
Created May 23, 2012 10:14
Userscript that enable using GoogleWebHistory in Opera and Firefox
// ==UserScript==
// @name EnableGoogleWebHistory
// @author mallowlabs
// @namespace http://mallowlabs.s206.xrea.com/
// @version 0.0.2
// @license public domain
// @description : Enable Google Web History
// @published 2007-01-05
// @modified 2006-01-05
// @include *
@yuiseki
yuiseki / facebook_event_selenium.html
Created March 30, 2012 08:22
facebook event comment form selenium
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://www.facebook.com/" />
<title>facebook event</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
@yuiseki
yuiseki / app.rb
Created March 29, 2012 06:05
sushi-yabai sinatra+redis
# -*- coding: utf-8 -*-
# http://sushi-yuiseki.dotcloud.com/
require 'rubygems'
require 'rack'
require 'sinatra'
require 'redis'
require 'json'
configure do
set :public_folder, 'public'
require "rubygems"
require "open-uri"
require "json"
require "google_spreadsheet"
# sudo gem install google-spreadsheet-ruby
if ARGV.size > 0
google_name = ARGV[0]
google_password = ARGV[1]
else