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
#/usr/bin/env python | |
# ex1.py | |
@g | |
def f(): | |
print("xyz") | |
# is equivalent to | |
def f(): |
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
#!/usr/bin/env python | |
import wx | |
class demo(wx.Frame): | |
def __init__(self, parent,id): | |
wx.Frame.__init__(self,parent,id,'Frame title here', size=(300,200)) | |
if __name__=='__main__': | |
app=wx.PySimpleApp() |
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 surround(tag) | |
"Surround content within html TAG. | |
TAG can be <>," ",' ',[ ], etc." | |
(interactive "sWord should be inside: ") | |
(backward-word) | |
(mark-word) | |
(when (region-active-p) | |
(kill-region (region-beginning) (region-end))) | |
(insert tag) | |
(backward-char) |
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
;; get IP-address of host or remote | |
;; Ref: EMACS-FU ==> Programming. by: Eric Ludlam | |
(defun get-ip-address (&optional dev) | |
"Get the IP-address for device DEV (default: eth0)" | |
(interactive) | |
(let ((dev (if dev dev "eth0"))) | |
(substring ;; chop the final "\n" | |
(shell-command-to-string | |
(concat | |
"ifconfig " dev |
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
function mcd() | |
{ | |
# Make and change directory. | |
# Optionally initialize it as a GIT repo. | |
# Copy this function to ~/.bashrc or /etc/profile | |
if [ "$#" -eq 1 ] | |
then | |
echo "Do you want to initialize this as a git repo? " | |
select ynq in "Yes" "No" "Quit"; do | |
case $ynq 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
"<p>[' '-z\"!]+</p>" | |
"<address>[\n.[' '-z<>\"!]+</address>$" |
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 index(request): | |
context=RequestContext(request) | |
# data=[] | |
categories=Category.objects.all() | |
for category in categories: | |
print "%s: %d percent" % (category, category.percent) | |
context_dict = { | |
'categories': categories, |
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 yh/orgtbl-to-rst-paddings (table) | |
(let* ((pruned-table (remove 'hline table)) | |
(size-table (mapcar (lambda (row) | |
(mapcar #'length row)) | |
pruned-table))) | |
(apply #'mapcar* #'max size-table))) | |
(defun yh/orgtbl-padded-hline (paddings &optional chr) | |
(let ((chr (or chr ?-))) | |
(concat (format "+%c" chr) |
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
(if (file-exists-p "/usr/bin/soffice") | |
(setq org-export-odt-convert-processes | |
"/usr/bin/soffice --headless --convert-to %f%x --outdir %d %i" | |
org-export-odt-preferred-output-format "odt" | |
org-export-odt-convert-process "/usr/bin/soffice") | |
(message "SOFFICE path not found")) |
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
#!/usr/bin/env python | |
import numpy as np | |
# Know the delimiter used(Useful to differentiate between a space and tab). | |
# f = open('test.txt') | |
# lines = f.readlines() | |
# print lines | |
# Uncomment below line to import data from a file. |
OlderNewer