Skip to content

Instantly share code, notes, and snippets.

View dyama's full-sized avatar

Daisuke YAMAGUCHI dyama

View GitHub Profile
@dyama
dyama / gist:7103855
Last active December 26, 2015 05:49 — forked from kachi/gist:2053869
<?php
// [gist id="ID" file="FILE"]
function gist_shortcode($atts) {
return sprintf(
'<script src="https://gist.github.com/%s.js%s"></script>',
$atts['id'],
$atts['file'] ? '?file=' . $atts['file'] : ''
);
} add_shortcode('gist','gist_shortcode');
@dyama
dyama / jbclock.html
Created November 17, 2013 15:45
JavaScriptによる二進数時計のサンプルです。上段から時、分、秒。24時間表示です。
<head>
<script type="text/javascript">
<!--
// 2010/01/08 jbClock by dyama
// for Firefox, Opera and Google Chrome
var BgColor = '#F00000';
var BaseColor = '#351309';
var ActiveColor = '#FF470F';
@dyama
dyama / update.sh
Created September 12, 2014 19:47
My markdown to html
#!/bin/bash
for file in `find . -type f -name '*.md' | xargs -I{} basename {} | sed 's/\.md$//g'`
do
(
echo '<!--#include file="head.html" -->'
markdown $file.md
echo '<!--#include file="foot.html" -->'
) > $file.html
chmod 644 $file.html
# Windows (notepad) like keybinding for nano editor
# Modified by dyama, Original code written by zonuexe,
# license under GPLv3 or NYSL(0.9982)
# lastupdate: h261124
#
# how to install
# a. rename and move this file to $HOME/.nanorc
# % mv nanorc.keybindings $HOME/.nanorc
# b. concatenate this file with tail of $HOME/.nanorc
# % cat nanorc.keybindings >> $HOME/.nanorc
@dyama
dyama / bfi.c
Last active August 29, 2015 14:18
Brain F*ck Interpretor
#include <stdio.h>
#define RAMSIZE 30000
int main(int argc, char **argv)
{
FILE *f; /* インストラクションポインタ */
int *p; /* データポインタ */
int b[RAMSIZE] = { 0 }; /* バッファ */
char c; /* 文字 */
int i; /* カウンタ */
@dyama
dyama / twitcast.sh
Last active February 7, 2021 07:16
Simple recorder for Twitcasting.tv
#!/bin/bash
# coding: utf-8
# twitcast.sh by dyama
if [ -n "$1" ]; then
id=$(echo "$1" | sed 's|^.*/||g')
fname="${id}_$(date +'%F_%H-%M-%S').ts"
ffmpeg -i "http://twitcasting.tv/$id/metastream.m3u8" \
-vcodec copy -acodec copy -f mpegts "$fname"
else
@dyama
dyama / conv.sh
Last active August 29, 2015 14:18
#!/bin/bash
# coding: utf-8
function compress_hash()
{
echo $2 | sed \
-e 's/aaa*/A/g' \
-e 's/abb*/B/g' \
-e 's/acc*/C/g' \
-e 's/add*/D/g' \
@dyama
dyama / vtl7.c
Created April 7, 2015 02:46
7 lines VTL interpretor
#include <stdio.h>
#include <stdlib.h>
char c[80];int v[25];int G(char*p){char*q=p;int n=(int)strtol(p,&p,0);return q-
p?n:v[*p++-65];}int E(char*p){int n=G(p);for(;*p;){char o=*p++;int m=G(p);if(o
==43)n+=m;if(o==45)n-=m;if(o==42)n*=m;if(o==47)n/=m;if(o==60)n=n<=m;if(o==61)n=
n==m;if(o==62)n=n>=m;}return n;}P(){printf("OK\n* ");}int main(){P();for(;gets(
c);){c[1]-61||*c-63?v[*c-65]=E(c+2):printf("%d\n",E(c+2));P();}return 0;}
@dyama
dyama / vtl.c
Created April 7, 2015 02:47
7 lines VTL interpretor (original)
#include <stdio.h>
#include <stdlib.h>
char c[80];
int v['Z'-'A'] = {0};
// 数値・値を解釈して取得
int getval(char* p)
{
char* q = p;
#!/usr/bin/ruby
# coding: utf-8
def get_score file1,file2
def pattern path
f = 16
tmp = '/tmp/imgmatch.xbm'
`convert -level 0%,75%,0.8 -fuzz 50% -trim -resize #{f}x#{f}! #{path} #{tmp}`
ptn = File.open(tmp).read.scan(/0x[\dA-F]{2}/).map{|n| n.hex.to_s(2).rjust(8, '0')}.join.split(//)
File.delete tmp