Skip to content

Instantly share code, notes, and snippets.

import tkinter as tk
class SimpleTableInput(tk.Frame):
def __init__(self, parent, rows, columns):
tk.Frame.__init__(self, parent)
self._entry = {}
self.rows = rows
self.columns = columns
@cryptogun
cryptogun / MVC.py
Created October 22, 2017 07:28
MVC example in Python
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
class Observable:
def __init__(self, initialValue=None):
self.data = initialValue
self.callbacks = {}
import matplotlib
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg
from numpy import arange, sin, pi
import tkinter as tk
matplotlib.use('TkAgg')
# auto mount network folder:
192.168.1.x:/home/i/Desktop /home/i/Desktop/xxx nfs rw,auto,sync,rsize=8192,wsize=8192,timeo=14,intr 0 0
@cryptogun
cryptogun / localhosting
Last active September 7, 2017 19:48
Serve a folder for phone access.
python3 -m http.server
# or
python2 -m SimpleHTTPServer
# If not working, check your firewall and restart server.
@cryptogun
cryptogun / android_auto_brightness.sh
Created September 7, 2017 09:59
Script for adjusting android brightness. Run in Tasker. Current brightness function is not perfect.
#!/bin/bash
# phone symmmetric brightness function: y=200*sin(0.2361*x-1.31)+0
# run as root. executed by tasker.
A=200
w=0.2361
t="-1.31"
c="0"
now=`date | awk -F ' ' '{print $4}'`
hour=`echo $now | awk -F ':' '{print $1}'`
@cryptogun
cryptogun / nginx.conf
Created September 7, 2017 06:11
mutiple port hosting via nginx
upstream server2{
server 127.0.0.1:9000;
}
server {
listen 80;
server_name 119.xx.xx.xx;
client_max_body_size 4G;
@cryptogun
cryptogun / kill_nemo.sh
Created July 29, 2017 18:54
nemo 100% CPU bug long time no fix. Kill it.
#!/bin/bash
# */3 * * * * xxx bash /path/to/kill_nemo.sh
cpu=`top -b -n 1 | grep " nemo" | head -n 1 | awk -F ' ' '{print $9}'`
memory=`top -b -n 1 | grep " nemo" | head -n 1 | awk -F ' ' '{print $10}'`
pid=`top -b -n 1 | grep " nemo" | head -n 1 | awk -F ' ' '{print $1}'`
if [[ "none"$cpu == "none" || "none"$memory == "none" || "none"$pid == "none" ]]; then
exit 0
fi
#!/bin/bash
REMOTE="xxx@192.168.1.2:/home/xxx/Desktop"
MOUNTPOINT=$( mount | grep -E "^${REMOTE}/? " | awk '{print $3}' )
if [ -z "$MOUNTPOINT" ] ; then
sudo sshfs -o allow_other,default_permissions xxx@192.168.1.2:/home/xxx/Desktop /home/xxx/Desktop/latitudeDT
else
echo "LATI ALREADY DONE."
fi
@cryptogun
cryptogun / dell_auto_brightness.sh
Last active July 29, 2017 18:45
1. make sure ddccontrol works for you. 2. find out time-brightness sine function. 3. find out the correct dev and address. #phone sine brightness: y=53*sin(0.2361*x-1.31)+0
#!/bin/bash
# */10 * * * * root path/to/auto_brightness.sh
A=80
omega=0.3
t="-2.5"
c="0" #5
now=`date | awk -F ' ' '{print $4}'`
hour=`echo $now | awk -F ':' '{print $1}'`
minute=`echo $now | awk -F ':' '{print $2}'`