Skip to content

Instantly share code, notes, and snippets.

@teeceepee
teeceepee / weibo-login.js
Created February 5, 2017 13:35
Weibo login
// Usage: phantomjs weibo-login.js [username] [password]
// API: http://phantomjs.org/api/
var system = require('system');
// Arguments
var username = system.args[1]
var password = system.args[2]
if (!username || !password) {
console.log("Usage: phantomjs " + system.args[0] + " [username] [password]")
@teeceepee
teeceepee / bilibili-cover.js
Created June 13, 2016 15:21
Bilibili 显示视频封面图片
$('.cover_image').css({
display: 'inline-block',
height: '128px',
position: 'absolute',
top: '42px',
'z-index': '1000'
});
@teeceepee
teeceepee / create_songlist.js
Created September 8, 2015 13:42
豆瓣歌单 API
var songlist_create_url = '/j/songlist/create';
var addsong_url = '/j/songlist/addsong';
// 根据名字创建一个新歌单。
var create_songlist = function(name, callback) {
var title = name.slice(0, 20);
$.ajax_withck({
url: songlist_create_url,
type: 'POST',
data: {
@teeceepee
teeceepee / brackets.md
Last active August 29, 2015 14:15
Bracket names.

http://en.wikipedia.org/wiki/Bracket

Names for various bracket symbols

  • ( ) — parentheses, brackets (UK, Canada, New Zealand, and Australia), parens, round brackets, soft brackets, or circle brackets
  • [ ] — square brackets, closed brackets, hard brackets, or brackets (US)
  • { } — braces (UK and US), flower brackets (India), French brackets, curly brackets, definite brackets, swirly brackets, curly braces, birdie brackets, Scottish brackets, squirrelly brackets, gullwings, seagulls, squiggly brackets, twirly brackets, Tuborg brackets (DK), accolades (NL), pointy brackets, or fancy brackets
  • ⟨ ⟩ — pointy brackets, angle brackets, triangular brackets, diamond brackets, tuples, or chevrons
  • < > — inequality signs, pointy brackets, or brackets. Sometimes referred to as angle brackets, in such cases as HTML markup. Occasionally known as broken brackets or brokets.
  • ⸤ ⸥; 「 」 — corner brackets
@teeceepee
teeceepee / emacs_right_click_menu.reg
Created August 12, 2014 01:53
在Windows的右键菜单中添加"Edit with Emacs"项。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\editwithemacs]
@="Edit with Emacs"
[HKEY_CLASSES_ROOT\*\shell\editwithemacs\command]
@="C:\\Program Files\\emacs-24.3\\bin\\runemacs.exe %0"
class Tree
attr_accessor :name, :left, :right
def initialize(name)
@name = name
@left = nil
@right = nil
end
require 'bindata'
module W3G
# 68 bytes
class ReplayHeader < BinData::Record
endian :little
string :id_string, :read_length => 28
uint32 :header_size
uint32 :compressed_size
class Buffer
def initialize(initial_bytes = '')
@bytes = initial_bytes
end
%w[size empty? clear].each do |method|
define_method(method) do
@bytes.send(method)
end
@teeceepee
teeceepee / http-download.rb
Created January 28, 2014 06:52
HTTP download
require 'socket'
require 'uri'
#TestUrl = 'http://ftp.gnu.org/gnu/autoconf/autoconf-2.56.tar.gz'
TestUrl = 'http://googletest.googlecode.com/files/gtest-1.7.0.zip'
class Response
attr_reader :content_length
def initialize(socket)
parse_header(socket)
@teeceepee
teeceepee / bilibili-youku.js
Last active January 3, 2016 20:59
bilibili优酷黑科技
// 只访问播放器页面
javascript:location.href='https://secure.bilibili.tv/secure,cid='+document.getElementById('bofqi').childNodes[2].attributes.flashvars.value.split(/[=&]/)[1];
// 替换优酷播放器,保留页面其他内容。将所有内容用void()包裹来防止页面刷新, 参考 http://www.ruanyifeng.com/blog/2011/06/a_guide_for_writing_bookmarklet.html
javascript:void(document.getElementById('bofqi').innerHTML='<iframe width="950" scrolling="no" height="482" frameborder="no" onload="window.securePlayerFrameLoaded=true" framespacing="0" border="0" src="####" class="player"></iframe>'.replace("####",'https://secure.bilibili.tv/secure,cid='+document.getElementById('bofqi').childNodes[2].attributes.flashvars.value.split(/[=&]/)[1]));
var cid = document.getElementById('bofqi').childNodes[2].attributes.flashvars.value.split(/[=&]/)[1];
var url = 'https://secure.bilibili.tv/secure,cid=' + cid;