Posts

Connecting to the LAN using USB

The USB port on most routers is not actually for connecting computers. It’s for making storage devices (such as USB drives) accessible over the network. Many modern computers (such as the new Macs) do not have an Ethernet port. So the only way for them to connect to a network is either over the wireless, or using a USB-to-Ethernet adapter. But note that for the Mac to recognize the network connection over USB, the USB adapter has to be plugged in with a live Ethernet connection. If the Ethernet is turned on after the adapter is plugged in, the Mac won’t recognize the connection.

The Product vs Services Conundrum

Image
Have you read Peter Thiel's Zero to One? In simple terms: One to Two players are those who are focused on increasing revenue in an existing market. Zero to One players are those who creating a totally new market or new product. They will not have any competitors. Think of a startup like Facebook or WhatsApp. They have no customers, or competitors. That’s a zero to one startup. A completely new domain. Thiel was a founder of PayPal and the first investor of Facebook. Both zero to one startups. You will find the following model in a lot of startups: They will have a product division for long-term growth. But they will have a services division for meeting short term expenses. But the services division will always get more focus because it delivers revenue essential for survival. In my former employer's case, they were doing both with the same code. They were implementing the code at each client location for revenue. But they were also trying to build the code bas...

Drupal 7 Create Node With Specific NID using PHP

$node = new stdClass(); $node->type = "page"; // Sets some defaults. Invokes hook_prepare() and hook_node_prepare(). node_object_prepare($node); // Or e.g. 'en' if locale is enabled. $node->language = LANGUAGE_NONE; $node->uid = 234; // Status is 1 or 0; published or not. $node->status = 1; // Promote is 1 or 0; promoted to front page or not. $node->promote = 0; // Comment is 0, 1, 2; 0 = disabled, 1 = read only, or 2 = read/write. $node->comment = 0; $node->nid =123; $node->title = 'title 123'; $node->is_new = true; $node = node_submit($node); // Prepare node for saving node_save($node);

Cron on alternate weeks - Simple hack

The below cron entry will run a script file at 5am on every Sunday. 0 5 * * 0 sh script.sh Simply include the below three lines in your script to swap your actual code file with an empty file on every run. cp GetData.php Temp.php mv Swp.php GetData.php mv Temp.php Swp.php GetData.php = actual code Swp.php = blank file This will run the code only on alternate weeks.

iPhone - Keeping WiFi Connected

If your iPhone suddenly starts disconnecting from WiFi every time it's locked — maybe due to an update — the solution is to reset (only) your Network Settings .

Comparing C to Machine Language

Image
This video nicely demonstrates something I've been curious about for 24 years now; how high level languages translate to assembly code. (even though I hate code that has opening braces on the same line as the code) Observations: 1. C and ASM are very similar structurally, which means C does not lose any power through abstraction. 2. C abstracts the grunt work of remembering addresses etc so one can focus on the actual algorithm, and is also better structured which greatly improves readability. 3. ASM is not really that hard and is in fact, structurally simpler than C; somewhat similar to the original BASIC (basica.exe).

htaccess rewrite for https and www

RewriteCond %{ HTTPS } off # First rewrite to HTTPS: # Don't put www. here. If it is already there it will be included, if not # the subsequent rule will catch it. RewriteRule .* https ://%{ HTTP_HOST }%{ REQUEST_URI } [ L , R = 301 ] # Now, rewrite any request to the wrong domain to use www. # [NC] is a case-insensitive match RewriteCond %{ HTTP_HOST } !^ www\. [ NC ] RewriteRule .* https :// www .%{ HTTP_HOST }%{ REQUEST_URI } [ L , R = 301 ]