Skip to content

Instantly share code, notes, and snippets.

;;-----------------------
;; WIP
;;-----------------------
(defn deep-reverse [l]
(cond (not (coll? l)) l
(= (count l) 0) []
(= (count l) 1) (deep-reverse (first l))
:else [(deep-reverse (rest l)) (deep-reverse (first l))]
(define (make-exponentiation x n)
(cond ((= n 0) 1)
((= n 1) x)
(else (list '** x n))))
(define (exponentiation? x)
(and (pair? x) (eq? (car x) '**)))
(define (base x)
(cadr x))
@xorphitus
xorphitus / jabber-hipchat.el
Last active December 26, 2015 04:29
EmacsでHipChat jabber.elが必要
;; HipChatのJabber IDが 1234_5678@chat.hipchat.com の場合
(require 'jabber-autoloads)
;; HipChat
(defvar hipchat-number "1234")
(defvar hipchat-full-number (concat hipchat-number "_5678"))
(defvar hipchat-nickname "Foo Bar")
(defvar hipchat-server "chat.hipchat.com")
(defvar hipchat-full-name (concat hipchat-full-number "@" hipchat-server))
@xorphitus
xorphitus / feed_to_growl.py
Last active December 11, 2015 07:09
feedをgrowlで通知する。python 2.7 (3系はむりぽ) nstallation (Linux) $ pip install gntp $ pip install feeparser $ pip install python-daemon $ sudo apt-get install growl-for-linux usage $ gol & $ ./feed_to_growl.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
# https://github.com/mattn/growl-for-linux
# https://github.com/kfdm/gntp
# http://code.google.com/p/feedparser/
# https://github.com/serverdensity/python-daemon
import gntp.notifier
import feedparser
@xorphitus
xorphitus / node_jquery_sample.js
Created September 20, 2012 04:52
Node.jsにてjQueryを使ってDOM操作して出力する例
// appreciate for http://sakuratan.biz/archives/3393
var sys = require('sys'),
fs = require('fs'),
jsdom = require('jsdom'),
jqSrc = 'https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js',
content,
document,
window;
@xorphitus
xorphitus / MultiPartEntityCreator.java
Created July 29, 2012 12:42
HttpClient4ではMultipart用のエンティティクラスが存在しないため自前でこしらえる
String filename = getFilename();
InputStream is = getFileContent();
MultipartEntity mEntity = new MultipartEntity(HttpMultipartMode.STRICT, null, Charset.forName("UTF-8"));
mEntity.addPart(filename, new InputStreamBody(is, filename));
ByteArrayOutputStream oaos = new ByteArrayOutputStream();
try {
mEntity.writeTo(oaos);
} catch (IOException e) {
@xorphitus
xorphitus / duplsort.js
Created July 19, 2012 07:41
charsの中で2度以上現れる文字を降順にソートした文字列を得る
var chars = ['a', 'w', 'b', 'b', 'c', 'w', 'q', 'e', 'w', 'u', 't', 'e', 'b', 'b', 'e', '1', 'e', '2', 'e'];
var set = Object.create(null),
result = chars.filter(function (i) {
var bl = set[i];
set[i] = true;
return bl;
}).sort().reverse().reduce(function (a, b) {
return a + (a.indexOf(b) < 0 ? b : '');
});
@xorphitus
xorphitus / template.user.js
Created July 8, 2012 01:17
jQueryを使えるuser.jsのテンプレート
// ==UserScript==
// @name user.js template
// @namespace http://hoge.co.jp/
// @include http://foo.com/*
// @exclude
// @author xorphitus
// @description this is a template of user script
// @version 0.0.1
// ==/UserScript==
@xorphitus
xorphitus / lazyload.js
Created May 24, 2012 14:18
jQuery Defferedを使った画像の遅延ロード
/*global jQuery */
(function ($, window) {
"use strict";
$.fn.lazyload = function (options) {
var orgSrcAttr = options.orgSrcAttr || 'original',
altImgSrc = options.altImgSrc,
timeout = isNaN(options.timeout) ? 3000 : options.timeout, // milli sec
deferred = typeof options.deferred === 'boolean' ? options.deferred : true,
targets,
@xorphitus
xorphitus / XlsExtract.scala
Created May 15, 2012 15:04
特定のフォルダ配下にあるExcelファイル (xls形式限定) の全シートからから特定のセルを抽出してCSV出力する
import java.io.File
import jxl._
val xlsDir = "./xls"
new File(xlsDir).listFiles.foreach ({ xlsFile =>
Workbook.getWorkbook(xlsFile).getSheets.filter(_.getName.matches("[A-Z_]+")).foreach({ sheet =>
val group = sheet.getCell(2, 1).getContents
for (row <- 3 until sheet.getRows()) {
val category = sheet.getCell(0, row).getContents