Skip to content

Instantly share code, notes, and snippets.

View fand's full-sized avatar
💭
🔪

AMAGI / Jun Yuri fand

💭
🔪
View GitHub Profile
@fand
fand / md5.pl
Created January 31, 2014 08:26
Digest::MD5 hex digest ???
use strict;
use warnings;
use utf8;
use Encode;
use Digest::MD5;
use v5.010;
my $str = 'ジムに行き筋肉ムキムキ';
# OOP style
@fand
fand / mosh.pl
Created May 16, 2014 01:20
Perl AVI datamosh 修正版
open $f_in, '<', $ARGV[0];
read $f_in, my $buf, -s $ARGV[0];
my ( $movi, $idx1 ) = ( index( $buf, "movi" ), index( $buf, "idx1" ) );
my @frames =
map { [ unpack( 'a4VVV', substr( $buf, $idx1 + 8 + $_ * 16, 16 ) ) ] }
0 .. ( ( unpack( 'V', substr( $buf, $idx1 + 4, 4 ) ) / 16 ) - 1 );
my ( $movi_new, $idx1_new, $count ) = ( "movi", substr( $buf, $idx1, 8 ), 0 );
for (@frames) {
my $offset = length $movi_new;
if (@$_[0] =~ /00d./ && @$_[1] & 0x10 && $count != 0) {
@fand
fand / cpusound.js
Created June 4, 2014 02:52
CPUSOUND
var spawn = require('child_process').spawn;
var top = spawn('top', ['-b', '-d', '1']);
var buf = '';
top.stdout.on('data', function(data){
buf = data.toString();
});
var baudio = require('baudio');
var b = baudio(function (t, i) {
@fand
fand / check-odd.coffee
Created September 20, 2014 08:13
Q.Promiseつかう
## いろいろなPromiseライブラリを使ってみる
## Qだけthrow new Errorが捕まえられなかった
# {Promise} = require 'es6-promise'
Promise = require('q').Promise
# Promise = require 'bluebird'
checkOdd = (num) ->
return new Promise (resolve) ->
if typeof num isnt 'number'
@fand
fand / initManually.js
Created July 11, 2015 15:36
WDIO3 multi browser test
'use strict';
var webdriverio = require('webdriverio');
var assert = require('assert');
describe('top page', function () {
var chrome, firefox;
before(function *() {
chrome = webdriverio.remote({ desiredCapabilities : {browserName : 'chrome'} });
@fand
fand / memo.md
Last active August 29, 2015 14:24
Esprima Syntax メモ

かならず Program で始まる

Program

  • type
  • body: [Statement]
    • ExpressionStatement, VariableDeclaration, EmptyStatement, DebuggerStatement, TryStatement が入る?
@fand
fand / router.js
Created July 17, 2015 06:41
Promiseベースの簡易ルータ
const EVENT = (pageID) => 'register:' + pageID
class Router extends EventEmitter {
constructor () {
this.routes = {};
}
getController (pageID) {
return new Promise((resolve, reject) => {
this.once(EVENT(pageID), function () {
@fand
fand / eslint.js
Created October 1, 2015 03:28
勤怠と同時にESLint設定かえるくん
'use strict';
var fs = require('fs-promise');
var SECRET = require('../SECRET');
module.exports = function (mode) {
// ESLint設定を変更する
var indentValue;
@font-face {
font-family: droidsans;
src: url('http://font.gmork.in/droidsans') format('svg');
}
#droidsans{
font-family: droidsans;
}
@fand
fand / synth one liner
Created July 19, 2013 20:14
one-liner music in perl one-liner
perl -e 'while(1){print pack("S",(((($t*(($t<<3)+303|$t<<7|$t>>10|($t<<4)+200|($t>>5&80)|($t*$t-606)&(~$t>>4))&808+$t>>12)&(101|151)&$t>>4))|($t|(($t>>8|$t<<5|$t<<7|$t>>14)&7|(~$t>>5))&$t>>6)&(~$t>>10))).pack("S",(((($s*(($s<<3)+303|$s<<7|$s>>10|($s<<4)+200|($s>>5&80)|($s*$s-606)&(~$s>>4))&808+$s>>12)&(101|151)&$s>>4))|($s|(($s>>8|$s<<5|$s<<7|$s>>14)&7|(~$s>>5))&$s>>6)&(~$s>>10))); $t+=1.5; $s+=96}' | pacat