EmailTweetor v2019.02.20 for Android builds a list of tweets it creates

This feature should have been there from the beginning.

Earlier, the app used to copy the tweet URL to the email body. In this version, EmailTweetor will build a list at the bottom of the screen with the Twitter messages it creates. Each tweet in the list will have a context menu with which, you can copy the text or the URL. An option to delete/un-retweet/de-favourite the tweet is also available.

http://www.vsubhash.com/subhash-email-tweetor-app-for-android.html

Tweets, retweets and favorites are differently colored for easy identification.

Advertisements

3-LED flip-flop circuit

I made this circuit sometime back and I am still unsure of how it works. I saw a 2-LED version from Talking Electronics and tried this 3-LED version. All the explanations I found online are confusing. Apparently, one of the capacitors drains charge from its side of the circuit and switches off its transistor. The resistor connected to it ensures that it accumulates charge slowly. While this happens, it turns on the transistor on another side of the circuit. When that transistor turns on, the its LED lights up. When the first capacitor is fully charged, it stops supplying charge to this transistor and its LED turns off. By this time, its capacitor is accumulating charge and turning on another transistor and the LED connected to it turns on. This repeats one after another. At least, that is my understanding. It could be wrong. The flip-flop delay is controlled by the capacitor and resistor values. The voltage supplied to the circuit should be just enough to light up one LED.

Electronic Dice circuit using Arduino Uno

A re-creation of a e-Dice found in a children’s book

Some years ago, I went to a book exhibition where they literally sold imported books by the kilo. I am not speaking metaphorically. They sold books by weight. One of the books I bought was a children’s book. It had a circle-shaped plastic electronic toy stuck to the cover. It was an electronic dice. It cut through all pages and you could play a different board game on each of the pages in the book using the dice.

The dice construction was simple. Several LEDs were placed in a circle. When you pressed the center button, the LEDs lit up one after another along the circle. The dice also had a clear-plastic membrane speaker. The whole thing was powered using button-cell batteries. I saved the speaker and threw the dice away after the batteries ran out.

Silly me! I was then only interested in speaker circuits. Now that I am learning to play with Uno, I decided to re-create the dice. I have a ATtiny85 chip with which I will make this a self-contained toy. The ATtiny85 has 6 pins to connect the LEDs (I will hack the reset pin) and that leaves nothing for the speaker. I gave it a direct connection to power.

The circuit is simple. Connect the positive leads of the LEDs to the digital out pins marked for analog use (~). Connect the negative leads to a 220-ohm resistor. Connect the other end of the resistor to the ground pin on the Arduino. Connect the speaker parallel to the resistor. Add a 1uF capacitor to speaker terminals if the sound is weak.

Almost all dice circuits online are dumb. Not this one. It has sound and will be fun for kids to play with. I will order a circle-shaped sticker with numbers so that the dice is fully functional like the original toy.

How to make your website serve pages faster?

I made this list for CNN but it might be useful for any website owner.

CNN source code message

HTML source code at CNN.com has a hidden message. CNN Labs team asks for more ways to speed up their website.

