Skip to content

Instantly share code, notes, and snippets.

View gist:576290
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oauth.h>
int main(int argc, char **argv)
{
char *consumer_key = "*********************";
char *consumer_secret = "******************************************";
char *access_token = "********-*****************************************";
View variadic-template-fizzbuzz-c++0x.cpp
#include <iostream>
using namespace std;
namespace vtstring {
// 文字列を表す可変引数テンプレート
template <char... a> struct vtstring;
template <char a, char... b>
struct vtstring<a, b...>
{
View oauth-sign-url.rb
require 'oauth'
request = OAuth::RequestProxy.proxy(
"method" => 'GET',
"uri" => 'https://betastream.twitter.com/2b/user.json',
"parameters" => {
"oauth_consumer_key" => "******************",
"oauth_token" => "***-******************",
"oauth_nonce" => OAuth::Helper.generate_key,
"oauth_timestamp" => OAuth::Helper.generate_timestamp,
@NeoCat
NeoCat / chirp.js
Created Sep 25, 2010
Streaming API plugin and proxy server for twicli
View chirp.js
var chirp_cnt = 0;
function update() {
if (!myname) return auth();
callPlugins("update");
if (chirp_cnt++ == 0)
update_ele = loadXDomainScript(twitterAPI + 'statuses/home_timeline.json' +
'?count=' + (since_id ? 200 : max_count) +
'&suppress_response_codes=true&callback=twShow', update_ele);
else
update_ele = loadXDomainScript('http://localhost:10080/?seq='+ (seq++) +
@NeoCat
NeoCat / tweet_URL_with_twicli.js
Created Oct 9, 2010
Open twicli and input tweet with current URL and title
View tweet_URL_with_twicli.js
javascript:void(window.open('http://twicli.neocat.jp/twicli.html?status="'+encodeURIComponent(document.title)+'":%20'+location.href,'twicli'))
View transfer PTY via network
#!/usr/bin/ruby
require 'pty'
Signal.trap(:CHLD, 'IGNORE')
system "stty raw -echo 2> /dev/null"
p = PTY.spawn '/bin/sh'
until p[0].closed? || STDIN.closed?
s = IO.select [p[0], STDIN]
@NeoCat
NeoCat / test.html
Created Feb 6, 2011
Test for double onload of iframe in Opera with oAutoPagerize.js
View test.html
<html>
<head>
<script>
function test() {
var ifr = document.createElement("iframe");
document.body.appendChild(ifr);
ifr.onload = function(){ document.getElementById("log").innerHTML += "onload " }
ifr.contentWindow.document.write('');
ifr.contentWindow.document.close();
};
@NeoCat
NeoCat / toptracks.html
Created Mar 9, 2011
get toptracks of artist using last.fm API
View toptracks.html
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>last.fm API test</title>
<script>
var api_key = '0809689c938abf942a0d980ff25b5689';
var api_url = "http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&api_key="+api_key+"&format=json&autocorrect=1&artist=";
function $(id) { return document.getElementById(id); }
@NeoCat
NeoCat / share-input.rb
Created Apr 29, 2011
Share input within multiple terminals
View share-input.rb
#!/usr/bin/ruby
# share-input.rb: share input within multiple terminals
# Author: NeoCat
require 'socket'
require 'pty'
require "thread"
require "curses"
def server(sock, sock_name)
puts "relay server started."
@NeoCat
NeoCat / Bookmarklet.js
Created May 15, 2011
Send 'Chrome to Phone' request usig CGI and bookmarklet
View Bookmarklet.js
javascript:window.open('http://localhost/utils/chrome2phone.cgi?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href),%20'_blank',%20'width=200,height=100');undefined;