Swift 3.0 changes

Erica Sadun wrote a good article on what’s coming up in Swift 3.0. Funny, how many people noticed that “++” and “–” operators are going to be cut. Honestly, it’s not important thing in the world of iterators and dynamic arrays. However, I don’t like the trend of calling indexes evil. People, do you understand what random access in arrays existed for!? How about matrixes and vector operations? Programming is not just about traversing sets and maps.
Another takeout from the Swift 3.0 is that most of improvements are in the department of code styling, syntax sugaring, interoperability API’s and future versions of Swift, meaning that language finally becomes stable. It’s a good thing, right? 🙂

Anyway, here’s the article.

Free Icons for Web Designers

Speaking of the web design. If you’re looking for a free vector art (mostly icons), you can look at this list of sources, which was put together by this guy:
https://habrahabr.ru/post/276249/
Text is in Russian, but self descriptive and does require translation really.
Thanks to Sergey Vakulenko for the find!

HTML and CSS Editors

HTML Editor

Many people google HTML and CSS editors and get basically the same list of articles. If you’re tired of articles talking about obscure commercial product or Aptana or Notepad, you should look at this article:

Very informative and simple. The reason why I started looking around is that I don’t have Dreamweaver license anymore and not going to buy it and because I’m tired from Aptana. It’s ok to use for syntax checks and highlights, but I wanted something more visual. I don’t expect a miracle of discovering full WYSIWIG editor for free, but it’s be nice to find something that can do CSS and div’s editing visually. Your suggestions are welcome as usual. I guess, I’ll return to this subject eventually again.

Google Depot Tools bug on iOS

Hope it will save some time for you. If you see

AssertionError: Multiple codesigning identities for identity: iPhone Developer

and don’t know how to fix, when building webrtc, libyuv or any other libraries with Google’s depot tools, simplest fix you can do is just remove the assertion. You don’t need developer’s profile and binary singing for libraries. That’s obvious for you, but not obvious for the script. 🙂 In my case, I found the assertion in the /chromium/src/tools/gyp/pylib/gyp/xcode_emulation.py.

P.S. Found similar post on Stackoverflow.

Javascript’s this is nuts

It’s not going to be a rant as title might suggest you. I’ve been reading a book about Phonegap (now known as Apache Cordova), and came across a cool remark in the text:

Javascript’s this is a bit
nuts, so it’s always better to refer to a variable that we know
will always refer to the object.

I smiled. This remark was referring to a simple code that had this assignment:

self = this

I’ve learned about JS “this” the hard way. Indeed, it’s not intuitive and goes against what developer learned from other languages. Anyway, I thought I know how it works well… until I read this quote. I went back online to refresh my knowledge, just to learn the damn thing again. 🙂 Anyway, in case if you’re in the same boat, old friend MDN (Mozilla Developer Network) is your friend. That’s the best article about “this” scope, strict and non-strict mode (who came up with these names!?), syntax for event handlers etc.

Here’s the link

asm.js

Idea of using Javascript as an intermediate for different programming languages is not new. I can say exact same thing about attempts to make browser runtimes closer to hardware. There was a big push toward JVM and Java in general at one point. Then Google did a splash with NaCl (which stand for Native Client). Developers needed a high performance secure environment to build efficient browser apps and have a path of porting existing apps from C/C++ realm to Javascript. asm.js supposedly is going to solve this issue by introducing a Javascript library and cross-complier from other high level languages into asm.js.
And this attempt is more serious than previous ones. For starters, it’s supported by Javascript godfather Brandon Eich.
Here’s his interview on this matter:
https://medium.com/javascript-scene/why-we-need-webassembly-an-interview-with-brendan-eich-7fb2a60b0723

