Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
laclefyoshi / App.java
Created May 25, 2013 07:30
hosebird_kafka java code
package hosebird_kafka;
import com.twitter.hbc.ClientBuilder;
import com.twitter.hbc.core.Constants;
import com.twitter.hbc.core.endpoint.StatusesSampleEndpoint;
import com.twitter.hbc.core.processor.StringDelimitedProcessor;
import com.twitter.hbc.httpclient.BasicClient;
import com.twitter.hbc.httpclient.auth.Authentication;
import com.twitter.hbc.httpclient.auth.OAuth1;
import kafka.javaapi.producer.Producer;
@laclefyoshi
laclefyoshi / pom.xml
Created May 25, 2013 07:29
pom.xml for hosebird_kafka
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>hosebird_kafka</groupId>
<artifactId>hosebird_kafka</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hosebird_kafka</name>
int focusPin = 2;
int shutterPin = 3;
void setup() {
pinMode(focusPin, OUTPUT);
pinMode(shutterPin, OUTPUT);
pinMode(13, OUTPUT);
}
@laclefyoshi
laclefyoshi / gist:3925286
Created October 20, 2012 23:53
set font in emacs
(create-fontset-from-ascii-font
"Source Code Pro-14:weight=normal:slant=normal"
nil "codekakugo")
(set-fontset-font "fontset-codekakugo"
'unicode
(font-spec :family "Hiragino Kaku Gothic Pro" :size 16)
nil
'append)
(add-to-list 'default-frame-alist '(font . "fontset-codekakugo"))))
@laclefyoshi
laclefyoshi / gist:3883443
Created October 13, 2012 06:05
an example of MathML
<?xml version="1.0" encoding="UTF-8"?>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics>
<mtable>
<mtr>
<mtd>
<mrow>
<mrow>
<msup>
@laclefyoshi
laclefyoshi / gist:3830694
Created October 4, 2012 00:07
get indexies of local maximum values
#!/usr/bin/python
sample = [10, 11, 12, 1, 2, 3, 4, 2, 3]
temp = [0] + sample[0:-1]
points = map(lambda (x, y): x - 1,
            filter(lambda (i, v): v < 0,
                enumerate(map(lambda (a, b): a - b, zip(sample, temp)))))
if points[-1] != len(sample) - 1:
@laclefyoshi
laclefyoshi / test_phash.cpp
Created September 8, 2012 12:24
cpp code using phash
/**
Copyright: (c) SAEKI Yoshiyasu
License : MIT-style license
<http://www.opensource.org/licenses/mit-license.php>
last updated: 2012/09/08
**/
#include<cstdio>
#include<pHash.h>
@laclefyoshi
laclefyoshi / test_libpuzzle.c
Created September 8, 2012 11:42
c code using libpuzzle
/**
Copyright: (c) SAEKI Yoshiyasu
License : MIT-style license
<http://www.opensource.org/licenses/mit-license.php>
last updated: 2012/09/08
**/
#include<stdio.h>
#include<stdlib.h>
#include<puzzle.h>
@laclefyoshi
laclefyoshi / get_unused_port.py
Created June 16, 2012 08:00
get unused port in Jython
>>> import socket
>>> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> sock.bind(('localhost', 0))
>>> sock.getsockname()
(u'127.0.0.1', 0)
>>> sock.listen(1)
>>> sock.getsockname()
(u'127.0.0.1', 49201)
>>> unused_port = _[1]
>>> sock.close()
@laclefyoshi
laclefyoshi / get_unused_port.py
Created June 16, 2012 07:55
get unused port
>>> import SocketServer
>>> ss = SocketServer.TCPServer(('localhost', 8080), None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 408, in __init__
self.server_bind()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 419, in server_bind
self.socket.bind(self.server_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)