Using curl with Proxy PAC configuration files

curl is an essential tool that most developers use, it will allow you to execute a wide range of HTTP requests from your terminal, it supports using a proxy to execute your requests, but it does not support PAC configuration files. At my work I have to use a PAC file due to the large list of servers I’d interact with, and many would require me passing through specific proxies. It is a cumbersome process for me to memorize or try every URL I want to request and to identify which proxy to use, that’s why I wrote a simple perl script (yes perl not Python!) to help me with this issue. ...

March 16, 2015 · 2 min · Abdullah Diab

Django Country Context

This module solves a small problem that can be found in many sites, where the website has to support multiple countries, e.g. e-commerce website with different stores for different countries, this module allows the developer to define a context per thread, this context holds all the information about the currently available country, and allows the developer to rely on the context always to get the current country instead of passing it through the different levels of code. This module is thread-safe, it defines a different context for each thread. ...

April 5, 2014 · 3 min · Abdullah Diab

How to make django management commands send errors email to admins

I usually use django’s custom management commands to do different tasks on the web application, most of the times with a cron job running those commands. The problem is that when you’re using a cron job, you won’t get the beautiful django error email when something goes wrong. ...

December 8, 2013 · 2 min · Abdullah Diab

How to make logrotate use SSMTP

A few days ago I was looking at my server logs, my website logs are more than a year old and growing, so I was reading some of them and wanted to download the old logs, truncate the logs, so that next time I read the logs I won’t have to look at very old data. So basically I wanted to rotate the logs and archive them, luckily logrotate is there to let me manage and administer log files in my system. It has a long list of features with a very easy configuration, so it was the tool I’m looking for. ...

December 8, 2013 · 3 min · Abdullah Diab

Adding a timestamp to command output in linux

This is just a quick solution to put a timestamp with each line of the output of some command in Linux (*nix). It’s a very simple thing, thought I’d write it down here so maybe it’ll help somebody some day. I have a cron job running on my server, it’s a high frequency job so I don’t want to send email reports each time, I’m logging it into a file, but I want to log the timestamp of each time it runs and logs something to this file, I didn’t want to change the code behind it to also print the timestamp with each write to the output, so I pipelined the command to a simple bash script that will append the timestamp to each line in the output then write the result to the stdout again. ...

February 13, 2013 · 1 min · Abdullah Diab

Google Talk Status Countdown

A few days ago I was counting down to a presentation in my faculty. As I was setting counters all over my world (Side Bar Gadget, To Do List) I thought of a way to change my Google Talk status to a counter also. Since I know that Google Talk uses XMPP protocol, and since my friends and I implemented XMPP last year in our faculty I tried to make a program to set my status to a counter; and here is the result: ...

May 25, 2010 · 4 min · Abdullah Diab

Display Sub-terms In Drupal Term Page

After working with Drupal in the last two months I’ve really got used to searching for modules for every problem I face and installing them. While I was working on iCommunity website, I was creating taxonomy terms to categorize the files using them. I created terms with sub terms. The problem was that when browsing a specified term the term page doesn’t display the sub terms of that term. ...

March 30, 2010 · 3 min · Abdullah Diab

Simple AJAX Comment Preview in Drupal 6

As I said in my previous post, I’m working on upgrading Computer Science in Syria website to Drupal 6. I wanted also to have AJAX comment preview in nodes, but I wanted it to be simple without lots of JavaScript loaded. So as usual I got pissed off and decided to create my own code to do it. 8) ...

February 15, 2010 · 2 min · Abdullah Diab

Simple AJAX Quote in Drupal 6

I’ve been upgrading the forum of Computer Science in Syria for a week now. The forum uses Drupal, and it ran a beta version of Drupal 4, and I upgraded it to the latest Drupal version now. I wanted to have AJAX quoting in the forum, but I wanted it to be simple without lots of JavaScript loaded. So as usual I got pissed off and decided to create my own code to do it. 8) ...

February 12, 2010 · 2 min · Abdullah Diab

Notepad++ Plugin To Run Python Scripts

I use Python everyday, it has become my first tool to use when I need to do anything. In Arabic (in Syrian Arabic specifically) I’d say that Python has become my hand and leg 😛 Yesterday I was writing a small Python script to read the YACC file and generate a list of all the specified rules inside it, so I don’t have to scroll through the long file to find out what rules are inside it 😉 I use Notepad++ as my default text editor on Windows, and I was writing the script using it – Notepad++. I wanted to test if the script is working, so I ran an instance of Command Line Prompt, and as I was going to change the directory to the directory of the script I thought; “Why doesn’t Notepad++ have a Run In Python command in it?”. So as usual I got pissed off and decided to create my own plugin to have that command in Notepad++ 8) ...

November 3, 2009 · 6 min · Abdullah Diab