Skip to content

Instantly share code, notes, and snippets.

View indiejoseph's full-sized avatar
🏠
Working from home

Joseph cheng indiejoseph

🏠
Working from home
View GitHub Profile
@indiejoseph
indiejoseph / 21-u8300
Created August 26, 2015 02:06
openwrt u8300 LTE model
#!/bin/sh
U8300_PROID="1c9e/9b05/232"
if [ "${PRODUCT}" = "${U8300_PROID}" ]; then
if [ "${ACTION}" = "add" ]; then
#register usbserial and option device driver with the modem mode id:
echo '1c9e 9b05 ff' > /sys/bus/usb-serial/drivers/option1/new_id
logger -t HOTPLUG "${U8300_PROID} plugged in."
@indiejoseph
indiejoseph / network
Created August 27, 2015 10:20
openwrt lte network
config interface wan
option ifname ppp0
option device /dev/ttyUSB1
option apn '3gnet'
option service umts
option proto 3g
option 'pppd_options' 'debug noipdefault'
option username '3g'
option password '3g'
option peerdns 0
@indiejoseph
indiejoseph / gist:9243727
Last active August 29, 2015 13:56
Schema.org: Mailchimp confirm subscription
<span itemscope itemtype="http://schema.org/EmailMessage">
<span itemprop="description" content="We need to confirm your email address."></span>
<span itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="Confirm Subscription">
<span itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<meta itemprop="url" content="https://sightreadingmachine.us7.list-manage.com/subscribe/smartmail-confirm?u=d3fc6=b673c9cc2799bb4b47ca&id=abb8a8adb6&e=3dfc6cfa34&inline=true">
<link itemprop="method" href="http://schema.org/HttpRequestMethod/POST">
</span>
</span>
</span>
@indiejoseph
indiejoseph / gist:9244089
Created February 27, 2014 03:55
Schema.org: Spotify listen
<span itemscope itemtype="http://schema.org/EmailMessage">
<meta itemprop="description" content="Jim Hall 的 Stella by Starlight 已在 Spotify 上架!">
<span itemprop="about" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="Stella by Starlight">
<span itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<meta itemprop="url" content="http://www.spotify.com/redirect/email-wp/?username=1211379188&template_name=notify_new_album.html&utm_medium=email&open=http%3A%2F%2Fopen.spotify.com%2Falbum%2F7JSVEy2xPiVRyluX9N6csF">
<meta itemprop="name" content="在 Spotify 收聽"></span>
</span>
</span>
</span>
@indiejoseph
indiejoseph / gist:9252049
Created February 27, 2014 15:17
Schema.org: Dropbox share folder
<script type=3D"application/ld+json">
{
"action": {
"url": "https://www.dropbox.com/invite?k=3DiZfxq5WwbyhujKJcmTocBE8ouwjT7zKr"
"name": "View folder"
"@type": "ViewAction"
}
"@context": "http://schema.org"
"@type": "EmailMessage"
"description": "shared folder invitation"
@indiejoseph
indiejoseph / gist:9621725
Created March 18, 2014 14:56
Express 4.x Router index.coffee
fs = require 'fs'
path = require 'path'
router = (require 'express').Router()
role = require './role'
# acl
router.use '/admin*', role.isAuthorized()
@indiejoseph
indiejoseph / gist:7bd16acc3958348bd1d6
Created May 2, 2014 10:16
基于统计模型的人名识别
编码 意义 例子
B 姓氏 (张)华平先生 ;(欧阳)修
C 双名的首字 张(华)平先生
D 双名的末字 张华(平)先生
E 单名 张(浩)说“: 我是一个好人”
F 前缀 (老) 刘 、(小) 李
G 后缀 王(总) 、刘(老) 、肖(氏) 、吴(妈) 、叶(帅)
K 人名的上文 又(来到)于洪洋的家.
L 人名的下文 新华社记者黄文(摄)
M 两个中国人名之间的成分 编剧邵钧林(和)稽道青说
@indiejoseph
indiejoseph / increment_number.sql
Created May 16, 2014 03:06
Increment number in MySQL
SELECT
`chars`.`id`,
@n := @n +1 AS `index`
FROM
`characters` AS `chars`,
(SELECT @n := -1) AS `m`;
http://zh.wikipedia.org/w/api.php?action=query&titles=%E8%B4%9D%E5%A1%9E%E5%B0%94%E6%9B%B2%E7%BA%BF&redirects=&converttitles=&prop=revisions&rvprop=content&format=json
@indiejoseph
indiejoseph / dbc2sbc.coffee
Created May 24, 2014 10:35
全角轉半角
DBC2SBC = (str, flag) ->
result=''
return no if str.length <= 0
for i in [0...str.length]
str1=str.charCodeAt(i)
if !flag
if str1 < 127
result += String.fromCharCode str.charCodeAt(i) + 65248
else