-rw-r--r-- 9.2K Nov 13, 2014 · 9717C8C · ~7 min

How to update a Hackintosh from OS X Mavericks to Yosemite

хакинтош os x yosemite mavericks шпаргалки

How to update a Hackintosh from OS X Mavericks to Yosemite

I finally updated my work Hackintosh from OS X 10.9 to 10.10. It took a lot of time. Here is how I did it and what problems I ran into.

[↵] open page kak-obnovit-hakintosh-s-os-x-mavericks-do-yosemite.md
-rw-r--r-- 2.0K Oct 9, 2014 · 786D734 · ~2 min

A note about HTTPS and VK apps

https ssl nginx вк

Once browsers realize that a site can be opened over https, they no longer want to open it over plain http. Firefox and Chrome definitely behave like that. VKontakte is an example. And once a site is opened over https, some resources on the page may still be loaded over http, but not Javascript files. Those get blocked and must be loaded over https only.

Today I was making a simple iframe app for VK. Basically it was just a lightly styled php page into which I inserted the php code of a ticket booking and purchase system. After setting the URL in the VK app, I discovered that VK works over HTTPS and my page was also trying to load over HTTPS. Since my server did not support https, I had to configure it.

I got the certificate from StartSSL for free. I configured everything, everything started working (my blog could now also be opened as https://arm1.ru — I turned that off and left only http for now, because all Disqus comments and social-media likes broke :) and I do not really need https on that domain anyway), hallelujah, the script started loading. But the PHP code of the ticket system essentially returns its own HTML, and that HTML loads various js code over http. Since that gets blocked, nothing works again :) It is a hellish chain, really. VK -> iframe -> my server -> ticket server. Now I am waiting for them to set up https on their side and serve all js code over it.

But I did get a couple of useful lessons out of it.

  1. Whenever possible, load external js not as “http://site.com/code.js” but as “//site.com/code.js”. The // means “use the current connection protocol”. The browser handles the check, so you do not need to check the protocol in code yourself.
  2. Experience gained from bringing up and configuring https on my own server. Two guides so I do not lose them:
    1. Getting a free SSL certificate (via StartSSL).
    2. Configuring an HTTPS server in nginx.

Now the main thing is not to forget that in a year the SSL certificate will need to be renewed.

[↵] open page zametka-pro-https-i-prilozheniya-dlya-vk.md
-rw-r--r-- 1.5K Sep 18, 2014 · 6ECD816 · ~2 min

Safari extension for Funkysouls.com

safari javascript расширения funky-play

Safari extension for Funkysouls.com

I stop by Funkysouls from time to time looking for new music. I scroll through the first few pages, check the tags to see whether it might be interesting, then copy the artist name, go to VK or Yandex.Music, paste it there, and listen to a couple of tracks. If I like it, only then do I try to get the album.

I got tired of all that copy-pasting and wrote a Safari extension (I had been wanting to learn how for a while).

The extension does only 2 things:

  1. When you open Funkysouls, each release gets 2 Play buttons, as you can see in the screenshot. The red one searches for the artist on Yandex.Music, the blue one searches for the artist on VK. No more copy-pasting. 2 clicks and you are listening.
  2. I got slightly carried away while writing it and also added a browser toolbar panel. The extension fetches the site’s RSS feed every 5 minutes and shows the latest 3 releases in the toolbar. So you can follow them without even opening the site. Naturally, if you click a release title in the toolbar, a new tab opens with that release page on Funkysouls.

If you want, you can take the extension code from end.js and button.css, paste it into something like the Control Freak extension in Chrome, and get the same 2 Play buttons in Chrome. I assume you could do the same in Firefox through Greasemonkey.

Source code on GitHub.

Install extension.

[↵] open page rasshirenie-dlya-safari-dlya-funkysouls-com.md
-rw-r--r-- 6.3K Sep 16, 2014 · A3123D2 · ~4 min

HTML5 video as a page background

html5 javascript css3 video

HTML5 video as a page background

I recently made a promo page for Dolphin’s site for a book of poems that is coming out soon. During the discussion I suggested making it in the form of video, so the animations would look nice. Along the way a few nuances surfaced.

[↵] open page html5-video-kak-fon-stranitsy.md
-rw-r--r-- 3.0K Aug 19, 2014 · B3B2675 · ~3 min

Escaping the sandbox in iOS

ios xcode jailbreak боль

A post born of pain. It just so happens that right now I am poking at someone else’s project that is designed to run on jailbroken iPhones. And not just run on them — it needs access outside the sandbox.

As everyone knows, all apps in iOS run inside a sandbox and cannot go outside it. All App Store apps are installed into /var/mobile/Applications/ (apps installed onto an iPhone from Xcode go there as well), where a separate folder with an unreadable name is created for each app. You cannot go outside that folder. Not for reading and certainly not for writing.

Escaping the sandbox in iOS

This, for example, is the folder of Google’s Ingress game.

Escaping the sandbox in iOS

And this is the iOS Calculator app, for example, living in /Applications.

If we want, for example, to read the phone’s SMS messages from inside an app, we need to read the file /var/mobile/Library/SMS/sms.db — it is a regular SQLite database with no encryption or protection. You can download it from a jailbroken phone and open it with any tool that knows how to open SQLite files, look at all SMS messages, and even hammer it with sql queries for search and other tasks.

Escaping the sandbox in iOS

Here, for example, is the file with all iPhone SMS messages.

So, there is no access to that file from the sandbox. And Jailbreak does not solve that. It gives full access to the file system, but only if you are working outside the sandbox.

For an app to work outside the sandbox, it has to be moved from /var/mobile/Applications/ to the /Applications directory. Then the app will live in the system apps folder, have access to the file system on a jailbroken device, not be removable from the phone by holding a finger on its icon, and so on.

And that is where the pain starts: Xcode simply cannot install the app there; it can install only into the sandbox. You can do it by hand — connect to the phone and move it with something like iFunBox — but that is a huge pain every single time. The worst part is that you lose the convenience of debugging. You cannot run the app on the device from Xcode and calmly watch the console to see what your app is printing and whether it is working.

No tweaks from Cydia that supposedly give apps file-system access even from inside the sandbox had any effect. At least not for me on iOS 7.1.2. They say that even if you run the app as root but still inside the sandbox, it still will not get permission to read system directories. Although it feels like this used to work before, but jailbreaks were different back then too.

That is the hell I am in. In the near future I am going to try some scripts I found online to automate moving the app around inside the iPhone after the build via SSH while also capturing syslog. I also want to write up what I have dug out inside the iPhone in terms of “where everything is stored”, but later, once this hell is over :)

