Skip to content

Instantly share code, notes, and snippets.

@ccat3z
ccat3z / main.cpp
Last active November 14, 2024 10:24
mmap read large file
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <cerrno>
#include <cstring>
#include <iostream>
#include <fstream>
void dump_mem() {
@ccat3z
ccat3z / .msan-dynamic-tls-example
Last active July 27, 2023 04:20
msan-dynamic-tls
//
[Desktop Entry]
Name=vscode-right-click-hotfix
Type=Application
Exec=/usr/bin/env vscode-right-click-hotfix
@ccat3z
ccat3z / gen_credential.sh
Created January 13, 2022 07:47
Generate credential for k3s cluster admin
#! /bin/bash
# Based on scripts in https://github.com/k3s-io/k3s/issues/684
set -e
clus_name="default"
user="user"
clus_url="https://127.0.0.1:6443"
ca_path=/var/lib/rancher/k3s/server/tls
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Initializing cgroup subsys schedtune
[ 0.000000] Linux version 4.4.268-perf+ (nobody@android-build) (Android (7284624, based on r416183b) clang version 12.0.5 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee)) #1 SMP PREEMPT Sun May 9 10:47:59 CEST 2021
[ 0.000000] Boot CPU: AArch64 Processor [51af8014]
[ 0.000000] Machine: Qualcomm Technologies, Inc. MSM 8998 v2.1 MTP
[ 0.000000] Reserved memory: reserved region for node 'removed_regions@85800000': base 0x0000000085800000, size 55 MiB
[ 0.000000] Reserved memory: reserved region for node 'pil_adsp_region@0x8b200000': base 0x000000008b200000, size 30 MiB

Keybase proof

I hereby claim:

  • I am ccat3z on github.
  • I am ccat3z (https://keybase.io/ccat3z) on keybase.
  • I have a public key whose fingerprint is A784 DBF8 8D71 8B5F A46C F254 040B D409 F274 BE67

To claim this, I am signing this object:

@ccat3z
ccat3z / find-volumes.sh
Created May 23, 2018 16:21
Find all volumes in a docker container
docker inspect -f '{{ range $index, $mount := .Mounts }}{{ if eq $mount.Type "volume"}}{{ $mount.Name }} {{ end }}{{ end }}' $NAME
@ccat3z
ccat3z / 2-12.py
Created May 8, 2017 16:55
一道不知道什么时候的数学题
#!/bin/python
import timeit
maxNum=10
numList=list(range(maxNum,0,-1)) #生成1...MAX的数列
result=0 #初始化结果
@ccat3z
ccat3z / genSmallData.sh
Last active March 28, 2017 15:12
各种报名照片转换
#!/bin/sh
if [ -d out_small_data ];then
echo "out_small_data dir existed."
read -n 1 -p "remove it?[y/N]" answer
echo
if [ "$answer" == "y" ];then
rm -rf out_small_data
else
exit
@ccat3z
ccat3z / ToastNotification_Windows10.ps1
Created March 17, 2017 14:29 — forked from altrive/ToastNotification_Windows10.ps1
Windows 10 toast notification sample
$ErrorActionPreference = "Stop"
$notificationTitle = "Notification: " + [DateTime]::Now.ToShortTimeString()
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01)
#Convert to .NET type for XML manipuration
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $null