Skip to content

Instantly share code, notes, and snippets.

@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;
@laclefyoshi
laclefyoshi / print.c
Created February 12, 2012 05:47
scanf and printf
#include <stdio.h>
int main() {
char buf[256];
printf("string> ");
scanf("%s", buf);
printf(buf);
return;
}
@laclefyoshi
laclefyoshi / fizzbuzz.go
Created January 29, 2012 12:55
fizzbuzz in go
package main
import (
"fmt"
"os"
"strconv"
)
func stream(ch chan int) {
@laclefyoshi
laclefyoshi / cropping_pdf.scpt
Created January 21, 2012 12:58
cropping PDF by iBooks Author
-- Copyright : (c) SAEKI Yoshiyasu
-- License : MIT-style license
-- <http://www.opensource.org/licenses/mit-license.php>
-- last updated: 2012/01/21
on open droppedItems
tell application "Finder"
repeat with obj in droppedItems
set fileName to ((name of obj) as string)
set fileNameNoExt to (do shell script "basename " & fileName & " .pdf")
@laclefyoshi
laclefyoshi / tabliboutput.py
Created January 21, 2012 03:39
using tablib
import tablib
ds = tablib.Dataset()
ds.rpush(("Bob", 20), tags=['male', 'us'])
ds.rpush(("Carol", 31), tags=['female', 'us'])
ds.lpush(("Alice", 21), tags=['female', 'us'])
ds.rpush(("Taro", 10), tags=['male', 'jp'])
ds.headers = ["name", "age"]
@laclefyoshi
laclefyoshi / gist:1650970
Created January 21, 2012 02:54
tablib for jython patch
diff -r tablib-0.9.11.org/tablib/compat.py tablib-0.9.11/tablib/compat.py
15c15
<
---
> is_jython = sys.platform.lower().startswith("java")
28c28,29
< from tablib.packages.odf3 import opendocument, style, text, table
---
> if not is_jython:
> from tablib.packages.odf3 import opendocument, style, text, table
@laclefyoshi
laclefyoshi / post_im_kayac_com.py
Created January 6, 2012 14:02
posting message to im.kayac.com
#!/usr/bin/python
# -*- coding: utf-8 -*-
import hashlib
import urllib
user = "MY_IM_KAYAC_COM_ID"
secret_key = "MY_SECRET_KEY"
url = "http://im.kayac.com/api/post/" + user
message = u"This is a test message".encode("UTF-8")
@laclefyoshi
laclefyoshi / bot_im_kayac_com.py
Created January 6, 2012 13:57
xmpp client for monitoring im.kayac.com
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import sleekxmpp
class MonitoringBot(sleekxmpp.ClientXMPP):
def __init__(self, id, password):
sleekxmpp.ClientXMPP.__init__(self, id, password)
@laclefyoshi
laclefyoshi / gist:1360136
Created November 12, 2011 06:30
a python script
class Calc:
def __init__(self):
print "init Calc"
def add(self, a, b):
return (a + b)
def sub(self, a, b):
return (a - b)
@laclefyoshi
laclefyoshi / insertpackagepath.el
Created October 29, 2011 03:30
elisp for inserting package statement for Java
;; Copyright : (c) SAEKI Yoshiyasu
;; License : MIT-style license
;; <http://www.opensource.org/licenses/mit-license.php>
;; last updated: 2011/10/29
(defun join (sep lst)
(mapconcat 'identity lst sep))
(defun tail (lst)
(reverse (cdr (reverse lst))))