Skip to content

Instantly share code, notes, and snippets.

View yuhr123's full-sized avatar
🏠
Working from home

Herald Yu yuhr123

🏠
Working from home
View GitHub Profile
@yuhr123
yuhr123 / DB.sql
Created June 24, 2016 04:15 — forked from msurguy/DB.sql
Dynamic dropdown in Laravel, let's say you have multiple drop downs (selects), you click on one and the contents of the other need to be dynamically changed. One solution is to dynamically load JSON from the API and change the dropdown dynamically depending on the user choice.
CREATE TABLE `makers` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
@yuhr123
yuhr123 / controller.php
Last active June 24, 2016 08:39
Laravel 5.1.x 级联下拉列表
<?php
namespace App\Http\Controllers\Dash;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Category;
@yuhr123
yuhr123 / Settings.json
Last active September 17, 2017 15:24
EspoCRM 添加自定义货币
# custom/Espo/Custom/Resources/metadata/entityDefs/Settings.json
{
"fields": {
"currencyList": {
"options": ["__APPEND__","RMB"]
}
}
}
@yuhr123
yuhr123 / install-docker-on-debian.sh
Created October 19, 2017 07:18
Install Docker CE on Debian Strach x86_64
#!/bin/bash
# install dependency packages
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
# add gpg key
Verifying my Blockstack ID is secured with the address 1NWuk5A3KPrSRYSs8ApqEEmjAA97uEfevJ https://explorer.blockstack.org/address/1NWuk5A3KPrSRYSs8ApqEEmjAA97uEfevJ
@yuhr123
yuhr123 / datatime_by_timezone.py
Created February 2, 2018 03:06
Python datatime 模块按时区打印时间
from datetime import datetime, timedelta, timezone
# 东8区时间
time_utc_8 = datetime.now().astimezone(timezone(timedelta(hours=8)))
print(time_utc_8)
# 2018-02-02 10:56:10.496695+08:00
# 格式化
format = time_utc_8.strftime('%Y-%m-%d %H:%M:%S')
@yuhr123
yuhr123 / frpc-runit-sample.sh
Created March 22, 2018 00:35
FRP 客户端 runit 脚本示例
#!/bin/sh
FRPC=/usr/bin/frpc
CONFIG=/etc/frp/frpc.ini
LOG=/var/log/frp.log
USER=pi # change this with the actual user
exec chpst -u $USER $FRPC -c $CONFIG -L $LOG
"gettext": {
"scope": "html",
"prefix": "_",
"body": "{{ _('$1') }}",
"description": "create a gettext code"
},
"variable": {
"scope": "html",
"prefix": "jv",
"body": "{{ $1 }}",
@yuhr123
yuhr123 / backup-docker-volume-to-s3.sh
Last active February 7, 2024 10:21
导出并打包 Docker volume 上传到 s3 对象存储
#!/bin/bash
# Docker Volume: ghost_data
# MariaDB Container: mariadb
# 定义文件名变量
data_filename="ghost_data-`date +%Y-%m-%d_%H%M%S`.tar.gz"
db_filename="ghost_db-`date +%Y-%m-%d_%H%M%S`.sql"
# 通过临时创建的中间容器挂载 volume 并压缩打包成带时间的 tar.gz 文件
docker run --rm \
@yuhr123
yuhr123 / scroll.html
Created January 31, 2019 09:20
ul 列表项自动循环滚动,每次显示一条。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>滚动条</title>
<style>
#s1 {
overflow: hidden;