Skip to content

Instantly share code, notes, and snippets.

View vaiorabbit's full-sized avatar
🎮
busy playing video games

vaiorabbit

🎮
busy playing video games
View GitHub Profile
@vaiorabbit
vaiorabbit / patable.el
Created May 5, 2012 08:29
Generates pattern animation table from
; Generates pattern animation table from
; * image width/height
; * cell row/column/width/height.
(let (cw ch iw ih cc cr y)
(setq cw 240) (setq ch 296) (setq iw 1440) (setq ih 1480) (setq cc 6) (setq cr 5)
(setq y 0)
(while (< y cr)
(let (x)
(setq x 0)
(while (< x cc)
@vaiorabbit
vaiorabbit / gist:3155418
Created July 21, 2012 10:50
grep / grep-find のデフォルト引数
; [2012-07-21] grep / grep-find のデフォルト引数。文字コードが混在していても使えるよう lv を利用している。
(setenv "LC_CTYPE" "ja_JP.UTF-8")
(setq grep-use-null-device nil)
(setq grep-command "lv -g -Au8 -Kej -Ou8 -Ia -n ")
(setq grep-find-command '("find . ! -name '*~' -type f -print0 | xargs -0 lv -g -Au8 -Kej -Ou8 -Ia -n "))
(defadvice grep (around grep-coding-setup activate)
(let ((coding-system-for-read 'utf-8))
ad-do-it))
; [OS X 対策] grep.el にある '(setenv "TERM" "emacs-grep")' という記述のせいで grep の検索結果バッファに
; tput: unknown terminal "emacs-grep"
@vaiorabbit
vaiorabbit / close-open-paren.el
Created January 13, 2013 16:16
close-open-paren.el : insert appropriate closing parenthesis. 適切な閉じ括弧を自動入力する関数 (開き括弧と同時入力ではなく)
;;; -*- coding:euc-jp-unix; -*-
;;; close-open-paren.el : insert appropriate closing parenthesis.
;;; Ref.: http://www.emacswiki.org/emacs/UniversialCloseParen
;;; http://emacswiki.org/emacs/EmacsSyntaxTable
;;; skk/skk-tankan.el
(defconst close-open-paren-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?{ "(}" table)
(modify-syntax-entry ?} "){" table)
@vaiorabbit
vaiorabbit / zopfli(Per-Segment_Compression-20130303).c
Created March 3, 2013 09:28
Zopfli (https://code.google.com/p/zopfli/) のテスト用コマンド (zopfli.c) でセグメント単位の圧縮をやってみるテスト * "./zopfli --zlib [infile]" で 8Kごとに切って圧縮する * zlib_pufftest (https://github.com/vaiorabbit/zlib_pufftest) の inflate で展開できることを確認
/*
Copyright 2011 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@vaiorabbit
vaiorabbit / zopfli.h
Last active December 14, 2015 10:59
Zopfli (https://code.google.com/p/zopfli/) User API Header and Makefile to build libzopfli.a
# makefile_libzopfli : builds libzopfli.a from library codes.
# Usage :
# $ make -> libzopfli.a
# $ make command -> ./zopfli (test command)
SRCS = \
blocksplitter.c \
cache.c \
deflate.c \
gzip_container.c \
typedef unsigned int uint32;
#define FNV1_32A_INIT 0x811c9dc5
#define FNV_32_PRIME 0x01000193
uint32 fnv32a( const char* str )
{
uint32 hval = FNV1_32A_INIT;
while ( *str )
module Hashcode
FNV1_32A_INIT = 0x811c9dc5
FNV_32_PRIME = 0x01000193
UINT32_MAX = 2 ** 32
module_function
def fnv32a( str )
hval = FNV1_32A_INIT
str.bytes.each do |s|
@vaiorabbit
vaiorabbit / fnv32a.el
Last active October 8, 2023 03:50
FNV-1a Hash (http://isthe.com/chongo/tech/comp/fnv/) in Emacs Lisp.
(defun fnv32a (s)
"Calculates FNV-1a 32-bit hash of given string s."
(let (hval)
(setq hval 2166136261) ; hval = FNV1_32A_INIT
(loop for c across s do
(setq hval (logxor hval c)) ; hval ^= c
(setq hval (* 16777619 hval)) ; hval *= FNV_32_PRIME
(setq hval (mod hval 4294967296))) ; hval %= UINT32_MAX
hval))
@vaiorabbit
vaiorabbit / fnv32a.js
Last active February 4, 2024 19:49
FNV-1a Hash (http://isthe.com/chongo/tech/comp/fnv/) in JavaScript.
// 32 bit FNV-1a hash
// Ref.: http://isthe.com/chongo/tech/comp/fnv/
function fnv32a( str )
{
var FNV1_32A_INIT = 0x811c9dc5;
var hval = FNV1_32A_INIT;
for ( var i = 0; i < str.length; ++i )
{
hval ^= str.charCodeAt(i);
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
using System;
using System.IO; // TextReader,TextWriter,StreamReader,StreamWriter
using System.Text; // Encoding
using System.Text.RegularExpressions; // Regex, Match
/*
$ /Library/Frameworks/Mono.framework/Commands/mcs fnv32a.cs
$ /Library/Frameworks/Mono.framework/Commands/mono ./fnv32a.exe > tmp_cs.txt
*/
public class Hashcode
{