Skip to content

Instantly share code, notes, and snippets.

@metaphox
metaphox / rename.sh
Created February 21, 2013 13:09
change committer name
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "<Old Name>" ];
then
GIT_COMMITTER_NAME="<New Name>";
GIT_AUTHOR_NAME="<New Name>";
GIT_COMMITTER_EMAIL="<New Email>";
GIT_AUTHOR_EMAIL="<New Email>";
git commit-tree "$@";
else
git commit-tree "$@";
@metaphox
metaphox / .zshrc
Created February 20, 2013 17:07
zsh theme
# metaphox.zsh-theme
#
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
# primary prompt, 80 col ruler, with double dash at 40
# PROMPT='$FG[237]\
'#'+Math.floor(Math.random()*16777215).toString(16);
@metaphox
metaphox / tree.md
Created January 3, 2013 06:32 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

#!/bin/sh
#
# This shows a MacBook Pro Retina screen model number.
# The modile number will be something like LP154YL01001.
#
# * "LS" prefix: built by Samsung
#
# * "LP" prefix: built by LG
#
# The screens manufactured by LG have had many problems with ghosting and image retention.
@metaphox
metaphox / playback.m
Created November 21, 2012 10:19
play back from - to snippet
NSString *myAudioFileInBundle = @"words.mp3";
NSTimeInterval wordStartsAt = 1.8;
NSTimeInterval wordEndsAt = 6.5;
NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:myAudioFileInBundle];
NSURL *myFileURL = [NSURL fileURLWithPath:filePath];
AVAudioPlayer *myPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:myFileURL error:nil];
if (myPlayer) {
[myPlayer setCurrentTime:wordStartsAt];
[myPlayer prepareToPlay];
[myPlayer play];
@metaphox
metaphox / font-stack.css
Created October 24, 2012 15:15
font stack
/* Times New Roman-based stack */
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
/* Modern Georgia-based serif stack */
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif;
/* Traditional Garamond-based serif stack */
font-family: "Palatino Linotype", Palatino, Palladio, "URW Palladio L", "Book Antiqua", Baskerville, "Bookman Old Style", "Bitstream Charter", "Nimbus Roman No9 L", Garamond, "Apple Garamond", "ITC Garamond Narrow", "New Century Schoolbook", "Century Schoolbook", "Century Schoolbook L", Georgia, serif;
/* Helvetica/Arial-based sans serif stack */
@metaphox
metaphox / toolbox.md
Last active June 2, 2020 10:29
Toolbox Construction

Rebuild Your OS X Toolbox: A Reminder

From Metaphox for Metaphox

Prerequisites

  1. XCode
  2. xcode-select --install
  3. iTerm2 http://iterm2.com/
@metaphox
metaphox / DCPU-16Spec.txt
Created October 14, 2012 09:40
DCPU-16 Specification
DCPU-16 Specification
Copyright 1985 Mojang
Version 1.7
=== SUMMARY ====================================================================
* 16 bit words
* 0x10000 words of ram
@metaphox
metaphox / random.c
Created September 21, 2012 20:06
random C thing
//以下は、c でも c++ でも同じ。
//X(x) になってるところは全て警告orエラーになる。
// http://d.hatena.ne.jp/cicupo2/
void foo(void*x){}
#define C const
#define X(x) /* x */
int main()