Skip to content

Instantly share code, notes, and snippets.

View ggicci's full-sized avatar
🍉
Happy summer ~

Ggicci ggicci

🍉
Happy summer ~
  • Toronto
  • 07:25 (UTC -04:00)
View GitHub Profile
@ggicci
ggicci / get_qqmusic_songlist.js
Created October 29, 2023 20:26
QQ音乐获取歌单列表
// 在浏览器打开如下 URL,替换 id 为你自己的歌单 id
// https://y.qq.com/musicmac/v6/playlist/detail.html?id=3011946123
// Console Script:
const songList = [];
for (const doc of document.querySelectorAll('.songlist__li')) {
songList.push({
song: doc.querySelector('.mod_songname__name').text,
singer: doc.querySelector('.singer_name').text,
album: doc.querySelector('.album_name').text,
@ggicci
ggicci / block.py
Last active April 21, 2023 19:32
Find acrossing multilines content blocks in pattern from a text file and process each block
#!/usr/bin/env python3
import re
# 1. define your block by a regular expression
RE_BLOCK = re.compile(
r"MariaDB \[test\]> desc (?P<name>\w+?);\n(?P<definition>.+?)\n\d+? rows in set.+?",
re.DOTALL | re.MULTILINE,
)
@ggicci
ggicci / ghost-goplay-injection.js
Last active October 15, 2022 02:52
goplay for ghost blog code injection
<style>
.goplay-container { margin-top: 8px; }
.goplay-run { margin-right: 5px; }
.goplay-output .stderr { color: #b50000; }
.goplay-output .system { color: green; }
</style>
<script type="module">
import { GoPlayProxy } from "https://unpkg.com/@ggicci/goplay/dist/index.js";
const goplay = new GoPlayProxy("https://goplay.ggicci.me");
@ggicci
ggicci / crypto-js-md5.js
Last active November 11, 2021 06:41
CryptoJS - Get MD5 of Binary Files
import CryptoMD5 from "crypto-js/md5";
import CryptoLatin1Encoder from "crypto-js/enc-latin1";
function handleUploadClick(e: React.ChangeEvent<HTMLInputElement>) {
if (!e.target.files) {
return;
}
const selectedFile = e.target.files[0];
const reader = new FileReader();
@ggicci
ggicci / smtp.py
Created August 2, 2021 04:00
Python script to send emails (SMTP)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import json
import smtplib
from argparse import ArgumentParser
from email.header import Header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
// 1. Define you input struct
type ListUsersInput struct {
Page int `in:"form=page"`
PerPage int `in:"form=per_page"`
IsMember bool `in:"form=is_member"`
}
// 2. Bind this input struct with an HTTP handler
func init() {
http.Handle("/users", alice.New(
func ListUsers(rw http.ResponseWriter, r *http.Request) {
input := &ListUserInput{}
if err := ParseURLParams(&input); err != nil {
return
}
if input.IsMember // ...
}
type ListUsersInput struct {
Page int `in:"form=page"`
PerPage int `in:"form=per_page"`
IsMember bool `in:"form=is_member"`
}
input := &ListUsersInput{}
@ggicci
ggicci / sample.go
Created May 17, 2021 06:25
Go net/http parse URL params
// GET /v1/users?page=1&per_page=20&is_member=true
func ListUsers(rw http.ResponseWriter, r *http.Request) {
page, err := strconv.ParseInt(r.FormValue("page"), 10, 64)
if err != nil {
// Invalid parameter: page.
return
}
perPage, err := strconv.ParseInt(r.FormValue("per_page"), 10, 64)
if err != nil {
// Invalid parameter: per_page.
@ggicci
ggicci / loadscript.js
Created May 18, 2020 03:19
JS create script element
function loadScript(src) {
const s = document.createElement('script')
s.src = src
document.body.appendChild(s)
}
loadScript('https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.4.456/pdf.min.js')