-rw-r--r-- 448B Feb 19, 2013 · C4B7FE3 · ~1 min

Phuket Airport Schizophrenia

phuket airport schizophrenia видео путешествия

I got back from Thailand. On the way home I had to wait six hours at night at Phuket airport before check-in for my flight started. I was really counting on the Irish pub at the airport, but it turned out it was open only until 11 pm. As a result, everything at the airport was closed except the flight check-in counters. During those six hours I explored all three floors of the airport, shot some video, and even found a power outlet to recharge.

[↵] open page phuket-airport-schizophrenia.md
-rw-r--r-- 1.6K Jan 10, 2013 · 87BA54F · ~2 min

PHP script for building all views in CouchDB

couchdb скрипты

I wrote this little script before New Year. It goes through all databases in CouchDB and builds all views one by one. Leaving it here.

<?php

            set_time_limit( 0 );

            // all dbs
            $ch = prepareCurlResource();
            curl_setopt( $ch, CURLOPT_URL, 'http://localhost:5984/_all_dbs' );
            $data = curl_exec( $ch );
            $dbs = json_decode( $data );

            foreach ( $dbs as $db ) {
                // skip _users and _replicator
                if ( substr( $db, 0, 1 ) == '_' )
                    continue;

                // getting all databases
                $chCC = prepareCurlResource();
                curl_setopt( $chCC, CURLOPT_URL, 'http://localhost:5984/' . $db . '/_all_docs?startkey="_design/"&endkey="_design0"&include_docs=true' );
                $data = json_decode( curl_exec( $chCC ) );

                if ( false === empty( $data->rows ) ) {
                    foreach( $data->rows as $design ) {

                        // creating views of design
                        if ( false === empty( $design->doc->views ) ) {
                            foreach( $design->doc->views as $viewName => $tmp ) {
                                echo 'Creating view: ' . $db . '/' . $design->id . '/_view/' . $viewName . "
";

                                $chCC = prepareCurlResource();
                                curl_setopt( $chCC, CURLOPT_URL, 'http://localhost:5984/' . $db . '/' . $design->id . '/_view/' . $viewName . '?limit=0' );
                                curl_exec( $chCC );
                            }
                        }
                    }
                }
            }

            function prepareCurlResource() {
            $ch = curl_init();
            curl_setopt( $ch, CURLOPT_PORT, 5984 );
            curl_setopt( $ch, CURLOPT_HEADER, false );
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
            curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-type: application/json' ) );

            return $ch;
            }
            
[↵] open page php-skript-dlya-sborki-vseh-vidov-v-couchdb.md
-rw-r--r-- 7.7K Dec 31, 2012 · 181EA8A · ~7 min

2012 in review

новый год итоги жизнь концерты итоги года

The year was insane. Packed. With everything that follows from that.

[↵] open page itogi-goda-2012.md
-rw-r--r-- 1.9K Dec 18, 2012 · EDC0F30 · ~2 min

Escaping image URLs with Russian filenames in Objective-C

objective-c ios

Management at the office started uploading images with Russian filenames into news on the portal — things like Фото-Ресторана.jpg.

Images from news items are shown inside the app, so the app fetches them by these URLs.

The URL arrives in the app already percent-encoded, e.g.:


http://allcafe.ru/s/pic/news/!_2012/2012_12/%D0%A0%D0%B5%D1%81%D1%82%D0%BE%D1%80%D0%B0%D0%BD-Graf-in-%D0%A1%D0%B0%D0%BD%D0%BA%D1%82-%D0%9F%D0%B5%D1%82%D0%B5%D1%80%D0%B1%D1%83%D1%80%D0%B3-%D0%B7%D0%B8%D0%BC%D0%BD%D1%8F%D1%8F-%D1%82%D0%B5%D1%80%D1%80%D0%B0%D1%81%D0%B0.jpg

The app uses a class called AsynchronousUIImage that I found online about a year ago. It just loads the image asynchronously via NSURLConnection.

- (void)loadImageFromURL:(NSString *)anUrl {
    anUrl = [anUrl stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:anUrl] 
        cachePolicy:NSURLRequestReturnCacheDataElseLoad 
        timeoutInterval:30.0
    ];

    connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}

The catch turned out to be in stringByAddingPercentEscapesUsingEncoding. Since the URLs come in already percent-encoded, it looks like double-encoding was happening and the image simply wouldn’t load. And if the NSURLConnectionDelegate method connection:didFailWithError: isn’t implemented, you get a crash — which is what hit me.

The funny conclusion: if you have URLs containing Cyrillic characters, you have to escape them either on the server before sending them to the client, or in the client. Doing it in both places — doesn’t work. Doing it nowhere — also doesn’t work :)

Luckily I fixed it on the server side without breaking anything and avoided shipping an emergency client update. By the way, on Android there is no such problem.

[↵] open page pro-ekranirovanie-url-ov-izobrazhenij-s-russkimi-imenami-v-objective-c.md
-rw-r--r-- 787B Dec 16, 2012 · 1B3F6E5 · ~1 min

Est Est Est at DA:DA on December 14, 2012, audio

есть есть есть бутлеги аудио

Est Est Est at DA:DA on December 12, 2012

Recorded an Est Est Est show for the third time.
They were presenting the new album «Satan on Vacation».

Cover photo by Dasha.

Tracklist:

01. Intro
02. Homer
03. Victory Day
04. Brodsky night, Svyatki skit
05. Svyatki
06. Plyonka
07. Kapitoshki
08. The Journalists
09. Already
10. Heroic Poem
11. Satan on Vacation
12. Spring
13. Résumé
14. Lisbon
15. Palette
16. The House Painter Duck
17. Autumn

Download (mp3, 320 kbps, 230 mb): Narod | Rutracker

[↵] open page est-est--est--v-klube-da-da-14-dekabrya-2012--audio.md
-rw-r--r-- 1.1K Dec 11, 2012 · 4AFEB6A · ~1 min

Optimising an iOS app for the iPhone 5 screen

шпаргалки ios objective-c iphone 5
  1. For the xib files of your View, set Size: Freeform. The interface will then stretch to the full height of the screen. If you need full control, you can set the view size for either the 3.5" or the 4" screen and switch programmatically.
    Optimising an iOS app for the iPhone 5 screen
  2. The most important thing — add a launch image for the 4" screen. Without it, the app for some reason thinks the screen is small. And yes, if you weren’t using a launch image at all before, looks like you’ll have to start now.
    Optimising an iOS app for the iPhone 5 screen

I haven’t tried this with Storyboard yet. And one more small handy trick — if you need to detect in code whether the screen is wide or regular, you can define this in prefix.pch:

#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON ) 

and then check it in code:

if ( IS_WIDESCREEN == YES ) {
    // use the 4" interface
} else {
    // use the 3.5" interface
}
[↵] open page optimizatsiya-ios-prilozheniya-dlya-ekrana-iphone-5.md
makoni@arm1:~/blog$ cd ../page-24/ // ← previous cd ./page-26/ // more posts →