Skip to content

Instantly share code, notes, and snippets.

View psachin's full-sized avatar
🚀
Evolving

Sachin psachin

🚀
Evolving
View GitHub Profile
# Shell script to download Oracle JDK from command prompt / terminal.
# You can download all the binaries one-shot by just giving the BASE_URL.
## Features:
# Resumes a broken [previous] download, if any.
# Renames the file to a proper name with platform adding platform info.
# Downloads all the following from Oracle Website with one shell invocation.
# a. Windows 64 and 32 bit;
# b. Linux 64 and 32 bit; and
# c. API Docs.
@psachin
psachin / Makefile
Last active August 29, 2015 14:17 — forked from jvns/Makefile
obj-m += hello-packet.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
@psachin
psachin / Google HN
Created April 2, 2015 09:17
l337 50f7w4r3 3n61n33r
#!/usr/bin/env python
# https://www.google.com/about/careers/search?src=Online/Google+Website/ap2015?utm_source=hacker-news&utm_medium=other&utm_campaign=Online/Social/hacker-news#!t=jo&jid=98895001&
en_dict = {
'a': '4',
'b': 'b',
'c': 'c',
'd': 'd',
'e': '3',
'f': 'f',
@psachin
psachin / python-insert-utf8
Created May 16, 2015 05:27
python-insert-utf8
(defun python-insert-utf8()
"Insert default uft-8 encoding for python"
(interactive)
(newline)
(goto-char (point-min))
(insert "# -*- coding: utf-8 -*-")
(next-line))
(add-hook 'python-mode-hook 'python-insert-utf8)
@psachin
psachin / super_duper.py
Last active May 6, 2016 06:04
Using Super() in python2
# -*- coding: utf-8 -*-
class Person(object):
def __init__(self, firstname, lastname):
self.firstname = firstname
self.lastname = lastname
def name(self):
return self.firstname + " " + self.lastname
@psachin
psachin / reverse_iter.py
Last active November 7, 2015 06:12
reverse iterator
class ReverseIter:
def __init__(self, step):
self.step = step
def next(self):
if self.step == 0:
raise StopIteration
self.step -= 1
return self.step
def __iter__(self):
return self
@psachin
psachin / tcp.py
Last active October 29, 2015 06:54
Django template context processors
** django
- Variable defined in settings.py available to templates(templates
context processor)
Create =context_processors.py= in app directory. Say the
value of variable is =ADMIN_MEDIA_PREFIX=
#+BEGIN_SRC python -n
# app/context_processors.py
@psachin
psachin / py_mail.py
Last active November 7, 2015 06:13
Python Gmail client
#!/usr/bin/env python
# Basic script for GMail.
import os
import smtplib
from email.MIMEText import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from secret import password
@psachin
psachin / screenshot-frame.el
Last active December 12, 2015 08:25
Take screeeshot from Emacs
(defun screenshot-frame ()
"Take screenshot.
Default image ~/screenshots/TIMESTAMP.png
Usage:
M-x screenshot-frame
Enter custom-name or RET to save image with timestamp"
(interactive)
(let* ((insert-default-directory t)
@psachin
psachin / vm-ip.sh
Last active March 21, 2016 11:04
Fetch VM's IP-address
# Fetch VM's IP address
#
# Usage:
# bash vm-ip <DOMAIN>
#
# Example:
# bash vm-ip fedora23
arp -an | grep `virsh dumpxml "${1}" | xmllint --xpath "string((//interface/mac/@address)[1])" -`