Skip to content

Instantly share code, notes, and snippets.

View viktorsteinwand's full-sized avatar

Viktor Steinwand viktorsteinwand

View GitHub Profile
@viktorsteinwand
viktorsteinwand / Enable Linux sed on OS X
Created February 17, 2016 12:59
Enable Linux sed on OS X
# Install gnu-sed via brew
brew install gnu-sed
# using it
gsed
Please note: if installing with option "--default-names" it will replaces the default OS X sed command in the shell
@viktorsteinwand
viktorsteinwand / Add private-var-folders to docker-machine
Last active March 28, 2016 19:43
This script add the folder /private/var/folders to the docker-machine (this is helpful for execution of phpunit in docker containers with PhpStorm)
docker-machine-nfs default --shared-folder=/Users --shared-folder=/private/var/folders
@viktorsteinwand
viktorsteinwand / le-renew-webroot
Created May 30, 2016 11:17 — forked from thisismitch/le-renew-webroot
Let's Encrypt Auto-Renewal using the Webroot Plugin (Nginx)
#!/bin/bash
web_service='nginx'
config_file="/usr/local/etc/le-renew-webroot.ini"
le_path='/opt/letsencrypt'
exp_limit=30;
if [ ! -f $config_file ]; then
echo "[ERROR] config file does not exist: $config_file"

Keybase proof

I hereby claim:

  • I am viktorsteinwand on github.
  • I am viktorsteinwand (https://keybase.io/viktorsteinwand) on keybase.
  • I have a public key whose fingerprint is 8828 2E62 2617 18E1 06E1 ADF2 B0B7 0375 02D9 FB63

To claim this, I am signing this object:

@viktorsteinwand
viktorsteinwand / git - change author of commit
Created October 28, 2016 19:04
git - change author of commit
git commit --amend --author "New Author Name <[email protected]>"
See also http://stackoverflow.com/questions/750172/change-the-author-and-committer-name-and-e-mail-of-multiple-commits-in-git
@viktorsteinwand
viktorsteinwand / cleanImages.php
Created November 28, 2016 10:04 — forked from peterjaap/cleanImages.php
Script to clean up the images tables in a Magento installation. Removes references to non-existing images, removes duplicate images, sets correct default image and deletes orphaned images from the filesystem.
<?php
/*
* This script deletes duplicate images and imagerows from the database of which the images are not present in the filesystem.
* It also removes images that are exact copies of another image for the same product.
* And lastly, it looks for images that are on the filesystem but not in the database (orphaned images).
*
* This script can most likely be optimized but since it'll probably only be run a few times, I can't be bothered.
*
* Place scripts in a folder named 'scripts' (or similar) in the Magento root.

Notice

This script is no longer required with Docker for Mac which includes an option to run Docker at startup and doesn't use docker-machine to administer the local Docker engine.

Requirements

  • Docker Machine + Docker
  • curl
  • A Virtualbox-driven Docker Machine called "default" docker-machine create --driver virtualbox default (this is the default with Docker toolkit).
@viktorsteinwand
viktorsteinwand / README.md
Created June 27, 2017 19:27 — forked from ralphschindler/README.md
Docker (For Mac) De-facto Host Address Alias (10.254.254.254) - "The 10254 Trick".

Docker (Mac) De-facto Standard Host Address Alias

This launchd script will ensure that your Docker environment on your Mac will have 10.254.254.254 as an alias on your loopback device (127.0.0.1). The command being run is ifconfig lo0 alias 10.254.254.254

Installation

Copy/Paste the following in terminal with sudo (must be root as the target directory is owned by root)...

sudo curl -o /Library/LaunchDaemons/com.ralphschindler.docker_10254_alias.plist https://gist.githubusercontent.com/ralphschindler/535dc5916ccbd06f53c1b0ee5a868c93/raw/com.ralphschindler.docker_10254_alias.plist
@viktorsteinwand
viktorsteinwand / IIS_Parallels_Win8_Mac.md
Created May 28, 2018 08:15 — forked from justingarrick/IIS_Parallels_Win8_Mac.md
Expose IIS or IISExpress running in a Parallels Windows 7/8 VM to your OS X host

Expose IIS or IISExpress running in a Parallels Windows 7/8 VM to your OS X host

Rename your virtual machine

In your Windows 7/8 VM, go to Control Panel > System > Advanced system settings > Computer Name and click Change. Name this whatever you like, e.g. windows. Restart your VM.

Add an ACL rule

Open CMD or Powershell as administrator. Add a URL ACL entry for your new name on the port of your choice, e.g.
netsh http add urlacl url=http://windows:8080/ user=everyone

Add a firewall rule

@viktorsteinwand
viktorsteinwand / sample.cs
Created August 23, 2018 14:57 — forked from dtchepak/sample.cs
SAMPLE: Sub properties using reflection
// SAMPLE ONLY -- DON'T USE FOR REAL STUFF UNLESS YOU'VE REVIEWED AND TESTED :)
// Needs work to make robust: check property type's class has default ctor and so on.
// Can also filter out interfaces as these will be auto-subbed.
public static T SubFor<T>() where T : class
{
var gettableVirtualProps = typeof(T).GetProperties()
.Where(x => x.CanRead && x.GetGetMethod().IsVirtual)
.Select(x => x);
var sub = Substitute.For<T>();