Skip to content

Instantly share code, notes, and snippets.

@lengshuiyulangcn
lengshuiyulangcn / tokyo_station_list.csv
Created January 13, 2016 14:28 — forked from pastak/tokyo_station_list.csv
scraping data from mapion.
東京駅 東北新幹線,山形新幹線,秋田新幹線,上越新幹線,長野新幹線,東海道新幹線,JR東海道本線,JR中央線,JR横須賀線,JR京葉線,東京メトロ丸ノ内線,JR総武線快速,JR京浜東北線,JR山手線 1
飯田橋駅 JR中央線,都営大江戸線,東京メトロ東西線,東京メトロ南北線,東京メトロ有楽町線,JR総武線 1
秋葉原駅 つくばエクスプレス,東京メトロ日比谷線,JR京浜東北線,JR総武線,JR山手線 1
大手町駅 東京メトロ丸ノ内線,東京メトロ半蔵門線,東京メトロ東西線,都営三田線,東京メトロ千代田線 1
市ケ谷駅 都営新宿線,JR中央線,東京メトロ南北線,東京メトロ有楽町線,JR総武線 1
四ツ谷駅 JR中央線,東京メトロ南北線,東京メトロ丸ノ内線,JR総武線 1
神田駅 JR中央線,東京メトロ銀座線,JR京浜東北線,JR山手線 1
九段下駅 都営新宿線,東京メトロ半蔵門線,東京メトロ東西線 1
永田町駅 東京メトロ半蔵門線,東京メトロ南北線,東京メトロ有楽町線 1
日比谷駅 都営三田線,東京メトロ千代田線,東京メトロ日比谷線 1
@lengshuiyulangcn
lengshuiyulangcn / redirect_to
Created June 23, 2015 14:19
redirect_to in ruby
in ruby,
redirect_to record means that redirect to link_to that record.
@lengshuiyulangcn
lengshuiyulangcn / send_message.html
Created June 15, 2015 12:42
send message to weibo and facebook, not yet wechat
<html xmlns:wb="http://open.weibo.com/wb">
<head>
<title>js-weibo</title>
<script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=your_api_key" type="text/javascript" charset="utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
WB2.anyWhere(function (W) {
W.widget.connectButton({
id: "wb_connect_btn",
type: '3,2',
@Issue_checked=Issue.where(:checked=>true)
print @Issue_checked.size
#=>3 (for example)
@Issue_unchecked=Issue.where(:checked=>false)
@Issue_checked.update(:checked=>false)
print @Issue_checked.size
#=>0
#!!!! what a fuck
@lengshuiyulangcn
lengshuiyulangcn / ruby_waza.rb
Last active August 29, 2015 14:18
how to tell if two array have the complete same elements
# [1,2,3,3]!=[1,2,3]
#[1,2,3,3,]==[3,2,1,1]
arr1.sort==arr2.sort?
###########
## format to hex
"%.2X" %20
#=>14
##########
## something about regex
1000023444.to_s.reverse.scan(/\d{1,4}/)
#to compare if have the same elements
set(string1)==set(string2)
@lengshuiyulangcn
lengshuiyulangcn / js_tips.js
Last active August 29, 2015 14:18
javascript tips
//滚动到相应的标签处
document.getElementById("tagname").scrollIntoView()
//借用array里面的一些方法处理函数参数
Array.prototype.forEach.call(arguments){function(arg){..dosomething...}}
//array的迭代运算
[0,1,2,3,4].reduce(function(previousValue, currentValue, index, array){
return previousValue + currentValue;
});
@lengshuiyulangcn
lengshuiyulangcn / array_difference.js
Created March 31, 2015 14:35
How figure array difference in javascript
A = [1, 2, 3, 4];
B = [1, 3, 4, 7];
diff = A.filter(function(x) { return B.indexOf(x) < 0 })
@lengshuiyulangcn
lengshuiyulangcn / proxy.rb
Last active August 29, 2015 14:15 — forked from torsten/proxy.rb
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
@lengshuiyulangcn
lengshuiyulangcn / parse_torrent.rb
Created February 14, 2015 13:41
a script for parsing adult video torrents
# usage:
# ruby parse_torrent.rb keyword page_numbers
require "mechanize"
agent=Mechanize.new
term=ARGV[0]
offset=0
offset=ARGV[1].to_i if ARGV[1]!=nil
torrent_links=[]
for i in 0..offset