Skip to content

Instantly share code, notes, and snippets.

View yihong0618's full-sized avatar
🏃‍♂️
Running

yihong yihong0618

🏃‍♂️
Running
View GitHub Profile
@yihong0618
yihong0618 / shanbay_decode.js
Created November 30, 2020 07:08
shanbay decode
class Func {
static loop(cnt, func) {
'v'
.repeat(cnt)
.split('')
.map((_, idx) => func(idx));
}
}
@yihong0618
yihong0618 / 专注森林.py
Last active March 22, 2023 10:45
专注森林.py
import argparse
import json
from collections import Counter
from datetime import datetime
import pendulum
import requests
from rich import print
@yihong0618
yihong0618 / postgres_queries_and_commands.sql
Created January 28, 2023 02:26 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@yihong0618
yihong0618 / shanbay_remember.js
Last active December 1, 2022 04:40
扇贝加密破解自动发送今日新词到 telegram
const https = require("https");
const token = ""; // change this to you telegram bot token!
const chatId = ""; // change this to your telegram chat id!
const cookie = ""; // change this to your shanbay cookie!
const PATH_API = (page) =>
`/wordsapp/user_material_books/blozps/learning/words/today_learning_items?ipp=10&page=${page}&type_of=NEW`;
const options = {
@yihong0618
yihong0618 / Quirks of C.md
Created November 20, 2022 13:23 — forked from fay59/Quirks of C.md
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
import requests
API = "https://api.wmdb.tv/api/v1/top?type={movie_type}&skip=0&limit={limit}"
def get_top_movies(movie_type, limit=250):
r = requests.get(API.format(movie_type=movie_type, limit=limit))
if not r.ok:
raise Exception(f"Can not get movies for {movie_type} type")
return r.json()
@yihong0618
yihong0618 / kpc_demo.c
Created December 31, 2021 06:32 — forked from ibireme/kpc_demo.c
A demo shows how to read Intel or Apple M1 CPU performance counter in macOS.
// =============================================================================
// XNU kperf/kpc demo
// Available for Intel/Apple M1, macOS/iOS, with root privileges
//
// XNU source (since xnu 2422.1.72):
// https://github.com/apple/darwin-xnu/blob/main/osfmk/kern/kpc.h
// https://github.com/apple/darwin-xnu/blob/main/bsd/kern/kern_kpc.c
//
// System Private frameworks (since macOS 10.11, iOS 8.0):
// /System/Library/PrivateFrameworks/kperf.framework
from telethon import TelegramClient, sync
from telethon.tl.functions.channels import GetParticipantsRequest
from telethon.tl.functions.messages import GetHistoryRequest

from PIL import Image
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
import numpy as np
{
"since_id": [
"1400315510017773570",
"1400310811004870664",
"1400310789886464000",
"1400301511956045825",
"1400276115483107328",
"1400275292397076486",
"1400253696026431488",
"1400253351976075264",
@yihong0618
yihong0618 / 📊 Weekly development breakdown
Last active October 23, 2020 00:18
Weekly development breakdown
Python 19 hrs 6 mins █████████████████▏░░░ 82.0%
JavaScript 1 hr 55 mins █▋░░░░░░░░░░░░░░░░░░░ 8.2%
Other 1 hr ▉░░░░░░░░░░░░░░░░░░░░ 4.3%
JSX 50 mins ▊░░░░░░░░░░░░░░░░░░░░ 3.6%
YAML 20 mins ▎░░░░░░░░░░░░░░░░░░░░ 1.5%