iPhone5 power button repaired

Common issue. Power button got broken after a while, I switched to iPhone6, so this ‘old’ phone stayed forgotten. Then my son wanted to use it, so I had to repair it. Looked around, for the first time it as eligible to Apple repair program, but after a while my SN was removed, not sure why. Anyway, the off-warranty repair costs more than 2500CZK (w/o VAT), quite a lot. So I looked around and found few links. Ordered spare button/ribbon cable, few tools and .. got it repaired (but I have to admit, it was a tough fight) :)

Price to repair was (excluding tools) around $4.

Things ordered from Aliexpress:

Cool links to follow when repairing

PS: a small advice at the end. Sort your screws to small groups, on some sticker or a stick tape, put them in that order as removed – as there’s a bunch of really small screws and almost every one differs from others

Side by side images

Quick script. As I’ve got FLIR images of my house, I wanted to have them side by side – original image + FLIR. So I wrote some small (fast) script in bash to do that.

#!/bin/bash

ir=IR_
img=DC_

im_start=$1
ir_start=$((im_start-1))

echo "Starting from $start - $(printf "%s%04d.jpg" $img $im_start)"
echo "IR will be from $ir_start - $(printf "%s%04d.jpg" $ir $ir_start)"

if [[ ! -f "$(printf "%s%04d.jpg" $img $im_start)" ]]; then
  echo "Image doesn't exist!"
  exit
fi

if [[ ! -f "$(printf "%s%04d.jpg" $ir $ir_start)" ]]; then
  echo "IR doesn't exist!"
  exit
fi

loop=1

while [ $loop -ne 0 ];do

  image=$(printf "%s%04d.jpg" $img $im_start)
  ir_image=$(printf "%s%04d.jpg" $ir $ir_start)

  combined_image=$(printf "flir-%04d-%04d.jpg" $im_start $ir_start)

  echo -n "$image + $ir_image --> $combined"
  montage -mode concatenate -tile x1 $image $ir_image $combined_image
  echo "..Done!"

  # increase
  im_start=$((im_start+2))
  ir_start=$((ir_start+2))

  #echo "Next file $(printf "%s%04d.jpg" $img $im_start)"

  # test if file?
  if [[ ! -f "$(printf "%s%04d.jpg" $img $im_start)" ]]; then
    loop=0
  fi
done

And the resulting image:

flir-0941-0940

sidekiq getting stuck?

We had quite strange scenario. Two hosts with sidekiq, one working well, second one gets stuck after few seconds or minutes. Happened in workers with opening new TCP/UDP connections. So, I started to review all the files, where ‘max files’ is set.

$ cat /etc/security/limits.conf
* soft nofile 30000
* hard nofile 60000

tom@web:~$ ulimit -Hn
60000
tom@web:~$ ulimit -Sn
30000

tom@web:~$ /sbin/sysctl -a | grep "file-max"
fs.file-max = 60000

So, all this looks OK so far. After numerous checks I’ve found, that our eye  process is running for a while, maybe since the beginning and probably it took old file-max  settings. How to check? Simply run eye info  or get PID of the sidekiq  process and run following command (assume 22613 is the PID):

tom@web:~$ cat /proc/22613/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             516140               516140               processes
Max open files            1024                 4096                 files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       516140               516140               signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

Gotcha! 1024 as soft-limit, 4096 hard limit. The fix is pretty simple – just quit eye , load it’s config and restart sidekiq.

tom@web:~$ eye quit
quit...

tom@web:~$ eye load config.eye
eye started!
config loaded!

tom@web~$ eye restart sidekiq

tom@web:~$ cat /proc/4624/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             516140               516140               processes
Max open files            30000                60000                files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       516140               516140               signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

voila! We’re back on track :)

sendmail + osx 10.10.4/ios 8.4/ios 9

After upgrade I was unable se to send mails through my sendmail, from both OSX 10.10.4 and upgraded iOS9 …

this was in my sendmail log:

Jul 12 19:58:03 orin sendmail[12164]: STARTTLS=server, error: accept failed=0, SSL_error=1, errno=0, retry=-1
Jul 12 19:58:03 orin sendmail[12164]: STARTTLS=server: 12164:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handsh
ake failure:s3_pkt.c:1053:SSL alert number 40

fix is amazingly easy and effective:

generate dh2048 certificate:

openssl gendh -out dh_2048.pem -2 2048

and add to sendmail.mc:

define(`confDH_PARAMETERS',`/etc/mail/certs/dh_2048.pem')

then recompile your .mc and restart sendmail.

BCD Boot troubles and WinMagic encryption

I’ve got a notebook to repair – HP ProBook, where Windows boot ended up with an error message – something about BCD. Tried to repair with standard tools, like recovery DVD, but without any success.

It was because main partition with OS was encrypted with WinMagic. So, now what?

Got some tools and info from local HP service, so you need to find our or get:

  • SDWinPEx64.iso
  • SDWmgRecovery package
  • encryption key or password (key is better)

So, now steps how to fix it:

  1. create bootable USB/DVD media with WinPE
  2. unpack and store SDWmgRecovery somewhere (USB flash)
  3. copy key to the same place
  4. boot with WinPE (takes a while, be patient)
  5. first of all, run TB Launcher/SD Recovery
  6. expand your hdd with all the partition and check Lock column
  7. select those with Lock as true (one by one)
  8. click Unlock and enter your password or open a key
  9. back to TB Launcher, open a file manager to check which disk letter belongs to Windows (eg. “d:”)
  10. open Console
  11. type bootsect /nt60 c: /force /mbr
  12. type bcdboot d:\windows /s c:
  13. reboot

It should be working fine now. :-)

Rubymotion – new bug found

I’m using this motion-addressbook in my project. Reported http://hipbyte.myjetbrains.com/youtrack/issue/RM-630

fixed in 2.37


= RubyMotion 2.37 =

* Fixed a regression where Dispatch.once did not work correctly when it was
invoked in some points.
* Fixed a bug where the compiler would crash with an assertion message
`[BUG] Object: SubtypeUntil ...' when compiling certain Ruby files.
* Fixed a bug in the compiler when compiling for ARM64 where certain types
would still be emitted with a 32-bit architecture in mind.
* Fixed a bug in the compiler when compiling for ARM64 where certain structs
would not be properly available (such as NSDecimal).