Skip to content

Instantly share code, notes, and snippets.

@metaphox
metaphox / Importing posts from Wordpress into Jekyll.rb
Created February 26, 2012 10:31 — forked from vitobotta/Importing posts from Wordpress into Jekyll.rb
The script I used to import posts from my Wordpress blog into a new Jekyll one.
%w(rubygems sequel fileutils yaml active_support/inflector).each{|g| require g}
require File.join(File.dirname(__FILE__), "downmark_it")
module WordPress
def self.import(database, user, password, table_prefix = "wp", host = 'localhost')
db = Sequel.mysql(database, :user => user, :password => password, :host => host, :encoding => 'utf8')
%w(_posts _drafts images/posts/featured).each{|folder| FileUtils.mkdir_p folder}
@metaphox
metaphox / terminwatch.py
Created April 15, 2012 23:28
watch shanghai german consulate termin
#!/usr/bin/env python
#-*- coding: utf-8 -*-#
import smtplib, time, urllib2
from bs4 import BeautifulSoup
from email.mime.text import MIMEText
def mailme(message):
msg = MIMEText(message)
msg['Subject'] = 'German Consu Termin!'
msg['From'] = '[email protected]'
@metaphox
metaphox / vim7.3_mac_install.rb
Created April 24, 2012 23:46 — forked from sirupsen/vim7.3_mac_install.rb
Script to install Vim 7.3 with ruby support for Mac OS X Lion
# requires root permissions in /usr/bin/
star = String.new
8.times { star += "*" }
Star = "\n#{star * 3}\n"
def newblock string
puts "\n#{Star}#{string}#{Star}\n"
end
@metaphox
metaphox / example-user.js
Created May 5, 2012 14:42 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9-_]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@metaphox
metaphox / Default (OSX).sublime-keymap
Last active October 10, 2015 21:48
sublime text 2 settings
[
{
"keys": ["alt+w"],
"command": "toggle_setting",
"args":
{
"setting": "word_wrap"
}
}
]
@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()
@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 / 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 / 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 / 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];