Skip to content

Instantly share code, notes, and snippets.

@ewenchou
ewenchou / README.md
Last active July 8, 2023 04:36
Run Python script as systemd service
  1. Create a service file like dash_sniffer.service
  2. Put it in /lib/systemd/system/
  3. Reload systemd using command: systemctl daemon-reload
  4. Enable auto start using command: systemctl enable dash_sniffer.service
@ewenchou
ewenchou / dict_diff.py
Last active September 30, 2016 06:33
Check for difference in key/value of one dictionary compared to another
def dict_diff(d1, d2):
"""Checks if all the key/values in d1 are in d2.
Returns True if there is a difference, i.e.
* There is a key in d1 that is not in d2
* There is a key/value in d1 that is different in d2
Otherwise, returns False.
"""
for k, v in d1.iteritems():
@ewenchou
ewenchou / remix_os_on_virtualbox.md
Last active September 20, 2016 22:19
Install RemixOS on VirtualBox

Reference: Reddit

Reference: XDA

  • Create new VM (Linux Ubuntu 64-bit)
  • Configure 4096MB RAM, 20GB disk
  1. Click "Settings">"Storage">"Controller:IDE" and add an optical drive (icon looks like an optical disk with a plus symbol). Choose the OS's ISO. This should appear above any existing optical drives and below the hard drive.
  2. Select the drive you just added and check the "Live CD/DVD" toggle. Then click "OK".
  3. We are now ready to start the machine. When you do, there should be a splash screen - press the tab key before it tries to perform a default installation. If you missed it, just power down the machine (don't save its state or send the shutdown signal, just power it off) and try again. It only gives you about 3s to press tab.
@ewenchou
ewenchou / custom_docker_bridge_subnet.md
Last active September 15, 2016 18:26
Customize docker bridge subnet

Change the Docker Daemon's Startup Options (systemd)

  1. Stop docker daemon: sudo systemctl stop docker

  2. Override the docker daemon startup options via systemd by adding a conf file

     sudo mkdir -p /etc/systemd/system/docker.service.d
     sudo vim /etc/systemd/system/docker.service.d/docker.conf
    
  3. Override the ExecStart command and add the --bip option

@ewenchou
ewenchou / random_quotes.py
Last active January 6, 2023 22:12
Python script to get random quotes from quotedb.com
#!/usr/bin/env python
from requests_futures.sessions import FuturesSession
from pprint import pprint
from HTMLParser import HTMLParser
import re
import json
import sys
class MLStripper(HTMLParser):
@ewenchou
ewenchou / Twitter Bootstrap_multi_select_dropdown.html
Last active December 15, 2015 11:58 — forked from jculverwell/Twitter Bootstrap_multi_select_dropdown.html
Update GIST with nicer checkbox icons using Font Awesome. Added a "X Selected" counter on the dropdown to give feedback to user when dropdown list is hidden. Added "Select All" and "Select None" choices in the dropdown.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="//netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap.js"></script>
<meta charset=utf-8 />
</head>
<body>