Skip to content

Instantly share code, notes, and snippets.

View idleuncle's full-sized avatar

Jiangwen Su idleuncle

View GitHub Profile
@idleuncle
idleuncle / 0_reuse_code.js
Created September 1, 2017 02:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@idleuncle
idleuncle / get_localhost_ip.sh
Last active May 6, 2019 15:10
获得主机IP地址
ifconfig -a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | tr -d "addr:"
@idleuncle
idleuncle / disable_macos_integrity_protection.sh
Last active May 6, 2019 15:09
How to disable system integrity protection (rootless) in Mac OSX
Reboot with Command + R to enter into Recovery Mode.
"OS X Utilities" -> "Terminal"
$ csrutil disable; reboot
check status
$ csrutil status
@idleuncle
idleuncle / svg_2_png.sh
Last active May 6, 2019 15:08
svg图片转换为png格式
https://stackoverflow.com/questions/9853325/how-to-convert-a-svg-to-a-png-with-image-magick
$ inkscape -z -e test.png -w 1024 -h 1024 test.svg
npm install svgexport -g
svgexport input.svg output.png 64x
svgexport input.svg output.png 1024:1024
convert -density 1200 -resize 200x200 source.svg target.png
@idleuncle
idleuncle / update_locate_database.sh
Last active May 6, 2019 15:07
重新更新locate数据库
sudo /usr/libexec/locate.updatedb
@idleuncle
idleuncle / fix_alfred_alert.sh
Last active May 6, 2019 15:07
消除Alfred 3每次开机提示“是否允许访问通讯录”
sudo codesign -f -d -s - /Applications/Alfred\ 3.app/Contents/Frameworks/Alfred\ Framework.framework/Versions/A/Alfred\ Framework
@idleuncle
idleuncle / generate_random_password.sh
Last active May 6, 2019 15:06
随机生成密码
openssl rand -base64 8 | cut -c 1-9
# 生成128位随机串
cat /dev/urandom | od -X -N 16 | head -n 1 | cut -d ' ' -f 2- | tr -d ' '
# 生成8字节长度随机串,27 = 9 + 16
cat /dev/urandom | od -x | head -c 27 | cut -d ' ' -f 2- | tr -d ' '
# 生成16字节长度随机串,41 = 9 + 32
cat /dev/urandom | od -x | head -c 41 | cut -d ' ' -f 2- | tr -d ' '
# 生成32字节长度随机串(最长32字节)
@idleuncle
idleuncle / shell_auto_input_password_via_stdin.txt
Last active May 6, 2019 15:05
自动非交互式从标准输入管道输入密码
ssh 192.168.1.1 "echo 'newpassword' | passwd --stdin root"
Ubuntu下没有--stdin选项,此时用chpasswd
echo user:newpassword | chpasswd
@idleuncle
idleuncle / cairo_graphics_to_wxImage.cc
Last active May 6, 2019 15:04
Cairo graphics 转 wxImage
wxRect rect(0,0,200,200);
unsigned int image_buffer_len = rect.width * rect.height * 4;
unsigned char *image_buffer = (unsigned char*)new unsigned char[image_buffer_len];
cairo_surface_t *cairo_surface = cairo_image_surface_create_for_data(image_buffer, CAIRO_FORMAT_RGB32, rect.width, rect.height, rect.width * 4);
cairo_t *cairo_image = cairo_create(cairo_surface);
Render(cairo_image, rect.width, rect.height);
unsigned char *output = (unsigned char*)new unsigned char[image_buffer_len];
@idleuncle
idleuncle / python_http_server_for_debug.txt
Last active May 6, 2019 15:03
临时调试网页载入用的http服务器
python -m SimpleHTTPServer 8080
python3 -m http.server
npm install -g live-server