Skip to content

Instantly share code, notes, and snippets.

@nitoyon
nitoyon / rgb.go
Created Jan 1, 2016
Generate Animation GIF with Golang
View rgb.go
package main
import (
"fmt"
"image"
"image/color"
"image/gif"
"math"
"os"
)
View redcarpet-header-bug.rb
# 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 / peco-select-git-restore.sh
Last active Aug 29, 2015
Clean unstaged & untracked files in git repository with peco
View peco-select-git-restore.sh
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
View crlf-test.txt
End of Line Character Test
Which do you like CR LF or LF?
This file uses "CR LF"!!!!
Clone me!
@nitoyon
nitoyon / test.lua
Last active Dec 17, 2015
Get selected file size and path in Lightroom (tested with https://github.com/nitoyon/lua-console-lightroom-plugin & Lightroom 4.3)
View test.lua
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 / Foo.as
Created Oct 13, 2012
ure ActionScript SWF capture demo 2
View Foo.as
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 / HelloSpace.as
Created Oct 13, 2012
Pure ActionScript SWF capture demo 1
View HelloSpace.as
// キラキラ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 / parse_log.pl
Created Apr 25, 2012
Parse HTTP access log and find web font download ratio.
View parse_log.pl
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 / replace_glyph.py
Created Apr 19, 2012
Cipher text with web font
View replace_glyph.py
#!/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 / async_await_js.html
Created Sep 21, 2011
Test Implementation of .NET 5 `await` and `async` in JavaScript 1.7
View async_await_js.html
<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: