Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
laclefyoshi / chrome_socket_sample.js
Created May 16, 2012 13:23
sample code for using socket API in Google Chrome
var udp_socket_writer = function(host, port, string) {
var string2ArrayBufferAndWrite = function(str) { // http://goo.gl/1eJnn
var bb = new WebKitBlobBuilder();
bb.append(str);
var f = new FileReader();
f.onload = function(e) {
var data = e.target.result;
chrome.experimental.socket.create(
'udp', {},
@laclefyoshi
laclefyoshi / checkstyle.sh
Created April 15, 2012 04:24
checkstyle script
#!/bin/sh
java -cp /opt/src/checkstyle-5.5/checkstyle-5.5-all.jar com.puppycrawl.tools.checkstyle.Main \
-c /opt/src/checkstyle-5.5/sun_checks.xml "$1"
@laclefyoshi
laclefyoshi / flymake_checkstyle.el
Created April 15, 2012 04:15
using checkstyle with flymake
;; flymake + checkstyle
(require 'flymake-cursor)
(add-hook 'java-mode-hook
'(lambda ()
(flymake-mode t)))
(when (load "flymake" t)
(defun flymake-java-checkstyle-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
@laclefyoshi
laclefyoshi / SumURLHandler.py
Created April 1, 2012 02:09
handler for URL:sum://
#!/usr/bin/env jython
# -*- coding: utf-8 -*-
# Copyright : (c) SAEKI Yoshiyasu
# License : MIT-style license
# <http://www.opensource.org/licenses/mit-license.php>
# last updated: 2012/04/01
from java.lang import String
from java.net import URL
@laclefyoshi
laclefyoshi / SumURLHandler.scala
Created April 1, 2012 01:27
handler for URL:sum://
/**
Copyright: (c) SAEKI Yoshiyasu
License : MIT-style license
<http://www.opensource.org/licenses/mit-license.php>
last updated: 2012/03/31
**/
import java.net.{URL, URLConnection, URLStreamHandler, URLStreamHandlerFactory}
import java.io.{InputStream, InputStreamReader, ByteArrayInputStream}
@laclefyoshi
laclefyoshi / Mode.java
Created March 24, 2012 13:10
show size of pointer
class Mode {
public static void main(String[] args) {
System.out.println(System.getProperty("sun.arch.data.model"));
}
}
@laclefyoshi
laclefyoshi / mode.py
Created March 24, 2012 12:27
show size of pointer
#!/usr/bin/env python
import struct
print(struct.calcsize("P")) # "P" = (void *) ; seealso: http://docs.python.org/library/struct.html#format-characters
@laclefyoshi
laclefyoshi / mode.c
Created March 24, 2012 12:23
show size of pointer
#include<stdio.h>
int main() {
printf("%ld\n", sizeof(void *));
return 0;
}
@laclefyoshi
laclefyoshi / mode.pl
Created March 24, 2012 12:38
show size of pointer
use warnings;
use strict;
use Config;
print $Config{ptrsize};
@laclefyoshi
laclefyoshi / MyURL.java
Created March 17, 2012 12:49
class for manipulating URL
package org.saekiyoshiyasu.common;
/**
Copyright: (c) SAEKI Yoshiyasu
License : MIT-style license
<http://www.opensource.org/licenses/mit-license.php>
last updated: 2012/03/16
**/
import java.net.URL;