I am always on the lookout for junk-serving domain names that I can add to my OS hosts file and CNN provided a number of them. Browsing through their source code, I found a message asking for ideas to improve site speeds. The CNN Labs team has already implemented several speed improvement techniques such as CDN, DNS prefetching, aysnc loads, and code minifying, and were interested in anything developers curious enough to look into their code could provide. Here are a few that I came up with:

  • Load HTML first. Everything else should be loaded afterwards. When CSS and JS are loaded along with HTML, they will block the display of the page content for at least one or two seconds. To do it properly, pre-press static HTML pages from your CMS and serve those static HTML pages to your visitors. Don’t put your HTML content in a database and serve them using a server-side script every time some one requests an article. Static HTML pages are served without any server-side processing latency. Like an image file, static pages are copied to the browser without any processing. They will not be parsed and interpreted like a PHP or ASPX script. (Pre-compiled scripts may be faster but not as fast as a simple file copy to an output response stream.) Use server-side scripts for what they were originally meant for – really dynamic stuff such as Ajax requests, database searches and changes, handling live data and processing user input.
  • Lazy-load Javascript files, CSS stylsheets, images and videos using Javascript code in the static HTML pages. (My unreleased CMS does these two things already – check out www.vsubhash.com. While this CMS is targeted at people with personal websites, these two ideas can reduce waiting times for any kind of website.)
  • Don’t use custom fonts that get automatically downloaded from your website or even the Google fonts repository. (CNN uses its own “CNN” font.) Use a universal stylesheet instead. Browsers can render web pages faster if they can use fonts already installed on the device. Does that make your webpages appear differently on different devices? Sweet mother of God! How will you survive? Really? No, sir, we don’t think much about your corporate/branding font. It barely registers on our minds. You are serving English text to an English audience. You don’t need a custom font. Custom fonts are meant for languages that don’t have universal device support or if the text is in a non-Unicode non-standard encoding tied to some legacy font. The need to display bar codes on a shopping site is a good use-case for a custom font. Emojis are not. Your EOT font download is likely to get stuck with all the other junk your page is downloading simultaneously. The visitor sees blanks everywhere in place of text, wondering what has gone wrong. Is that good for your corporate image? Don’t shock the user. Please learn about the Principle of Least Surprise (PLS).
  • Don’t think people with enough bandwidth will have no problem. Whether you are on a PC or a mobile device (good Linux computers exempted), there are hundreds of processes that are forever talking to base and downloading/uploading files and data.  Your webpage is competing with that and other tabs already opened in the browser. (Google’s policy states that Android will be talking to base, even if no app is running, even if it is in sleep mode, even if you have turned off wireless… So, imagine the situation when the device is being actively used.)
  • Don’t use images when the same effect can be achieved by CSS. But don’t use a CSS or Javascript framework when a simple image would do.
  • Don’t use a third-party CMS or big Javascript frameworks for your high-traffic website. This kind of software suffer from code bloat as CMS developers try to cram more features or try to make certain features work in all situations. Write your own CMS with custom Javascript and CSS optimized for your website. Maximum control & efficiency should be the goal. (CNN web pages, typical of off-the-shef CMS-driven websites, contain a ton of JS and CSS and very little HTML.) Another problem with popular CMS programs are that site admins well-versed with them are not easy to find. Even if you do find them, it may be difficult for them to determine what a piece of code is doing. You eventually end up hiring developers who can add extra or customized functionality over the CMS-generated Javascript and CSS. Good developers will write their own code but many will resort to using more third-party CMS plugins. Over time, the code bloat will get beyond control. Very few developers in the Web team will be familiar with the site’s code and be able to troubleshoot effectively.
  • When you use ad networks, it is inevitable that you lose some control. However, you:
    • can load their script asynchronously (as CNN has already done).
    • ensure that their code is within limits. Many ad networks download a ton of (the same) Javascript libraries to do the simplest of things.
    • do not use more than one ad network in one page serving. You can rotate different providers on different browser requests. If you hit so many third-party sites for one request, as CNN does, what efficiency will you achieve?
  • Don’t use autoplay videos, even if you are a TV news channel. Are you misrepresenting video plays to advertisers? What? Top tech companies do it as well? Well, it is not a matter of just ethics but money too. Be assured that autoplay videos are a waste of bandwidth when the visitor just wants to read your article or is already listening to music. Even with the inflated statistics, you will still lose money… over time.
  • Why use a third-party service to serve related articles from your own site? Ensure that your articles are tagged and categorized appropriately and serve their links on the sidebar, ordered by date and/or popularity. Ensure that this “related” stuff is not part of the static HTML churned out by your CMS. Lazy-load related content as well.
  • Limit the number of redirects in the links you post online. CNN links on Twitter pass through a maze of domains before settling down. These hops are time-consuming because they are on a https connection. Here is a list of redirects for one of their links (https://cnn.it/2DtZSme).
    • t.co (Twitter) to cnn.it
    • cnn.it to bit.ly
    • bit.ly to trib.al
    • trib.al to www․cnn.com
    • www․cnn.com to edition.cnn.com
  • Is your website accessibility-friendly? When you create an accessible website, you create a fast website by default. If you see more CSS+JS than HTML in a ‘View Source’, then your site is not accessible. It is not search engine-friendly either.
  • Don’t use pages that automatically reload. Are you a moron? (Not you, sir/madam, but I can list a dozen websites, a prominent news aggregation site among them, that do this without shame and this question is rhetorically addressed to them.) Use Ajax unobtrusively to change only the updated content.
  • Understand the principle behind Ajax. You display a page first and then use Ajax to inject data into it without reloading. Gmail does this in reverse. It will make you wait while it loads several megabytes of XML data, containing all your emails, before it displays your inbox – totally defeating the idea behind XML requests. Load what is not needed, not everything from the beginning of time.
  • Don’t use social media plugins as-is-where-is. They usually block the loading of the page. Study their no-script versions and use your Javascript to generate valid links dynamically.
  • Analytics code increases bloat , reduce the responsiveness of the site and increases bandwidth usage. Do you really need them? There are many free server software that can process server log files and generate insightful visitor stats. Check your CMS or ask your hosting provider. If you need to study click-intensive regions for improving site effectiveness, use them on a temporary basis and get rid of it once you have generated enough data.
  • Don’t think that as Javascript engines are so fast, browsers will have no problem with all the gunk you have included in your webpages. Nah-hah! Javascript engines may claim to be fast but HTML and CSS rendering is still slow. Don’t believe me? Check out my Javascript benchmark test. After that, add network latencies (over which you have no control) to the mix and judge for yourself.
  • Over time, your pages will become overweight and be lethargic. Either give your site a redesign or start afresh. If not, do regular weight trimming. Measure the dry and wet weight of a web page. Is it really worth it? Regular code reviews help identify parts that are no longer required and provide ideas to optimize CSS and JS.

How to get the silly Twitter verified status without any real verification

With this Greasemonkey script it is easy.

// ==UserScript==
// @name        Twitter Verified Status For Everyone
// @namespace   com.vsubhash.js.twitter-verified-status-for-everyone
// @include     https://twitter.com/*
// @version     1
// @grant       none
// ==/UserScript==

var oEls;
var sVerifiedHtml1 = "<span>‏</span><span class=\"UserBadges\"><span class=\"Icon Icon--verified\"><span class=\"u-hiddenVisually\">Verified account</span></span></span><span class=\"UserNameBreak\">&nbsp;</span></span>";
var sVerifiedHtml2 = "<span class=\"ProfileHeaderCard-badges\"><a href=\"/help/verified\" class=\"js-tooltip\" target=\"_blank\" title=\"Verified account\" data-placement=\"right\" rel=\"noopener\"><span class=\"Icon Icon--verified\"><span class=\"u-hiddenVisually\">Verified account</span></span></a></span>";


function addTwitterVerifiedStatus() {
	console.log("TVSFE: Changing HTML");
	oEls = document.getElementsByTagName("span");
	if (oEls.length > 0) {
		for (var i = 0; i < oEls.length; i++) {
			if (oEls[i].className) {
				if (oEls[i].className.indexOf("FullNameGroup") > -1) {
					if (oEls[i].innerHTML.indexOf("Icon Icon--verified") == -1) {
						oEls[i].innerHTML += sVerifiedHtml1;
						console.log("TVSFE: Screenname icon added");
					}
				}
			}
		}		
	}
	oEls = document.getElementsByClassName("ProfileHeaderCard-name");
	if (oEls.length > 0) {
		for (var i = 0; i < oEls.length; i++) {
			if (oEls[i].innerHTML.indexOf("ProfileHeaderCard-badges") == -1) {
				oEls[i].innerHTML += sVerifiedHtml2;
				console.log("TVSFE: Profile icon added");
			}
		}
	}	
}


function handle_DOMLoaded(aoEvent) {
	try {
		console.log("TVSFE: Page loaded");
		window.setTimeout(addTwitterVerifiedStatus, 3*1000);
		
		addTwitterVerifiedStatus();
	} catch (e) {
		console.error("TVSFE: Error - " + e);
	}
}


document.addEventListener("DOMContentLoaded", handle_DOMLoaded, false);

Double heroes of Hollywood

  • Bert Wheeler & Robert Woolsey: They ruled the 1930s with their comedy and musical act. In many of their movies, they played poor drifters or runaways eager for a break. The quiet and younger Wheeler played the straight guy while the sauve and pretend-sophisticated Woolsey took upon slightly crooked roles. Many of their movies had the adorable Dorothy Lee. The best movies I saw are:
  • Bud Abbot & Lou Costello: They were famous in the 1940s. They were vaudeville actors who moved to radio and then film and television. The fat Costello is the straight gullible guy while Bud Abbot is the scheming type. Costello is not very bright and does not understand words with more than three syllables. This creates several comedic situations in which Bud says something and Costello understands either the literal meaning or the something it sounds like. The most famous of such routines is “Who is on first”. Who or Hu is a player but Costello think he is asking a question. Then, Bud says Watt’s second and Costello thinks “What is second”. Some of their movies that I saw were:
    • Pardon My Sarong
    • Abbott and Costello Meet Frankenstein
    • Abbott and Costello Go to Mars
  • Bing Crosby and Bob Hope: Their “Road to” pictures are famous to this day. Road to Bali, Road to Hong Kong and Road to Singapore are among them. Beautiful actress Dorothy Lamour appeared in many of these movies.
  • Bud Spencer & Terrence Hill: These Italian actors were famous in the 1980s and made

    Bud Spencer and Terrence Hill

    several films set in the US and dubbed in English to the target the larger audience worldwide. Bud Spencer is the tall fat guy and his punches seemed to pack quite a lot of power and that was one of the reasons why people all over the world turned up at cinemas to watch his films. In one movie a tough takes a thick steel road and bends it with his bare hands. Bud Spencer picks up the bent bar and straightens it with his bare hands. Top that! When not being Chuck Norris, Bud Spencer is the most nicest guy except when he has to deal with the crooked blue-eyed Terrence Hill. Because of this, he becomes a hero to all kids who get to watch his films.  Bud Spencer has a website – https://en.budspencerofficial.com/ It is written in the same friendly and jovial character that he played in the movie.

    • Who finds a friend, finds a treasure
    • Double trouble
    • Miami cops

2-year user review of environment-friendly washing soaps (as opposed to detergents)

Two years ago, I purchased some bars of washing soap. The white more expensive one disappeared in a month. The yellow bar lasted well two years! I wash only my undergarments, lungis/mundus and the occasional blanket. Still, it is good value for money. If I had used detergents (made from petroleum), I would have gone through two dozen bars and it would have been more expensive too. So, the judgement is in favour of soaps on all counts.

IMPORTANT: Washing soaps need to be stored in an air-tight container. They seem to lose their softness if left out like detergents.

Two washing “soap” brands, available in Palakkad, Kerala.

NetCheck v2019.02.09 for Linux, Mac and Windows

NetCheck v2019.02.09 for #Linux, #Mac and #Windows adds ability change ping URL and interval (20 to 300 seconds) via the command-line arguments and notification tray icon menu. The Android version can already change the URL (but not the interval).

http://www.vsubhash.com/netcheck-app-for-android.html

 

Subhash TweetsToRSS v2019.02.04 for Android, Linux, Mac and Windows adds support animated GIFs and videos

A bug led to the discovery new capabilities.

EmailTweetor (desktop version) has the ability to post multiple images in one tweet. When checking this capability, I found to my dismay that TweetsToRSS was displaying only the last image in any tweet. Instead of += in the for loop, I had been using just =, which made the previous image details to be overwritten. I further explored the API and discovered support for animated GIFs and videos. So, the changes are:

  • Support for animated GIF images and videos.
  • Fix for bug which caused only the last image in a tweet to be displayed.
  • Fix for the bug (in Android) causing the locations.html file was displayed as raw HTML.
  • Fix for the following error, which caused the whole request to be cancelled if just one tweet in the list sent by Twitter generated it:

    404:The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the requested format is not supported by the requested method. message – No status found with that ID. code – 144

Support for animated GIFs and videos in Subhash TweetsToRSS

Subhash TweetsToRSS now displays multiples images and any GIF animations or video found in a tweet.

A news report playing as a video from a Twitter account