Blocking all incoming requests except specific IP using iptables
If you are using linux and wants to block all incoming requests to a specific port except a specific IP (your static IP or localhost in my example) , You should first block all incoming requests to this PORT using the following command :
~ iptables -A INPUT -p tcp --dport PORT_NUMBER -j DROP
Then, Allow this specific IP using the following command :
~ iptables -A INPUT -p tcp -s THE_IP_YOU_WANT_TO_ALLOW --dport PORT_NUMBER -j ACCEPT
خواطر عن مواقع الانتخابات المصرية (من الاستفتاء للرئاسية)
كمية المقاومة و الغباء الاداري اللي الناس ديه شافته كفاية يدخلهم الجنة
كل واحد كان عليه Task ممكن يعملها في ساعة، كان بياخد ساعتين علشان يتقنها و يطلعها احسن حاجة.
ناس كتيرة جدا كالعادة قعدت تفتي و يقولوا (الموقع ده بيتعملوه هاكر بسهولة D:) ، (متكتروا السيرفرات شوية، ده بطيق قوي) ، (ده شغل اي حد ممكن يعملو و موقع عادي جدا)، و كلام عبيط كتير من ده. الشغل التقني المعمول في الموقع ده معقد جدا علشان المحافظة على سرية العلومات و سرعة. الموقع عليه حوالي 5 قواعد بيانات كل واحدة حوالي 40 مليون record !
فيه حوالي 40 سيرفر مخصصين للموقع و في زيادة. و يا ريت تاخدوا بالكو ان البنية التحتية في مصر مش جامدة قوي كدة ![]()
اكبر موقع في مصر كان موقع نتيجة الثانوية العامة و كان اخره نصف مليون طالب، المره ديه فيه حوالي 20 مليون مواطن. والله ماكنش فيه حاجة ممكن تتعمل و متعملتش
مفيش اي تزوير او لعب او اي كلام فاضي من اللي بيتقال ده في الموقع. لو فيه خطأ حصل ( و ده كان مرة او مرتين بالكتير ) فده كان خطأ بشري عادي جدا غير مقصود لمصلحة اي حد.
اخيرا و ليس اخرا ( مع اني مش عارف الفرق ) ادعوا لنا
و انتخبوا حد يصلح حال البلد
That’s why I am in love with eSpace
- We have no dress code, Actually I spent most of last summer wearing shorts !
- Flexi-Hours, join whenever you are ready to work !
- Open Management Meeting, a weekly meeting that gather the whole company staring office boy to the CEO to discuss anything regarding the company !!
- Our office boy is rarely to find, he’s really funny when u ask him for a drink and he tells you “la2 kfaya 3alaik kda el naharda” or when you ask him “7atet kam ma3la2et sukar” and he replies with “eshrab we mate2la2sh howa Tamam kda” and at the same time he’s treated typically like any one of us.
- There’s no manager office, it’s the same works space for all of us
- it’s never about how old are you or how much experience do you have, it’s normal when you find the CTO is listening to the most new junior and tell him “I’ll try your way”
- Same for CEO, he listens to everyone in the management meetings and he applies the typical meaning of teamwork, I can barely remember any decision he took that the other people didn’t agree to it.
- OPENNESS, our door is almost open to anyone who is looking for consultation. We have no top secrets
we always publish our technical tips and tricks - TECH-TALK, a weekly talk is presented by different employees about latest technology trends.
- There is no specific people for a specific tasks, it’s normal when you find a junior is trying in critical part in critical project, it’s about trusting your team.
- The fun room and PES community
, the xbox is almost never turned off
! And it’s really funny when you listen to a junior talking to one of the co-founders telling him “e7na mal3ebnash el naharda
“ - Salaries, they pay almost the best salaries in Alexandria, the owners don’t think of their revenues as thinking of keeping the employees satisfied.
- On hard times, you can find many of us are ready to work for more than 14 hours to help other teams.
- LOL, and of course working from home
I though you would guess it after all what I mentioned. - No one is looking for personal credit, we all are looking for eSpace credit
- It was my 1st job and I think my last too.
- Recruitment is not restricted to any specific education degree, gender or religious.
- Our clients are our friends, they even join us in Xbox PES community
Finally, after all this I think you can understand how hard is it to leave such a comfort zone !
Oops, If you don’t know what is eSpace, it’s a technologies company based in Alexandria, Egypt where am working at : http://www.espace.com.eg
Using Scrapy with different / many proxies
Ref. to the previous post (Using Scrapy with proxies), I mentioned how to use a SINGLE proxy with Scrapy.
Now, what if you have different proxies ? here are a simple few changes to make it .
1. Add a new array with your proxies to your config file as follows :
PROXIES = [{'ip_port': 'xx.xx.xx.xx:xxxx', 'user_pass': 'foo:bar'},
{'ip_port': 'PROXY2_IP:PORT_NUMBER', 'user_pass': 'username:password'},
{'ip_port': 'PROXY3_IP:PORT_NUMBER', 'user_pass': ''},]
2. Update your middlewares.py file to the following :
import base64
import random
from settings import PROXIES
class ProxyMiddleware(object):
def process_request(self, request, spider):
proxy = random.choice(PROXIES)
if proxy['user_pass'] is not None:
request.meta['proxy'] = "http://%s" % proxy['ip_port']
encoded_user_pass = base64.encodestring(proxy['user_pass'])
request.headers['Proxy-Authorization'] = 'Basic ' + encoded_user_pass
else:
request.meta['proxy'] = "http://%s" % proxy['ip_port']
That’s it
!
Using Scrapy with proxies
I’m working currently on a scraping some websites for B-kam.com. I used to develop in PHP but when I searched for best scraping / crawling, I found Scrapy (written in Python) is the best.
You can read more about it and how to start here :
http://readthedocs.org/docs/scrapy/en/latest/index.html
I searched a lot for how to use proxies with Scrapy but couldn’t find simple / Straight forward way to do it. All are talking about Middlewares and Request object but not how to use them.
So, here’s the steps to use Scrapy with proxies :
1 – Create a new file called “middlewares.py” and save it in your scrapy project and add the following code to it.
# Importing base64 library because we'll need it ONLY in case if the proxy we are going to use requires authentication
import base64
# Start your middleware class
class ProxyMiddleware(object):
# overwrite process request
def process_request(self, request, spider):
# Set the location of the proxy
request.meta['proxy'] = "http://YOUR_PROXY_IP:PORT"
# Use the following lines if your proxy requires authentication
proxy_user_pass = "USERNAME:PASSWORD"
# setup basic authentication for the proxy
encoded_user_pass = base64.encodestring(proxy_user_pass)
request.headers['Proxy-Authorization'] = 'Basic ' + encoded_user_pass
2 – Open your project’s configuration file (./project_name/settings.py) and add the following code
DOWNLOADER_MIDDLEWARES = {
'scrapy.contrib.downloadermiddleware.httpproxy.HttpProxyMiddleware': 110,
'project_name.middlewares.ProxyMiddleware': 100,
}
Now, your requests should be passed by this proxy. Simple, isn’t it ?
If you want to test it, just create a new spider with the name test, and add the following code
from scrapy.spider import BaseSpider
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.http import Request
class TestSpider(CrawlSpider):
name = "test"
domain_name = "whatismyip.com"
# The following url is subject to change, you can get the last updated one from here :
# http://www.whatismyip.com/faq/automation.asp
start_urls = ["http://automation.whatismyip.com/n09230945.asp"]
def parse(self, response):
open('test.html', 'wb').write(response.body)
Then cat test.html to find the IP.
For cheap / reasonable proxies, try the following websites :
http://proxymesh.com/pricing/
http://squidproxies.com
References :
http://snippets.scrapy.org/snippets/32/
https://groups.google.com/forum/?fromgroups#!msg/scrapy-users/mX9d05qcZw8/RkjWkqBT-HIJ
The Story of the American Businessman and the Mexican Fisherman
An American businessman was standing at the pier of a small coastal Mexican village when a small boat with just one fisherman docked. Inside the small boat were several large yellowfin tuna. The American complimented the Mexican on the quality of his fish.
“How long it took you to catch them?” The American asked.
“Only a little while.” The Mexican replied.
“Why don’t you stay out longer and catch more fish?” The American then asked.
“I have enough to support my family’s immediate needs.” The Mexican said.
“But,” The American then asked, “What do you do with the rest of your time?”
The Mexican fisherman said, “I sleep late, fish a little, play with my children, take a siesta with my wife, Maria, stroll into the village each evening where I sip wine and play guitar with my amigos, I have a full and busy life, senor.”
The American scoffed, “I am a Harvard MBA and could help you. You should spend more time fishing and with the proceeds you buy a bigger boat, and with the proceeds from the bigger boat you could buy several boats, eventually you would have a fleet of fishing boats.”
“Instead of selling your catch to a middleman you would sell directly to the consumers, eventually opening your own can factory. You would control the product, processing and distribution. You would need to leave this small coastal fishing village and move to Mexico City, then LA and eventually NYC where you will run your expanding enterprise.”
The Mexican fisherman asked, “But senor, how long will this all take?”
To which the American replied, “15-20 years.”
“But what then, senor?”
The American laughed and said, “That’s the best part. When the time is right you would announce an IPO (Initial Public Offering) and sell your company stock to the public and become very rich, you would make millions.”
“Millions, senor? Then what?”
The American said slowly, “Then you would retire. Move to a small coastal fishing village where you would sleep late, fish a little, play with your kids, take a siesta with your wife, stroll to the village in the evenings where you could sip wine and play your guitar with your amigos…”
Source : The 4-hour Workweek , STEP IV: L IS FOR LIBERATION, Fables and Fortune Hunters
كام واحد سألته عامل ايه فى شغله و قالك مبسوط ?
فيه ناس تانية بتبقى مضايقة انها شغالة فى حاجة مش بتحبها، مع كامل لحترامى سيبك من اي حد يقولك (حب ما تعمل حتى تعمل ما تحب و شغل اسامه منير ده)، عمرك ما حتبقى شاطر فى حاجة و متفوق فيها اللى لو انت بتحبها، و اوعى تفكر الحاجة اللى انت بتحبها ملهاش شغل او مش حتجبلك فلوس، لأ اتأكد انك اسهل حاجة ممكن تعملها الفلوس (الا طبعا لو عايزة تتجوزى و تقعدى فى البيت، ده موضوع تانى) بس اعمل اللى انتى بتحبه، وساعتها حتشتغل 16 ساعه فى اليوم و انت مبسوط و راضى جدا عن كل دقيقة بتشتغل فيها.
للأسف ان المجتمع اللى اتربينا و اتعلمنا فيه خلى معظمنا يطلع مش عارف اصلا هو بيحب ايه، ساعتها ارجع اقولك (حب ما تعمل)
!! ماهو اصل ملهاش حل تانى !! و بعدين يومك فى الشغل و مودك، دول انت اللى بتتحكم فيهم
!
ابدأ يومك بسماع حاجة انت بتحبها (قرأن – موسيقى – مسرحيات – راديو – اى حاجة انت بترتاحلها) ، خليك مبتسم و سعيد (ايوه زى العبيط، عادى جدا) اهم حاجة انك تبقى مبسوط، محدش ليه عندك حاجة، حاول تستمتع بأى حاجة و كل حاجة فى شغلك، لو لقيت قلم واقع و انت شيلته حطيته على المكتب، فأتأكد انك عملت حاجة جامدة جدا طالما ان فيه حد قبلك شافها و معملهاش و انت احسن منه 100 مرة !!
يعنى، فكر فى نفسك و اللى حواليك و حاول تبقى راضى عن شغلك، علشان بقيت الناس اللى حواليك ملهاش ذنب فى العكننة ديه !
و شكرا لوقتك، و يارب ميكونش راح على الفاضى
وجهة نظر – جواز الصالونات
بس برضوا مش معنى كلامى ان لازم كل الجوازات تبقى ناتجة عن قصص حب وهمية و ال Couple يبقوا زى العصافير ياخواتى
!! لأن دول برضوا فيه منهم كتير جدا بتبقى فاشلة !
بس الموضوع ممكن يبقى اذكى و اشيك من كده. بمعنى، انت جدع او انتى جدعة و عايزين تظبطوا اتنين صحابكوا مع بعض و قصدكم شريف و كتر 1000 خيركوا، مش لازم بقى تقولوا للطرفين انكوا عايزين تظبطوهم !! متخرجوا مع بعض و استعبطوا و كأنكوا قابلتم الاتنين صدفة، و ساعتها حتحسوا بانطباع الطرفين عن بعض، من غير ما تهين او تكأب اى طرف فيهم و تقولوا انه مش عاجب الطرف التانى !!
اخيرا، شوفوا حواليكوا المجتمع بقى عامل ازاى والمتجوزين بقى نسبة كبيرة منهم شكلها يسد النفس !! تشوفهم فى Mall تلاقى لازم بين الاتنين متر و طرف فيهم سابق الطرف التانى، يا اما الاتنين جنب بعض بس ده باصص فى حته و هي بتبص فى حتة تانية و حاجة عجيبة !! اكيد طبعا الدنيا صعبة و مليانة مشاكل بس اعتقد اختيراك للطرف التانى بمزاجك و بطريقة شيك من الاول علشان انت عايزه مش علشان اتعرض عليك و قلت ماشى اهو احسن من غيره حيخلى الدنيا احسن شوية
!
و تعيشوا فى تبات و نبات و تجيبوا صباين و بنات اسمه هو اللى حياخدوه منه و بس
!
شكرا لوقتك و يارب مايكونش ضاع على الفاضى
Preventing Joomla! from sending no-cache in headers
If you are using Joomla! 1.5+ and trying to cache with nginx or other caching server and at same time you don’t want to use Joomla! system cache plugin. You’ll face a big problem, that Joomla! is sending “Cache-Control: no-cache” and “Pragma: no-cache” in response headers.
Here’s the solution :
1. Edit the following file :
Joomla root/libraries/joomla/environment/response.php
2. Search for the following code :
if (self::allowCache() === false) {
self::setHeader('Cache-Control', 'no-cache', false);
// HTTP 1.0
self::setHeader('Pragma', 'no-cache');
}
3. Comment this if condition, to be as follows
/*
if (self::allowCache() === false) {
self::setHeader('Cache-Control', 'no-cache', false);
// HTTP 1.0
self::setHeader('Pragma', 'no-cache');
}
*/
Now, you can disable Joomla! caching, and run whatever caching server, as nginx.
CEO Vs. CEO
Almost 1 year later since my last post, but it’s time to talk
! Let’s start with 1st topic, which ‘s CEO Vs. CEO.
and here’s the story : Continue reading »
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Recent Posts
Recent Comments
- بعمل اللى بحبه on كام واحد سألته عامل ايه فى شغله و قالك مبسوط ?
- Mahmoud M. Abdel-Fattah on Preventing Joomla! from sending no-cache in headers
- Ahmad Alfy on Preventing Joomla! from sending no-cache in headers
- modsaid on CEO Vs. CEO
- modsaid on CEO Vs. CEO





