Skip to content

Instantly share code, notes, and snippets.

View wfxr's full-sized avatar
☃️
I may be slow to respond.

Wenxuan wfxr

☃️
I may be slow to respond.
  • Earth
View GitHub Profile
@wfxr
wfxr / github-release-download.sh
Created July 24, 2017 08:16
从Github上面下载最新的Release包
# eg: download exa
curl -s https://api.github.com/repos/ogham/exa/releases/latest | grep browser_download_url | grep linux | cut -d'"' -f4
@wfxr
wfxr / swap_ctrl_caps.ps1
Last active October 10, 2022 05:48
Swap ctrl and capslock in Win10
$hexified = "00,00,00,00,00,00,00,00,03,00,00,00,3A,00,1D,00,1D,00,3A,00,00,00,00,00".Split(',') | % { "0x$_"};
$kbLayout = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout';
New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified);

GoogleTest 在 CLion (JetBrains 的跨平台 C++ IDE) 中使用和配置


安装CLion

安装CLion很简单,流程和JetBrains的其他IDE基本是一样的,只是最后需要配置一下工具链。我使用的是Cygwin。

安装Cygwin

安装Cygwin的教程网上有很多,cmakemakegcc/clang, gdb/lldb这些是必须要安装的组件。

编译安装GoogleTest

打开Cygwin,找一个合适的位置,将GoogleTest的最新源码克隆到本地,然后进行编译和安装。

@wfxr
wfxr / surfingkeys.js
Last active December 29, 2021 05:37
surfingkeys config
// vim: set ft=javascript:
settings.tabsMRUOrder = false;
mapkey('T', 'Choose a tab with omnibar', function() {
Front.openOmnibar({type: "Tabs"});
});
mapkey('gt', '#8Open a URL', function() {
Front.openOmnibar({type: "URLs", extra: "getAllSites"});
package main
import "fmt"
func foo1() {
fmt.Println("Hello, world")
fmt.Println("Hello, world")
fmt.Println("Hello, world")
fmt.Println("Hello, world")
fmt.Println("Hello, world")
@wfxr
wfxr / main.go
Last active April 18, 2021 10:34
Primes
package main
import "fmt"
func main() {
for prime := range primes(100) {
fmt.Println(prime)
}
}
@wfxr
wfxr / gist:126c6d0ca716a60f1db53ff8d3f922d3
Created January 28, 2019 03:25
gpg safe private key
gpg --s2k-cipher-algo AES256 --s2k-digest-algo SHA512 --s2k-mode 3 \
--s2k-count 65000000 --edit-key <key id>
@wfxr
wfxr / PercentageRound.kt
Created September 6, 2018 11:51
Algorithms
// 保证总和为100%的前提下损失精度最小的百分比Rounding算法
import com.google.common.math.IntMath
fun percentageRound(a: List<Double>, precision: Int): List<Double> {
val factor = IntMath.pow(10, precision)
val scaled = a.map { it * factor }
val rounded = scaled.mapIndexed { i, num -> i to Math.round(num) }
val sum = rounded.fold(0L) { acc, pair -> acc + pair.second }
@wfxr
wfxr / snippet.md
Created November 16, 2017 08:24
Zsh代码片段

将字符串分割成数组

str='Tom,Jarry'
users=(${(@s/,/)str})

将数组合并成字符串

# 用回车符Join
${(j:\n:)users}
@wfxr
wfxr / ssh.md
Last active November 15, 2017 10:28
Linux commands

基本参数

正向代理

ssh -fCNL

反向代理

ssh -fCNR