I/O completion port’s advantages and disadvantages

Why do many people say I/O completion port is a fast and nice model? What are the I/O completion port’s advantages and disadvantages? I want to know some points which make the I/O completion port faster than other approaches. If you can explain it comparing to other models (select, epoll, traditional multithread/multiprocess), it would be … Read more

API Design: HTTP Basic Authentication vs API Token

I’m currently creating an authentication system on front of a public web API for a web application. Given that each user account has an API key and each request must be authenticated, I have two alternatives: Using an HTTP Basic Authentication, like GitHub does. Requests must be sent to the URL http://api.example.com/resource/id with basic authentication … Read more

Is it possible to create a Logon System with ASP.NET MVC but not use the MembershipProvider?

I have an existing database with a users table, and we are planning to take the database and use it for a new system built in ASP.NET MVC. However, what I am uncertain about is whether or not I am able to create a login system that doesn’t use the built in account controller or … Read more

How to achieve a Safe (!) authentication system in an angularjs app?

I’m new with angularjs… I read the docs, and completed the tutorial; i also tried something else by myself, and things start to make sense to me. Now i wonder how to make a safe authentication system. The easy part: no code, i will describe operations my code execute: I’ve a classic form: username, and … Read more

Creating a directory in /sdcard fails

I have been trying to create a directory in /sdcard programmatically, but it’s not working. The code below always outputs directory not created. boolean success = (new File(“/sdcard/map”)).mkdir(); if (!success) { Log.i(“directory not created”, “directory not created”); } else { Log.i(“directory created”, “directory created”); } Answer There are three things to consider here: Don’t assume … Read more

Sinatra – API – Authentication

We going to develop a little API application in Sinatra. What are the authentication options available to secure the API calls? Answer Sinatra has no built-in authentication support. There are some gems available, but most are designed for user authentication (i.e. for a website). For an API, they seem like overkill. It’s easy enough to … Read more

How to write bytes to a file in Python 3 without knowing the encoding?

In Python 2.x with ‘file-like’ object: sys.stdout.write(bytes_) tempfile.TemporaryFile().write(bytes_) open(‘filename’, ‘wb’).write(bytes_) StringIO().write(bytes_) How to do the same in Python 3? How to write equivalent of this Python 2.x code: def write(file_, bytes_): file_.write(bytes_) Note: sys.stdout is not always semantically a text stream. It might be beneficial to consider it as a stream of bytes sometimes. For … Read more