May 02

HTTPie – command line HTTP client

Reading time: 1 – 2 minutes

I imagine you are used to using curl for many command line scripts, tests, and much more things. I did the same but some weeks ago I discovered HTTPie which is the best substitute that I’ve ever found for curl. Of course, it’s also available for a lot of Linux distributions, Windows, and Mac. But I used it with docker which is much more transparent for the operative system and easy to update. To be more precise I use next alias trick for using this tool:

alias http='sudo docker run -it --rm --net=host clue/httpie'

Official website: httpie.org

Let me paste some highlights about HTTPie:

  • Sensible defaults
  • Expressive and intuitive command syntax
  • Colorized and formatted terminal output
  • Built-in JSON support
  • Persistent sessions
  • Forms and file uploads
  • HTTPS, proxies, and authentication support
  • Support for arbitrary request data and headers
  • Wget-like downloads
  • Extensions
  • Linux, macOS, and Windows support

From the tool webpage a nice comparison about how HTTPie looks like versus curl.

Feb 08

PHP: notes sobre arrays i tres classes (myCurl, barcodes, WSSoapClient)

Reading time: 2 – 3 minutes

A HowtoForge han publicat un howto (local) sobre com funcionen els arrays en PHP que esta molt bé. Realment el que més valoro són les notes sobre les funcions que menys s’acostumen a usar i per tant, les menys documentades o més mal documentades. Tot i que sovint quan les descobreixes ja no pots viure sense elles, funcions de búsqueda, de push, pop, var_dump per depurar, etc.

A més a través de phpClasses he trobat tres classes que els hi he de donar un bon cop d’ull ja que tenen molt bona pinta:

  • MyCurl This class provides an alternative implementation of the cURL extension functions in pure PHP. It automatically detects whether the cURL library is available. If it is not available, it defines several functions with the same names of the cURL extension that use the class to emulate part the original functionality. Currently it implements the functions: curl_init, curl_exec, curl_setopt and curl_close. Several of the most important options can be set with the curl_setopt function.
  • HTML Bar Codes This package can be used to display bar codes using only HTML with CSS styles. It takes a code to represent and generates CSS style definitions and HTML tags to render that code in an HTML page. There are two classes that can render bar codes using the Code39 and Interleave 2 of 5 standards respectively.
  • WSSoapClient This class can add WSSecurity authentication support to SOAP clients implemented with the PHP 5 SOAP extension. It extends the PHP 5 SOAP client support to add the necessary XML tags to the SOAP client requests in order to authenticate on behalf of a given user with a given password. This class was tested with Axis and WSS4J servers.