Stanford CS251: Lecture 3

Lecture 3: Bitcoin overview There are three Bitcoin protocols Consensus Protocol - decides what the ledger is Transaction Protocol - assigns meaning to the ledger Network Protocol - the P2P protocol which decides what new should be added to the ledger Consensus Protocol Bitcoin fields (Virtual field) Hash - 4 bytes. SHA256-squared. This is not part of the block but is calculated on the fly. Version - 4 bytes. Set to 3, might never change....

Stanford CS251: Lecture 2

Lecture 2: Creating a digital currency Desirable properties of a good digital ledger No deletion Temporal ordering Global consensus Semantic correctness Live - writable, no DOS, no censorship Attempts to create a digital currency in the increasing order of sophistication. A signing key based approach can confirm the authenticity of the transaction but cannot prevent double-spend. Append-only ledger with signing keys聽ensures a temporal ordering and global consensus, thus, prevents double-spending....

Stanford CS251: Lecture 1

Lecture 1: Introduction Bitcoin is a cryptocurrency with distributed trust. The blockchain is a public append-only ledger. The append-only property is sufficient for having a currency. Hash functions: H: M -> T where |M| 禄 |T| that is space of messages is larger than space of the hash. If H(m0) =H(m1) => collision. Hash function H is collision-resistant if it is hard to find the collision聽of H. For example, SHA-256 maps long strings to 256-bit hashes....

Iao Valley State Park

Maui (Hawaii) in 4 days

Maui is a small but beautiful island of Hawai鈥檌. Here is a recommended 4-day itinerary for Maui. This itinerary is a slightly modified version of what I was able to do. The public transport on the island is poor. For聽solo聽travel outside the rainy season, I would recommend renting a moped to go around. Otherwise, rent a car. The island has a much more developed western part consisting of Kaanapali and Lahaina, which have major聽resorts.

Closeum - closed-source in disguise

Earlier, the Software world was rigidly divided between closed and open-source software. Microsoft Windows is closed-source, GNU/Linux is open-source. Microsoft Office and Lotus Notes are closed-source, LibreOffice is open-source. Turbo C++ is closed-source, and GCC is open-source. But now, a new class of software products has emerged whose core is open-source, but still, the open-source software is of limited use. One model is to offer some critical and useful functionality in a closed-source layer via a managed service in AWS/GCP/Azure, for example, Redis is open-source, but useful modules on top of it are not....

Android: Fragment related pitfalls and how to avoid them

Don鈥檛 use platform fragments ( android.app.Fragment), they have been deprecated and can trigger version-specific bugs. Use the support library fragments ( android.support.v4.app.Fragment) instead. A Fragment is created explicitly via your code or recreated implicitly by the FragmentManager. The FragmentManager can only recreate a Fragment if it鈥檚 a public non-anonymous class. To test for this, rotate your screen while the Fragment is visible. FragmentTransaction#commit can fail if the activity has been destroyed....

Bora Bora as seen from Motu Tapu

Cruising in French Polynesia

We sailed on the Windstar cruise in French Polynesia. On a 7-day cruise, we stopped on six different islands, including two days in Bora Bora. The cruise ship has a crew of 99 and 74 staterooms for~150 passengers. This ratio ensures exceptionally personalized service, and you get to know pretty much everyone else on the ship. The crew members learn everyone鈥檚 name pretty quickly, and, especially, in our case, we got custom orders for vegetarian food of our choice regularly.

Water Bungalows in Bora Bora

French Polynesia - the basics

Getting to French Polynesia Getting from the US to French Polynesia used to be hard and expensive, with Air Tahiti Nui being the only option from the Los Angeles airport (LAX). In 2018, French Bee and United Airlines started direct flights from San Francisco (SFO) to Papeete (PPT). Papeete, the main island, is relatively dull, and there is nothing much to do at it. The two best islands are Moorea and Bora Bora. Alternatively, one can take a 10+ day-long cruise from New Zealand or Australia. Do check whether you need a TOM visa or not on the official website. For some nationalities like India, a French Schengen visa suffices.

Android: Handling JPEG images with Exif orientation flags

A JPEG file can have Exif metadata聽which can provide the rotation/translation field information for a raw JPEG image. So, a landscape raw JPEG image could actually be a portrait聽because it鈥檚 EXIF聽orientation could be set to ORIENTATION_ROTATE_90, the best way to handle such scenarios is to either use a library like Picasso or Glide or at least learn from them. Here is a piece of code from Picasso which loads a JPEG as an in-memory bitmap and performs the right translation/rotation....

Sipapu Bridge

Hiking Natural Bridges National Monument

Natural Bridges National Monument聽in Utah is a National Park consisting of three natural bridges. One can spend ~1-3 hours hiking nearby each of the bridges. The hikes are short and require ascent/descent. Even without the hike, one can drive around to see the views.