Skip to content

Instantly share code, notes, and snippets.

View tankxu's full-sized avatar
:octocat:

Tank Xu tankxu

:octocat:
View GitHub Profile
@tankxu
tankxu / ttc2ttf.py
Last active August 29, 2015 14:23 — forked from kayahr/ttc2ttf.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#First released as C++ program by Hiroyuki Tsutsumi as part of the free software suite “Beer”
#I thought porting it to Python could be both a challenge and useful
from sys import argv, exit, getsizeof
from struct import pack_into, unpack_from
def ceil4(n):

Keybase proof

I hereby claim:

  • I am tankxu on github.
  • I am tankxu (https://keybase.io/tankxu) on keybase.
  • I have a public key whose fingerprint is D505 7C14 6BBA EA2F 1165 FD79 2049 DF9B 8E4E 378A

To claim this, I am signing this object:

@tankxu
tankxu / A list of sketch scripts
Last active June 14, 2020 03:47
Sketch Script
A list of sketch scripts
@tankxu
tankxu / gif图片压缩.md
Created June 28, 2019 07:44
Gif 图片压缩

方法一:

gifsicle -O3 --lossy=130 input.gif -o output.gif

lossy 的值越大压缩越严重

方法二:

convert input.gif -fuzz 15% -layers Optimize output.gif
@tankxu
tankxu / pdf2image.sh
Last active January 15, 2020 16:26
Convert multi page pdf to a single jpg file
#! /bin/bash
# set -e
for file in ./pdf/*
do
fileName=$(basename -- "$file")
fileName="${fileName%.*}"
# echo $filename
pdfName=./pdf/$fileName.pdf
outputName=./jpg/$fileName.jpg
(*
https://apple.stackexchange.com/questions/184633/how-do-i-clear-all-os-x-notifications-with-1-click
*)
tell application "System Events"
tell process "NotificationCenter"
set numwins to (count windows)
repeat with i from numwins to 1 by -1
click button "Close" of window i
end repeat
@tankxu
tankxu / 0 Generate icons collection.sketchscript
Last active June 14, 2020 03:45
Use this script to genrate icons collection artboard for your icon sketch library.
const sketch = require("sketch")
const document = sketch.getSelectedDocument()
const selection = document.selectedLayers.layers
const Group = sketch.Group
const Style = sketch.Style
const Rectangle = sketch.Rectangle
const Artboard = sketch.Artboard
const ShapePath = sketch.ShapePath
const Text = sketch.Text
const SymbolInstance = sketch.SymbolInstance
const tokenArray = [
{ name: 'color-background-default', value: '#f5f7fa'},
{ name: 'color-background-white', value: '#fff'},
{ name: 'color-background-dark', value: '#202d40'},
{ name: 'color-background-tooltip', value: '#202d40'},
{ name: 'color-background-message-warning', value: '#fffbe5'},
{ name: 'color-background-message-success', value: '#f2ffe0'},
{ name: 'color-background-message-error', value: '#fff0f0'},
{ name: 'color-background-message-info', value: '#e6f7ff'},
{ name: 'color-background-list-row-hover', value: '#f5f7fa'},
@tankxu
tankxu / rename-files-name.md
Last active June 1, 2020 07:58
Rename files name.sh

批量重命名文件的两种方法:

1. 通过 rename 命令配合 regex 修改替换文件名

macOS 需安装 rename brew install rename

rename -n 测试 regex 修改结果,不会执行修改命令

rename -n "s/oldname/newname/" input_files

在 oldname 中使用 regex 匹配文件名中的内容,newname 中可使用\1来引用匹配的结果

@tankxu
tankxu / full screenshot for website.js
Last active July 2, 2020 13:28
Take a full screenshot for long website
const puppeteer = require("puppeteer")
// Set parameter
const urls = [
'https://github.com/enterprise',
'https://github.com/team'
]
const pageWidth = 1600
const delayTime = 5000