This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstdlib> | |
#include <cstring> | |
#include <cassert> | |
#include "sha256.h" | |
typedef struct _block | |
{ | |
unsigned int version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# you should install pypiwin32 first: pip install pypiwin32 | |
import win32com.client | |
import re | |
import os | |
config = {'delimiter':'\n\n', # delimiter between each word | |
'group': 3, | |
'pattern': '([^\t]+)\t([^\n]+)\n?([\s\S]*)', # group 0 =Vocab / group 1 =Chinese Definition / group 2 =English Definition | |
'voice': [1, 0, 1], # the voice, used to each group | |
'volume': 100, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gtts | |
from gtts import gTTS | |
import re | |
import os | |
from pydub import AudioSegment | |
from tqdm import tqdm, trange | |
import tempfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install cuda 10.0 | |
!apt-get update; | |
!wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64 -O cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64.deb | |
!dpkg -i cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64.deb | |
!apt-key add /var/cuda-repo-10-0-local/7fa2af80.pub | |
!apt-get update | |
!apt-get -y install gcc-7 g++-7 | |
!apt-get -y install cuda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = lambda x, j: [j] + f(x/j,j) if x%j==0 else f(x,j+1) if j<x else [] | |
print(*f(int(input()), 2), sep='x') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf #tf2.0 | |
from collections import OrderedDict | |
class MyNamedTuple(OrderedDict): | |
def __iter__(self): # iterate over values to unpack, e.g., arg1, arg2, arg3 = MyNamedTuple(...) | |
for v in self.values(): | |
yield v | |
class MyModule(tf.Module): | |
def __call__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import tensorflow as tf # 2.0 | |
''' | |
input = ... # shape (batch, h*w, 19, 2) | |
indices = ... # shape (h*w) | |
tf.stack([tf.gather(x, y) for x, y in zip(tf.unstack(input, axis=1), tf.unstack(tf.reshape(indices, [-1, 1]), axis=0))], axis=1) | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import time | |
import multiprocessing as mp | |
mnist = tf.keras.datasets.mnist | |
(x_train, y_train),(x_test, y_test) = mnist.load_data() | |
x_train, x_test = x_train / 255.0, x_test / 255.0 | |
model = tf.keras.models.Sequential([ | |
tf.keras.layers.Flatten(input_shape=(28, 28)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
# update package info | |
sudo apt-get update | |
# download kernel | |
KERNEL_VERSION="4.15.1" | |
LINUX_KERNEL=linux-${KERNEL_VERSION} | |
LINUX_KERNEL_TAR=${LINUX_KERNEL}.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://ppt.cc/fgUIKx | |
sudo apt-get install -y git | |
if [ ! -f "dmesg-initcall.pl" ] ; then | |
wget https://raw.githubusercontent.com/tinyclub/tinydraw/master/histogram/examples/linux-boot-graph/dmesg-initcall.pl -O dmesg-initcall.pl | |
fi | |
if [ ! -f "bootgraph.pl" ] ; then |
OlderNewer