viernes, 23 de noviembre de 2018

Pharo Script of the Day: Super easy meme generation

Couldn't resist sharing this one:

ZnClient new
 logToTranscript;
 url: 'https://api.imgflip.com/';
 addPath: 'caption_image';
 formAt: 'template_id' put: '95158268';
 formAt: 'username' put: '...'; 
 formAt: 'password' put: '...'; 
 formAt: 'text0' put: 'Just Zinc';
 formAt: 'text1' put: 'HTTP Components'; 
 accept: 'application/json';
 contentReader: [ : entity | 
   ZnEasy getJpeg: (((NeoJSONReader fromString: entity contents) at: #data) at: #url) display ]; 
 post.

To save you from generating a user in imgflip API, this is the resulting output:


sábado, 17 de noviembre de 2018

Pharo Script of the Day: DesignInfo

Hi there.

Not so much of a script today. Continuing a little bit on the SLOC subject, yesterday I kind of resurrected on GitHub a package called DesignInfo. This package is based purely on Morphic (so it is possible even to run it without Roassal or Moose) and takes every package in a Pharo image, and count the lines of code (LOC, as provided by RPackage), along with other metrics like:

  • Lines of production code
  • Lines of test code
  • Percentage of production code
  • Percentage of test code

You can have a look with the following expressions:

DesignInfo linesOfCodeSortedMorph openInWorld.
DesignInfo linesOfCodeMorph openInWorld.

A histogram is displayed where red bars represents production code and blue bars represents test code. See two screenshots of what the package provides:

sábado, 3 de noviembre de 2018