Mac OS High Sierra on VirtualBox on Linux/Ubuntu 16.04/Xenial

    1. Need a way to download the install cd from Apple’s store
      I got an xcloud for a month – could have used macincloud
    2. download High Sierra from the app store on the mac
    3. Create virtualbox image
      I Had to go for generic Mac OSX 64 bit, not the specific High Sierra one !!
VBoxManage modifyvm Sierra  --cpuidset 00000001 000306a9 00020800 80000201 178bfbff
VBoxManage setextradata "Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "Sierra" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "Sierra" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "Sierra" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
VBoxManage setextradata "Sierra" "VBoxInternal2/EfiGraphicsResolution" "1920x1080"
  1. Configure
  2. change resolution
    Method 1: VBoxManage setextradata “Type Your VM Name Here” VBoxInternal2/EfiGraphicsResolution HxV  (Recommended)
    -------------------------------------------------------------------------------------------------------------------
    
    Method 2: VBoxManage setextradata “Type Your VM Name Here” VBoxInternal2/EfiHorizontalResolution H  (Alternative)
    	  VBoxManage setextradata “Type Your VM Name Here” VBoxInternal2/EfiVerticalResolution V
    -------------------------------------------------------------------------------------------------------------------
    Resolutions to choose:
      1280x720 | 1920x1080 | 2560x1440 | 2048x1080 | 3840x2160 | 5120x2880 | 1280x800 | 1280x1024 |1600x900 | 1440x900
         HD 	FHD	    QHD          2K	     4K	         5K
    -------------------------------------------------------------------------------------------------------------------

     

Perl still does my hostnames resolving

Again, I had a large list of hostnames which I needed resolved to their ip addresses.

  • nslookup: slow
  • ping -c 1: slow
  • getent hosts: “random” ipv6 addresses
  • no fping available

So I still use perl for gethostbyname() or getaddrinfo():

Example below takes input from stdin/pipe.

perl -MSocket -nwle'my @addresses = gethostbyname($_); my @ips = map { inet_ntoa($_) } @addresses[4 .. $#addresses]; print "@ips"'

Build an IOS app on Linux – without MAC – using React Native

I found myself not finding an app in the apple store that accommodates my requirements.  I have built an app in the past using mac + xcode which works nicely, but now I have an ubuntu running on my lenovo yoga.  So no Mac.  I have been reading about React and React Native so that’s what I’ll try.  It would allow me to publish the app not only for ios but also for android. Also, saves me from investing in a Mac.  And on top of that, I learn React to build apps just about anywhere.  Win Win Win…

I don’t want to waste time with hackintosh, vm, simulators etc.  I really want this to work.

My two new programming languages for this year will now be Golang (backed by Google) and React (facebook).

Sources:

http://facebook.github.io/react-native/
https://expo.io/learn
https://github.com/expo/xde

So we need Nodejs and expo.  Coding is done in either the online Expo IDE or XDE offline.  On the iPhone, we need the expo client.

nginx change http request header value based on source address

Let’s say you want to change the value of a header value based on the source location, ie localhost vs external.  Or you can drop it all together. This is how it’s done in nginx.

We’re setting a variable first using map in the http{} block and then use it later in the location{} section.

  • Add this to the http{} section:   if loopback, it will set the $customkey variable to the original header value of ‘custom-key’, else it will default to empty
map $remote_addr $customkey {
     127.0.0.1 $http_custom_key ;
     default "";
}
  • Add this to the location{} section where you want the use this for your proxy_pass:  (re)set the header to the previously set variable or remove it.
proxy_set_header custom-key  $customkey;

 

boot-repair to the rescue

Installing ubuntu from the live-cd these days is too easy, really: insert usb stick, boot, install. Done.

The ability to try before installing is just the icing on the cake.  You check if all your hardware is supported (especially network, display, mouse/keyboard) and go…

If you installed it next to the preinstalled Windows and the latest update destroyed your GRUB bootloader config (or any other), use the same live-cd/usb stick to recover.

https://help.ubuntu.com/community/Boot-Repair

just run these lines in a terminal and let the repairing begin:

sudo add-apt-repository ppa:yannubuntu/boot-repair 
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair