Sunday, May 31, 2020

MacBook unplugged from external monitor thinks it's still the Secondary Desktop



Command + Brightness Up is the keyboard shortcut for Detect Displays


src: https://apple.stackexchange.com/a/58952


Wednesday, October 16, 2019

Faster Time Machine backups on macOS

This seems to speed up TimeMachine backups:

sudo sysctl debug.lowpri_throttle_enabled=0



To restore normal slow speed use:


sudo sysctl debug.lowpri_throttle_enabled=1

Wednesday, January 4, 2017

RVM and SSL certificates

When on Mac while 'bundle install' or 'bundle update' you get following error:

Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most
likely your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see http://bit.ly/ruby-ssl. To connect
without using SSL, edit your Gemfile sources and change 'https' to 'http'.



then try to use this
sudo rvm osx-ssl-certs update all 

Monday, November 14, 2016

Mac OS X Sierra and self signed certificates

For some reason after upgrading to Sierra some of self signed certificates stopped being trusted.
Keychain Access was hanging and guru meditating while trying to delete/reinstall certificate.

this helps to reinstall self signed certificate:


0. find your certificate among installed

security find-certificate -a -Z|grep -e "SHA\|alis"

1. remove cert with

security delete-certificate -Z certSha

2. install cert via command line

sudo security add-trusted-cert -d -r trustAsRoot -p ssl myCoolSelfSigned.cer

3. in Keychain Access in system keychain open certificate and select "Always Trust"


as well this tool does magick


sudo certtool i myCert.crt

Tuesday, November 1, 2016

Ruby Prime numbers

Ruby is the only language that has all the prime numbers in a set.

Prime
The set of all prime numbers.


it's like "Chuck Norris Has Counted To Infinity. Twice" 

Just kidding - basically, the class provides Enumerable type API to prime number generator with limitation to methods 'each' and 'first', but I like the Ruby Doc description :-)

Wednesday, September 21, 2016

Xcode 8 libimobiledevice lockdownd

with Xcode 8 libimobiledevice s could stop working. just in case if you see something like:

    ERROR: Could not connect to lockdownd, error code -5

this should fix it (add your user to _usbmuxd group)

    sudo dseditgroup -o edit -a $USER -t user _usbmuxd



Friday, September 11, 2015

GPU-emulation for Android Emulator on a headless Linux

Eventually Google've released GPU emulation to public with new SDK 24.3.4

With GPU-EMULATION  it is possible to move your Android test farm to clouds like AWS without pay lots of money for instances with GPU.

Here is a how-to configure a headless GNU/Linux for Android with GPU emulation.

# install packages for android sdk
dpkg --add-architecture i386
apt-get update
apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386 lib32stdc++6 lib32z1 -y

# install Xorg (along with 32bit libs) for emulator to work with imaginary GPU
apt-get install xserver-xorg xserver-xorg-video-dummy x11-xserver-utils \
 x11vnc libgl1-mesa-dev libx11-6 libx11-dev libx11-6:i386 libx11-dev:i386 -y

# create config file /etc/X11/xorg.conf

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "dummy"
    VendorName     "Dummy Corporation"
    Option "NoDDC" "true"
    Option "IgnoreEDID" "true"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "NoLogo" "True"
    Option         "UseDisplayDevice" "none"
    SubSection     "Display"
        Virtual     1024 768
        Depth       24
    EndSubSection
EndSection

# start Xorg
Xorg :0


# get fresh SDK
wget http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz
.....

# do not forget about environment variables
JAVA_HOME=...

ANDROID_HOME=/usr/local/android/android-sdk-linux

LD_LIBRARY_PATH=${ANDROID_HOME}/tools/lib/gles_mesa:${ANDROID_HOME}/tools/lib/:${LD_LIBRARY_PATH}

PATH=${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}

export JAVA_HOME ANDROID_HOME PATH LD_LIBRARY_PATH

# after creating android virtual device, add to config.ini :
hw.gpu.enabled=true
hw.gpu.mode=mesa


# start emulator
DISPLAY=:0 emulator -avd a442 -no-boot-anim -noaudio -no-jni -gpu mesa

# see in logs
emulator: Initializing hardware OpenGLES emulation support
emulator: OpenGL Vendor=[Google (VMware, Inc.)]
emulator: OpenGL Renderer=[Android Emulator OpenGL ES Translator (Gallium 0.4 on llvmpipe (LLVM 3.5, 256 bits))]
emulator: OpenGL Version=[OpenGL ES 2.0 (3.0 Mesa 10.4.2 (git-))]

Ansible Rocks

Even when you don't want to create playbooks http://docs.ansible.com/ansible/intro_adhoc.html

Real help with farms of virtual appliances in OpenStack or AWS

Saturday, August 29, 2015

