Skip to content

Instantly share code, notes, and snippets.

View lamhoangtung's full-sized avatar
👨‍💻
Working ...

Hoàng Tùng Lâm (Linus) lamhoangtung

👨‍💻
Working ...
View GitHub Profile
// run in console
function ReconnectColab(){
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click();
console.log("Reconnect clicked.");
}
setInterval(ReconnectColab,120000);
@FanchenBao
FanchenBao / my_queue.py
Last active October 24, 2023 04:20
A custom MyQueue class that avoids `NotImplementedError` when calling queue.qsize() method.
from multiprocessing.queues import Queue
import multiprocessing
# The following implementation of custom MyQueue to avoid NotImplementedError
# when calling queue.qsize() in MacOS X comes almost entirely from this github
# discussion: https://github.com/keras-team/autokeras/issues/368
# Necessary modification is made to make the code compatible with Python3.
class SharedCounter(object):
@yashkumaratri
yashkumaratri / Google Colab SSH
Created December 31, 2018 05:19
SSH into google colab
#CODE
#Generate root password
import random, string
password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20))
#Download ngrok
! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
! unzip -qq -n ngrok-stable-linux-amd64.zip
#Setup sshd
@mprostock
mprostock / dataloader_mem_leak_copy-on-access_problem.ipynb
Created December 10, 2018 10:32
"Memory Leak" copy-on-access problem in pytorch dataloaders
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lamhoangtung
lamhoangtung / add_space_to_sentence.py
Created November 23, 2018 14:52
Python program to add space in sentence using a dictionary (eg: "Ilovesanwiches" to"I love sandwiches")
import time
#input_str = input()
input_str = 'Ilikesandwiches'
word_dict = ['I', 'like', 'sandwiches', 'sand', 'and', 'a', 'lot', 'a', 'ability', 'able', 'about', 'above', 'accept', 'according', 'account', 'across', 'act', 'action', 'activity', 'actually', 'add', 'address', 'administration', 'admit', 'adult', 'affect', 'after', 'again', 'against', 'age', 'agency', 'agent', 'ago', 'agree', 'agreement', 'ahead', 'air', 'all', 'allow', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'American', 'among', 'amount', 'analysis', 'and', 'animal', 'another', 'answer', 'any', 'anyone', 'anything', 'appear', 'apply', 'approach', 'area', 'argue', 'arm', 'around', 'arrive', 'art', 'article', 'artist', 'as', 'ask', 'assume', 'at', 'attack', 'attention', 'attorney', 'audience', 'author', 'authority', 'available', 'avoid', 'away', 'baby', 'back', 'bad', 'bag', 'ball', 'bank', 'bar', 'base', 'be', 'beat', 'beautiful', 'because', 'become', 'bed', 'before', 'begin', 'behavior', 'behind', 'believe', 'benefi
'#&()+-,.:;/ 0123456789AÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬBCDĐEÊẾỀỂỄỆFGHIÍÌỈĨỊJKLMNOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢPQRSTUÚÙỦŨỤƯỨỪỬỮỰVWXYÝỲỶỸỴZaáàảãạăắằẳẵặâấầẩẫậbcdđeéèẻẽẹêếềểễệfghiíìỉĩịjklmnoóòỏõọôốồổỗộơớờởỡợpqrstuúùủũụưứừửữựvwxyýỳỷỹỵz'́
@rudolfratusinski
rudolfratusinski / parallels_tools_ubuntu_new_kernel_fix.md
Last active November 23, 2022 20:01
Parallels Tools fix for Ubuntu 18.04 and other Linux distributions with Kernel version >= 4.15

Preparation

  • In open Ubuntu 18.04 machine click Parallels Actions -> "Install Parallels Tools"

  • A "Parallels Tools" CD will popup on your Ubuntu desktop.

  • Open it by double mouse click, copy all the content to a new, empty directory on a desktop, name it for e.g. "parallels_fixed"

  • Open terminal, change directory to parallels_fixed (cd ~/Desktop/parallels_fixed)

  • Make command line installer executable (chmod +x install)

  • Change directory to "installer" (cd installer)

  • Make few other scripts executable: chmod +x installer.* *.sh prl_*

@andyrbell
andyrbell / scanner.sh
Last active June 16, 2024 12:48
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@victor-shepardson
victor-shepardson / pytorch-glumpy.py
Last active March 25, 2024 19:47
using pycuda and glumpy to draw pytorch GPU tensors to the screen without copying to host memory
from contextlib import contextmanager
import numpy as np
import torch
from torch import Tensor, ByteTensor
import torch.nn.functional as F
from torch.autograd import Variable
import pycuda.driver
from pycuda.gl import graphics_map_flags
from glumpy import app, gloo, gl
@kylehounslow
kylehounslow / client.py
Last active April 23, 2024 10:58
Send and receive images using Flask, Numpy and OpenCV
from __future__ import print_function
import requests
import json
import cv2
addr = 'http://localhost:5000'
test_url = addr + '/api/test'
# prepare headers for http request
content_type = 'image/jpeg'