Skip to content

Instantly share code, notes, and snippets.

View huwan's full-sized avatar

Hu Wan huwan

  • City University of Hong Kong
  • 19:13 (UTC +08:00)
View GitHub Profile
@jtilly
jtilly / install.sh
Last active May 23, 2024 10:36
Install qcachegrind on Ubuntu
#!/bin/bash
sudo apt-get install qt5-default
wget http://kcachegrind.sourceforge.net/kcachegrind-0.7.4.tar.gz
tar xvf kcachegrind-0.7.4.tar.gz
cd kcachegrind-0.7.4
qmake && make
sudo install -m 755 qcachegrind/qcachegrind /usr/local/bin
sudo install -m 644 qcachegrind/qcachegrind.desktop \
/usr/local/share/applications/
@Overdrivr
Overdrivr / cffi-python-struct.py
Last active August 8, 2023 22:58
Pass and return structs (by copy) between C and Python using CFFI
from cffi import FFI
ffi = FFI()
ffi.cdef("""
typedef struct T T;
struct T
{
int a;
float b;
};
@spaghetti-
spaghetti- / fanctl.sh
Last active March 26, 2022 04:32
How to control nvidia fan speeds via command line (works with the latest drivers on the latest gen gpus (titanx)) and how to set it on boot
#/bin/sh
/opt/bin/nvidia-settings -a [gpu:0]/GPUFanControlState=1
/opt/bin/nvidia-settings -a [gpu:1]/GPUFanControlState=1
/opt/bin/nvidia-settings -a [gpu:2]/GPUFanControlState=1
/opt/bin/nvidia-settings -a [gpu:3]/GPUFanControlState=1
/opt/bin/nvidia-settings -a [fan:0]/GPUTargetFanSpeed=100
/opt/bin/nvidia-settings -a [fan:1]/GPUTargetFanSpeed=100
/opt/bin/nvidia-settings -a [fan:2]/GPUTargetFanSpeed=100
/opt/bin/nvidia-settings -a [fan:3]/GPUTargetFanSpeed=100
@application2000
application2000 / how-to-install-latest-gcc-on-ubuntu-lts.txt
Last active January 13, 2025 03:52
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@ArseniyShestakov
ArseniyShestakov / add.sh
Last active August 25, 2023 14:14
My compiler alternatives
# Cleanup old alternatives
update-alternatives --remove-all cc
update-alternatives --remove-all c++
update-alternatives --remove-all gcc
update-alternatives --remove-all g++
update-alternatives --remove-all clang
update-alternatives --remove-all clang++
update-alternatives --remove-all icc
update-alternatives --remove-all icc++
@marcan
marcan / linux.sh
Last active July 21, 2024 14:00
Linux kernel initialization, translated to bash
#!/boot/bzImage
# Linux kernel userspace initialization code, translated to bash
# (Minus floppy disk handling, because seriously, it's 2017.)
# Not 100% accurate, but gives you a good idea of how kernel init works
# GPLv2, Copyright 2017 Hector Martin <[email protected]>
# Based on Linux 4.10-rc2.
# Note: pretend chroot is a builtin and affects the current process
# Note: kernel actually uses major/minor device numbers instead of device name
@wojtuss
wojtuss / device_dax_setup_commands.txt
Created May 23, 2017 10:41
device dax setup commands
Assuming your linux kernel supports Device DAX properly, the following describes a full procedure of how to set up 2 Device DAXes of 1G and 2G sizes on a machine with 32G RAM.
1. Configure grub.
Add the following line to /etc/default/grub:
GRUB_CMDLINE_LINUX="memmap=1G!31G memmap=2G!29G"
(meaning: take 1G after 31G of your RAM and 2G after 29G of RAM, which makes the last 3G of your RAM devoted to Device DAXex)
2. Update grub.
$ sudo update-grub2
@GavinXing
GavinXing / mini-word2vec-pytorch.py
Created August 6, 2017 01:44
A complete word2vec based on pytorch tutorial
# encoding=utf-8
# Project: learn-pytorch
# Author: xingjunjie github: @gavinxing
# Create Time: 29/07/2017 11:58 AM on PyCharm
# Basic template from http://pytorch.org/tutorials/beginner/nlp/word_embeddings_tutorial.html
import torch
import torch.nn as nn
import torch.autograd as autograd
import torch.optim as optim
@TestItOnlyOnce
TestItOnlyOnce / pdftitle.py
Last active March 23, 2022 03:30 — forked from hanjianwei/pdftitle.py
Rename pdf files to their content's titles (for Python 3; with wildcard support; default rename all pdfs)
#!/usr/bin/env python
"""
Extracts title from PDF files (Python 3).
Depends on: pdf, pyPDF2, PDFMiner3k, unidecode.
Usage:
pdftitle -d tmp --rename *.pdf{}
@adujardin
adujardin / bitbucket-pipelines.yml
Created September 8, 2017 16:55
Bitbucket pipeline file for latex document (including bibtex and upload to dropbox)
# SETTING UP :
# Generate an application token for your dropbox account and set it as environment variable named "DROPBOX_TOKEN"
# - https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/
# - https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html
# Edit TEX_FILE (see below) according to the main tex file name
image: fermiumlabs/latex-docker:latest
pipelines:
custom: # Manually only