Skip to content

Instantly share code, notes, and snippets.

View RustingSword's full-sized avatar
🤦‍♂️

RustingSword

🤦‍♂️
View GitHub Profile
@RustingSword
RustingSword / mastodon_bot.py
Last active March 4, 2024 14:00
一个简单的 mastodon bot
#!/usr/bin/env python3
import os
import random
from mastodon import Mastodon
API_BASE_URL = "https://me.ns.ci" # 注册网站,比如 https://me.ns.ci
EMAIL = os.environ.get("MASTODON_EMAIL") # 注册用的邮箱
PASSWORD = os.environ.get("MASTODON_PASSWORD") # 账号密码
@RustingSword
RustingSword / fitPlane.py
Created September 7, 2014 12:33
least square plane fitting of 3d points
import numpy as np
import scipy.optimize
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')
def fitPlaneLTSQ(XYZ):
@RustingSword
RustingSword / SimpleTimeTracker.ahk
Last active January 25, 2024 19:07
A simple time tracker implemented in AutoHotkey, modified from http://www.autohotkey.com/board/topic/37998-tiny-computer-usage-tracker/
; ticker - A Simple Time Tracker
; track your time usage on a daily basis
#InstallKeybdHook
#InstallMouseHook
Menu, Tray, Icon, %A_WinDir%\system32\shell32.dll, 44
Menu, Tray, Tip, ticker - A Simple Time Tracker`nPress right control to see details
SetWorkingDir, C:\Users\%A_UserName%\Documents
SetTimer, CheckTime, 60000 ; updates every 1 minute
@RustingSword
RustingSword / extraction.py
Last active January 16, 2023 16:38
stay point extraction from dataset provided by GeoLife project
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# extract stay points from a GPS log file
# implementation of algorithm in
# [1] Q. Li, Y. Zheng, X. Xie, Y. Chen, W. Liu, and W.-Y. Ma, "Mining user similarity based on location history", in Proceedings of the 16th ACM SIGSPATIAL international conference on Advances in geographic information systems, New York, NY, USA, 2008, pp. 34:1--34:10.
import time
import os
import sys
汝南陳仲舉,潁川李元禮二人,共論其功德,不能定先後。蔡伯喈評之曰:「陳仲舉彊於犯上,李元禮嚴於攝下。犯上難,攝下易。」仲舉遂在三君之下,元禮居八俊之上。 (《世說新語·品藻第九》)
龐士元至吳,吳人並友之。見陸績、顧劭、全琮而為之目曰:「陸子所謂駑馬有逸足之用,顧子所謂駑牛可以負重致遠。」或問:「如所目,陸為勝邪?」曰:「駑馬雖精速,能致一人耳。駑牛一日行百里,所致豈一人哉?」吳人無以難。「全子好聲名,似汝南樊子昭。」 (《世說新語·品藻第九》)
顧劭嘗與龐士元宿語,問曰:「聞子名知人,吾與足下孰愈?」曰:「陶冶世俗,與時浮沈,吾不如子;論王霸之餘策,覽倚仗之要害,吾似有一日之長。」劭亦安其言。 (《世說新語·品藻第九》)
諸葛瑾弟亮及從弟誕,並有盛名,各在一國。于時以為「蜀得其龍,吳得其虎,魏得其狗」。誕在魏與夏侯玄齊名;瑾在吳,吳朝服其弘量。 (《世說新語·品藻第九》)
司馬文王問武陔:「陳玄伯何如其父司空?」陔曰:「通雅博暢,能以天下聲教為己任者,不如也。明練簡至,立功立事,過之。」 (《世說新語·品藻第九》)
正始中,人士比論,以五荀方五陳:荀淑方陳寔,荀靖方陳諶,荀爽方陳紀,荀彧方陳群,荀顗方陳泰。又以八裴方八王:裴徽方王祥,裴楷方王夷甫,裴康方王綏,裴綽方王澄,裴瓚方王敦,裴遐方王導,裴頠方王戎,裴邈方王玄。 (《世說新語·品藻第九》)
冀州刺史楊淮二子喬與髦,俱總角為成器。淮與裴頠、樂廣友善,遣見之。頠性弘方,愛喬之有高韻,謂淮曰:「喬當及卿,髦小減也。」廣性清淳,愛髦之有神檢,謂淮曰:「喬自及卿,然髦尤精出。」淮笑曰:「我二兒之優劣,乃裴、樂之優劣。」論者評之:以為喬雖高韻,而檢不匝;樂言為得。然並為後出之雋。 (《世說新語·品藻第九》)
劉令言始入洛,見諸名士而嘆曰:「王夷甫太解明,樂彥輔我所敬,張茂先我所不解,周弘武巧於用短,杜方叔拙於用長。」 (《世說新語·品藻第九》)
王夷甫云:「閭丘沖,優於滿奮、郝隆。此三人並是高才,沖最先達。」 (《世說新語·品藻第九》)
王夷甫以王東海比樂令,故王中郎作碑云:「當時標榜,為樂廣之儷。」 (《世說新語·品藻第九》)
汝南陳仲舉,潁川李元禮二人,共論其功德,不能定先後。蔡伯喈評之曰:「陳仲舉彊於犯上,李元禮嚴於攝下。犯上難,攝下易。」仲舉遂在三君之下,元禮居八俊之上。 (《世說新語·品藻第九》)
龐士元至吳,吳人並友之。見陸績、顧劭、全琮而為之目曰:「陸子所謂駑馬有逸足之用,顧子所謂駑牛可以負重致遠。」或問:「如所目,陸為勝邪?」曰:「駑馬雖精速,能致一人耳。駑牛一日行百里,所致豈一人哉?」吳人無以難。「全子好聲名,似汝南樊子昭。」 (《世說新語·品藻第九》)
顧劭嘗與龐士元宿語,問曰:「聞子名知人,吾與足下孰愈?」曰:「陶冶世俗,與時浮沈,吾不如子;論王霸之餘策,覽倚仗之要害,吾似有一日之長。」劭亦安其言。 (《世說新語·品藻第九》)
諸葛瑾弟亮及從弟誕,並有盛名,各在一國。于時以為「蜀得其龍,吳得其虎,魏得其狗」。誕在魏與夏侯玄齊名;瑾在吳,吳朝服其弘量。 (《世說新語·品藻第九》)
司馬文王問武陔:「陳玄伯何如其父司空?」陔曰:「通雅博暢,能以天下聲教為己任者,不如也。明練簡至,立功立事,過之。」 (《世說新語·品藻第九》)
正始中,人士比論,以五荀方五陳:荀淑方陳寔,荀靖方陳諶,荀爽方陳紀,荀彧方陳群,荀顗方陳泰。又以八裴方八王:裴徽方王祥,裴楷方王夷甫,裴康方王綏,裴綽方王澄,裴瓚方王敦,裴遐方王導,裴頠方王戎,裴邈方王玄。 (《世說新語·品藻第九》)
冀州刺史楊淮二子喬與髦,俱總角為成器。淮與裴頠、樂廣友善,遣見之。頠性弘方,愛喬之有高韻,謂淮曰:「喬當及卿,髦小減也。」廣性清淳,愛髦之有神檢,謂淮曰:「喬自及卿,然髦尤精出。」淮笑曰:「我二兒之優劣,乃裴、樂之優劣。」論者評之:以為喬雖高韻,而檢不匝;樂言為得。然並為後出之雋。 (《世說新語·品藻第九》)
劉令言始入洛,見諸名士而嘆曰:「王夷甫太解明,樂彥輔我所敬,張茂先我所不解,周弘武巧於用短,杜方叔拙於用長。」 (《世說新語·品藻第九》)
王夷甫云:「閭丘沖,優於滿奮、郝隆。此三人並是高才,沖最先達。」 (《世說新語·品藻第九》)
王夷甫以王東海比樂令,故王中郎作碑云:「當時標榜,為樂廣之儷。」 (《世說新語·品藻第九》)
@RustingSword
RustingSword / bean_vine.js
Last active April 22, 2022 19:37
修复了豆藤的一点点问题,同时又引入了新的问题
// ==UserScript==
// @name 豆藤 Bean vine
// @namespace http://userscripts.org/scripts/show/49911
// @description 为豆瓣(www.douban.com)添加各种人性化的功能。
// @include https://*.douban.com/*
// @version 2015.3.24
// @grant GM_log
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @grant GM_getValue
@RustingSword
RustingSword / hosts.md
Created November 26, 2012 13:20
Hosts for Google Services

via http://shen0956.com/?p=1523

173.194.72.82 www.google.com.hk

74.125.31.189 mail.google.com
74.125.31.189 plus.google.com
74.125.31.189 adsense.google.com
74.125.31.189 analytics.google.com
74.125.31.189 drive.google.com

74.125.31.189 translate.google.cn

@RustingSword
RustingSword / tsne_plot.py
Created April 23, 2018 06:09
Plot TSNE-ed embedding of word vectors generated by fasttext. Require https://github.com/DmitryUlyanov/Multicore-TSNE
#!/usr/bin/env python
#! coding: utf8
from __future__ import print_function
from bokeh.plotting import figure, show, output_file
from bokeh.models import ColumnDataSource, LabelSet, HoverTool
import argparse
import numpy as np
from numpy.linalg import norm
from MulticoreTSNE import MulticoreTSNE as TSNE
#include <chrono>
using std::chrono::system_clock;
using std::chrono::time_point;
using std::chrono::duration_cast;
using std::chrono::microseconds;
class Timer {
public:
void start() {
start_time = system_clock::now();