From one side, this does not sound like a best solution for porting high performance apps like games (more exact, game engines), but since W3C will never come to agreement on lower level solutions, asm.js AKA Web Assembly may be the best compromise of the moment. It’s going to be based on many hacks and quirks. For instance, they virtually are going to disable GC. It did not take 20 years for web developers to understand that GC is a… garbage that they have to deal when it comes to speed optimization. There will be hacks around offline downloadable binaries or something like that. Otherwise, loading big games will be going to be a major pain. Anyway, it looks like major game engine developers are on board. Unity and Unreal already got prototypes and whole thing looks more promising than NaCl initiative.

Here’s another good article about Web Assembly:
http://ejohn.org/blog/asmjs-javascript-compile-target/

Unreal Engine is free now!

images

Epic Megagames decided to make Unreal Engine free. Good news!
Here’s the announcement and video message from Tim Sweeney:

Nice SWIFT tutorial from AirPair

In case if you want to get a basic introduction on what SWIFT is all about, look here:

Radio Shack TRS-80

Radio Shack is definitely dying, but its legacy will not die for sure. 🙂 Exactly 27 years ago in August of 1977 Radio Shack started sales of the first real home computer.
It did not have much of software at launch, had poor video text-only video controller, small amount of RAM (4Kb), crippled built-in Basic, crappy video monitor that could be purchased together with the bundle, but it was good enough to break sales records and create new market of home computers. Couple years later, Radio Shack could brag about having the largest available software library on the market, thanks to enthusiasts and young software company that were born together with birth of Apple II, Commodore PET and Radio Shack TRS-80, – three most popular mass produced computers of that time, together called “Trinity” by Byte magazine.

TRS-80

Authentication API for Ruby on Rails (Devise)

Devise is a commonly used authentication gem for Rails projects. It comes with controllers, data model and html templates that don’t require much time for configuration. Basically it works just out of the box for web projects. However, to my surprise, Devise is not that friendly with non-web clients. Say, you’ve built a REST API that works with your web app and now you want to reuse it with mobile native apps. Sounds reasonable and easy to do at first glance, isn’t it? Well, it’s not that easy with Devise.
If you try to google solutions for this matter, most likely you’ll stumble upon articles, talking about token authentication approach, similar to this one:
http://matteomelani.wordpress.com/2011/10/17/authentication-for-mobile-devices/
Unfortunately, this solution does not work anymore, because Devise changed.
It’s still possible to use token authentication, but you have to modify the code of your Session controller and Devise itself. I found that using token is not necessary as authentication cookies were working too. I did not need to change the Devise and append every single URL with ?auth_token=.
In one of the Devise own examples called “Simple Token Authentication” you can find following message:

Note: these examples are out of date, TokenAuthenticatable has been removed from Devise. See this gist for alternatives.

Here’s the gist it’s referencing to:
https://gist.github.com/josevalim/fb706b1e933ef01e4fb6

New article on how to build an API with Devise authentication:
http://www.soryy.com/ruby/api/rails/authentication/2014/03/16/apis-with-devise.html

Good article with the example that returns authentication token and result of the authentication back to the client:
http://jessewolgamott.com/blog/2012/01/19/the-one-with-a-json-api-login-using-devise

Basically, in order to make token authentication work again, you need to merge modifications for ApplicationController from gist I mentioned above and SessionController the way it’s shown in the last article.

My SessionController looks like this:

class SessionsController < Devise::SessionsController
  skip_before_filter :verify_authenticity_token

  def create
    respond_to do |format|
      format.html do
        params[:user].merge!(remember_me: 1)
        super
      end
      format.json do
        resource = User.find_for_database_authentication(:email => params[:email])
        return invalid_login_attempt unless resource
        resource.ensure_authentication_token

        if resource.valid_password?(params[:password])
          sign_in(:user, resource)
          render :json => {:success => true, :auth_token => resource.authentication_token, :email => resource.email}
        else
          invalid_login_attempt
        end
      end
    end
  end

  def invalid_login_attempt
    render :json => {:success => false, :error => "invalid login"}
  end

end

Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.