Skip to content

Instantly share code, notes, and snippets.

View tiye's full-sized avatar
💭
Make Cirru great again!

题叶 tiye

💭
Make Cirru great again!
View GitHub Profile
@tiye
tiye / index.coffee
Created April 26, 2012 10:43
coffee_page, tiny template functions in CoffeeScript
pair_elems = 'html head title body script '
pair_elems+= 'div nav header footer section article '
pair_elems+= 'p span textarea br pre code '
pair_elems+= 'ul li ol table tr td'
pair_elems = pair_elems.split ' '
single_elems = 'img meta input link'
single_elems = single_elems.split ' '
@tiye
tiye / recursion_demo.py
Created May 1, 2012 04:10
recursion of ESC
import types
cursor = '\t'
def recursion (arr):
copy = []
# 循环列表每个元素然后一个个附着到 copy 里面最后返回的
for item in arr:
if type (item) is types.ListType:
# 如果子列表存在 cursor 就把它提出放到列表同一级的后面一个位置, 否则原样递归
if cursor in item:
@tiye
tiye / .vimrc
Created May 3, 2012 03:51
my vim basic cinfiguration
set nu
syntax on
filetype on
set ts=2 sts=2 sw=2 noexpandtab
set autoindent
set fencs=utf-8,gbk,ucs-bom,shift-jis,gb18030,gb2312,cp936
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
hi Pmenu ctermbg=0 ctermfg=6
@tiye
tiye / compile.coffee
Created May 6, 2012 10:43
the output of fs.watchFile when I save a .coffee file
{spawn} = require 'child_process'
{print} = require 'util'
fs = require 'fs'
coffee_file = 'convert.coffee'
coffee_eval = 'run/eval.coffee'
jade_file = 'html.jade'
stylus_file = 'page.styl'
@tiye
tiye / narkcown.coffee
Created May 7, 2012 05:30
Convert .nc file to Markdown..
#!/usr/bin/coffee
fs = require 'fs'
chars = ['>', '-', '*', ' ', '+']
ss = ' '
if process.argv[2]? then filename = process.argv[2]
else
console.log 'You need to name one file here --!'
do process.exit
@tiye
tiye / end.rb
Created May 9, 2012 12:07
Add many "end"s and parse line using "\" as line-end into one line
if ARGV.length > 0 then filename = ARGV[0]
else
puts 'need filename?'
exit
end
flag = FileTest::exist? filename
unless flag
puts 'no such file'
exit
end
@tiye
tiye / .bashrc
Created May 13, 2012 14:27
my current shell setting
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
@tiye
tiye / gist:2707054
Created May 16, 2012 03:17
关于文本输入

我常被琐碎的事干扰, 包括噪音, 包括粗糙的界面和交互,
就算曾经有什么梦想, 也已经消磨在一次次失败的界面定制中了.
曾为 Linux 各种头疼的交互尝试学 Gtk, 可没有结果.
网页简单一些, 但我挑剔和努力到现在也仅限于 Markdown 的练习. 我纠结于两点: 操作系统中文输入不流畅; 文本录入太句局限在字符串.

操作系统整个用英文字符, CJK 字符的麻烦, 我困扰在中文输入法上.
比如 Sublime 说的捕捉快捷键而妨碍了中文输入法,
textareaEditor 遇到键盘事件被输入法遮挡.

@tiye
tiye / gist:2711916
Created May 16, 2012 16:29
聊天室接口

这里的代码主要是 CoffeeScript 形式的伪代码, 为方便表达而已,
用 Node 作为例子, 请求的消息通过 socket.io 传送:

socket.on 'register', (json) ->
  json = handle_function json
  socket.emit 'register', json

每个 `socket` 会被时间计数, 比如 `100` 个消息每秒,
@tiye
tiye / gist:2757183
Created May 20, 2012 07:29
关于网页的生成

关于网页编写的一些点子

页面定义变量以便在网页中使用:

title = 'Title of Demo'
name = 'Another Title'
f1 = (x)  -> console.log 'given x:', x

makeHTML 函数生成文档树, 返回 html 对象用于操作: