Skip to content

Instantly share code, notes, and snippets.

View psachin's full-sized avatar
🚀
Evolving

Sachin psachin

🚀
Evolving
View GitHub Profile
#/usr/bin/env python
# ex1.py
@g
def f():
print("xyz")
# is equivalent to
def f():
#!/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()
@psachin
psachin / surround.el
Last active August 29, 2015 14:01
Wrap word or region inside user specified input. like <>," ",' ',[ ], etc.
(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)
@psachin
psachin / get-ip-add.el
Created May 22, 2014 04:46
Get IP-address of device.
;; 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
@psachin
psachin / mcd.sh
Last active August 29, 2015 14:01
Make and change directory.
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
@psachin
psachin / select-tag-content.el
Created May 28, 2014 17:07
Select content inside html tag
"<p>[' '-z\"!]+</p>"
"<address>[\n.[' '-z<>\"!]+</address>$"
@psachin
psachin / views.py
Created June 17, 2014 07:10
Kavleen
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,
(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)
@psachin
psachin / org-to-odt.el
Created August 5, 2014 11:28
Convert org file to ODT(Libre Ofiice)
(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"))
@psachin
psachin / normalize.py
Last active August 29, 2015 14:05
Import data as a Matrix and normalize its values by finding the mean of each column
#!/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.