Skip to content

Instantly share code, notes, and snippets.

View kamikat's full-sized avatar

Kamikat kamikat

View GitHub Profile
@kamikat
kamikat / pipeline_pattern.py
Last active March 18, 2021 19:02
a simple demo of pipeline pattern for python
def processor1(obj):
"""Require: text; yield firstchar"""
obj['firstchar'] = obj.text[:1]
return obj
def processor2(obj):
"""Require: firstchar, text2; yield concat"""
obj['concat'] = obj.firstchar + obj.text2
return obj
@kamikat
kamikat / attrdict.py
Last active December 17, 2015 12:09
python 2.7 implementation of AttributeDict
class AttributeDict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
a = AttributeDict()
a['item'] = 1
assert a.item == 1
@kamikat
kamikat / gist:5607705
Last active December 17, 2015 12:09
Java, "auto" class binding wrapper for Map class
import java.utils.Map;
public class ABMap implements Map {
private final Map src;
public ABMap(Map src) {
this.src = src;
}
@kamikat
kamikat / frontend.js
Created July 24, 2013 05:50
use iframe-transport with jasny bootstrap-fileupload
// First, you need download iframe-transport from following address
// https://github.com/cmlenz/jquery-iframe-transport/raw/master/jquery.iframe-transport.js
// Then, add <script/> tag to your page
$.ajax({
url: '<url to send file to>',
files: $('select the input:file html tags'),
iframe: true, // use iframe as ajaxTransport
success: function (data) {
// Here we got data(response from server)
@kamikat
kamikat / opencl-mat.md
Last active December 29, 2015 05:38
Mark some material for OpenCL development
// ==UserScript==
// @name Nekonazo Party Wacom Support Fix
// @namespace https://kirisetsz.github.io/
// @version 0.1
// @description Load Wacom Tablet support to Nekonazo Party (for WacomWebPlugin)
// @match http://oekaki.so/partyex/*
// @copyright 2012+, kirisetsz
// ==/UserScript==
window.addEventListener('load', function ()
@kamikat
kamikat / skydrive.js
Created January 27, 2014 11:37
Bookmarklet generating external link address for SkyDrive
(function () {
var $ = jQuery;
// Selected Items
var $selected = $('.surface .child .isSelected');
if (!$selected.is('a.file')) {
// Handle List Box View
@kamikat
kamikat / onedrive.user.js
Last active August 29, 2015 13:55
不可視境界線を示す! Permanent external links from skydrive, useful to share links with friends or apply as source for image/audio
// ==UserScript==
// @name OneDrive External Links Button
// @namespace https://kirisetsz.github.io/
// @version 0.1
// @description 不可視境界線を示す! Permanent external links from skydrive, useful to share links with friends or apply as source for image/audio
// @match https://onedrive.live.com/*
// @copyright 2014, kirisetsz
// ==/UserScript==
var sekai = function () {
@kamikat
kamikat / burnin.bash
Last active November 2, 2015 02:33
Headphone burnin script
#!/bin/bash
# Headphone burnin program use SoX tools
function wlog {
echo "[`date +%F\ %T`]" $@
}
AUDIODEV=${AUDIODEV:-"default"}
wlog "Select device [$AUDIODEV]"
@kamikat
kamikat / wc.c
Created March 21, 2014 06:09
咱这是多久没写 C 了……
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFER_SIZE (1024)
int main (int argc, char **argv) {
int flags = 0;
char* path = NULL;