programming

Scrapy and persistent cookie manager middleware

Scrapy is a nice python environment for web scraping, i.e. extracting information from web sites automatically by crawling them. It works best with anonymous data discovery, but nothing stops you from having active sessions as well. In fact, scrapy transparently manages cookies, which are usually used to track user sessions. Unfortunately, the sessions don't survive between runs. This, however, can be fixed quite easily by adding custom cookie middleware. Here is an example:

Topic: 

No more Mr JavaScript guy?

After doing some web development work recently, I have clearly remembered why I hate JavaScript so much. Not only is it ugly as a language, lacking in type checking or even decent syntax for inheritance (actually faking it with various workarounds), but the actual fact of having effectively two separate code bases - front end and back end forces you to repeat quite a bit of code. And hunting for missing variables and fields or mismatching types is the favourite pastime of JavaScript developers.

Topic: 

Google calendar - download all entries with Python

Google provides APIs to access its data using various languages. You can manipulate Google calendars, contacts, documents etc. Most of the time the usage is pretty straightforward, but sometimes it is not clear how to achieve a specific goal. For example, it took me some time to figure out how to download all events for a given calendar. The main reason behind the difficulty is the upper limit Google places on the number of calendar entries returned by a single query. There are API calls, which help you to overcome this constraint. Below is the relevant code for your enjoyment.

Topic: 

Event Importer for Google calendar

I have released a new product: Event Importer for Google calendar. It allows importing iCalendar files (.ics), downloaded via browser quickly and easily. Possible use cases: event export from Facebook, Meetup, other online services, e-mailed .ics files etc. Please give it a try and let me know what you think.

Topic: 

Right-align help menu in a WPF application

If you want to right-align the "Help" (or any other) menu entry in your menu bar in a WPF application, you can use the following example:

  1. <Menu>
  2.     <Menu.ItemsPanel>
  3.         <ItemsPanelTemplate>
  4.             <DockPanel HorizontalAlignment="Stretch"/>
  5.         </ItemsPanelTemplate>
  6.     </Menu.ItemsPanel>
  7.     <MenuItem Header="File">
  8.         <MenuItem Header="Exit"/>

Topic: 

Use system icons in WPF

Sometimes you would like to use a standard Windows system icon, such as error, warning, question etc. in your WPF program. The main reason is usually consistent look with the rest of the system. While you could have extracted the desired icon from one of the system resource files, there is a much better technique for doing it. First, add a reference to System.Drawing to your project. Then you can use this sample code to get the desired icon quickly:

Topic: 

Side by side editing of .resx files for localization

WPF allows you to create localized applications with relatively little effort. The localized strings are put into resource files (.resx), one per target language, and maintained as needed. The editing facilities of Visual Studio, however, are not designed to help the localization efforts, however. The GUI can only show one resource file at a time.

Topic: 

Microsoft icons for developers

Apparently, Microsoft allows users of Visual Studio to include some icons, supplied with the product. For example, to look at available icons in Visual Studio 2010, locate the file VS2010ImageLibrary.zip in the installation directory of your copy of VS (i.e. C:\Program Files\Microsoft Visual Studio 10.0\Common7\VS2010ImageLibrary\1033) and extract the .png files you need. You can extract the necessary sub-images from them.

Topic: 

Pages

Subscribe to programming