Tag: programming

Showing 7 posts.

Creating command line tools with Node.js

March 15th, 2016    by sigman    1226
  Tips   nodejs, javascript, linux, programming

I needed to create an utility that when installed as a global module, it would be both available as a command line tool in bash and as a Node module that could be imported with require function from any Node script. As the command line tool, i wanted it to take input in two ways: take parameters and read input from a file or take piped streams. This tip explains how this can be achieved.

continue reading...

Markdown basics

July 23rd, 2013    by sigman    1856
  Primers   programming

Markdown has been made a markup language of choice by many different platforms including the one I use often: Github, Atlassian Jira, Stack Exchange. The language was designed to be readable as-is, without looking like it's been marked up with tags or formatting instructions (unlike HTML). Since its initial development in 2004 by John Gruber’s there have been number of efforts attempting to standarise it. John's own Perl script converting Markdown into HTML has been used as the initial definition for Markdown but since it has number of ambiguous definitions causing issues, many different standards of the language emerged. The differences are mainly around more advanced features thought and the base is rather common and this is what I'm going to concentrate on here. Also there is an inititiative called CommonMark (commonmark.org) describing itself as a strongly specified, highly compatible implementation of Markdown, with many popular individuals involved that standarises the language.

continue reading...

Using modules and dependency management in JavaScript applications with AMD - require.js

June 2nd, 2013    by sigman    2035
  Tutorials   programming, javascript

requirejs logoOne of the first things I had to learn when starting developing JavaScript applications was how to overcome lack of dependency management and concept of modules and namespaces. Unfortunately there are few JS books touching on these topics. When building large scale application, implementing hundreds of <script> tags becomes really hard to manage, especially when we need to keep them in specific order. Also the more script tags are included in the html files, the more requests a browser needs to do - this may cause a significant impact to the overall user experience - loading times, UI freezes... As JS lately became a language of choice for developing web applications targeting not only desktops but also mobile devices, developers needed to find a solution for that. Instead of waiting for changes to the JS specification (http://wiki.ecmascript.org/doku.php?id=harmony:modules) and for implementing that consequently to the popular browsers, they agreed for a standard that would be used both on server and client side and they named it CommonJS (http://wiki.commonjs.org/wiki/CommonJS). The solution works great with JS on the server side but due to the fact that files are loaded synchronously, it doesn't work well with browsers as this would block user interface during script load process. So the client side solution was modified for asynchronous loading by wrapping modules in files into callback functions. This is known as AMD - Asynchronous Module Definition
(https://github.com/amdjs/amdjs-api/wiki/AMD, http://requirejs.org/docs/whyamd.html). One of the most popular AMD loader solutions is the require.js and in this article we will look how to use it.

continue reading...

AGAL multitexture shader

September 5th, 2012    by sigman    4238
  Tutorials   actionscript, programming

Inspired by the great blog post from Devon_O on conversion of GLSL (OpenGL) shaders to AGAL shaders, I decided to pick one of the examples available on Shader Toy website and to my suprise it wasn't that hard to get it working. I wanted to put the example with code on the Wonderfl but I can't get it running over there so I decided to put it here. And while I put it here, why not add just few additional words about shaders in AGAL...

continue reading...

Box2D basics - Part 1

February 12th, 2012    by sigman    8229
  Primers   box2d, actionscript, programming

Box2D logoBox2D probably doesn't have to be introduced to anyone, even if you have never used it, you have probably still heard about it. This is the most popular physics simulation engine that has been ported to every popular platform available. I had a chance to work with Box2D in C++ and I have been reading tutorials from guys using it with Python, Objective-C, Java and JavaScript. So if you come from other platform than Flash, I encourage you to read this article anyway as although I'm using a Flash port here, everything works exactly the same way in other platforms. In the first part, I cover how to create a world, static and dynamic objects, how to add interaction and work with collision detection.

continue reading...

Saving and loading complex objects from a file with FlashPlayer

January 19th, 2012    by sigman    3492
  Tips   actionscript, programming

When building Flash apps or games there is very often a need to save some user data. It might be a player's progress in a game or some work done in an application. Usually online application data is being kept in a database and desktop apps are saving to a file on a hard drive. Flash also allows saving to shared objects, so called Flash's cookie files but there is a limit of size set by an operating system and some browsers or anti-viruses may clear them periodically effectively erasing users saved data. While for desktop apps developers choose Adobe AIR, which allows deeper integration with operating systems, not many people know that since Flash Player 10 there is also an option of saving and loading data from a file. In this quick article I will give you a code example of how this feature could be use along with JSON and ByteArrays to effectively save your data to a file.

continue reading...

Simple pathfinding algorithm in ActionScript 3

August 6th, 2011    by sigman    9516
  Tutorials   actionscript, programming

I was asked to quickly build an algorithm to find the shortest path for a labirinth game. First thing I did was check for some quick ideas on Wikipedia and found this article: http://en.wikipedia.org/wiki/Pathfinding. As there was only a text description I quickly wrote a simple ActionScript 3 class returning coordinates that create the shortest path.

continue reading...