Skip to content

Instantly share code, notes, and snippets.

@nitoyon
nitoyon / async_await_js.html
Created September 21, 2011 15:49
Test Implementation of .NET 5 `await` and `async` in JavaScript 1.7
<html>
<body onload="init2()">
<script type="application/javascript;version=1.7">
/*===========================================================================*
* Test Implementation of .NET 5 `await` and `async` in JavaScript 1.7
*===========================================================================*
* !!!!! This sample only works on Firefox !!!!!
* (Other browsers don't support `yield` statement)
*===========================================================================*
* use `async` function like:
@nitoyon
nitoyon / replace_glyph.py
Created April 19, 2012 17:37
Cipher text with web font
#!/usr/bin/python
# -*- coding: utf-8 -*-
import fontTools.ttLib.tables
import fontTools.ttLib
s1 = u"コピペできない文章です!! 嘘じゃないよ"
s2 = u"ほら。無理でしょ?絶対に不可能なんです!"
tt = fontTools.ttLib.TTFont("mplus-2p-regular.ttf")
@nitoyon
nitoyon / parse_log.pl
Created April 25, 2012 17:35
Parse HTTP access log and find web font download ratio.
use strict;
use warnings;
use HTTP::BrowserDetect;
use Data::Dumper;
use DateTime::Format::HTTP;
use DateTime::Duration;
my $browser = new HTTP::BrowserDetect("");
my $total = 0;
@nitoyon
nitoyon / HelloSpace.as
Created October 13, 2012 15:31
Pure ActionScript SWF capture demo 1
// キラキラ3D Typography
//-----------------------------------------------------
// 次の2つの組み合わせ+αです
// - HelloWorld3D
// http://wonderfl.net/code/50225c9944de6206a3813f515fce2c51fd56ab23
// - キラキラPixel3D! in Native Flash 10 3D API
// http://wonderfl.net/code/8283df8a03a8f3c290bc88a056b44b3c6084b123
package {
import flash.display.*;
import flash.events.Event;
@nitoyon
nitoyon / Foo.as
Created October 13, 2012 17:13
ure ActionScript SWF capture demo 2
package{
import flash.display.*;
import flash.events.Event;
import flash.text.*;
import flash.filters.*;
import flash.geom.*;
import caurina.transitions.Tweener;
[SWF(width=640, height=360)]
public class Foo extends Sprite{
@nitoyon
nitoyon / test.lua
Last active December 17, 2015 23:59
Get selected file size and path in Lightroom (tested with https://github.com/nitoyon/lua-console-lightroom-plugin & Lightroom 4.3)
local LrApplication = import 'LrApplication'
local catalog = LrApplication.activeCatalog()
local size = 0
local pathes = ""
local photos = catalog:getMultipleSelectedOrAllPhotos()
for k,photo in ipairs(photos) do
size = size + photo:getRawMetadata("fileSize")
pathes = pathes .. "\n" .. photo:getRawMetadata("path")
end
@nitoyon
nitoyon / crlf-test.txt
Last active May 2, 2019 10:21
CR LF Test
End of Line Character Test
Which do you like CR LF or LF?
This file uses "CR LF"!!!!
Clone me!
@nitoyon
nitoyon / peco-select-git-restore.sh
Last active August 29, 2015 14:21
Clean unstaged & untracked files in git repository with peco
function peco-select-git-restore() {
git status --porcelain | \
peco --query "$LBUFFER" | \
cut -f 2- -d ' ' | \
while read FILE; do
git clean -f -- "$FILE"
if [ -f "$FILE" ]; then
git checkout -- "$FILE"
fi
done
# reproducable code for https://github.com/vmg/redcarpet/issues/474
# (redcarpet-3.3.3, Windows 10 x64)
require 'redcarpet'
class TestRenderer < Redcarpet::Render::HTML
def emphasis(text)
"a" * 117
end
end
@nitoyon
nitoyon / rgb.go
Created January 1, 2016 16:08
Generate Animation GIF with Golang
package main
import (
"fmt"
"image"
"image/color"
"image/gif"
"math"
"os"
)