Skip to content

Instantly share code, notes, and snippets.

@jw-foss
jw-foss / clash.md
Created November 26, 2021 01:32
Installing clash proxy with command line on Linux distros

How to install clash on POSIX system with command line.

Pre-request: You need to know which executable your distro can run without complaining.

  1. Go to https://github.com/Dreamacro/clash/releases to find the latest or the version you desired.
  2. Find the correct distro version, for example, if you are running a distro with arm64 archtecture, you should download the one with armv8 suffix.
  3. Download the executables with curl or wget at your wish.
$ curl -O [url/to/clash]
@sorenlouv
sorenlouv / useComponentId.js
Last active June 16, 2023 15:26
React hook for getting a unique identifier for a component
import { useRef } from 'react';
let uniqueId = 0;
const getUniqueId = () => uniqueId++;
export function useComponentId() {
const idRef = useRef(getUniqueId());
return idRef.current;
}
@Mistobaan
Mistobaan / TENSORFLOW_DEBUG.md
Last active June 29, 2023 06:32
Tensorflow Internals Debugging Techniques

Machine Setup August 2016

Linux Ubuntu 2016.

  • 1080 GTX
  • SDK 8.0
  • CuDNN 5.1

ENABLE Core dumps

ulimit -c unlimited
@qinjian623
qinjian623 / onnx2pytorch.py
Last active November 8, 2023 08:21
ONNX file to Pytorch model
import onnx
import struct
import torch
import torch.nn as nn
import torchvision as tv
import warnings
# enum DataType {
# UNDEFINED = 0;
@raedwulf
raedwulf / ctxswitch.go
Created October 22, 2016 20:43
Context switch benchmark in Go
import (
"fmt"
"time"
"flag"
"strconv"
"runtime"
)
func worker(count int) {
for i := 0; i != count; i++ {
@jakirkham
jakirkham / shm.py
Last active January 20, 2024 15:27
Some Python ctypes-based POSIX shared memory functions
import ctypes
import mmap
import os
import stat
import sys
try:
unicode
except NameError:
@diegopacheco
diegopacheco / latest-protobuf-ubuntu-18-04.md
Created June 7, 2018 20:13
How to Install Latest Protobuf on Ubuntu 18.04
sudo apt-get install autoconf automake libtool curl make g++ unzip -y
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
make
make check
sudo make install
sudo ldconfig
@garcia556
garcia556 / get.c
Created December 3, 2017 21:08
POSIX shared memory IPC example (shm_open, mmap), working on Linux and macOS
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define STORAGE_ID "/SHM_TEST"
#define STORAGE_SIZE 32
int main(int argc, char *argv[])
@Jongbhin
Jongbhin / check_cuda_cudnn.md
Last active February 10, 2024 23:24
[Cuda cudnn version check] #cuda #cudnn #nvidia

To check nvidia driver

modinfo nvidia

To check cuda version

cat /usr/local/cuda/version.txt
@dlqqq
dlqqq / ryzen_bug.md
Last active February 22, 2024 22:22 — forked from wmealing/C-states.md
AMD Ryzen "Freezing" Bug on GNU/Linux Systems

Random "Freezing" with AMD Ryzen CPUs

It seems that numerous GNU/Linux users (including myself) have been having issues with the system randomly "freezing" during light usage. From journalctl output and anecdotal accounts, it is speculated that the AMD Ryzen CPUs do not support other C-states for power management very well (at least on GNU/Linux distributions), and the freezing may be resolved by limiting the C-state of the CPU.

Possible Solution

Limiting the C-state of the CPU can be done through the addition of the following kernel boot parameter.

processor.max_cstate=1