Skip to content

Instantly share code, notes, and snippets.

View zonble's full-sized avatar

Weizhong Yang a.k.a zonble zonble

View GitHub Profile
@zonble
zonble / gist:1164254
Created August 23, 2011 03:17
大字產生器
#!/usr/bin/python
# -*- coding:utf-8 -*-
import objc
from Cocoa import *
def bigText(text):
attrs = {NSFontAttributeName : NSFont.boldSystemFontOfSize_(200.0)}
attributedString = NSAttributedString.alloc().initWithString_attributes_(text, attrs)
frame = attributedString.boundingRectWithSize_options_(NSMakeSize(640.0, 1600.0), 0)
@zonble
zonble / gist:1183940
Created August 31, 2011 16:23
寫好玩的
import math
def solve(x):
left = []; right = []; nums = [1]; i = 0
while x > sum(nums): i += 1; nums.append(3 ** i)
for num in nums:
r = int(math.ceil(float(x - sum(nums[:nums.index(num)])) / num)) % 3
if r == 1: left.append(num)
elif r == 2: right.append(num)
return sorted(left), sorted(right)
l = []
for i in range(0,1000):
if i % 3 == 0 or i % 5 == 0: l.append(i)
print sum(l)
@zonble
zonble / gist:1770738
Created February 8, 2012 16:06
sublime text 設定檔
{
"color_scheme": "Packages/Color Scheme - Default/Pastels on Dark.tmTheme",
"font_size": 18,
"tab_size": 4,
"translate_tabs_to_spaces": false,
"rulers": [78],
"spell_check": true,
"trim_trailing_white_space_on_save": true
}
@zonble
zonble / gist:1770757
Created February 8, 2012 16:08
在 Lion 上裝 Xcode 3
export COMMAND_LINE_INSTALL=1
open "/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg"
http://anatomicwax.tumblr.com/post/8064949186/installing-xcode-3-2-6-on-lion-redux
@zonble
zonble / gist:1993376
Created March 7, 2012 14:15
純粹練習…
fahrenheit :: RealFloat a => a -> a
fahrenheit c = c * (9 / 5) + 32
celsius :: RealFloat a => a -> a
celsius f = (f - 32) * 9 / 5
@zonble
zonble / gist:2312228
Created April 5, 2012 16:12
寫來練習…
object Converter {
def CelcusToFahrenhei(TC:Double):Double = {
return TC * (9.0/5.0) + 32.0;
}
def FarentheitToCelcus(TF:Double):Double = {
return (5.0/9.0) * (TF - 32.0);
}
}
@zonble
zonble / parser.php
Created April 16, 2012 17:22
PHP MP3 Parser
<?php
/*
* A tiny parser which parses ID3 tags and MP3 frames.
*/
function parseMP3($mp3file) {
function _parseID3TagsV2($data) {
define("HEADER_LENGTH", 10);
@zonble
zonble / check.py
Created April 17, 2012 08:24
把音檔丟去給 QuickTime 問問看能不能播,PyObjC
#!/usr/bin/env python
# encoding: utf-8
import sys
import getopt
import os.path
import objc, Cocoa, QTKit
help_message = '''Input the path of the file that you want to validate.'''
@zonble
zonble / core.clj
Created April 27, 2012 02:12
Piano Flow
(ns flow.core
(:gen-class)
(:use [overtone.core][overtone.inst.piano])
)
(definst kick [freq 120 dur 0.3 width 0.5]
(let [freq-env (* freq (env-gen (perc 0 (* 0.99 dur))))
env (env-gen (perc 0.01 dur) 1 1 0 1 FREE)
sqr (* (env-gen (perc 0 0.01)) (pulse (* 2 freq) width))
src (sin-osc freq-env)