[↵] open page vyhod-za-predely-pesochnitsy-v-ios.md
-rw-r--r-- 1.8K Aug 13, 2014 · 0B5B06B · ~2 min

node-couchdb-mover

node.js couchdb полезное

node-couchdb-mover

A few days ago I wrote my first Node.js tool. I wrote it only partly for myself, because for me it is not very relevant yet, but for some people it very much is.

The tool is for CouchDB. Since CouchDB keeps document revisions after changes and deletions and does not always clean them up, a database can grow like crazy. For example, for the guys who need this tool right now, something that should weigh 6 GB weighs 50-60. Maybe they started something somewhere or messed something up, changed and wrote a ton of stuff into the database, and that blew up its size. So, overall, it is easier to just create a new clean database and move all live documents there.

The tool simply takes all documents from 1 database in CouchDB and puts them into another one. For now it works rather crudely: it grabs all documents in one shot and then inserts them into the database one by one. For databases with a relatively small number of documents it works fine, but if there are something like 80 thousand documents, fetching them on my computer took about 4-5 minutes. So I will rework it soon so that it pulls documents in batches and writes them to the database sequentially instead of asynchronously.

But it is already usable. You can embed the tool into your own Node.js project, for example.

In the console:

npm install node-couchdb-mover

In code:

var mover = require('node-couchdb-mover');
mover.moveDocuments('dbName1', 'dbName2');

It can also be used directly from the console:

npm install -g node-couchdb-mover
couchdb-mover --from=dbName1 --to=dbName2

And, as expected, here are the sources on GitHub and the package on npmjs.org.

[↵] open page node-couchdb-mover.md
-rw-r--r-- 826B Jul 3, 2014 · 770754A · ~1 min

How to tell whether a display is Retina or not?

retina баловство полезное

How to tell whether a display is Retina or not?

My blog gets a lot of search-engine traffic for queries like “How to detect a Retina display”. People land on my article about Objective-C, but they are clearly not looking for code :) So I ended up making a page like this one: you just open it in the browser on your device. If it is Retina, the result is green, like in the screenshot above. If it is not Retina, it is red, like in the screenshot below.

How to tell whether a display is Retina or not?

It works for iOS devices (iPhone, iPad, iPod) and Macs with a Retina display. On screens with a high pixel density it also says Retina :)

Page URL: https://arm1.ru/retina/

[↵] open page kak-uznat-retina-displej-ili-net.md
makoni@arm1:~/blog$ cd ../page-18/ // ← previous cd ./page-20/ // more posts →