Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / sprite_shader.cpp
Created May 15, 2014 01:47
Cocos2d中设置Sprite的Shader
CCGLProgram* p = new CCGLProgram();
p->initWithVertexShaderFilename("shader/BanishShader.vsh", "shader/BanishShader.fsh");
p->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
p->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
p->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
p->link();
p->updateUniforms();
pSprite->setShaderProgram(p);
p->release();
@1901
1901 / string_wstring.cpp
Created May 31, 2013 10:28
std::string和std::wstring之间相互转换
// 把一个wstring转化为string
std::string& to_string(std::string& dest, std::wstring const & src)
{
std::setlocale(LC_CTYPE, "");
size_t const mbs_len = wcstombs(NULL, src.c_str(), 0);
std::vector<char> tmp(mbs_len + 1);
wcstombs(&tmp[0], src.c_str(), tmp.size());
dest.assign(tmp.begin(), tmp.end() - 1);
@1901
1901 / gitconfig_colorful
Created May 10, 2013 01:56
使Git命令输出变成彩色的方法
# 参数可选(auto, ture, false)
$ git config --global color.status auto
$ git config --global color.diff auto
$ git config --global color.branch auto
$ git config --global color.interactive auto
$ git config --global color.ui auto
@1901
1901 / all_class_in_objc.c
Created January 24, 2013 11:26
Objective-C获取所有的类
int numClasses = 0;
Class * classes = NULL;
numClasses = objc_getClassList(NULL, 0);
if (numClasses > 0 )
{
classes = malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
for (int i = 0; i < numClasses; i++)