Skip to content

Instantly share code, notes, and snippets.

View satishgoda's full-sized avatar

Satish Goda satishgoda

View GitHub Profile
import sys
pyversion = sys.version
pyexecutable = sys.executable
print(f"""You are using \n\tPython {pyversion} \nIt is located at \n\t{pyexecutable}""")
@satishgoda
satishgoda / crontab
Created February 10, 2017 17:21 — forked from mahmoud/crontab
A supervisord + jupyter notebook setup on a remote server, without root access.
# restart supervisor (and the notebook) every minute in case the machine has been restarted
*/1 * * * * /x/home/notebook_training/start_supervisord.sh >> /x/home/notebook_training/nbserver_start_log.txt
# separate user does something like:
# */1 * * * * /x/home/mhashemi/notebook_repo_update.sh >> /x/home/mhashemi/notebook_cron_log.txt 2>&1
from rx import Observable, Observer
from collections import defaultdict
users = [
{ "id" : 0, "name" : "Hero" },
{ "id" : 1, "name" : "Dunn" },
{ "id" : 2, "name" : "Sue" },
{ "id" : 3, "name" : "Chi" },
{ "id" : 4, "name" : "Thor" },
{ "id" : 5, "name" : "Clive" },
@satishgoda
satishgoda / outline-mode-folding-python-elisp-shell.el
Created January 22, 2017 02:49 — forked from alphapapa/outline-mode-folding-python-elisp-shell.el
Emacs: outline-mode folding for Python, elisp, and shell
(defun my/python-mode-outline-hook ()
(setq outline-level 'my/python-outline-level)
(setq outline-regexp
(rx (or
;; Commented outline heading
(group
(* space) ; 0 or more spaces
(one-or-more (syntax comment-start))
(one-or-more space)
@satishgoda
satishgoda / python-monkey-patch-built-ins.py
Created October 9, 2016 09:13 — forked from mahmoudimus/python-monkey-patch-built-ins.py
pythonic monkey patching built-in types
# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import DictProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
@satishgoda
satishgoda / newinstance.py
Created September 23, 2014 16:04
__call__, __new__ and __init__ in Python
"""
"""
"""
In this interactive tutorial we are going to take a look at the process of the
creation of an instance object by calling an user-defined class.
"""
"""
We will be running the sample program via the ipython interpreter and in a
@satishgoda
satishgoda / example1.py
Created September 18, 2014 13:45
operator.methodcaller
import operator
last = operator.itemgetter(-1)
l1 = []
l2 = [1,2,3]
l3 = [-100, 10, 400]
def gaurdedLast(l):
return (last(l) if l else None)
#!/bin/sh
VALUE_ICON=`cygpath -d "$HOME/pict/terminal.png"`
VALUE_TITLE="terminal"
VALUE_MESSAGE="Ha!!"
while getopts hi:t:m: OPT
do
case $OPT in
@satishgoda
satishgoda / py_dict_fail.py
Last active August 29, 2015 13:56
python dict fail
def foo():
l = []
return l[:]
#attr_map = dict.fromkeys(prefixes_unique, foo())
attr_map = dict.fromkeys(prefixes_unique, [])
for key in attr_map:
print(key, id(attr_map[key]))
# -*- coding: utf-8 -*-
def foo(a, b="B", c=[], *args, **kwargs):
print(a, b, c)
if not args:
print("No *args passed")
else:
print(args)