Skip to content

Instantly share code, notes, and snippets.

View chunlea's full-sized avatar
👨‍💻
Working from home

chunli chunlea

👨‍💻
Working from home
View GitHub Profile
@chunlea
chunlea / gist:3284898
Created August 7, 2012 12:24
Get Pow working under OS X ML Server
https://github.com/37signals/pow/issues/172#issuecomment-6803225
@chunlea
chunlea / Deploying-Rails-on-VPS-with-Ubuntu-64Bit.sh
Created August 28, 2012 14:04
在Ubuntu 64位上部署Rails开发环境
echo "export LC_ALL=C" >> /root/.bashrc
source /root/.bashrc
# 这个是我的VPS上系统的原因
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
# 官方的要求
vim /etc/apt/sources.list
# 偷偷安装了VIM,不为别的,好像比VI好用
# 在Sources文件后面加入如下两行:
# deb http://nginx.org/packages/ubuntu/ precise nginx

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

替换上你的Email,密码,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获得domain_id可以用curl curl -k https://dnsapi.cn/Domain.List -d "login_email=xxx&login_password=xxx"

获得record_id类似 curl -k https://dnsapi.cn/Record.List -d "login_email=xxx&login_password=xxx&domain_id=xxx"

require 'open-uri'
require 'nokogiri'
code = 2904
doc = Nokogiri::HTML(open("http://just2.entrust.com.tw/z/zc/zca/zca_#{code}.djhtm"))
# 當前股價,既網頁中的收盤價
doc.css('table')[2].css('tr')[1].css('td').last.inner_text.to_f
# http://stackoverflow.com/questions/14972253/simpleform-default-input-class
# https://github.com/plataformatec/simple_form/issues/316
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
@chunlea
chunlea / input-group-in-simple-form.md
Last active October 5, 2021 20:03
How to use Boostrap 3 input-group in Simple Form

Finally, Simple Form support Boostrap 3. 👏

But I found it still dosen't support some components in Bootstrap 3. Or may be in the future. But I can't wait, so I find a solution to support them. It was inspired by heartcombo/simple_form#531 (comment) .

This is a final solution and I used in my project.

simple_form

module ProMotion
module Table
module LoadmoreClassMethods
def load_moreable=(val)
@load_moreable = val
end
def load_moreable
@load_moreable || false
end
def load_more_options=(val)

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }