Skip to content

Instantly share code, notes, and snippets.

View gufengxiaoyuehan's full-sized avatar

logan gufengxiaoyuehan

View GitHub Profile
@gufengxiaoyuehan
gufengxiaoyuehan / switch_inteface.py
Created June 27, 2019 07:25
windows system switch interface need run as administrator and change the interace name in line:30-39
import locale
import subprocess
from argparse import ArgumentParser
from collections import namedtuple
Interface = namedtuple("Interface", "admin_status status type name")
p = subprocess.run("netsh interface show interface", stdout=subprocess.PIPE)
interfaces = [Interface(*line.split()) for i, line in enumerate(p.stdout.decode(locale.getpreferredencoding()).replace("\r", "").split("\n"))
if i > 2 and len(line.split()) == 4
@gufengxiaoyuehan
gufengxiaoyuehan / swtichIP.bat
Last active April 27, 2018 04:30
swtich between static ip address and dhcp
@echo off
:: replace <xxx> with your configuration include "<" and ">"
setlocal enableextensions disabledelayedexpansion
set ip=<your staic ip>
set name=<your adapter name>
netsh interface ipv4 show addresses "%name%" | findstr /r /i /c:"ip.*%ip%$" >nul 2>nul
if errorlevel 1 (
echo "current dynamic ip, swtich to %ip%"
@gufengxiaoyuehan
gufengxiaoyuehan / extractdomain.txt
Last active December 24, 2017 05:17
extract domain from url using regex in scala
val pattern = """(?:https?://)?(?:[^\./]*\.)*([^\./]*\.(?:com|cn|com\.cn|net|org|me))(?::\d+)?(?:$|/.*)""".r
val pattern(url) = "some url"
@gufengxiaoyuehan
gufengxiaoyuehan / automobile.ipynb
Created July 11, 2017 15:49 — forked from martinwicke/automobile.ipynb
Estimator demo using Automobile dataset
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.