Skip to content

Instantly share code, notes, and snippets.

View pcdinh's full-sized avatar

Pham Cong Dinh pcdinh

View GitHub Profile
@pcdinh
pcdinh / ttf-vista-fonts-installer.sh
Created December 30, 2019 09:32 — forked from maxwelleite/ttf-vista-fonts-installer.sh
Script to install Microsoft Vista TrueType Fonts (TTF) aka Microsoft’s ClearType fonts on Ubuntu distros
#!/bin/bash
# Author: Maxwel Leite
# Website: http://needforbits.wordpress.com/
# Description: Script to install Microsoft Vista TrueType Fonts (TTF) aka Microsoft’s ClearType fonts on Ubuntu distros
# Microsoft added a group of new "ClearType Fonts" to Windows with Windows Vista and Office 2007.
# These fonts are named Constantia, Corbel, Calibri, Cambria (and Cambria Math), Candara, and Consolas.
# Calibri became the default font on Microsoft Word 2007, and it’s still the default font on Word 2016 today.
# Dependencies: wget, fontforge and cabextract
# Note: Microsoft no longer provides the PowerPoint Viewer 2007 (v12.0.4518.1014) or any version anymore for download
# Tested: Ubuntu Saucy/Trusty/Xenial/Bionic
@pcdinh
pcdinh / python-ml-notebook-windows
Created September 10, 2019 10:05
Install Jupyter and required libs and datasets
1. Download 3.7
https://www.python.org/ftp/python/3.7.0/python-3.7.0-amd64.exe
Assuming that you will install Python 3.7 into C:/Python37 and allow Python installer to add python.exe into Windows's PATH environment variable.
2. Upgrade Python's pip
python -m pip install --upgrade pip
@pcdinh
pcdinh / uploader.py
Created September 9, 2012 18:44 — forked from JordanReiter/uploader.py
Python snippet for uploading file to another server
import errno
import os
import paramiko
class Uploader(object):
def __init__(self, host, basepath='', username=None, password=None, keyfile=None, *args, **kwargs):
self.host = host
self.basepath = basepath
self.username = username
@pcdinh
pcdinh / decorators.py
Created April 29, 2012 18:05
Flask login_required decorator
from flask import request, g
from functools import wraps
def login_required(f=None, url="public.login", next=None):
"""
Check if user is logged or redirect to a certain page.
By default go to public login.
"""
def outer_decorator(decorated_fn):
@pcdinh
pcdinh / NioScalabilityTest.java
Created January 7, 2012 15:59 — forked from jbrisbin/NioScalabilityTest.java
Pure Java NIO scalability test
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
./amdgpu-pro-install --opencl=legacy,pal
sudo apt list --installed | grep icd
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
ocl-icd-libopencl1/bionic,now 2.2.11-1ubuntu1 amd64 [installed,automatic]
opencl-amdgpu-pro-icd/unknown,now 18.50-708488 amd64 [installed]
opencl-orca-amdgpu-pro-icd/unknown,now 18.50-708488 amd64 [installed]
@pcdinh
pcdinh / beam0
Last active January 1, 2019 00:49
sudo apt install -y gcc make perl git
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update -y
sudo apt install -y g++-7 libboost-all-dev libssl-dev -y
sudo apt -y autoremove
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --config gcc
sudo wget "https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.sh"
sudo sh cmake-3.12.0-Linux-x86_64.sh --skip-license --prefix=/usr
apt-get --no-install-recommends --yes install clang libclang-dev llvm-dev libncurses5 libncursesw5 cmake git
ubuntu-drivers devices
sudo apt-get purge nvidia*
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-390
lsmod | grep nvidia
nvidia-smi
sudo apt install nvidia-cuda-toolkit
https://blog.aeternity.com/q-a-at-reddit-with-john-tromp-inventor-of-the-cuckoo-cycle-mining-algorithm-c316119c07e9
Trong Cuckoo Cycle, chứng cứ xử lý có dạng một chu trình 42 cạnh (khép kín) nằm trong 1 đồ thị lớn ngẫu nhiên hình thành trên một vài con số dùng một lần (nonce) nào đó. Thử tưởng tượng 2 quốc gia, mỗi quốc gia có 1 tỉ thành phố, và thử tưởng tượng chọn 1 tỉ con đường chạy cắt qua biên giới kết nối 1 thành phố ngẫu nhiên ở một quốc gia này với 1 thành phố ngẫu nhiên của một quốc gia khác (PoW này thật ra là dùng một hàm băm không dùng nhiều tài nguyên để ánh xạ 1 con số dùng một lần, số của con đường, và quốc gia đến một thành phố). Câu hỏi ở đây là liệu có tồn tại 1 chu trình gồm 42 con đường kết nối 42 thành phố khác nhau hay không. Nếu một ai đó trao cho bạn một con số dùng một lần và con số của 42 con đường thì bạn sẽ thấy là cực kì dễ kiểm chứng (verify) trong thời gian và bộ nhớ rất nhỏ. Nhưng để tìm ra được 1 chu trình như vậy thì lại không hề là một bài toán dễ giải. Tuy nhiên lưu ý ở đ