Skip to content

Instantly share code, notes, and snippets.

View teddy-ma's full-sized avatar

Ma Lucheng teddy-ma

View GitHub Profile
#! /usr/bin/env ruby
# usage:
# $ das_download.rb
require "mechanize"
require "fileutils"
class DasDownloader
attr_reader :agent, :email, :password
@jodosha
jodosha / Gemfile
Last active December 9, 2020 15:09
Full stack Lotus application example
source 'https://rubygems.org'
gem 'rake'
gem 'lotus-router'
gem 'lotus-controller'
gem 'lotus-view'
group :test do
gem 'rspec'
gem 'capybara'

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
@nightire
nightire / Changes in Rails 4_1.md
Last active May 11, 2022 04:50
拥抱 Rails 4 —— 详述 Rails 4 的新变化

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb
@nightire
nightire / Rails 4 - Active Record Associations.md
Last active March 27, 2016 12:40
Rails 4 - Active Record Associations

Rails 4 - Active Record Associations

has_one

一对一关系:有 A 和 B,A 拥有且仅拥有一个 B

has_one

belongs_to

@HungYuHei
HungYuHei / batch-delete-documents.js
Created December 15, 2012 05:32
batch delete kindle's archived personal documents
items = document.getElementsByClassName('rowBodyCollapsed');
for(var i = 0; i < items.length; i++) {
Fion.deleteItem('deleteItem_' + items[i].getAttribute('asin'));
}