All posts by Angel Vladov

JSON vs XML

Many of you have probably wondered which format is better or which should be used. You might have even participated in a full blown nerd rage war on the matter.

Both formats are good when you want to describe a hierarchical structure.

Differences

  • XML is a markup language and is good for documents description or text documents with formatting information.
  • JSON syntax is light. It’s much easier to parse from JavaScript and that’s why it’s preferred for browser-based and Phonegap mobile applications.

So when should you use each one of them?
Continue reading JSON vs XML

How to read an HTML page with UTF8 encoding using PowerShell

Yesterday I was working on a project that requires heavy HTML pages content scraping.

What I wrote were several PowerShell files which were scraping the content using Invoke-WebRequest and Invoke-RestMethod. And everything was great and smooth… until I got to an HTML page with some Greek letters inside. To my surprise both PowerShell built in functions failed miserably when I tried to retrieve those UTF8 encoded pages. In short, I was bombarded with ℠and ¢ here and there.

So, after I lost several hours trying to figure out what’s going on and experimenting with all kinds of options it turned out It’s impossible to read properly a UTF8 encoded page without BOM with Invoke-WebRequest.

Here is a simple function I wrote which uses .NET classes to tackle the problem.

Note that this is just a simple example and it lacks the extensible functionality you get with Invoke-WebRequest.

Reusing page jQuery in a Greasemonkey script

Many times I’ve used a RIA or a website and wanted it to behave differently or have an additional functionality that I need. Thanks to Greasemonkey this is possible.

We live in a jQueritifed world where most of the web pages use jQuery.

That’s why on of the things that I need to do most of the time when I write a userscript is to reuse the jQuery from the webpage without loading a new jQuery instance from the web. This will make my script much more responsive and who needs to load something that is already there.

Save your time by not reinventing the wheel and just use the boilerplate code I’m using for my Greasemonkey scripts.

Continue reading Reusing page jQuery in a Greasemonkey script

Eclipse Keybindings for Sublime Text 2

Ever wanted to use your Eclipse keybindings/shortcuts in Sublime Text 2?
Are you too lazy to learn new shortcuts? (as I am)

If the answer is yes then the following JSON is just for you:

Open Sublime Text, goto Preferences -> Key Bindings-User and paste the JSON there.

image

Enjoy the good old Eclipse shortcuts.

The GIST with the shortcuts is what I need and use. It might not be full or contain all the features you need. If you need more or other shortcuts  visit the Sublime Forum or see one of the following links.

If this is not enough then Google it or click the link – http://bit.ly/1f3wS0p (now we both know how lazy you are).

Applying CSS Styles Before Printing with AngularJS

In a world full of fancy shining jQuery plugins one can’t simply print.

Often you’ll be using a grid JavaScript plugin or another heavy visualization component. One of the pitfalls you might experience with those components is that they don’t look nice when you try to print them. Sometimes this can’t be solved by with the dark side of the force a.k.a pure CSS.

So, what are our options?

Continue reading Applying CSS Styles Before Printing with AngularJS

eRepublik Economy Helper

eRepublik Economy Helper is an addon script I’ve created for the browser game eRepublik. It’s purpose is to simplify the game economy and identify scammers on the black market. You can install the script from its UserScripts page INSTALL

Features list:

  • Shows available products in  your inventory on market page. Never again buy more resources than you need.
  • Sets market and exchange market offers initial quantity from 1 (0) to max.
  • Shows total value in CC for each offer inside the market.
  • Show scammers warning on both – profile page and private messages page.

Continue reading eRepublik Economy Helper

How to open FXG files?

Most of you, who’ve used Adobe Flex related products have probably used Flash Catalyst and the FXG format.

You can open your old FXG files with Adobe Illustrator CS 6 or Flash Catalyst CS 5.5. Unfortunately (as it happens to all Fllex related technologies these days) the new version of Illustrator (Illustrator CC) can’t open the FXG files anymore and Catalyst is discontinued since 2012. So, what happens if we’ve upgraded to Adobe CC products. How do you open FXG files from your older projects?

Well, this happened to me several days ago. After banging my head agains t the wall for a while I found this tool: http://labs.7jigen.net/2010/05/15/fxg-editor-air-app/ Continue reading How to open FXG files?

Disable bounce and pull effects on Flex Scroller component

Today I stumbled on a problem with Flex Spark Scroller and List components while developing an AIR mobile application.

Scroller component has a nice bounce effect when you pull it and it works the same way as you’ll expect the scrolling to work on iPhone (read here).

You don’t always need this behavior, and for some reason you can’t disable this effect. Another problem is that all the possible properties and methods on the Scroller class, which might allow you to change this functionality are eighter private or protected.

The only possible way to go is extending the Scroller class and disabling this effect manually in your class.

Here is a class I’ve created which does exactly thiscom.avladov.components.Scroller

In order to disable the viewport dimensions overshooting just set overhsootEnabled value to false when you use the component.

Bouncing is diabled through overriding of performDrag and performThrow methods and resetting required values when needed.

If you have a better idea, feel free to share it 😉

Using AIR 3.3 SDK with Flash Builder 4.6

Just a few steps showing you how to setup AIR 3.3 in Flash Builder 4.6 on Windows:

  1. Download AIR 3.3 SDKair-sdk-download
  2. Navigate to your SDKs folder (under Flash Builder 4.6 installation directory).

    • For 64x Windows: C:Program Files (x86)AdobeAdobe Flash Builder 4.6sdks
    • For 32x Windows: C:Program FilesAdobeAdobe Flash Builder 4.6sdks
  3. Clone SDK 4.6 folder and rename it (Example: 4.6.0_AIR_3.3)
  4. Extract AIR SDK zip inside the new folder and overwrite all matches.
  5. Download Playerglobal SWC for Flash Player 11.3
  6. Go to /frameworks/libs/player/ inside your new SDK folder, create a new folder and name it “11.3” and place the SWC file from the previous step there. Don’t forget to rename it to playerglobal.swc
  7. Go back to 4.6.0_AIR_3.3 folder and open flex-sdk-description.xml
    file. Change <name> value to something more meaningful and different from the current one. I preffer using Flex 4.6 (AIR 3.3)
  8. Open Flash Builder, go to Window->Preferences->Flash Builder->Installed Flex SDKs and add the new folder.

If you want to move an old project from AIR 3.1 or 3.2 to AIR 3.3 open its application.xml file and change the namespace at the top to match AIR 3.3. It should look like this:

<application xmlns="http://ns.adobe.com/air/application/3.3">

For every project you create and uses AIR 3.3 don’t forget to add -swf-version=16 to the compile arguments right after -locale en_US


External links: