Skip to content

Instantly share code, notes, and snippets.

View ous50's full-sized avatar

ous fifty ous50

View GitHub Profile
@ous50
ous50 / rfc-8908-cf-worker.js
Last active July 10, 2026 02:56
Added timezone offset support
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
function getTimezoneOffset() {
const date = new Date();
const formatter = new Intl.DateTimeFormat('en-US', {
timeZone: request.cf.timezone,
@ous50
ous50 / gist:1eec204e7a413580b01003dd42da0a1e
Created April 5, 2024 21:47
Check Power Consumption in Apple Silicon MacOS
powerstat() {
info=$(ioreg -w 0 -f -r -c AppleSmartBattery)
volInMili=$(echo $info | grep '"Voltage" = ' | grep -oE '\d+')
ampInMili=$(echo $info | grep '"Amperage" = ' | grep -oE '\d+')
ampInMili=$(bc <<< "if ($amp >= 2^63) $amp - 2^64 else $amp")
vol="$(( (vol / 1000.0) ))"
amp="$(( (amp / 1000.0) ))"
power="$(( (vol / 1000.0) * (amp / 1000.0) ))"
printf " Battery Power Information:\n"
printf " Voltage (V): %.3f\n" $vol
@ous50
ous50 / vw-bkp.sh
Last active January 21, 2023 17:43
A shell script automatic backup vaultwarden and bitwarden(untested) data folder
#!/bin/bash
PATH=/sbin:/usr/sbin/:/usr/local/sbin:/bin:/usr/local/bin
#This script requires gnupg and rsync installed.
#set variables
presentHour=$(date '+%H')
parentDirectory= #The parent directory of the targetDirectory
backupDirectory=#bw-bkp
targetDirectory=#bw-data
This file is used to be tracked and identified by https://lrc-maker.github.io
@ous50
ous50 / lyric.py
Created January 1, 2020 02:48 — forked from 3rogue/lyric.py
网易云音乐歌词下载
# -*- coding: utf-8 -*-
import requests
import os
import re
# 163 api https://github.com/yanunon/NeteaseCloudMusic/wiki/%E7%BD%91%E6%98%93%E4%BA%91%E9%9F%B3%E4%B9%90API%E5%88%86%E6%9E%90
def downloadlyric(songname):
songname = re.search(r'.*\\(.*).mp3',songname)
songname = songname.group(1)
headers = {'referer':'http://music.163.com', 'appver':'2.0.2'}