Skip to content

Instantly share code, notes, and snippets.

View mutoe's full-sized avatar
😃
Charging

Dongsen mutoe

😃
Charging
View GitHub Profile
@mutoe
mutoe / canvas.util.js
Last active July 23, 2019 02:57
canvas 工具类 (可绘制圆角图片、含有缩放模式的图片绘制)
/**
* Canvas 助手方法
*/
export class CanvasUtil {
constructor (ctx, canvasWidth, canvasHeight) {
this.ctx = ctx
this.canvasWidth = canvasWidth
this.canvasHeight = canvasHeight
return this
window.onwheel = function (e) {
e.preventDefault();
if (e.ctrlKey) {
// Your zoom/scale factor
scale -= e.deltaY * 0.01;
} else {
// Your trackpad X and Y positions
posX -= e.deltaX * 2;
posY -= e.deltaY * 2;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Tab::Send {Tab}
Tab & J::Send {Down}
Tab & U::Send {Shift Down}
Tab & K::Send {Up}
Tab & I::Send {Shift Up}
@mutoe
mutoe / grouped-scss-order
Created August 8, 2020 08:58
grouped-scss-order
composes
@import
@extend
@mixin
@at-root
position
top
right
bottom
left
@mutoe
mutoe / mutoe.json
Created February 25, 2021 12:36
Karabiner modifier
{
"title": "HHKB modifiers for mutoe (Tab key)",
"rules": [
{
"description": "Change left_shift to caps_lock if pressed alone.",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_shift",
@mutoe
mutoe / .gitconfig
Last active March 21, 2021 11:47
Personal profiles (Vim, Tmux, Zsh, etc.)
[user]
signingkey =
name = mutoe
email = [email protected]
[core]
editor = vim
[diff]
tool = vimdiff
[difftool]
prompt = 0
@mutoe
mutoe / index.js
Created March 7, 2023 05:36
Get IP address
const http = require('http')
function getClientIp (req) {
const forwardedIpsStr = req.headers['x-forwarded-for']
if (forwardedIpsStr) {
console.log('forwardedIpsStr: ' + forwardedIpsStr)
return forwardedIpsStr.split(',')[0]
}
console.log('remoteAddress: ' + req.connection.remoteAddress)
@mutoe
mutoe / listener.js
Created April 4, 2024 09:47
Github Webhooks
const http = require('http')
const crypto = require('crypto')
const execFile = require('child_process').execFile
const port = 10010
const secret = 'your_secret'
const bashFile = './onpush.sh'
const sign = data => `sha1=${crypto.createHmac('sha1', secret).update(data).digest('hex')}`