Skip to content

Instantly share code, notes, and snippets.

View smbanaie's full-sized avatar

S.Mojtaba Banaie smbanaie

View GitHub Profile
@smbanaie
smbanaie / twitter-step-2-Remove-Special_Chars.py
Created March 19, 2018 14:36
twitter-step-2-Remove-Special_Chars
counter = 0
for dirpath, dirs, files in os.walk('tweets'):
for filename in fnmatch.filter(files, '*.txt'):
with codecs.open(os.path.join(dirpath, filename),'r',encoding="utf-8")as f:
for tweet in f:
try :
tweet_id = tweet.split("\t")[0]
tweet = tweet.split("\t")[1]
counter += 1
# حذف منشن یا ااسمی افراد
@smbanaie
smbanaie / twitter-step-1-Get-Tweets.py
Last active March 19, 2018 14:17
twitter-step-1-Get-Tweets
class TweetListener(StreamListener):
counter = 0
def on_data(self, data):
try:
self.counter +=1
json_data = json.loads(data)
Tweet_File_Name = 'tweets/'+datetime.now().strftime("%Y-%m-%d")+".txt"
with codecs.open(Tweet_File_Name, 'a',encoding="utf-8") as f:
if 'extended_tweet' in json_data:
if 'full_text' in json_data['extended_tweet']:
@smbanaie
smbanaie / Tweepy-Step-0.py
Last active March 19, 2018 14:13
Tweepy-Step-0
# -*- coding: utf-8 -*-import twitter_config
from tweepy import OAuthHandler,Stream
from tweepy.streaming import StreamListener
import json, twitter_config
consumer_key = twitter_config.consumer_key
consumer_secret = twitter_config.consumer_secret
access_token = twitter_config.access_token
access_secret = twitter_config.access_secret
@smbanaie
smbanaie / tornado-nginx-example.conf
Created October 17, 2016 20:16 — forked from didip/tornado-nginx-example.conf
Nginx config example for Tornado
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
x=2;
y=3.5 ;
z=4
if x<y and z<=y :
print("not run")
elif x<y and z>y :
print(" Ok")
else:
print("not run this command")
@smbanaie
smbanaie / tornado_error_handler
Created November 9, 2014 19:05
tornado error handler
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os.path
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from pycket.session import SessionManager
@smbanaie
smbanaie / GlobalVars
Created September 7, 2014 20:41
Share Global Vars
__author__ = 'Amir H. Nejati'
class SCAbstract(type):
################## Shared Connections ##################
__RepublishanDB = None
__BackendDB = None
__ElasticSearchConnection = None
__redisInstance = None
__redisInstanceRead = None
@smbanaie
smbanaie / Tornado_Upload_Sample
Created September 3, 2014 21:31
Tornado Upload Sample
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/", IndexHandler),
(r"/upload", UploadHandler)
]
tornado.web.Application.__init__(self, handlers)
class IndexHandler(tornado.web.RequestHandler):
def get(self):
@smbanaie
smbanaie / Mail Serrver Setup in ubuntu
Last active August 29, 2015 14:05
Zoho Mail Serrver Setup in ubuntu
#install and configure BIND9 DNS Server
#edit sudo nano /etc/bind/zones/foodlist.ir.db
# Add
@ IN MX 10 mx.zohomail.com.
@ IN MX 20 mx2.zohomail.com.
# sudo service bind9 restart
@smbanaie
smbanaie / RabbitMQ Commands
Created August 24, 2014 19:17
RabbitMQ Commands
#Reset All things
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
#List Queues
rabbitmqctl list_queues name messages messages_ready messages_unacknowledged