baazzilhassan-blog
baazzilhassan-blog
Lhassan Baazzi
18 posts
Freelance Web Developer PHP / Python & Scrapy Expert & Email List verification
Don't wanna be here? Send us removal request.
baazzilhassan-blog · 9 years ago
Text
Symfony: Get the default target URL from session
When you implement a LoginSuccessHandler in your Application and you want to redirect a user to some endpoints when some conditions are meet, you also want to redirect the user to a default target set by Symfony before login in the session.
So, if you want to get the default target from session this is the right way:
0 notes
baazzilhassan-blog · 10 years ago
Text
Google SERP Preview Emulator
Tumblr media
If you are looking for a tool or a service to see how your pages are presented in Google search results, you can try this useful tool, it take a URL as input and show you a Google snippet preview, please follow this link: https://websiteadvantage.com.au/Google-SERP-Emulator
0 notes
baazzilhassan-blog · 10 years ago
Text
Free Invoice online Generator
I’m sharing with you some of free invoice online generator:
https://www.shopify.com/pos/invoice-generator
https://invoice-generator.com/
http://invoiceto.me/
0 notes
baazzilhassan-blog · 10 years ago
Text
Show which Git Tag you are on?
git name-rev --tags --name-only $(git rev-parse HEAD)
0 notes
baazzilhassan-blog · 10 years ago
Text
Shutter: Edit button disabled
In some cases, the Edit button in Shutter - featureful screenshot tool - it’s disabled, in order to resolve this issue you may need to install some packages:
sudo apt-get install libgoo-canvas-perl gnome-web-photo nautilus-sendto shutter
This solution only work on Debian based distributions like Ubuntu, for others Linux distributions, please do some research to find equivalent packages.
1 note · View note
baazzilhassan-blog · 11 years ago
Text
Email Verification Tool
Email deliverability is a long way to reach it, to enhance it you need to follow more tricks, verify your lists of emails is one of this tricks.
The idea behind verifying emails lists is to enhance your bounce rate before you even send any mail, enhance your IP reputation in a way to reach good deliverability.
The mechanism of verifying an email is as below:
Check for syntax typos
Check for MX record
Check for account existence
There is more online services that offer email verification service but are all  expensive, offers are based on how much of emails you want to verify.
So, I decided to create a tool that embrace all these mechanisms, this tool can verify up to one million of emails, please see the picture above.
If you interested in this tool, please feel free to contact me.
1 note · View note
baazzilhassan-blog · 11 years ago
Text
Apache: a2query command
When installing apache in Ubuntu, there are many commands system that administer apache service.
In this blog post, we discuss about a2query command.
Description
a2query is a program designed to retrieve configuration values from a locally available Apache 2 HTTP web server. It was designed to be as robust as possible by returning feasible values even if the Apache 2 syntax validator fails.
Options
-a  Returns the Apache 2 "Module Magic Version" (API version) number,     the server was compiled with. The returned version does not contain     any minor versions which are known to be compatible with the major     version returned. -c [CONF]    Checks whether the configuration CONF is enabled. If no argument    was given, all enabled configuration files are being returned. CONF    is compared by string comparison by ignoring a leading "mod_"    prefix and possibly a '.conf' or '.load' suffix. -h Displays a brief summary how the program can be called and exits. -m [MODULE]    Checks whether the module MODULE is enabled, The argument is    interpreted in the same way, as for configuration files queried by    the -c switch. -M  Returns the currently enabled Apache 2 MPM (Multi Processing    Module). -s [SITE]    Checks whether the module SITE is enabled, The argument is    interpreted in the same way, as for configuration files queried by    the -c switch. -v  returns the currently installed Apache 2 HTTP server version -q  suppress any output. This is useful to invoke a2query from another     script. This is useful if only the return code is of interest.
0 notes
baazzilhassan-blog · 11 years ago
Text
Remove Trailing Whitespace Using Sublime Text
Sublime text editor already implement this future out of the box, but it's disabled by default and need to set a parameter on user settings and trim all trailing whitespace on saving a file.
So, click on Preferences menu => Settings - User and copy/paste this code:
{ // ......, "trim_trailing_white_space_on_save": true }
Trailing whitespace can be very helpful if you are using Git patch, as Git generate errors when patch contains trailing whitespace.
Hope this tip can be helpful for all.
0 notes
baazzilhassan-blog · 11 years ago
Text
How to get Scrapyd Configuration from Scrapy Spider
# In your spider, import the config class from scrapyd from scrapyd.config import Config # Then, in your functions def start_requests(self): # Get the path to logs dir of scrapyd print Config.get('logs_dir')
0 notes
baazzilhassan-blog · 11 years ago
Text
How to create a Scrapy CSV Exporter with a custom delimiter and order fields
Create a scrapy exporter on the root of your scrapy project, we suppose the name of your project is my_project, we can name this exporter: my_project_csv_item_exporter.py
from scrapy.conf import settings from scrapy.contrib.exporter import CsvItemExporter class MyProjectCsvItemExporter(CsvItemExporter): def __init__(self, *args, **kwargs): delimiter = settings.get('CSV_DELIMITER', ',') kwargs['delimiter'] = delimiter fields_to_export = settings.get('FIELDS_TO_EXPORT', []) if fields_to_export : kwargs['fields_to_export'] = fields_to_export super(MyProjectCsvItemExporter, self).__init__(*args, **kwargs)
In settings.py import this exporter and set the fields to export and the order to follow, like this:
FEED_EXPORTERS = { 'csv': 'my_project.my_project_csv_item_exporter.MyProjectCsvItemExporter', } FIELDS_TO_EXPORT = [ 'id', 'name', 'email', 'address' ]
For the CSV delimiter, you can set in settings.py or when you execute the spider in CLI In settings.py
CSV_DELIMITER = "\t" # For tab
OR in CLI
scrapy crawl my_spider -o output.csv -t csv -a CSV_DELIMITER="\t"
0 notes
baazzilhassan-blog · 12 years ago
Text
Symfony 2: Set a field form as rendered in TWIG
The problem is when we call to {{ form_rest(form) }} it display all fields that are not rendered before, so, if we want to hidden a field add this line before you call to form_rest
{% do form.field_name.setRendered %}
Or field_name is the name of the field we want to hide.
1 note · View note
baazzilhassan-blog · 12 years ago
Text
Enable / Disable a device on Ubuntu
Follow this steps:
Run xinput on terminal to display the lists of devices with IDs
Choose the device you want to enable or disable and remember the ID
Run xinput enable ID to enable the device with this "ID", or run xinput disable ID to disable it.
Another way but more complex, follow this steps:
Run xinput on terminal to display the lists of devices with IDs
Choose the device you want to enable or disable and remember the ID
Run xinput set-prop ID "Device Enabled" 1 ==> enable the device with id "ID", or  run xinput set-prop ID "Device Enabled" 0 ==> to disable it.
0 notes
baazzilhassan-blog · 12 years ago
Text
JSONSelect
JSONSelect defines a language very similar in syntax and structure to CSS3 Selectors. JSONSelect expressions are patterns which can be matched against JSON documents. Potential applications of JSONSelect include:
Simplified programmatic matching of nodes within JSON documents.
Stream filtering, allowing efficient and incremental matching of documents.
As a query language for a document database.
You can check the full documentation here and you can try it here.
0 notes
baazzilhassan-blog · 12 years ago
Text
Twitter bower & Bower for Sublime Text
A plugin for Sublime Text that integrates with Twitter’s Bower tool, check the source code on GitHub.
0 notes
baazzilhassan-blog · 12 years ago
Text
sprintf in JavaScript
JavaScript does not offer an native support of the sprintf() function, this is a basic script to implement sprintf() function, put it in your commons functions script file:
var sprintf = function sprintf(text) { var args = Array.prototype.slice.call(arguments), i = 1; return text.replace(/%s/g, function() { return (i < args.length) ? args[i++] : ""; }); }
Example
In this example we can use the sprintf() function to render an HTML anchor:
var format = sprintf("<a href=\"%s\">%s</a>", "http://www.google.com/", "Google website"); console.log(format); // <a href="http://www.google.com/">Google website</a>
Note
This implementation is just for parsing strings arguments %s, if you want an advanced support like parsing integers %d and others use this JavaScript plugin.
console.log()
log, info, warn and error functions of the console object supports formatted string:
console.log("<a href=\"%s\">%s %d</a>", "http://www.google.com/", "Google website", 2013); console.info("<a href=\"%s\">%s %d</a>", "http://www.google.com/", "Google website", 2013); console.warn("<a href=\"%s\">%s %d</a>", "http://www.google.com/", "Google website", 2013); console.error("<a href=\"%s\">%s %d</a>", "http://www.google.com/", "Google website", 2013);
Tumblr media
0 notes
baazzilhassan-blog · 12 years ago
Text
Need freelancers - Manchester
Urgently need to find a couple of strong PHP freelancers to work in our Manchester office. Anyone know anyone they can recommend? cc @phpnw
March 26, 2013
1 note · View note
baazzilhassan-blog · 12 years ago
Text
ReactPHP: an event-driven non-blocking IO in PHP
0 notes