Skip to content

Instantly share code, notes, and snippets.

View yiwenlu66's full-sized avatar

Yiwen Lu yiwenlu66

View GitHub Profile
@yiwenlu66
yiwenlu66 / queue_gpu.py
Created August 4, 2017 05:03
A simple script to run a command as soon as a GPU is idle.
import subprocess
import time
import re
import sys
while True:
out = subprocess.check_output('nvidia-smi')
usage = int(re.search(b'\d*MiB /', out).group(0).split(b'M')[0])
if usage < 1000:
subprocess.Popen(sys.argv[1:])
@yiwenlu66
yiwenlu66 / bmarks.py
Last active March 28, 2016 02:53
Convert DJVU outline to PDF metadata
#!/usr/bin/env python3
import sys
import sexpdata
def walk_bmarks(bmarks, level):
output = ''
wroteTitle = False
for j in bmarks:
@yiwenlu66
yiwenlu66 / udpbroadcast.py
Last active December 20, 2022 17:56
udp broadcast with asyncio
import asyncio
import socket
from string import ascii_letters
import random
class BroadcastProtocol:
def __init__(self, loop):
self.loop = loop
@yiwenlu66
yiwenlu66 / ne2x-sign.py
Created August 2, 2015 02:08
NE2X 每日任务脚本
import requests
from bs4 import BeautifulSoup
# Fill in your account here
EMAIL = ""
PASSWD = ""
session = requests.Session()
main_url = "http://ne2x.com/"
main = session.get(main_url)
@yiwenlu66
yiwenlu66 / mczip
Created April 24, 2015 14:08
Multi-charset zip
# From http://www.robberphex.com/2013/05/141
# -*- coding: utf-8 -*-
import os
import sys
import zipfile
from optparse import OptionParser
def listZip(zipf):
print "Archive: %s" %zipf