browse by category or date

When I was writing the previous post, I found numerous scenarios which JSON Table Editor unable to handle. These scenarios are based on three factors:

  1. Separator. Is the column separated by comma? Or tabs? Or fixed length?
  2. Name. Does the data has the column names in the beginning? Does these names only contained in one line? Or it’s spread across multiple lines?
  3. Start Location. Does the data started from the first line? Or we need to ignore a number of lines before arrive at the data?
  4. End Location. Does the data all the way to the end of the file? Or there are non-data lines at the end of the file?

The earlier version of CSV-handling functionality didn’t consider above factors. It simply assume that your CSV is comma-separated (Duh!). It has header on the first line. And the data goes all the way until the end of the file. Which is way it might not for your use-case.

The good thing is, I have take these factors into consideration. Without further ado, below are some of the test scenarios:

  1. Standard CSV file. Source file: LINK. Loaded in Editor: LINK
  2. Standard CSV file without header. Source file: LINK. Loaded in Editor: LINK
  3. TAB-separated text file without header. Source file: LINK. Loaded in Editor: LINK
  4. Text file with fixed-length columns. Source file: LINK. Loaded in Editor: LINK
  5. Fixed-length columns text file where the header is not on the first line. Source file: LINK. Loaded in Editor: LINK
  6. Fixed-length columns text file where the header is multi-lines. Source file: LINK. Loaded in Editor: LINK

What do you think? Is there any other factors that I can incorporate into the Editor?

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 9 years.

Since my last post, I’ve been adding new features to JSON Table Editor. Here are the enhancements:

  1. Button labels and tool-tips.
    As I carefully observe the page, I asked myself whether the user interface is intuitive enough. From there, I changed some of the button labels with a clearer text. I also added additional information whenever user hover above certain controls. Hopefully this will make the UI less confusing.

    On the sub-level, the “Output to JSON” button is changed to “Finish Editing”.

  2. Instantly load remote JSON/CSV file.
    Not sure why I never think of this feature before. Now we can make the editor to automatically load a remote JSON/CSV file by passing parameters.
    Example:

  3. URL Shortener.
    The URL described in point no. 2 will be very long. Sharing this long URL is definitely look ugly. Thus, I added option to shorten the URL whenever a remote JSON/CSV fis is successfully loaded.

     

  4. Upload to Paste Sites
    A long time ago, a user complained why he can’t save the JSON output to other online storage like Google Docs/Spreadsheet. Since I don’t think a JSON file will fit nicely to a Google Spreadsheet, I decided to look other alternatives on storing text online. After short research, I picked Hastebin, Pastebin and DPaste as the upload destination. Purely due to the easiness to use their API.

That’s all guys. Looking forward to your feature request, bug reports! Cheers!

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 9 years.

Five years ago, I created JSON Table Editor. Recently I have the time to revisit the project and do some minor bug fixes and enhancements.

  1. Array editing.
    In previous version, loading an array of string will give you a table of characters. This is embarrassingly wrong.

    The updated version has no more of this problem.

  2. Improvements on multi-level object editing.
    I changed the button title from ‘Save to Upper Level’ to ‘Finish Editing’, which is more appropriate. I also make the window closed when you click ‘Finish Editing’ button. I also show the updated JSON so we can notice the changes.

    The changes also propagated all the way to the top. In previous version, on each child-window we need to click the ‘Save to Upper Level’ button.

  3. Limiting the proxy
    The proxy in the previous version is just a dumb proxy. It fetches any url requested and dump whatever content. I see a potential misuse here. So I limit the proxy to only fetch JSON, CSV and raw/text content.

    <?php
    	$qUrl = $_REQUEST["q"];
    	// create a new cURL resource
    	$ch = curl_init();
    	// set the URL
    	curl_setopt($ch, CURLOPT_URL, $qUrl);
    	// get only the Head
    	curl_setopt($ch, CURLOPT_NOBODY, true);
    	// curl_exec return value instead of directly to out
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    	// do the request
    	$res = curl_exec($ch);
    	// check the content type
    	$contentType = curl_getinfo ($ch, CURLINFO_CONTENT_TYPE);
    	//only accept json, csv
    	curl_close($ch);
    	
    	//error_log($contentType);
    	
    	if (strpos($contentType,'/json')!== false || strpos($contentType, '/csv')!== false || strpos($contentType, 'text/plain')!== false)
    	{
    		// ... SNIP ...
    		// Normal CURL processing
    	}
    	else {
    		//error_log('Not JSON');
    		echo "Invalid resource. We only retrieve JSON/CSV/text resource. The requested URL returned ".$contentType;
    	}
    ?>
    
  4. That’s all, folks! Looking forward to hear your thoughts. Cheers!

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 9 years.

