Skip to content

Instantly share code, notes, and snippets.

View huwan's full-sized avatar

Hu Wan huwan

  • City University of Hong Kong
  • 15:41 (UTC +08:00)
View GitHub Profile
@gpchelkin
gpchelkin / dante_setup.sh
Last active August 22, 2023 06:45
How to Setup SOCKS5 Proxy Server for (not only) Telegram using Dante on Ubuntu 16.04 / 18.04 / 20.04
### NOT A SCRIPT, JUST A REFERENCE!
# install dante-server
sudo apt update
sudo apt install dante-server
# or download latest dante-server deb for Ubuntu, works for 16.04 / 18.04 / 20.04:
wget http://archive.ubuntu.com/ubuntu/pool/universe/d/dante/dante-server_1.4.2+dfsg-7build5_amd64.deb
# or older version:
wget http://ppa.launchpad.net/dajhorn/dante/ubuntu/pool/main/d/dante/dante-server_1.4.1-1_amd64.deb
@heartonbit
heartonbit / gist:2575ce02ca730559d2f2c65eb8682231
Created March 20, 2018 02:04
GCC 7 on Ubuntu 14.04 & 16.04
https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91
sudo apt-get update -y && \
sudo apt-get upgrade -y && \
sudo apt-get dist-upgrade -y && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update -y && \
sudo apt-get install gcc-7 g++-7 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7 && \
@yevrah
yevrah / Upgrade vim
Last active September 25, 2023 05:11
Update to Vim8 on Centos 7
################################################################################
# Method 1: Install using rpm packages (credit to DarkMukke)
#
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm
rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7
# WARNING: removing vim-minimal uninstalls `sudo` if you skip the second step
# make sure to at least run `yum install sudo`
yum -y remove vim-minimal vim-common vim-enhanced
@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
@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{}
@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
@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
@marcan
marcan / linux.sh
Last active December 1, 2023 15:18
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 <marcan@marcan.st>
# 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
@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++
@application2000
application2000 / how-to-install-latest-gcc-on-ubuntu-lts.txt
Last active May 23, 2024 07:53
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 && \