Skip to content

Instantly share code, notes, and snippets.

@liunian
liunian / optimg.fish
Last active April 21, 2023 14:25
optimize images
#!/usr/bin/env fish
# use optipng to optimize png
if type -q optipng
set pngs (command find . -name "*.png")
for i in $pngs
# echo $i
optipng -strip all $i
end
else
@liunian
liunian / cur-git-branch-name.sh
Last active August 31, 2019 03:10
is git dirty
git rev-parse --abbrev-ref HEAD
@liunian
liunian / Phoenix theme.json
Last active August 15, 2018 07:39
SublimtText settings
{
"caret_extra_bottom": 3,
"caret_extra_toop": 3,
"caret_extra_width": 3,
"color_scheme": "Packages/Theme - Phoenix/Color Scheme/Phoenix Dark Orange.tmTheme",
"font_size": 15,
"highlight_liine": true,
"ignored_packages":
[
"Theme - Cobalt2",
@liunian
liunian / random_modify.py
Created August 13, 2018 16:31
modify large randomly
#!/usr/bin/env python
import os
import sys
import mmap
import string
import random
from pathlib import Path
def random_str(len):
@liunian
liunian / delSvn.py
Created June 23, 2018 02:42
remove .svn directory
#!/usr/bin/env python3
import os
import shutil
path = input('enter dir path: ')
del_list = []
for p, d, f in os.walk(path):
if '.svn' in d:
del_path = os.path.join(os.path.abspath(p), '.svn/')
@liunian
liunian / Wallpapers.py
Last active September 4, 2021 15:07
Download wallpaper from https://wall.alphacoders.com/
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import bs4
import re
import os
import sys
from multiprocessing import Pool, cpu_count
try:
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="UAT FLOW">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.min.js"></script>
</head>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.min.js"></script>
</head>
<body>
@liunian
liunian / clone-json.js
Last active April 26, 2024 03:29
clone json
// from: https://jsperf.com/deep-copy-vs-json-stringify-json-parse/15
function recursiveDeepCopy(o) {
var newO,
i;
if (typeof o !== 'object') {
return o;
}
if (!o) {
@liunian
liunian / to_ascii.js
Last active April 26, 2024 03:29
把超出 ascii 范围的字符(如中文)等转为基于 ascii 范围字符的转义表达形式(https://github.com/mishoo/UglifyJS2/blob/master/lib/output.js#L76
// from https://github.com/mishoo/UglifyJS2/blob/harmony/lib/output.js
function to_ascii(str) {
return str.replace(/[\ud800-\udbff][\udc00-\udfff]|[\u0000-\u001f\u007f-\uffff]/g, function (ch) {
var code = get_full_char_code(ch, 0).toString(16);
if (code.length <= 2) {
while (code.length < 2) code = "0" + code;
return "\\x" + code;
} else {
while (code.length < 4) code = "0" + code;