Skip to content

Instantly share code, notes, and snippets.

@mcxiaoke
mcxiaoke / sina-weibo-img.js
Created September 5, 2017 02:59
Weibo image url to author id
// ==UserScript==
// @name sinaimg
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *://*.sinaimg.cn/*
// @grant none
// ==/UserScript==
@agentzh
agentzh / default.custom.yaml
Last active May 11, 2019 16:07
Rime 五笔98输入法的配置。将下列文件拷贝到 Rime 配置目录(在 Mac OS X 上为 ~/Library/Rime/),然后点击屏幕右上角输入法的 Rime 图标,在出现的输入法菜单中点击 Deloy(或“布署”)菜单项即可生效。
patch:
schema_list:
- schema: wubi98 # 五笔98
@marguerite
marguerite / plasma5-change-wallpaper.js
Created November 8, 2020 07:44
Plasma 5 Desktop Scripting: Change Wallpaper in InteractiveConsole
for (i in activities()) {
activityID = activities()[i];
desktops = desktopsForActivity(activityID)
for (j in desktops) {
desktop = desktops[j];
desktop.wallpaperPlugin = "org.kde.image";
desktop.wallpaperMode = "Scaled and Cropped";
desktop.currentConfigGroup = new Array("Wallpaper", "org.kde.image", "General");
desktop.writeConfig("Image", "file:///home/zhou/Pictures/Bing/AlpineLarches_ZH-CN10557456981_1920x1200.jpg");
}
def verify_sign(public_key_loc, signature, data):
'''
Verifies with a public key from whom the data came that it was indeed
signed by their private key
param: public_key_loc Path to public key
param: signature String signature to be verified
return: Boolean. True if the signature is valid; False otherwise.
'''
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
@Gargron
Gargron / account-resolve-test.md
Last active December 19, 2022 05:46
An attempt to resolve an ActivityPub account from counter.social

The fundamental part of ActivityPub federation is the "actor", or in Mastodon terms, the account. Accounts from other servers are queried and saved into the local database to allow sending and receiving interactions. The ResolveRemoteAccountService class is responsible for this, working in two steps: Converting a human-readable handle like username@domain into URLs to the remote account's resources via Webfinger, and then using the linked remote account's JSON representation to create a local mirror.

Step 1: Webfinger

% curl -i "https://counter.social/.well-known/webfinger?resource=th3j35t3r@counter.social"
HTTP/1.1 200 OK
Date: Thu, 04 Jan 2018 03:29:01 GMT
Content-Type: application/jrd+json; charset=utf-8
Transfer-Encoding: chunked
@anonfloppa
anonfloppa / user_messages.sql
Created November 3, 2021 02:47
query to display all unencrypted messages from one user
select event_json.json::json->'content'->>'body' as message,
events.room_id,
room_stats_state.name,
events.sender
from events
left outer join event_json on
events.event_id=event_json.event_id
left outer join room_stats_state on
room_stats_state.room_id=events.room_id
where event_json.json::json->'content'->>'body'<>'' and events.sender='@ACCOUNT_NAME:SERVER.DOM';
@kalxas
kalxas / README
Created July 23, 2016 00:15 — forked from gdamjan/README
Customize ubuntu live image
# first, get the iso from http://releases.ubuntu.com/
# make working dir hierarchy in /tmp (you'll need enough ram for this)
sudo mkdir -p /tmp/custom/{_squash,_work,iso,newiso,newlive,project}
sudo mount -o loop ~/Downloads/ubuntu-15.10-desktop-amd64.iso /tmp/custom/iso
sudo mount -t squashfs /tmp/custom/iso/casper/filesystem.squashfs /tmp/custom/_squash
sudo mount -t overlay overlay -onoatime,lowerdir=/tmp/custom/_squash,upperdir=/tmp/custom/project,workdir=/tmp/custom/_work /tmp/custom/newlive
# customize the live fs with systemd-nspawn (a better chroot)
sudo systemd-nspawn --bind-ro=/etc/resolv.conf:/run/resolvconf/resolv.conf --setenv=RUNLEVEL=1 -D /tmp/custom/newlive
@fengmk2
fengmk2 / WeiboUtil.js
Created February 16, 2012 12:11
新浪微博mid与url互转实用工具
/**
* 新浪微博mid与url互转实用工具
* 作者: XiNGRZ (http://weibo.com/xingrz)
*/
var WeiboUtil = {
// 62进制字典
str62keys: [
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
@Scrumplex
Scrumplex / 50-udisks.rules
Last active November 30, 2023 21:20
Polkit rules for udisks, and udisks2. Compatible with udiskie and Dolphin.
// Original rules: https://github.com/coldfix/udiskie/wiki/Permissions
// Changes: Added org.freedesktop.udisks2.filesystem-mount-system, as this is used by Dolphin.
polkit.addRule(function(action, subject) {
var YES = polkit.Result.YES;
// NOTE: there must be a comma at the end of each line except for the last:
var permission = {
// required for udisks1:
"org.freedesktop.udisks.filesystem-mount": YES,
"org.freedesktop.udisks.luks-unlock": YES,