iOS 8 Safari screenshots with variable browser header height

Capturing shots when a browser has variable header height
In iOS 8 Safari comes with a feature when browser's header might be 65px or 41px (when address bar is hidden on scroll, aka minimal-ui) .


For example to capture pages on iPad 2 one could use AShot utility with a strategy that can detect current height of browser's header.

int minHeader = 41;
int maxHeader = 65;
int minViewPortHeight = 960; // Height of viewport when address bar shown
HeaderDetectionStrategy strategy =
    new VariableHeaderDetectionStrategy(minHeader, maxHeader, minViewPortHeight);
new AShot()
  .shootingStrategy(new ViewportPastingStrategy(strategy))
  .takeScreenshot(webDriver);
When in JavaScript to guess the height of browser's header - whether address bar is shown, window.innerHeight property could be used.

Wednesday, July 22, 2015

Android remote control - Smartphone Test Farm

Really great piece of software for a QA engineer and even for a QA team!

Allows to control and manage real Android smartphone devices from your browser.


Tuesday, July 7, 2015

Maven-style continuous delivery

Let's say you have a java program.
Also you have a continuous integration server,
that builds java jar file (artifact) and deploys it to artifactory
(or you just use mvn clean compile deploy to upload latest version to artifactory).

Let's say you also have a bunch of hosts that suppose to run the artifact.
How do you deploy (deliver) the artifact to all the hosts?

We'll use maven for that - exec:java goal and dependency management would help a lot.

On target hosts:

1. create file pom.xml (a bit of xml)

    <modelVersion>4.0.0</modelVersion>

    <groupId>my.cool.sw</groupId>
    <artifactId>cool-program</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>my.cool.sw</groupId>
            <artifactId>my-cool-deployed-jar</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

2. exec 
mvn exec:java -Dexec.mainClass="my.cool.sw.MainClass"


That's it.
  • No need to copy jar file to hosts each time sw is updated and uploaded to artifactory.
  • All the hosts would run latest possible version from artifactory.
  • Easy to automate and to maintain.

Thursday, June 11, 2015

Maven single jar with dependencies

just add the following to pom.xml file

<build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>fully.qualified.MainClass</mainClass>
            </manifest>
          </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>
    </plugins>

  </build>

and you run it with
mvn clean compile assembly:single
Compile goal should be added before assembly:single or otherwise the code on your own project is not included.
See more details in comments.

Commonly this goal is tied to a build phase to execute automatically. This ensures the JAR is built when executing mvn install or performing a deployment/release.

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
      <archive>
        <manifest>
          <mainClass>fully.qualified.MainClass</mainClass>
        </manifest>
      </archive>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id>
 <!-- this is used for inheritance merges -->
        <phase>package</phase>
 <!-- bind to the packaging phase -->
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>


src: StackOverflow :-)

Wednesday, June 10, 2015

TextArea scrollbar width in Firefox

To get scroll bar width of text area - use

element.offsetWidth - element.clientWidth

spent an hour fighting with scroll bar....

Friday, April 10, 2015

Java Mission Control - profiling at your hands

Just add this to your java arg line

-XX:+UnlockCommercialFeatures
-XX:+UnlockExperimentalVMOptions
-XX:-UseFastUnorderedTimeStamps
-XX:+FlightRecorder
-XX:StartFlightRecording=duration=120m,filename=recording1.jfr


when java app exits, file recording1.jfr will be available for viewing with Java Mission Control
since JDK 1.7.40

Thursday, April 9, 2015

Thread stop in Java

Install Oracle's JDK to any linux again

untargz java jdk distro

define JAVA_HOME and export it

cd $JAVA_HOME/bin

fix alternatives - use as root or append sudo

for i in `ls`; do update-alternatives --install "/usr/bin/$i" "$i" "`pwd`/$i" 1; done;


Find files and tar them

/note to myself

Finding files with most powerful utility find sending them to tarball
  find . -maxdepth 2 -type f -print0 | tar -czvf backup.tar.gz --null -T -  

It will:
  • deal with files with spaces, newlines, leading dashes, and other funniness
  • handle an unlimited number of files
  • won't repeatedly overwrite your backup.tar.gz like using tar -c with xargs will do when you have a large number of files

chrome dev tools truncate text in console

Things can get long.
For example location.href.

To copy looong location.href to clipboard with chrome dev tools use 

copy(location.href)

Start Google Chrome on Android Emulator

Prepare Android emulator

  • Use Android emulator with enabled GPU - start emulator with -gpu on 
  • Use larger system and data partition - start emulator with -partition-size 1024


Get a binary of Chrome - I use apk from http://www.apkmirror.com/apk/google-inc/chrome/

adb install com.android.chrome...apk


For web test automation one can use appium bundled with chromedriver, as well as chromedriver solely.