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 / abcd.coffee
Created November 19, 2012 16:17
ABCD… 真是一個適合拿來寫些完全不熟的語言的小練習 XD
print (x for x in [0..9999] when Math.floor(x/1000) + Math.floor(x/100%10) == Math.floor(x/10%10) - x % 10)
@zonble
zonble / temperature.el
Created November 24, 2012 16:26
攝氏華氏轉換
(defun celsius-to-fahrenheit (number)
"Celsius to fahrenheit"
(interactive "nCelsius:")
(let ((fahrenheit (+ (* number (/ 9.0 5.0)) 32.0)))
(message "Fahrenheit:%f" fahrenheit)))
(defun fahrenheit-to-celsius (number)
"Fahrenheit to celsius"
(interactive "nFahrenheit:")
(let ((celsius (* (- number 32.0) (/ 5.0 9.0))))
print "Merry Xmas"
print "".join(["\n" if x==20 and y<8 else " " if (x<10-y or x>10+y) else "*" for y in range(0,9) for x in range(0, 21)])
print " ****\n" * 3
@zonble
zonble / xmas.py
Created December 4, 2012 16:42
對唷,這樣寫就好了
print ''.join(map(lambda x:(10-x)*' '+(x*2+1)*'*'+('\n' if x < 8 else ''), range(0,9))); print (' ' * 9 + '*' * 3 + '\n') * 3
@zonble
zonble / xmastree.st
Created December 4, 2012 17:24
來寫點正統的 OO…
'Merry Xmas' displayNl
(0 to: 9) do: [:x| (0 to: (9 - x)) do: [:y| ' ' display]. (0 to: (x * 2)) do: [:y| '*' display]. '' displayNl]
(0 to: 3) do: [:x| (0 to: 8) do: [:y| ' ' display]. (0 to: 2) do: [:y| '*' display]. '' displayNl]
@zonble
zonble / osstatus.el
Created December 5, 2012 03:16
A helper to read osstatus
(defun osstatus (number)
"Convert osstatus"
(interactive "nOSStatus:")
(let* ((a (logand (lsh number -24) 255))
(b (logand (lsh number -16) 255))
(c (logand (lsh number -8) 255))
(d (logand (lsh number 0) 255)))
(message (format "Output: %c%c%c%c" a b c d)))
)
@zonble
zonble / create_wifi.py
Created December 13, 2012 09:42
自動建立與關閉 Wifi 分享
#!/usr/bin/env python
# encoding: utf-8
create_wifi = u'''
property CreateMenuName : "Create Network…"
property NetworkName : "%s"
tell application "System Events"
tell process "SystemUIServer"
tell menu bar 1
import os
def share():
cmd = "/bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist"
os.system(cmd)
def stop():
cmd = "/bin/launchctl unload -w /System/Library/LaunchDaemons/com.apple.InternetSharing.plist"
os.system(cmd)
NSString *test1()
{
char chr[17] = "abcdabcdabcdabcd";
char output[33];
for (int i = 0; i < 16; i++) {
sprintf((char *)(output + i * 2), "%02x", chr[i]);
}
return [NSString stringWithUTF8String:output];
}
@zonble
zonble / index.html
Last active December 13, 2015 17:08
聽說這樣可以畫漫畫
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg);">
<scene id="scene1">
<label t="translate(0,346)">