Skip to content

Instantly share code, notes, and snippets.

View gofer's full-sized avatar

Gofer gofer

View GitHub Profile
#!/usr/bin/env perl
################################################################################
# Vyattaのhoeg{~~~}形式をset ~~~形式に変換するスクリプト
################################################################################
use strict;
use warnings;
use constant true => 1;
use constant false => 0;
fun op ** (a, b) = let
val succ = fn x => x + 1
val pred = fn x => x - 1
val c = if a < b then succ a else pred a
in
if a = b then [a] else a::(op ** (c ,b))
end;
infix **;
fun op *** (a, b) = let
.align 8
.text
.globl linux_fast_abs64
linux_fast_abs64:
movq %rdi, %rax # rax <- x
sarq $63, %rax # rax <- rax >> 63
xorq %rax, %rdi # rdi <- rdi ^ rax
subq %rax, %rdi # rdi <- rdi - rax
movq %rdi, %rax # rax <- rdi
retq
@gofer
gofer / encode
Last active August 29, 2015 14:12
ffmpeg -y -i input.ts -movflags faststart \
-f mp4 -vcodec libx264 -fpre /usr/local/share/ffmpeg/libx264.ffpreset -r 30000/1001 \
-aspect 16:9 -s 1440x1080 -bufsize 20000k -maxrate 25000k -vsync 1 \
-acodec libfaac -ac 2 -ar 48000 -ab 320k output.mp4 -map "0.0" -map "0.1"
# ffmpeg -y -i input.ts -movflags faststart -f mp4 -vcodec libx264 -fpre -r
# 14839.19s user 26.57s system 691% cpu 35:49.17 total
class HTTP_Digest
def initialize(uri)
@uri = uri
req = Net::HTTP::Get.new(@uri.path)
res = Net::HTTP.new(@uri.host, @uri.port).start { |http|
http.request(req)
}
@digest_hash = {}
@gofer
gofer / vector2d.hpp
Created April 25, 2015 16:15
Vector2DBase
#include <sstream>
#include <cmath>
template<typename T>
struct Vector2DBase
{
T x, y;
Vector2DBase() : x(0.0), y(0.0) {}
Vector2DBase(T x, T y) : x(x), y(y) {}
@gofer
gofer / bin_tree.sml
Last active August 15, 2018 16:34
Binary Search Tree
(* MLton用 ORD_KEY signature *)
(*
signature ORD_KEY =
sig
type ord_key
val compare : (ord_key * ord_key) -> order;
end;
*)
(* 2分木のシグネチャ *)
@gofer
gofer / avl_tree.sml
Last active August 15, 2018 16:33
AVL Tree
(* MLton用 ORD_KEY signature *)
(*
signature ORD_KEY =
sig
type ord_key
val compare : (ord_key * ord_key) -> order;
end;
*)
(* 2分木のシグネチャ *)
@gofer
gofer / cookie_expires_date
Last active August 29, 2015 14:23
Cookie Expires Date Regular Expression
@gofer
gofer / .zshrc
Last active November 13, 2015 11:06
Tools for Zsh on Cygwin
# Cygwin環境
if [ `uname -a | grep 'Cygwin' | wc -c` -ne 0 ]; then
# Standard ML
export SMLNJ_HOME="$(cygpath -u 'C:\Program Files\SMLNJ')"
function _sml()
{
export CM_PATHCONFIG="$(cygpath -w ${SMLNJ_HOME}/lib/pathconfig)"
${SMLNJ_HOME}/bin/.run/run.x86-win32.exe @SMLload="$(cygpath -w ${SMLNJ_HOME}/bin/.heap/sml.x86-win32)"
}
alias sml=_sml