Skip to content

Instantly share code, notes, and snippets.

View ChenchaoZhao's full-sized avatar

Chenchao Zhao ChenchaoZhao

View GitHub Profile
@usamec
usamec / resumable_sampler.py
Created August 25, 2020 10:50
Resumable (and savable) random sampler for Pytorch data loader
import torch
class ResumableRandomSampler(torch.utils.data.Sampler):
r"""Samples elements randomly. If without replacement, then sample from a shuffled dataset.
If with replacement, then user can specify :attr:`num_samples` to draw.
Arguments:
data_source (Dataset): dataset to sample from
replacement (bool): samples are drawn on-demand with replacement if ``True``, default=``False``
num_samples (int): number of samples to draw, default=`len(dataset)`. This argument
is supposed to be specified only when `replacement` is ``True``.
@tuananh
tuananh / configmap.yaml
Last active August 1, 2024 15:46
Pi-hole on Kubernetes
apiVersion: v1
kind: ConfigMap
metadata:
name: pihole-config
data:
WEBPASSWORD: pihole
TZ: 'Asia/Ho_Chi_Minh'
DNS1: 1.1.1.1
DNS2: 1.0.0.1
@eyturner
eyturner / 20k.txt
Created February 20, 2020 18:37
20K English Words
the
of
and
to
a
in
for
is
on
that
@linuxkathirvel
linuxkathirvel / nfs-server-and-client-installation-in-debian.md
Last active July 13, 2021 04:00
NFS Server and Client installation in Debian

NFS Server and Client installation in Debian

Server Side

sudo apt update
sudo apt install nfs-kernel-server nfs-common
sudo mkdir /data/nfs-mount
sudo chown username:groupname /data/nfs-mount
sudo chmod 755 /data/nfs-mount
sudo vim /etc/exports
# Add below line in /etc/exports
@omz
omz / CoreML Image Recognition.py
Created July 8, 2018 10:36
CoreML Image Recognition.py
#!python3
'''
This is a demo of how you can use the CoreML framework (via objc_util) to classify images in Pythonista. It downloads the trained 'MobileNet' CoreML model from the Internet, and uses it to classify images that are either taken with the camera, or picked from the photo library.
'''
import requests
import os
import io
import photos
import dialogs
@martinraison
martinraison / demo.py
Last active October 21, 2018 18:26
sparse pytorch embedding demo
import argparse
from collections import Counter
import csv
import os
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.optim as optim
import torch.utils.data as data
import tarfile
@omz
omz / Barcode Scanner.py
Created February 19, 2016 00:36
Barcode Scanner.py
# coding: utf-8
# Barcode scanner demo for Pythonista
# Based on http://www.infragistics.com/community/blogs/torrey-betts/archive/2013/10/10/scanning-barcodes-with-ios-7-objective-c.aspx
from objc_util import *
from ctypes import c_void_p
import ui
import sound
found_codes = set()
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active September 20, 2024 05:14
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname