JavaScript代码片段

编辑器

在html5中新多了一个特性,叫做contenteditable,这个特性可以让html里的一个元素变成可编辑状态。因此,我们可以通过这个属性来构造一个简单的文本编辑器。
在浏览器里新建一个标签页输入网址
data:text/html,<html contenteditable>
你会发现你的浏览界面变成了一个简单的文本编辑器。

montas 的改造:You can use textarea and make it “invisible” if you want autofocus.

1
data:text/html, <textarea style="font-size: 1.5em; width: 100%; height: 100%; border: none; outline: none" autofocus />

bgrins 的改造:编辑内容时,自动变换背景颜色;停止后变换白色。

1
data:text/html, <html><head><style type="text/css"> html { font-family: "Open Sans" } * { -webkit-transition: all linear 1s; }</style><script>window.onload=function(){var e=false;var t=0;setInterval(function(){if(!e){t=Math.round(Math.max(0,t-Math.max(t/3,1)))}var n=(255-t*2).toString(16);document.body.style.backgroundColor="#ff"+n+""+n},1e3);var n=null;document.onkeydown=function(){t=Math.min(128,t+2);e=true;clearTimeout(n);n=setTimeout(function(){e=false},1500)}}</script></head><body contenteditable style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;">

fvsch 的改造:

阅读全文 »

Privoxy

USAGE:

阅读全文 »

baidu OCR

百度OCR文字识别API for Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, urllib, urllib2, json
f = open("test.txt","w")
url = 'http://apis.baidu.com/apistore/idlocr/ocr'
data = {}
data['fromdevice'] = "pc"
data['clientip'] = "10.10.10.0"
data['detecttype'] = "LocateRecognize"
data['languagetype'] = "CHN_ENG"
data['imagetype'] = "1" #`2`代表图片原文件(只支持JPG)
data['image'] = "" ##image base64 data
decoded_data = urllib.urlencode(data)
req = urllib2.Request(url, data = decoded_data)
req.add_header("Content-Type", "application/x-www-form-urlencoded")
req.add_header("apikey", "自己的apikey")
resp = urllib2.urlopen(req)
content = resp.read()
if(content):
print(content)
f.write(content)
阅读全文 »

ADBLOCK block list

  • 用浏览器扩展ADBLOCK过滤掉以下网址,可提高个别网站的访问速度。

  • 如何发现拖慢网站访问速度的链接

    当发现网站在加载某一个链接时,迟迟打不开,就可以block掉这个网址了。

1
2
3
4
5
6
7
8
9
10
11
12
tags.crwdcntrl.net
fonts.googleapis.com
googletagservices.com
connect.facebook.net
translate.googleapis.com
chart.googleapis.com
maps.googleapis.com
adwords.google.com
apis.google.com
googleapis-ajax.l.google.com
google-analytics.com
ajax.googleapis.com
阅读全文 »

CNNIC证书

A Programmer's Rantings

language

  • 汇编
  • C D
  • Lisp Scheme Clojure
  • C++ Java
  • Perl Ruby Python JRuby Jython Rhino Groovy Smalltalk Cobol Fortran
  • Haskell Lua
  • 并行语言Erlang
  • R Matlab Mathematica

Web框架

  • Pylons
  • Django
  • TurboGears
  • Zope
  • Subway

TextEditor

Frontend Knowledge Structure


阅读全文 »

Help Sheet

Swift Style guide

A guide to our Swift style and conventions.

This is an attempt to encourage patterns that accomplish the following goals (in
rough priority order):

  1. Increased rigor, and decreased likelihood of programmer error
  2. Increased clarity of intent
  3. Reduced verbosity
  4. Fewer debates about aesthetics

If you have suggestions, please see our contribution guidelines,
then open a pull request. :zap:


Whitespace

  • Tabs, not spaces.
  • End files with a newline.
  • Make liberal use of vertical whitespace to divide code into logical chunks.
  • Don’t leave trailing whitespace.
    • Not even leading indentation on blank lines.
阅读全文 »

GFW

ip,镜像站

寻找可用ip,修改系统host

更改网络DNS

  • Hello DNS (可直接翻墙)

    1
    2
    DNS1: 123.56.46.123
    DNS2: 182.254.185.148
  • 任我行DNS(可直接翻墙)

    1
    121.201.13.176
阅读全文 »