This file contains hidden or 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
# 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. |
This file contains hidden or 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
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 |
This file contains hidden or 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 | |
# 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', |
This file contains hidden or 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 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) |
This file contains hidden or 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 -*- | |
class Person(object): | |
def __init__(self, firstname, lastname): | |
self.firstname = firstname | |
self.lastname = lastname | |
def name(self): | |
return self.firstname + " " + self.lastname |
This file contains hidden or 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
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 |
This file contains hidden or 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
** 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 |
This file contains hidden or 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 | |
# 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 |
This file contains hidden or 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 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) |
This file contains hidden or 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
# 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])" -` |