Skip to content

Instantly share code, notes, and snippets.

View sy-records's full-sized avatar
:octocat:
Looking for a job

Luffy sy-records

:octocat:
Looking for a job
View GitHub Profile
@sy-records
sy-records / get-cli-commands
Created January 2, 2020 07:48
PHP遍历命令行参数
function getCommands()
{
$argv = $GLOBALS['argv'];
$tmp = [];
foreach ($argv as $key => $item) {
$name = $item;
$value = '';
if (strpos($name, '=') !== false) {
list($name) = explode('=', $item);
$value = ltrim(strstr($item, "="), "=");
@sy-records
sy-records / redis-setnx.php
Created December 24, 2019 03:28
PHP使用Redis防止大并发下二次写入
<?php
$lock_key = 'LOCK_PREFIX_'. $key;
$is_lock = $redis->setNX($lock_key, 1); // 加锁
if ($is_lock == true) {// 获取锁权限
// ... 具体操作
// 释放锁
$redis->del($lock_key);
return true;
@sy-records
sy-records / iterm2-send-zmodem.sh
Last active September 3, 2019 01:39
在Mac上的iterm2使用rz命令进行文件的上传
#!/bin/bash
# Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domain
osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
else
@sy-records
sy-records / iterm2-recv-zmodem.sh
Last active September 3, 2019 01:38
在Mac上的iterm2使用sz命令进行文件的下载
#!/bin/bash
# Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domain
osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
else