Skip to content

Instantly share code, notes, and snippets.

View baongoc124's full-sized avatar

Ngoc baongoc124

View GitHub Profile
@baongoc124
baongoc124 / gist:c94e7b0c123bf25d26be
Last active September 10, 2015 09:35
Keep wifi network connected by pinging gateway regularly and reconnect if needed
#!/bin/bash
SSID=mywifi
uuid=$(nmcli c | grep $SSID | tr -s ' ' | cut -d\ -f3)
while :; do
sleep 1s
ping $(ip r | grep -oP "(?<=default via )[0-9.]*") -c2 -w8 > /dev/null
if [[ $? -ne 0 ]]; then
notify-send "Disconnected"
echo "==> " $(date) " Reconnecting"
nmcli c up uuid ${uuid}
@baongoc124
baongoc124 / chromecomplete.py
Last active April 8, 2017 16:27
web complete script for google chrome/chromium
#!/usr/bin/python2
from __future__ import print_function
# https://github.com/benslk/chrome_remote_shell
# should be installed from git. Using PIP to install will only get older, not working version
import chrome_remote_shell, json
import re
shell = chrome_remote_shell.Shell(host='localhost', port=9222)
shell.connect(0)
@baongoc124
baongoc124 / .emacs
Created October 29, 2016 06:17
Webcomplete implementation for Emacs with Chrome/Chromium on Linux.
(defvar ac-source-chrome-cache nil)
(defvar ac-source-chrome-complete
'((candidates . (ac-chrome-candidate))
(symbol . "w")))
(defun clear-chrome-cache ()
(setq ac-source-chrome-cache nil))
(add-hook 'focus-in-hook 'clear-chrome-cache)