Skip to content

Instantly share code, notes, and snippets.

View smbanaie's full-sized avatar

S.Mojtaba Banaie smbanaie

View GitHub Profile
PUT republishan/forum/459890
{
"name_sender": "asd asd",
"description": "یبریبر",
"tags": [
"ربیربیر"
],
"date": "1393-02-30",
"follow": [],
"photo_sender": "profile.jpg",
@smbanaie
smbanaie / Petrel Installation Checklist
Last active August 29, 2015 14:01
Setup Storm And Petrel
1. Download Storm
######
2. Set Storm in PATH variable using this code in ~/.profile
export PATH=$PATH:/path/to/storm/bin
#logout an login again and check storm version
3. check Java version (> = 1.7 and JDK Installed) and Python (>=2.7)
4.check VirtualEnv in python
chmod u+x runnable file # user + Execute
chmod o+x runnable file # other + Execute
tar -xvf file.tar
# Show right version of java
file /etc/alternatives/java /etc/alternatives/javac
@smbanaie
smbanaie / Singelton.py
Last active August 29, 2015 14:02
Python Global Variable - Singelton Pattern
class Mojtaba:
SharedVariable = {}
def __init__(self):
self.MyDict = self.SharedVariable
if __name__=='__main__':
a = Mojtaba()
{
"from" : 0, "size" : 20,
"sort" : [ { "RE" : {"order" : "desc"}}],
"query": {
"filtered": {
"query" : {
"query_string" : {
@smbanaie
smbanaie / LinuxUsefullResources
Last active August 29, 2015 14:02
Some Usefull Linux Resources - DNS Settings
1.Setup a dns server in ubuntu : http://www.servermom.org/how-to-install-and-setup-bind9-on-ubuntu-server/136/
@smbanaie
smbanaie / GPlus- Facebook _ Linkedin Sign
Created June 7, 2014 11:31
GPlus- Facebook _ Linkedin Sign in Process
1. in Google Developer Console , https://console.developers.google.com/ , create project -> create new Client ID in Credential Link at left sidebar
2.
@smbanaie
smbanaie / Git Essential Command
Created June 8, 2014 13:03
Git Essential Command
git reset --hard <old-commit-id>
git push -f
@smbanaie
smbanaie / PythonTips
Last active August 29, 2015 14:03
Some Python Code Imrovement TIPS
TIP #1 : Check Membership Efficiently
lyrics_list = ['her', 'name', 'is', 'rio']
# Avoid this
words = make_wordlist() # Pretend this returns many words that we want to test
for word in words:
if word in lyrics_list: # Linear time
print word, "is in the lyrics"
@smbanaie
smbanaie / Python Useful Code Snippet
Last active August 29, 2015 14:04
Python Useful Code Snippet
##Add File Logger
import logging
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('/var/tmp/myapp.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.WARNING)
We can use this logger object now to write entries to the log file: