Skip to content

Instantly share code, notes, and snippets.

@1901
1901 / timezone.lua
Last active March 25, 2023 08:26
lua中获取本地时区(timezone)的方法
--[[
打印时区信息
--]]
function os.printTimezone()
local t = os.time()
local ut = os.date('!*t',t)
local lt = os.date('*t',t)
local tzdt = (lt.hour - ut.hour) * 3600 + (lt.min - ut.min) * 60
print(string.format("本地时间与标准时间差 %d(%.1f小时) 分钟", tzdt, tzdt / 3600))
end
@1901
1901 / ios_memory.m
Last active October 7, 2015 08:13
ios memory info
// 获取当前设备可用内存及所占内存的头文件
#import <sys/sysctl.h>
#import <mach/mach.h>
// 获取当前设备可用内存(单位:MB)
- (double)availableMemory
{
vm_statistics_data_t vmStats;
mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
@1901
1901 / strip.conf
Created February 25, 2016 15:54 — forked from dextorer/strip.conf
google-play-services-strip-script
actions=true
ads=true
analytics=true
appindexing=true
appstate=true
auth=true
cast=true
common=true
drive=false
dynamic=true
@1901
1901 / upload_ipa.sh
Created September 18, 2017 15:50
Upload ipa to apple store.
#!/bin/bash
ipa_file=$1
[email protected]
altool='/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool'
echo "Validating..."
"$altool" --validate-app -f $ipa_file -u $apple_id
echo "Uploading..."
"$altool" --upload-app -f $ipa_file -u $apple_id --output-format normal
@1901
1901 / mysql_commands.sql
Last active June 21, 2019 10:08
[MySQL 账号和授权] #mysql #linux
-- 创建只读账号 (% 表示不限制 IP 登录)
GRANT SElECT ON *.* TO 'reader'@'%' IDENTIFIED BY "password";
-- 如果提示 `ERROR 1819 (HY000): Your password does not satisfy the current policy requirements`,可以使用下面的命令修改策略配置。
SHOW VARIABLES LIKE 'validate_password%';
SET GLOBAL validate_password_policy=LOW;
-- 创建拥有所有权限的账号,并限制只允许本机登录
-- Mysql 5.x
GRANT all privileges ON *.* TO 'camexgames'@'localhost' IDENTIFIED BY "password";
@1901
1901 / socat_forward_port.sh
Last active January 24, 2020 21:52
[socat 端口转发] #linux #mysql #network
# install socat on CentOS 6.x
rpm -ivh https://forensics.cert.org/cert-forensics-tools-release-el6.rpm
yum install socat
# tcp
nohup socat TCP4-LISTEN:3306,reuseaddr,fork TCP4:192.168.1.2:3306 >> socat.log 2>&1 &!
# udp
nohup socat UDP4-LISTEN:1194,reuseaddr,fork UDP4:192.168.1.3:1194 >> socat.log 2>&1 &!
@1901
1901 / nginx_return_code_content.cfg
Last active November 10, 2018 13:47
[Nginx 直接返回内容] #nginx #linux
location = /test {
add_header Content-Type text/plain;
return 200 'proxy-4001';
}
@1901
1901 / adb.sh
Created November 12, 2018 10:47
[adb] #android #adb
adb shell am start -W -a android.intent.action.VIEW -d "https://main.sea.camexgame.com/instant"
adb shell am start -W -a android.intent.action.VIEW -d "https://instant.app/com.camex.tactical.monsters"
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://play.google.com/store/apps/details?id=com.camex.tactical.monster&launch=true"
@1901
1901 / ip_api.sh
Last active February 12, 2020 03:42
[IP API] #network
curl ip.cn
curl us.ip.cn
curl ip.sb
curl cip.cc
curl cip.cc/1.1.1.1
curl myip.ipip.net
curl ipinfo.io
curl ifconfig.me
@1901
1901 / nginx_crossdomain.conf
Created November 15, 2018 05:50
[Nginx 跨域配置] #nginx #linux
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' '*';
add_header 'Access-Control-Allow-Credentials' 'true';