Skip to content

Instantly share code, notes, and snippets.

View aphe's full-sized avatar
👋
Oh, Hi there!

Afriyandi Setiawan aphe

👋
Oh, Hi there!
View GitHub Profile
# Installing OpenCV python libs on mac to work with virtualenv
# OpenCV 2.4.3
# Python 2.7.3 installed with brew
# assuming you have virtualenv, pip, and python installed via brew
# assuming $WORKON_HOME is set to something like ~/.virtualenvs
# using homebrew - make sure we're current
brew update
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@aphe
aphe / Multiple Positional Argument Python.py
Last active August 29, 2015 14:11
Multiple Positional Argument Python
import argparse
class DefaultListAction(argparse.Action):
CHOICES = ['file', 'folder']
def __call__(self, parser, namespace, values, option_string=None):
if values:
for value in values:
if value not in self.CHOICES:
message = ("invalid choice: {0!r} (choose from {1})"
.format(value,
@aphe
aphe / Python walk search for *.pdf file on directory and sub.py
Last active August 29, 2015 14:11
Python walk search for *.pdf file on directory and sub
for root, dirnames, filenames in os.walk(some_directory):
for filename in fnmatch.filter(filenames, '*.pdf'):
@aphe
aphe / Remove File extension.py
Created December 10, 2014 06:38
Python Remove file extension
filename = filenye[filenye.rfind("/") + 1:].replace(".pdf", "")
@aphe
aphe / Dump Cpickle.py
Created December 10, 2014 06:46
Dump Cpickle
import cPickle
f = open(some_file, "w")
f.write(cPickle.dumps(binary))
f.close()
@aphe
aphe / ImageMagick with Brew.sh
Created December 10, 2014 06:57
ImageMagick with Brew and Ghostscript support
brew install imagemagick --with-ghostscript
@aphe
aphe / vlc.sh
Created December 10, 2014 07:04
VLC Startup Script
vlc —no-video-title-show —fullscreen —repeat videonya
vlc --mouse-hide-timeout=1 --qt-minimal-view --video-on-top --no-video-title-show --fullscreen --repeat videonya
@aphe
aphe / VBoxStuff.txt
Last active August 29, 2015 14:11
VirtualBox Stuff
##Virtualbox change VDI
VBoxManage internalcommands sethduuid [new vdi]
##Virtualbox change from size changeable to fixed
VBoxManage clonehd vdia.vdi vdib.vdi --variant Fixed
##Virtualbox change size
VBoxManage modifyhd CentOs.vdi --resize 10000000 (on Mega)
@aphe
aphe / lask.py
Created January 7, 2015 09:54
RSSI to distance
__author__ = 'phe'
A = -72
n = 4
'''
RSSI = -(10*n*log10(d) + A)
A is the RSSI value at a reference distance
'''
distance = pow(10.0, ((A + 71)/(10.0*n)))
print distance;