Saturday, April 18, 2020

Open Link in New Tab


All major browsers use popup blockers to prevent sites from opening new tabs. Popup blockers works in slightly different ways and block popups in different contexts.

First chapter gives short overview of popup blockers. The rest of article shows multiple ways how to open new tab and how to work around browsers limitations.

Saturday, December 12, 2015

Speedwriting

Speedwriting is simple fast paced typing game with a twist - reading is not always easy. Read and write letters you see as quickly as possible anyway. The game can be played on newgrounds or on Github.


All my games can be found Games & Stuff page.

Monday, January 26, 2015

Testing Grunt Plugin From Grunt

Writing tests for grunt plugin turned out to be less straightforward then expected. I needed to run multiple task configurations and wanted to invoke them all by typing grunt test in main directory.

Grunt normally exits after first task failure. That makes it impossible to store multiple failure scenarios inside the main project gruntfile. Running them from there would require the --force option, but grunt then ignores all warnings which is not optimal.

Cleaner solution is to have a bunch of gruntfiles in separate directory and invoke them all from the main project gruntfile. This post explains how to do that.

Monday, September 1, 2014

Mud River Game

Mud River is small game I made three months ago. Your goal is to splash as much mud as possible within a short time limit. It was done under a week and can be played on Github.


Saturday, August 30, 2014

jUnit: Rules

Rules add special handling around tests, test cases or test suites. They can do additional validations common for all tests in the class, concurrently run multiple test instances, set up resources before each test or test case and tear them down afterwards.

The rule gets complete control over what will done with the test method, test case or test suite it is applied to. Complete control means that the rule decides what to do before and after running it and how to deal with thrown exceptions.

Saturday, August 23, 2014

jUnit: Dynamic Tests Generation

Dynamic tests generation is useful when you need to run the same set of tests on many different input values or configurations. It can be achieved either using parametrized tests or using theories.

Theories are valuable when you have a bunch of data to be used as parameters and want to run tests on all their combinations. You get less control, but you do not have to write combining and iterating code by yourself. Basics about how theories work are explained on java code geeks (original at java advent calendar), so this post focus on parametrized tests.

Parametrized tests are better when you need to have good control over the input values, e.g. directory with files that are served as an input or a list of meaningful parameters combinations.

Wednesday, April 2, 2014

Placeholdered Maps

Placeholdered map is able to associate keys with values. User can add key value pairs into it and ask for data associated with keys. It works exactly as it would work in an ordinary map.

The additional feature is ability to use placeholders. Placeholder knows when it was created and is useful to cheat on order in which data were added into the map. If the user adds data into placeholder, the datastructure behaves as if the data were added when the placeholder was created.

We will create two such structures. First keeps key value pairs and can return last value associated with the key. Value added into placeholder is returned only if user did not added the same key after the placeholder was created. Second returns all values associated with the key in order they were put in. Placeholders can be used to add data in the middle of those lists.

Thursday, March 13, 2014

Falling Ball Game

I released simple html5 game called Falling Ball. The player uses arrows to move the ball left, right and to make it jump. You get one point for every hit platform and if the ball touches screen border, any of them, then the ball dies.

Wednesday, February 19, 2014

Cryptography & Theory 2: What is Pseudorandom

As was concluded in the first part of this series, security without randomness is impossible. Deterministic ciphers are unable to protect against strong attackers and true random generators are impractical or hard to get, so cryptography is build on pseudorandom generators.

First two chapters of this post define what they are and explain what kind of pseudorandom generators secure cryptography needs. Third chapter introduces yet another way how to talk and think about pseudorandom generators and ciphers in general.

Saturday, November 30, 2013

Cryptography & Theory 1: Meaning of Secure

Cryptography & Theory is series of blog posts on things I learned in coursera stanford online crypto class. The class contained just right mixture of theory, math and programming and I enjoyed it a lot.

This first part explains what is meant by expression "good cipher". It contains definition of a cipher and multiple definitions of cipher security. Although it does not sounds like much, it is one of the most important things I learned there.

It is important because ciphers are designed to protect against well defined attacks and are vulnerable to anything else. One can not just take random cipher from build-in ciphers list of his favorite framework and call it a day. One has to understand what is he choosing and why.

Thursday, July 4, 2013

Matasano Crypto Challenge

I recently finished Matasano Crypto Challenges and it was an interesting experience. I started doing them because @tqbf tweets with standings showed up in my tweet feed and made me feel competitive. Now I'm very glad I did them.

Update: competition is not running anymore. All exercises and official solutions are available on cryptopals.org. My solutions are written in java and stored in matasano-cryptopals-solutions github repository.

Crypto Challenges is a collection of 48 exercises that demonstrate attacks on real world ciphers and protocols. Exercises exploit both badly designed systems and subtle implementation bugs in theoretically rock solid crypto. Most importantly, they make you see how tricky the security can be and how much various details matter.

If you solved all exercises while the competition was running, Matasano donated 20$ to a charity.

