Skip to content

Instantly share code, notes, and snippets.

View devld's full-sized avatar
😎

devld devld

😎
  • Xi'an
View GitHub Profile
@devld
devld / profile.ps1
Created April 12, 2018 11:13
colorful Prompt and `ls` in Powershell
function Prompt
{
if ($?) {
$color = "Green"
} else {
$color = "Red"
}
Write-Host -NoNewline -ForegroundColor $color '>> '
$pwd = $(Get-Location)
if ($pwd.Path -eq $env:USERPROFILE) {
@devld
devld / Util.java
Last active February 23, 2020 10:23
Java, JavaScript 数字转中文
private static String numToCN(int n, boolean appendZero, boolean appendOne) {
if (n == 0) return "";
if (n < 10) {
return (appendZero ? "零" : "") + NUMBER_MAPPING[n];
} else if (n < 100) {
return (appendZero ? "零" : "") + (!appendOne && n < 20 ? "" : NUMBER_MAPPING[n / 10])
+ "十" + (n % 10 == 0 ? "" : NUMBER_MAPPING[n % 10]);
} else if (n < 1000) {
return NUMBER_MAPPING[n / 100] + "百" +
numToCN(n % 100, n % 100 < 10, true);
@devld
devld / .bashrc
Last active April 28, 2020 07:44
Git-Bash configuration
export LANG=zh_CN.UTF-8
alias ls="ls --color=tty"
alias e="explorer .; true"
# alias for git
alias glg="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias ga="git add ."
alias gco="git checkout"
@devld
devld / global.ahk
Created March 30, 2020 01:56
AutoHotKey
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#NoTrayIcon
; #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.
; Ctrl + Alt + T: 打开 wsl-terminal
^!T::OpenWslTerminal()
OpenWslTerminal() {
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Function Set-NetConnectionSharing {
Param(
[Parameter(Mandatory=$true)][string] $LocalConnection,
[Parameter(Mandatory=$true)][bool] $Enabled,
[Parameter(Mandatory=$false)][string] $InternetConnection
)
Begin {
$netShare = $null
try {
@devld
devld / html-drag.html
Created June 20, 2022 06:49
Example code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>test scan files</title>
<style type="text/css">
.zone {
width: 400px;
height: 400px;
@devld
devld / lrc.js
Created June 20, 2022 07:33
Parse Lyric
class Lrc {
constructor(text) {
this.lrc = Object.freeze(this._parse(text))
}
find(time) {
return this.lrc[this.findIndex(time)]
}
location /_/ {
set $location_prefix '/_/';
set $target_uri '';
set $target_host '';
set $target_url '';
access_by_lua_block {
local target_uri = ngx.var.request_uri:sub(ngx.var.location_prefix:len() + 1)
if (not target_uri:lower():match("^https?://.+")) then
function parseURL(url) {
const regExp = /^(http|https):\/\/(([a-zA-Z0-9-_.]+)(:(\d{1,5}))?)([^?# ]*)(\?([^?#]*))?(#(.*))?$/
const a = regExp.exec(url)
if (!a) return
const parsedURL = {
schema: a[1],
host: a[2],
hostname: a[3],