Skip to content

Instantly share code, notes, and snippets.

View creamidea's full-sized avatar

NekoTrek creamidea

View GitHub Profile
#!/bin/sh
echo generating...
curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F\| '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /tmp/chnroute.txt && echo "chnroute.txt generated" || exit 0
echo copying...
cp /tmp/chnroute.txt /etc/storage/DEADC0DE/chnroute/
echo cleaning...
rm -rf /tmp/chnroute.txt
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://elpa.emacs-china.org/melpa/") t)
(add-to-list 'package-archives '("gnu" . "https://elpa.emacs-china.org/gnu/") t)
(add-to-list 'package-archives '("org" . "https://elpa.emacs-china.org/org/") t)
@creamidea
creamidea / BigDecimal.js
Created January 11, 2018 09:42 — forked from xinlc/BigDecimal.js
JavaScript高精度计算
//除法函数,用来得到精确的除法结果
//说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
//调用:accDiv(arg1,arg2)
//返回值:arg1除以arg2的精确结果
function accDiv(arg1, arg2) {
var t1 = 0,
t2 = 0,
r1, r2;
try {
t1 = arg1.toString().split(".")[1].length
@creamidea
creamidea / splid_words.html
Created July 4, 2017 15:03 — forked from onlytiancai/splid_words.html
javascript实现的正向最大匹配机械分词
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
</head>
<body>
<script type="text/javascript">
/*
* @description 原始词库
*/
@creamidea
creamidea / ReadMe.Txt
Created March 30, 2017 04:03 — forked from jb510/ReadMe.md
OS X LaunchD job and script to automaticaly update homebrew
1. Place homebrewupdate.sh where ever you like, I use ~/bin/homebrewupdate.sh
2. Place the .plist file in ~/Library/LaunchAgents and update the path to your bash script
3. run 'launchctl load ~/Library/LaunchAgents/com.jb510.homebrewupdate.plist' or whatever you've named your plist file.
4. check 'launchctl list | grep jb510' to see that it's running
Note: you might need to `chmod +x homebrewupdate.sh`
@creamidea
creamidea / request-jssvc-lib.py
Created March 12, 2017 07:47
获取苏州职业大学图书馆书籍信息(DEMO)
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
from time import sleep
from argparse import ArgumentParser
import requests
from bs4 import BeautifulSoup
from bs4.element import Tag
class Search(object):
@creamidea
creamidea / ping-ip.py
Last active February 4, 2017 14:29
测试 IP 联通质量
#!/usr/local/bin/python3
#-*- encoding:utf-8 -*-
from operator import itemgetter
from queue import Queue
from threading import Thread
from subprocess import STDOUT, check_output, CalledProcessError
from collections import OrderedDict
import re
#!/usr/bin/env python
# Linux usage: ./extract_tampermonkey_script.py "/home/<USER>/.config/<BROWSER>/Default/Local Extension Settings/<EXTENSION_ID>"
# i.e.: ./extract_tampermonkey_script.py "/home/foo/.config/google-chrome-beta/Default/Local Extension Settings/gcalenpjmijncebpfijmoaglllgpjagf"
# Mac usage: ./extract_tampermonkey_script.py "/Users/<USER>/Library/Application Support/Google/Chrome/Default/Local Extension Settings/<EXTENSION_ID>/"
# i.e.: ./extract_tampermonkey_script.py "/Users/foo/Library/Application Support/Google/Chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo/"
import leveldb
import sys
import re
@creamidea
creamidea / YoudaoDictionaryEnhancer.user.js
Last active September 14, 2016 04:16
Improve the experience of the Youdao Dictionary. Thank you: dict.youdao.com && etymonline.com :D
// ==UserScript==
// @name Youdao Dictionary Enhancer
// @namespace http://tampermonkey.net/
// @version 1.1
// @description search words Celerity
// @author creamidea
// @match http://dict.youdao.com/*
// @require http://cdn.bootcss.com/nprogress/0.2.0/nprogress.min.js
// @resource nprogress_css http://cdn.bootcss.com/nprogress/0.2.0/nprogress.min.css
// @resource etymoline_css http://www.etymonline.com/style.css
@echo off
"%~dp0emacsclientw.exe" -na "%~dp0runemacs.exe" "%1"