Recently I messed up an important git repository that I was working on. I had created some content in a specific file a few weeks ago. After multiple merges, commit squashing, git reset, rebases and other types of history rewrites I noticed that this content was missing.
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
How to add spacers to the macOS dock
Published 2018-01-12, 23:18
- Open Terminal
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
killall Dock
Source: https://howchoo.com/g/zdnmodkyngn/add-spacers-to-your-macs-dock
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
How to create a macOS High Sierra VM with VMware
Published 2017-12-01, 22:07
- http://www.tactig.com/download-install-macos-high-sierra-vmware/
How to create a macOS High Sierra VM with VirtualBox
Published 2017-11-24, 00:43
- macOS host system:
http://tobiwashere.de/2017/10/virtualbox-how-to-create-a-macos-high-sierra-vm-to-run-on-a-mac-host-system/ - Windows host system:
https://www.howtogeek.com/289594/how-to-install-macos-sierra-in-virtualbox-on-windows-10/
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
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.
Disable Windows Defender real time protection with a Desktop Shortcut
Published 2017-10-05, 17:31
I love how Microsoft made third party anti virus protection obsolete with Defender – it just works.
Unfortunately sometimes I need to disable (and later enable again) it’s real time protection feature because it slows down processes I know are secure – for example Gradle builds in Android Studio.
It normally takes 7 clicks to enable or disable Defender real time protection: Systray -> double click on icon -> „Virus & threat protection“ -> „Virus & threat protection settings“ -> Toggle „Real-time protection“ -> User Account Control „Yes“.
Fortunately there is a way to automate this in Powershell:
Set-MpPreference -DisableRealtimeMonitoring $true
Which means we can also create a desktop shortcut (Right click on Desktop -> New -> Shortcut):
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "C:/disable.ps1"
(„C:/disable.ps1“ is the file where I put the first code snippet)
In the properties you have to click „Advanced“ to activate „Run as Administrator“ so it can actually be executed.
Then to give it a nice icon, click „Change Icon“ in the shortcut properties and „open“ the icons from „%systemroot%\system32\imageres.dll“. There you’ll find a nice dark red Defender like „badge“ icon with a white x:
The real time protection feature will turn itself back on after some time. Alternatively you could replace „$true“ with „$false“ in a copy of that script to have a shortcut to enable it again. Or spend some time to figure out how to actually „toggle“ in on and off with the same shortcut by somehow doing this in the Powershell script. (Let me know if you do!)
Source: Script via StackOverflow answer by ‚djsmiley2k‘ to my question and icons file for the shortcut
Website Performance, Code, Images and SEO Testing Tools
Published 2017-09-29, 12:48
There are loads of web site and page analyzer tools out there that look at them under performance, quality, image compression, code or SEO aspects. Many are just (thinly veiled) lead generation tools that don’t really tell the true story, but some are actually useful. As I need them again and again, I collected them here:
- https://www.webpagetest.org/ – Performance
- https://tools.keycdn.com/performance – Performance (TTFB)
- https://webspeedtest.cloudinary.com/ – Images
- https://gtmetrix.com/ – Performance
- http://nibbler.silktide.com/ – Code, SEO
- https://tools.pingdom.com/ – Performance, Code
- https://developers.google.com/speed/pagespeed/insights/ – Code, Performance, Mobile
- https://www.dareboost.com/en/home – Quality, Code, Performance (only 1 test without account, 5/month with free account)
More on the marketing-y, rarely even questionable side, but sometimes still interesting to look at:
- http://tools.neilpatel.com/en/analyze/ – SEO, Code, Performance
- https://website.grader.com – Performance, SEO
- http://www.seowebpageanalyzer.com/ – SEO, Code
Visualize `git reflog` in a GUI (and put it in context) with SmartGit
Published 2017-09-28, 11:31
Oh-oh, seems what everybody warns you about when rewriting history happened: I lost some stuff.
But lucky for me, git never really deletes anything. Even if you do stupid things, each commit that was there before still is – just orphaned and without a connection to your normal branches.
Unlucky for me the tool to fix this is called git reflog and not supported by my usual git GUIs that I use, SourceTree and GitKraken.
I tried to use git reflog on the command line, but to be honest this didn’t help much. reflog just outputs a list of changes to the repository, and you have to sift through these manually to find the one you are looking for. There is no context which files where changed or what changes to these files were made. (Disclaimer: There probably is a way to work around this with some bash scripts – here or here for example – but I have no idea about how exactly. That’s why I normally use a GUI.) I had no idea when in the last month stuff broke, so I had no idea where to start looking.
After quite some time googling around I (re)found SmartGit.
SmartGit is also a Git GUI and calls itself „Git for Professionals.“. This means it doesn’t look as fancy as SourceTree or Gitkraken (its design reminded me of working in the Delphi IDE back in the day…), but it is indeed powerful. And most importantly, it can visualize lost commits in a way that is useful!
Funny enough this feature is only very lightly mentioned in the documentation, so here is how it works:
How to visualize lost and „orphaned“ commits with SmartGit
We are looking for the „Recyclable Commits“ branch in the „Log“ view: Open the repository in SmartGit, right click on the repository in the „Repositories“ panel, select „Log“ in the context menu, then in the opened „Log“ view, select „Recyclable Commits“ in the „Branches“ panel additionally to the already selected branch or „HEAD“:
The light orange-dot entries (vs. the bold black-dot ones) are the „orphans“ that are not part of the current tree any more.
You can filter these down by using a „Filter“ input, which optionally can search for File name and even File content! (So I could just type the filename I knew I had put my content into, and look only through these relevant commits – and even search for a few words I knew I wrote about in the file – how awesome is that!)
Important and super useful is that these commits are shown in the context of the current tree, so you can click the individual commits and see the file changes it includes, click the files to see the diff as you normally would. So much easier than on the command line.
After you found the missing commit, either copy the text over to your editor manually or cherry pick that commit with all its changes to your current branch by right clicking on it and selecting „Cherry-Pick…“. Then commit as usual (and dance a bit as you just saved a few days of work).