Skip to content

Instantly share code, notes, and snippets.

View ccqpein's full-sized avatar

ccQpein ccqpein

View GitHub Profile
@ccqpein
ccqpein / gist:a6f354b7388b49984bd498663f98a21c
Created December 13, 2019 06:42
select proxy in terminal
networksetup -getsocksfirewallproxy Wi-Fi
networksetup -setsocksfirewallproxy <networkservice> <domain> <port number> <authenticated> <username> <password>
networksetup -setsocksfirewallproxystate Wi-Fi on
function: ^func\ +\w+\((|(\w+\ +\w+\ *,*\ *)+(\w+\ +\.\.\.interface{})*)\)\ +(\w+|\((\w+\ *,*\ *)+\))\ *{.*$
interface: ^type\ +\w+\ +interface\ *{(|\ *\n*(\w+\((|(\w+\ +\w+\ *,*\ *)+(\w+\ +\.\.\.interface{})*)\)\ *(|\w+|\((\w+\ *,*\ *)+\))\n)*)*}
struct: ^type\ +\w+\ +struct\ *{(?<body>|\s*\n+(\s+?(\w+|\w+\s*,*\s*)+?\s+\w+\n+)*?)}
@ccqpein
ccqpein / graphic_card_switch_control.sh
Last active July 3, 2023 21:11
macOS 10.14 use pmset to control graphic card switch.
# I find this https://discussions.apple.com/thread/8160651
# but it not match my 2018 version MacBook with macos 10.14
#
# On my local, gpuswitch value is
# 0 -> does not use dedicated graphics
# 1 -> use dedicated graphics
# 2 -> switch automaticly (I guess), because 2 is default value when "automatic graphics switching" selected
# in energy in preference.
# check settings depended on charger/battery
@ccqpein
ccqpein / impl_trait_test.rs
Created December 30, 2018 15:58
Rust return different structs those implement same trait
struct Test0;
struct Test1;
trait A {}
impl A for Test0 {}
impl A for Test1 {}
//failed
/*fn test(a: i32) -> impl A {