Skip to content

Instantly share code, notes, and snippets.

View slow-is-fast's full-sized avatar

slow-is-fast slow-is-fast

View GitHub Profile
function random_color()
{
$colors = ['red', 'yellow', 'aqua', 'blue', 'light-blue', 'green', 'navy', 'teal', 'olive',
'orange', 'fuchsia', 'purple', 'maroon', 'black', 'red-active', 'yellow-active', 'aqua-active',
'blue-active', 'light-blue-active', 'green-active', 'navy-active', 'teal-active', 'olive-active',
'orange-active', 'fuchsia-active', 'purple-active', 'maroon-active', 'black-active',];
return Arr::random($colors);
}
@slow-is-fast
slow-is-fast / alacritty.yml
Created March 30, 2021 01:55
alacritty.yml
# 默认窗口无标题栏,16:9的窗口比例启动
window:
# decorations: "none"
# dimensions:
# columns: 120
# lines: 30
startup_mode: Maximized
# 背景半透明,方便抄代码
background_opacity: 0.9
@slow-is-fast
slow-is-fast / ArcUtils.java
Created July 10, 2020 02:44 — forked from Takhion/ArcUtils.java
Collection of methods to achieve better circular arc drawing, as Canvas.drawArc() is unreliable. See the related article: https://medium.com/p/9155f49166b8
/**
* ArcUtils.java
*
* Copyright (c) 2014 BioWink GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@slow-is-fast
slow-is-fast / laravel_model_observe_change.md
Created May 18, 2020 08:18
Laravel Model observer get changed data
    public function updated(Order $order)
    {
        $originals = [];
        if ($order->isDirty('order_status')) {
            Log::info("order new status :" . $order->order_status . " -- old status :" . $order->getOriginal('order_status'));
        }
        foreach ($order->getDirty() as $key => $val) {
            $originals[$key] = $order->getOriginal($key);
 }
@slow-is-fast
slow-is-fast / python_md5.md
Created March 18, 2020 02:38
file_md5 in python
import hashlib

def file_md5(fname):
    hash_md5 = hashlib.md5()
    with open(fname, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            hash_md5.update(chunk)
    return hash_md5.hexdigest()
@slow-is-fast
slow-is-fast / osx_install.sh
Created October 18, 2019 02:57 — forked from canering/osx_install.sh
Install most of my Apps with homebrew & cask
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Install and Set San Francisco as System Font
ruby -e "$(curl -fsSL https://raw.github.com/wellsriley/YosemiteSanFranciscoFont/master/install)"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@slow-is-fast
slow-is-fast / gist:b3d6fba9218d36e318d116836035bb5f
Created April 26, 2019 00:48 — forked from andphe/gist:3232343
Export your links from Safari reading list
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'
exiftool  "-CreateDate<FileModifyDate" "-DateTimeOriginal<FileModifyDate" "-ModifyDate<FileModifyDate" -overwrite_original .
pip install -U git+https://github.com/shadowsocks/shadowsocks.git@master
[
/*============= Emacs Style =============*/
{ "keys": ["ctrl+b"], "command": "move", "args": {"by": "characters", "forward": false} },
{ "keys": ["ctrl+f"], "command": "move", "args": {"by": "characters", "forward": true} },
{ "keys": ["ctrl+p"], "command": "move", "args": {"by": "lines", "forward":
false} },
{ "keys": ["ctrl+n"], "command": "move", "args": {"by": "lines", "forward":
true} },
{ "keys": ["ctrl+a"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["ctrl+e"], "command": "move_to", "args": {"to": "eol", "extend": false} },