Skip to content

Instantly share code, notes, and snippets.

View gofer's full-sized avatar

Gofer gofer

View GitHub Profile
@gofer
gofer / cookie_expires_date
Last active August 29, 2015 14:23
Cookie Expires Date Regular Expression
@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 / 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 / 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) {}
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 / 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
.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
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
#!/usr/bin/env perl
################################################################################
# Vyattaのhoeg{~~~}形式をset ~~~形式に変換するスクリプト
################################################################################
use strict;
use warnings;
use constant true => 1;
use constant false => 0;
@gofer
gofer / set.sml
Created December 19, 2013 09:16
Set.sml
signature SetSig =
sig
val empty : ''a list
val is_in : ''a -> ''a list -> bool
val is_not_in : ''a -> ''a list -> bool
val rm_elem : ''a -> ''a list -> ''a list
val isect : ''a list -> ''a list -> ''a list
val union : ''a list -> ''a list -> ''a list
val diff : ''a list -> ''a list -> ''a list
end