I first encountered this problem last Saturday. I made small modification to my blog’s theme, but I couldn’t see the changes. I want to change the display of posts with certain category. Here’s the change in index.php

<h1>
	<?php if (has_category('tweet')) { 
		the_title(); 
	} 
	else { ?>
		<a href="<?php the_permalink()?>" rel="bookmark" title="Permalink to: <?php the_title_attribute();?>">
			<?php the_title();?>
		</a>
	<?php } ?>
</h1>

So if the post has category ‘tweet’, the title will be just a text, not a link to single.php. But this simple change simply never appears. These are the steps I took in my quest to clear the PHP/Wordpress cache.

  1. W3 Total Cache’s Purge All caches.

    This blog is using W3 Total Cache plugin. This plugin provide 1-click to clear all the caches. Unfortunately, I still can’t see the changes after clicking the ‘Purge All Caches’ link. [ FAILED ]

  2. Restart Web Server
    One of the recommendation to clear the cache is by restarting the webserver. Since this blog is using Nginx, I run the following command.

     service nginx restart
    

    Again, this step also unable to clear the cache. [ FAILED ]

  3. Restart PHP Service
    Another recommendation is by reloading the PHP service. Since I didn’t know which service to restart, I run the following to list all services.

     service --status-all
    


    Then I restart/reload the PHP service.

     service php7.0-fpm reload
    

    Blast! This step is still unable to clear the cache [ FAILED ]

  4. Reset OpCache
    I also saw recommendation on how to clear PHP’s caching mechanism. I created flush.php in my web root.

    <?php
       opcache_reset();
    ?>
    

    Then I open the URL (https://sodeve.net/flush.php) in my browser, continued with opening this blog in a new tab. Alas! I still can’t see the changes.

  5. Desperate Actions
    Desperate because of the continuing failure, I tried some other steps like rebooting the web server

     shutdown -r now
    

    I also deactivated the W3 Total Cache plugin. All proven to be fruitless. [ FAILED ]

  6. Finally
    On my final attempt before giving up, I created info.php

    <?php
       //Delete the file after usage!!!
       phpinfo();
    ?>
    

    I open the page in my browser, then hit Ctrl+F and typed ‘cache’. After lots of F3s, I found this line:

    This could be the key! I checked the folder listed in opcache.file_cache, I found a folder with a random-generated name. I deleted that folder and Voila! My changes is now shown [ SUCCESS ]

Lesson Learned

If I make changes to WordPress blog content, I need to flush the cache using W3 Total Cache’s Purge All Caches. But if I make changes to the blog’s source code (php files), I need to delete the folder inside opcache.file_cache.

That’s all folks! I hope it helps. Cheers!

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 9 years.

Today I encountered a strange problem when debugging our company’s Ionic Android web app. Inside chrome://inspect tab, I clicked the inspect link for the app.

The pop-up window was totally blank. Puzzled, I clicked the blank window and press Ctrl+Shift+I to inspect the blank Inspect window (Inspect-ception, if I may 😀 ). And voila, the errors revealed:

inspector.js:8635 Uncaught TypeError: InspectorFrontendHost.setOpenNewWindowForPopups is not a function at Main.BackendSettingsSync._updateAutoAttach (inspector.js:8635)
at new Main.BackendSettingsSync (inspector.js:8633)
at Main.Main._createAppUI (inspector.js:8577)
at Main.Main._gotPreferences (inspector.js:8567)
at DevToolsAPIImpl.embedderMessageAck (devtools_compatibility.js:33)
at <anonymous>:1:13

When I googled the error message, the first result was this forum post which was posted 5 days ago (8th March 2018). Skimming through the comments, it seems the problem will be fixed by updating Chrome. True enough, when I go to Help -> About Chrome menu, it asking me to update.

After the download completed, click the RELAUNCH button to restart Chrome.

SOLVED!!!

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 9 years.

The past few days I have been scratching my head due to this seemingly simple problem. I can’t change the order of the pages in my Visio document.

Everytime I tried to drag the tab and change the order, it simply refused as shown above.

Today, I finally found out the cause. I need to change the Page Type from Backgroundto Foreground.

Once I did change to all pages, I noticed that the tab title is no longer italic.

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 9 years.