Skip to content

Instantly share code, notes, and snippets.

View babyking's full-sized avatar

Baby King babyking

View GitHub Profile
@babyking
babyking / thin.yml
Created September 23, 2022 03:01 — forked from Kapenaar/thin.yml
Default config file for thin web server with comments
### SERVER OPTIONS ###
## Bind Address
#address: HOST # Default: 0.0.0.0
## Bind port. If using multiple thin servers,
## they will bind to (PORT + n) where n is the server number
#port: PORT # Default: 3000
require 'net/http'
require 'net/https'
require 'uri'
uri = URI('https://example.com/rest/api/2/1')
Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == 'https',
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
@babyking
babyking / WindowPosition.swift
Created June 8, 2022 07:11 — forked from ABridoux/WindowPosition.swift
Logic to easily set a NSWindow's origin horizontally and vertically in a screen (AppKit and SwiftUI)
// Free to use
// Written by Alexis Bridoux - https://github.com/ABridoux
import AppKit
#if canImport(SwiftUI)
import SwiftUI
#endif
// MARK: Model
@babyking
babyking / command.txt
Created April 24, 2022 08:24 — forked from nrk/command.txt
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
File formats:
D. = Demuxing supported
.E = Muxing supported
--
E 3g2 3GP2 format
E 3gp 3GP format
D 4xm 4X Technologies format
D IFF IFF format
D ISS Funcom ISS format
D MTV MTV format
#!/bin/bash
find . -type f -not -name ".*" -print0 | while read -d $'\0' file; do
echo $file
level=$(ffmpeg -y -nostdin -i $file -af "volumedetect" -vn -sn -dn -f null /dev/null 2>&1 | grep max_volume | sed -n 's/.*max_volume: \([^ ]*\) .*/\1/p')
gain=$(bc -l <<< "-($level)")
echo "${gain}dB"
ffmpeg -y -nostdin -loglevel panic -i $file -af "volume=${gain}dB" temp.mp3
rm $file
mv temp.mp3 $file
done
@babyking
babyking / autohotkey.ahk
Last active December 18, 2019 03:01
自己使用的Autohotkey 脚本 绝大多数的习惯与我的MAC上定义快捷键是一致的. mac上实现此脚本中快捷键主要是通过 keyremap4macbook来实现的.大部分定义受vi以及unix的一些快捷键影响,另外,刚刚买了一个hhkb键盘,部分定义也受其启发.
/*
* email: babyking1949@gmail.com
* update: 2013/3/9
*/
;常用快捷命令
:://cmd:: ;打开命令行
Run cmd
return
@babyking
babyking / capslock_remap_alt.ahk
Created May 16, 2017 02:44 — forked from Danik/capslock_remap_alt.ahk
Autohotkey Capslock Remapping Script. Makes Capslock function as a modifier key to get cursor keys etc. on the left side of the keyboard, so you never have to move your hand to the right.
; Autohotkey Capslock Remapping Script
; Danik
; More info at http://danikgames.com/blog/?p=714
; danikgames.com
;
; Functionality:
; - Deactivates capslock for normal (accidental) use.
; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
; - Access the following functions when pressing Capslock:
; Cursor keys - J, K, L, I
@babyking
babyking / AutoHotkey.ahk
Created May 16, 2017 02:37 — forked from cowboy/AutoHotkey.ahk
AutoHotkey: Press quickly to send <key1>, hold for <delay> ms to send <key2>. Also, matching Logitech G700s profile.
; Press quickly to send <key1>, hold for <delay> ms to send <key2>
; Examples:
; Joy8::dualPress("[", "]")
; Joy10::dualPress("N", "{RShift Down}{N}{RShift Up}")
; MButton::dualPress("F12", "F11", 0.5)
dualPress(key1, key2, delay = 0.2) {
IfNotInString, key1, {
key1 = {%key1%}
IfNotInString, key2, {
@babyking
babyking / capslock.ahk
Created May 16, 2017 02:34 — forked from scottming/capslock.ahk
; Autohotkey Capslock Remapping Script
; Autohotkey Capslock Remapping Script
; - Deactivates capslock for normal (accidental) use.
; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
; - Access the following functions when pressing Capslock:
;Cursor keys - h, j, k, l
;Home,End - N, ;
;Page up,down - - =
;Esc - CapsLock only
;CapsLock - Space