Skip to content

Instantly share code, notes, and snippets.

@batako
batako / .zshrc
Last active April 14, 2021 06:00
Raspberry Pi / Ubuntu / zsh
# ------------------------------
# 定数定義
# ------------------------------
# Zsh
export ZSH_THEME="robbyrussell"
export RPROMPT="%m"
# Oh My Zsh
export ZSH=~/.oh-my-zsh
{
~省略~
"keybindings":
[
~省略~
以下を追加
{ "command": "closeTab", "keys": "ctrl+shift+w" },
{ "command": "newTab", "keys": "ctrl+t" },
{ "command": { "action": "splitPane", "split": "vertical" }, "keys": "alt+\\" },
@batako
batako / install_postgresql_9.2.sh
Last active April 5, 2019 09:51
vagrant_scripts
#!/usr/bin/env bash
POSTGRES_VERSION=9.2
POSTGRES_REPOSITORY=https://download.postgresql.org/pub/repos/yum/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-8.noarch.rpm
PG_CONF_PATH=/var/lib/pgsql/$POSTGRES_VERSION/data/pg_hba.conf
echo Adding repository for postgresql...
sudo yum -y localinstall $POSTGRES_REPOSITORY
echo Installing postgresql${POSTGRES_VERSION/./}...
@batako
batako / animation.js
Last active April 8, 2019 14:02
FPS指定して関数実行
const cancelAnimationFrame = window.cancelAnimationFrame
|| window.mozcancelAnimationFrame
|| window.webkitcancelAnimationFrame
|| window.mscancelAnimationFrame;
let animationHandler = (callback, fps, autoFps) => {
if (!fps) fps = 1;
let basetime = Date.now();
const fpms = 1000/fps;
const requestAnimationFrame = window.requestAnimationFrame
var electronicWatermark = (function(){
// 書き込み用バッファ
var _implanted = [];
// チャンク探索
var _process = function(png, type, handler) {
var dataLength;
var chunkType;
var nextChunkPos;
var Signature = String.fromCharCode(137, 80, 78, 71, 13, 10, 26, 10);
@batako
batako / gist:3756095
Created September 20, 2012 13:59
PHP : MySQLへの接続
class db{
// ホスト名
protected $host = null;
// ユーザ名
protected $id = null;
// パスワード
protected $pw = null;
// データベース名
protected $db = null;
// セッション
@batako
batako / gist:3748114
Created September 19, 2012 07:08
FFmpeg : 動画からアスキートを生成
TEMP_FILE='.FILE_LIST.tmp'
make_temp_file() {
cd ${NAME}
ls -F | grep -v ./ > ${TEMP_FILE}
cd ../.
}
convert_png() {
BUFIFS=${IFS}
@batako
batako / gist:3727852
Created September 15, 2012 13:24
面白いJavascriptの書き方
/*
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Easter egg</title>
</head>
<body>
<div style="width:100%;height:100%;position:relative;">
<div style="width:510;height:430;position:absolute;top:50%;left:50%;margin-left:-255;margin-top:-240;">
@batako
batako / gist:3727831
Created September 15, 2012 13:22
Kwartz : コンバート
# 第一引数をコンマ区切りで配列に変換
STRING=${1##*/}
ary=( `echo $STRING | tr -s '.' ' '`)
# コンバート後のファイルの保存ディレクトリ
DIR="./"
# ディレクトリ指定がある場合はパスにシュラッシュを付加して代入
if [ $# -gt 1 ] ; then
# 保存先のディレクトリが存在するかチェック
@batako
batako / simple.tcl
Created September 11, 2012 08:45
NS-2
set ns [new Simulator]
set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf
set n0 [$ns node]
set n1 [$ns node]