This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
pyversion = sys.version | |
pyexecutable = sys.executable | |
print(f"""You are using \n\tPython {pyversion} \nIt is located at \n\t{pyexecutable}""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
""" | |
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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) |