Skip to content

Instantly share code, notes, and snippets.

Avatar

Satish Goda satishgoda

View GitHub Profile
@satishgoda
satishgoda / outline-mode-folding-python-elisp-shell.el
Created Jan 22, 2017 — forked from alphapapa/outline-mode-folding-python-elisp-shell.el
Emacs: outline-mode folding for Python, elisp, and shell
View outline-mode-folding-python-elisp-shell.el
(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)
View python-monkey-patch-built-ins.py
# 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 Sep 23, 2014
__call__, __new__ and __init__ in Python
View newinstance.py
"""
"""
"""
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 Sep 18, 2014
operator.methodcaller
View example1.py
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)
View notify-send.sh
#!/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 Aug 29, 2015
python dict fail
View py_dict_fail.py
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]))
View python_callables_function.py
# -*- 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)
@satishgoda
satishgoda / 0_blender.crash.files
Last active Jan 3, 2016
Crash Report for # Blender 2.69 (sub 8), Commit date: 2014-01-12 19:10, Hash c925b5b
View 0_blender.crash.files
When blender crashes
View prncmdlineargsusingiterators.cpp
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <cstdlib>
int main(int argc, char* argv[])
{
using namespace std;
@satishgoda
satishgoda / enum_class_1.cpp
Last active Jan 1, 2016
Enumeration Classes
View enum_class_1.cpp
#include <iostream>
#include <string>
using namespace std;
enum class TrafficLight { green, yellow, red };
TrafficLight& operator++(TrafficLight& light) {
switch (light) {
case TrafficLight::green:
return light = TrafficLight::yellow;