R – Četnost podruhé

Mějme následující data:

A potřebujeme zjistit absolutní a relativní četnost výskytu žen a mužů, rozdělenou ještě podle hodnoty v type .

Opět převedeme na data frame

A máme absolutní četnost. Teď vypočítáme relativní četnost.

Což znamená: pro každý subset z framu tbl.frame , rozdělený podle proměnné Var2 , proveď transform , a vypočti relativní četnost podle frekvence (abs. četnosti) a součtu hodnot frekvence.

R – četnost a graf

Dostal jsem pověření z nejvyšších míst vyrobit statistické zhodnocení dotazníků. A protože bytostně nemám rád Excel, našel jsem R a zkouším.

Udělal jsem data do CSV souboru a nahrál do R (RStudio)

Zkusíme vyrobit četnost vzdělání (edu) a potom ji ještě rozdělit podle pohlaví (gender).

Máme tabulku, ale potřebujeme z ní frame

Přidáme relativní četnost (mean)

A teď na graf. Používáme ggplot2.

Rplot1

Fajn. Ale chceme graf otočit

Rplot2

Teď ještě smazat popisek osy x a přepsat osu y.

Rplot3

A finálně přidáme hodnoty frekvence do jednotlivých sloupců.

Rplot4

A teď trochu komplexněji. Ještě to rozdělíme na muže a ženy..

a přidáme graf

Rplot6

A co když budeme chtít jeden bar, ale rozdělený podle hodnot?

A graf

Rplot7

 

STM32F4Discovery + eLua + OSX

I fixed few bugs when compiling elua from git on osx – clone my branch clone official repo here.

create .bin file

create openocd config file for stm32f4 board:

and upload to the board:

Now you can connect to the board using /dev/tty.usbmodem621, 115200/8/n/1. You should get this prompt:

enjoy :)

nodemcu – simple webserver

I’ve modified and updated this source:

nodemcu + el capitan

To flash

  • upgrade firmware

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.

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.

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):

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

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:

fix is amazingly easy and effective:

generate dh2048 certificate:

and add to sendmail.mc:

then recompile your .mc and restart sendmail.