Skip to content

Instantly share code, notes, and snippets.

View devld's full-sized avatar
😎

devld devld

😎
  • Xi'an
View GitHub Profile
@devld
devld / HttpServeFile.java
Created April 14, 2023 09:33
HTTP serve file with range and cache headers
package me.devld;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.ref.SoftReference;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
git rebase -i <commit id> --committer-date-is-author-date
# change the command to `e`
GIT_COMMITTER_DATE=$(git log -n 1 --format=%aD) git commit --amend --author 'author <email>' --no-edit
@devld
devld / draw-heart.html
Created November 9, 2022 05:22
画一个♥
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Heart</title>
<style>
body {
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],
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
@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)]
}
@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;
Function Set-NetConnectionSharing {
Param(
[Parameter(Mandatory=$true)][string] $LocalConnection,
[Parameter(Mandatory=$true)][bool] $Enabled,
[Parameter(Mandatory=$false)][string] $InternetConnection
)
Begin {
$netShare = $null
try {
#!/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...]
@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() {