Measure command line program execution time on Windows

Published 2018-08-20, 10:05

Linux has the `time` command, which can be used to measure execution time of CLI commands:

$ help time

time: time [-p] PIPELINE
    Execute PIPELINE and print a summary of the real time, user CPU time,
    and system CPU time spent executing PIPELINE when it terminates.
    The return status is the return status of PIPELINE.  The `-p' option
    prints the timing summary in a slightly different format.  This uses
    the value of the TIMEFORMAT variable as the output format.

Example:

$ time sleep 2
real    0m2.009s
user    0m0.000s
sys     0m0.004s

Unfortunately this command doesn’t exist on Windows. But there are alternatives:

ptime.exe

ptime is a simple executable that you use to run your normal command, afterwards it will out output the execution time it measured:

Execution time: 7.844 s

Download it, put it in a place with a simple path and just prefix your command with the `ptime.exe`.

gnomon

A command line utility to prepend timestamp information to the standard output of another command. Useful for long-running processes where you’d like a historical record of what’s taking so long.

gnomon does a little bit more, as it times each line of the output of your command. But at the end it also outputs a total that can be used to measure the total execution time of your command, at the benefit of also knowing which lines took most of that time:

Total   6.5076s

You install it with npm running `npm install -g gnomon` and then just pipe your command to gnomon:

command | gnomon
Topic(s): Kram No comments - :(

Avoid accidentally closing programs on macOS with Cmd + Q

Published 2018-08-18, 15:24

I am a predominant Windows user. But as I dabble in mobile apps, I of course also have to use a Mac now and then.

This tended to be a pretty frustrating experience, as my Windows shortcut memory always uses Alt Gr + Q to type the @ sign in email addresses – which translates to Cmd + Q on Mac and closes your current program without any additional prompts.

My solution: System Preferences –> Keyboard –> Shortcuts –> Accessibility –> Invert colors: Activate and set to Cmd + Q.

No more accidentally closed programs when typing my email address :)

Topic(s): Technik No comments - :(

How to install Laravel (5.6) on Uberspace (7)

Published 2018-07-16, 12:57

Laravel is a great PHP framework, and Uberspace is a great and nice PHP host. Why not mix both?

Installing Laravel on shared hosting – which Uberspace still is despite the shell access etc. – can be difficult, especially because of public folder that is used to respond to requests instead of the project root.

Here are the basic instructions for getting a new Laravel project to respond to calls of your <username>.uber.space domain:

  1. Switch folder to /var/www/virtual/<username>.
  2. composer global require "laravel/installer" to install the Laravel Installer.
  3. Create a new Laravel project: laravel new <projectname>.
  4. Delete /var/www/virtual/<username>/html (make sure it is empty, or just rename it maybe) and replace it with a symlink from html to <projectname>/public.
  5. The default Laravel start page should now be available at your <username>.uber.space.

To be able to use the database in the project, you have to make some changes:

  1. Get your generated MySQL password from ~/.my.cnf.
  2. Update the .env file in your Laravel project:
    Username and database should be changed to your username, the password to the one you just retrieved.
  3. Caution: At the time of writing Uberspaces uses MariaDB 10.1.34 (find out by using the command mysql -v). Laravel needs some tiny changes if you work with MariaDB <10.2.2:
    • Edit the app/providers/AppServiceProvider.php file and add the following:
      use Illuminate\Support\Facades\Schema;
      public function boot()
      {
         Schema::defaultStringLength(191);
      }

      (Add both the method call and the import!)

  4. Now you can run php artisan migrate in your Laravel project to create the default tables.

Of course you probably don’t want to host your project at your uber.space domain, not create a new project but check out your already developed project from git, and also not use the default database – but I am sure you can find your way from here.

Laravel Homestead: Run phpunit with another PHP version

Published 2018-06-22, 13:09

Laravel Homestead is a nice development environment/server, that comes with multiple PHP versions installed. You can configure each project you are running through it for its own PHP version, and use e.g. php5.6 on the command line to execute code with a specific PHP version. Unfortunately phpunit always uses the default PHP version. What if the PHPUnit you installed in a project needs a specific PHP version to work and execute your tests (for example because the whole project only works with PHP 5.6)?

You can run phpunit with a specific PHP version by using this command:

php5.6 vendor/phpunit/phpunit/phpunit
Topic(s): Laravel, PHP No comments - :(

How to add spacers to the macOS dock

Published 2018-01-12, 23:18

  1. Open Terminal
  2. defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
  3. killall Dock

Source: https://howchoo.com/g/zdnmodkyngn/add-spacers-to-your-macs-dock

Topic(s): Kram No comments - :(

How to Install Ruby with rbenv on Ubuntu 16.04

Published 2017-12-13, 14:48

Each time I have to install Ruby + rbenv + bundler manually on a Ubuntu machine I somehow mess it up and have to google for a tutorial, then try some until I find a working one.

This one here did work perfectly yesterday, when it was time to do it once again: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-16-04

Topic(s): Development, Link No comments - :(

How to create a macOS High Sierra VM with VMware

Published 2017-12-01, 22:07

Topic(s): Link No comments - :(

How to create a macOS High Sierra VM with VirtualBox

Published 2017-11-24, 00:43

Topic(s): Development, Link No comments - :(

Unix command line: How to output to command line and file at the same time

Published 2017-11-22, 12:34

Use:

foo | tee output.file

https://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout/418899#418899

Topic(s): Development, Kram No comments - :(

Send tabs/URLs between desktop and iOS device

Published 2017-10-18, 15:26

Yay, with Firefox iOS it is finally possible to send tabs and URLs between desktop and iOS devices, in both directions.

iOS to Desktop

From Firefox for iOS to desktop computer, the functionality has its own button in the „tab options menu“ and a great explanation in the knowledge base.

What isn’t mentioned there is that Firefox for iOS also adds a „Send Tab“ share extension to iOS that is accessible from normal Safari. You can use it to send any open tab from Safari to your Firefox Desktop installations. You get a OS notification and the tab is automatically opened in the background when the information is received after a few seconds.

Desktop to iOS

In the other direction, from desktop computer to smartphone, you can use the „Send Tab to device“ extension to add a new Option „Send Page to Device“ to the right click menu of websites and tabs. Using it sends the URL to Firefox for iOS were it also opens a tab.

Only thing missing here is a push notification that also tells you that there is data waiting for you when Firefox iOS is not already open and a simpler way to get the URL from Firefox iOS to Safari – right now one has to manually copy the URL over.

Topic(s): Kram No comments - :(

18 queries. 0,319 seconds.