Skip to content

Instantly share code, notes, and snippets.

@9SQ
9SQ / Csv2array.java
Last active Aug 29, 2015
カンマ区切りで渡された引数を配列に
View Csv2array.java
public class Csv2array {
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java -jar Csv2array.jar [username(comma separated username)]");
System.exit(-1);
}
String[] split = args[0].split(",");
String[] usernameArray = new String[split.length];
for (int i = 0; i < usernameArray.length; i++) {
@9SQ
9SQ / gist:69de80d78d8b58a14750
Created Aug 15, 2014
PubSubHubbub subscriber (購読確認)
View gist:69de80d78d8b58a14750
private static final String verifyToken = "this_is_test";
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String hubMode = request.getParameter("hub.mode");
String hubChallenge = request.getParameter("hub.challenge");
String hubVerifyToken = request.getParameter("hub.verify_token");
if (hubMode != null && !hubMode.isEmpty() && hubChallenge != null
&& !hubChallenge.isEmpty() && hubVerifyToken != null && !hubVerifyToken.isEmpty()) {
if (hubVerifyToken.equals(verifyToken)) {
@9SQ
9SQ / Sent.java
Created Aug 17, 2014
カンマ区切りusername宛にYoを送信
View Sent.java
package sent_yo;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
@9SQ
9SQ / Callback.java
Last active Aug 29, 2015
Yo APIからのcallbackでコマンド等を実行
View Callback.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@9SQ
9SQ / SaxHandler.java
Created Aug 18, 2014
PuSHで来た気象庁XMLをSAXでパース
View SaxHandler.java
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.xml.bind.DatatypeConverter;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
public class SaxHandler extends DefaultHandler {
boolean entryFlag; // <entry></entry>内であることを記憶するフラグ
@9SQ
9SQ / openlayers_test1.html
Last active Aug 29, 2015
OpenStreetMap(EPSG:3857)の上にVector Layer(EPSG:4326)を乗せる (OpenLayers 3)
View openlayers_test1.html
<!doctype html>
<html lang="ja">
<head>
<link rel="stylesheet" href="http://openlayers.org/en/v3.0.0/css/ol.css" type="text/css">
<style>
.map {
height: 500px;
width: 100%;
}
</style>
@9SQ
9SQ / Uploader.java
Created Oct 15, 2014
multipart/form-dataで受けたデータを保存&Paramsも取得 (Tomcat7/Servlet3.0)
View Uploader.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
@9SQ
9SQ / openlayers3_test2.html
Created Oct 15, 2014
OpenLayers3でOSMにPointとPolygonを重ねる
View openlayers3_test2.html
<!doctype html>
<html lang="ja">
<head>
<link rel="stylesheet" href="http://openlayers.org/en/v3.0.0/css/ol.css" type="text/css">
<style>
.map {
height: 500px;
width: 100%;
}
@9SQ
9SQ / RCS620mod.cpp
Created Jul 3, 2015
RC-S620/SでTargetとして動作させる(特定のカードをエミュレート)
View RCS620mod.cpp
// add under "int RCS620S::initDevice(void){...}"
void RCS620S::tgInitTarget(const uint8_t* idm, const uint8_t* pmm, const uint8_t* rfu)
{
uint8_t response[RCS620S_MAX_RW_RESPONSE_LEN];
uint16_t responseLen;
uint8_t command[RCS620S_MAX_RW_RESPONSE_LEN] = {0x00};
uint8_t start[2] = {0xd4, 0x8c}; // command code & sub command code
uint8_t activated[1] = {0x02}; // Activated limit
uint8_t params106[6] = {0x00, 0x04, 0x00, 0x00, 0x00, 0x40}; // 106kbpsParams(6byte)
@9SQ
9SQ / AndroidManifest.xml
Created Jan 3, 2016
Androidの通知領域ボタンで動作分け(singleTaskで多重起動防止)
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.quitsq.notify3button">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
You can’t perform that action at this time.