Thursday, June 20, 2013

Building JavaScript Library with Grunt.js

New release of typical non trivial JavaScript project needs to run unit tests, concatenate all source files into one and minify the result. Some of them also use code generators, coding style validators or other build time tools.

Grunt.js is an open source tool able to perform all above steps. It is pluginable and was written in JavaScript, so anyone working on JavaScript library or project should be able to extend it as he needs.

Wednesday, May 1, 2013

Less CSS - Expressions and Traps

In an average case, less expressions are easy to use, very useful and behave the same way as expressions in any other programming language. Unfortunately, their interactions with the rest of css syntax can occasionally cause somewhat quirky behavior. Adding to that, next less language version will change in backward incompatible way and expressions are affected too.

This post shows when and why quirky behavior happens, which problems are going to be solved by planned changes and which traps will still remain there.

Sunday, March 31, 2013

Less CSS - Tips and Trics

Less is declarative language designed to behave and look as closely to css as possible. Less started as an attempt to make css style sheets easier to read and maintain and then added more features and abilities. It evolved so much that it became theoretically possible to do anything with it.

This post shows some less known but very useful less features. It also contains list of potentially useful workarounds and tricks you can use if the default less syntax is not sufficient for what you need. Finally, last chapter shows one practical application of those tricks. We will create mixin to auto generate vendor prefixes for css declarations.

Monday, December 17, 2012

ANTLR - Semantic Predicates

Parsing simple grammar with antlr is simple. All you have to do is to use regular expressions to describe your language and let antlr generate lexer and parser. Parsing big or complicated languages occasionally require more, because describing them in regular expressions only can be hard or even impossible.

Semantic predicates are java (or C++, or JavaScript, or ...) conditions written inside the grammar. Antlr uses them either to choose between multiple alternatives or as additional assertions to be checked. They can be placed inside both lexer and parser, but this post focus only on their usage within the parser. They add a lot of power to antlr.

Thursday, November 15, 2012

Project Report - Less4j


Few months ago I decided to create java port of less.js. Less is an extension of CSS - it adds constants, mixins, ruleset nesting, namespaces and so on. Both reasons why I picked up less and short less introduction are written in introduction into less.

This report starts with current project status and its possible future directions. Second part recaps development and my experiences with used tools. Finally, the last part sums up why did I started with the project in the first place and whether it was worth it.

Monday, October 1, 2012

Travis-CI - Continuous Integration Server

Travis-CI is hosted continuous integration server for Github projects. The continuous integration part is fairly standard: it runs unit tests and report results after each project change.

The hosting part is unusual: the service runs tests on their own infrastructure and provides access to test results. The user does not need his own hardware nor to install and run the server. All that is part of the service.

Any public repository hosted on Github can use Travis-CI for free. Private repositories have to pay and the Travis Pro version they get is a bit different from the regular one.

This post is mainly about the free version. First chapter describes what Travis-CI does. Second part contains few things about Travis-CI server, infrastructure and organization behind it. Mini review with our experiences is located in the last chapter.

Saturday, September 1, 2012

Tackling Comments in ANTLR Compiler

Most compilers treat comments as just another meaningless whitespaces. They identify them in the source code and then throw them away. On the other hand, things are a bit harder if you need to know comments content and their position.

Such requirement is not too common and official ANTLR documentation does not says much about how to do it. The compiler we have been working on needed to preserve comments, so we had to come up with our own solution. This post documents it.

First chapter introduces our compiler. It describes what it does, where it is located and how it is written. Second chapter explains our comment preserving requirements. The rest of the post describes datastructures and algorithms used in our solution.

Wednesday, August 1, 2012

Wro4j, Page Load Optimization and Less.js

Wro4j is primary a JavaScript and CSS merge and minimization library. Its original purpose was to speed up the page load. However, its final design made it easy to add integration with LESS, CoffeScript and few other technologies.

Less was introduced in previous article. In short, it is CSS with object oriented inheritance, variables and few other additional features. It is compiled into regular style sheets and served to the browser. Less was written in JavaScript and usually runs in the browser. If you want to run it on the server side, you have to use wro4j or some other integration library.

The post is mostly wro4j tutorial with focus on Less integration. It explains how wro4j works and how to configure it. There is very little about Less and almost everything is about wro4j.

Sunday, July 1, 2012

Inheritance and Variables in CSS with Less

I always missed object oriented inheritance and variables in CSS. Style sheets could be much more readable and maintainable, if they would have ability to say:
  • I want this selector color to be just like that one.
  • I want this class to be just like that one, with one simple change.

As multiple projects run into CSS explosion and maintenance problems problems, it was only question of time until someone comes with another solution. The original solution came from the Ruby world and is quite simple and elegant:
  • extend CSS with needed features,
  • compile extended CSS into regular CSS,
  • serve the result to the browser.

The browser does not have to deal with a new syntax. It was given standard CSS file and will process it as usually. On the other hand, the programmer had variables, inheritance and few other features available.