Posts

Showing posts from 2016

Simple HTTP/HTTPS server on Scala/Akka

Let me present a simple Scala script to serve local files over HTTP or HTTPS. I've used Scala/Akka to get the good performance and to play around with the programming language I really like. Toolchain We need Scala, SBT (Scala interactive build tool), Conscript  (a distribution mechanism for Scala apps) and Scalas (the script runner for Scala). Conscript is needed only to install Scalas here, so you may want to install the runner manually (see the Scalas link above) if you don't want to install Conscript. For Mac OS X we're going to use Homebrew to install Scala and SBT:  $ brew install scala sbt Next step is Conscript (please follow the installation instructions on the official site):  $ wget https://dl.bintray.com/foundweekends/maven-releases/org/foundweekends/conscript/conscript_2.11/0.5.1/conscript_2.11-0.5.1-proguard.jar  $ java -jar conscript_2.11-0.5.1-proguard.jar Next step is installing Scalas (please follow the  installat...

Android screen capture with GIF format

GIF format is still here, and it's a handy way to make small videos. It's very easy to do despite of all ads telling us to buy their commercial software, and I'm going to describe the tools we need. First, we need to capture the video of the screen. For Android, you can use  ADV Screen Recorder , but surely there are tools for any platform. Please verify the recorder settings (you may want to disable mic recording and change the output folder to be on an external SD). Second, after we recorded the video, we need to convert it into GIF-format. For that we're going to use FFMpeg tool (on Mac, just use "brew install ffmpeg"). GIF uses 256 colors, so we need to create an auxiliary palette file. Therefore, the converting process takes two steps: 1) create a palette, 2) use a palette and an input file to create the output GIF. The commands for that: $ ffmpeg -i input.mp4 -vf fps=10,scale=320:-1:flags=lanczos,palettegen palette.png $ ffmpeg  -i input.mp4 -...

shelljs node module

Let me share a little gem I've found: shelljs node module . I was working on updating my Cordova hooks to work with Windows environment and had to replace my bash script with the corresponding JS code. Unfortunately, the node modules I've found were disappointing, especially copying the files. Surely I could write the copying code by myself, but I supposed that in 2016 year one is not required to do such menial tasks. The biggest problem for the modules I've tried was the glob matching - I have to copy files from the sibling directory, and modules couldn't find it (looks like they don't parse ".." notation). I've tried fs.extra, fs-extra, ncp, filecopy, cp, but no luck. I guess I could find the good module after all, but after I've discovered shelljs I don't need it anymore anyway. With shelljs porting the code was a piece of cake - see the results below (the original and the new scripts).

Software licensing

For my software projects I've always preferred the GPL license, but nowadays its time has gone, at least for me. The IT industry is mature enough, and all copyleft (and copyright) licenses create more problems than advantages. Few examples: Inability to use the code in the commercial applications. Commercial applications are infamous for their poor quality, security-by-obscurity and other issues. I guess we all agree that in the perfect world the applications should be polished before releasing, but free market dictates faster release cycles, and therefore the overall poor quality of the software. At the end, it influences us all, directly or indirectly (commercial OSes, routers, cloud solutions and other infrastructure elements), and by lifting the software licenses restrictions we may help the commercial developers to use our code in their projects (instead of implementing their own, in many cases, inefficient, solutions). For example, because of the  readline  library r...