AMA recommended to reduce cycling speed on footpaths to 10 KPH and mandatory helmet on roads. It provoked quite a stir in the cycling community even resulted in the resignation of a member of the panel.
The reduction from 15 KPH to 10 KPH is probably in view of the increase of accidents between PMDs and pedestrians. It is quite difficult to judge whether it is appropriate as 10 KPH is considered very slow to cyclists. However, if it endangers pedestrians even on 15 KPH, it is for the good of pedestrians.
Dutch cycling rule prohibits cycling on footpaths and walkways. They have the most cyclist population. Their consideration is appropriate to protect pedestrians. However, they have extensive dedicated cycling paths which we are trying to achieve. In view of this, cycling on footpaths and walkways is an alternative but if it cause more injuries to pedestrians, the compromise should be to reduce speed.
I used to commute around and often encounters a lot of pedestrians on footpaths. It is almost impossible to cycle greater than 10 KPH. At times, I have to just patiently follow elderly folks at their speed. I don't advocate using bells to get people to give way. They have the same right to use the path. Moreover, pedestrians do not have "keep left" rule. They can any how walk on the footpath. Often two or more people will give way to both sides and I have to slowly inch forward between them so as not to accidentally make contact.
Obviously, if the footpath is empty then the law should close one eye and allow faster speeds. It should be a responsible cycling style rather than a regulated cycling style.
On mandatory cycling helmets on road. It is a very controversial issue. On the one end it is to provide some form of protection. On the other, it is not convenient for many users. For myself, I always wear helmets regardless. No big fuss about it.
For the Dutch, they have extensive cycling path. Cyclists are mostly shielded from other vehicles. In Singapore, we are just plainly underdogs on roads. Cycling helmet does not prevent accident. It is just trying to reduce injuries for minor accidents. I fell a number of times. If not for the helmet, I probably have a number of head injuries. I don't fully agree with mandatory helmet rule but I do highly recommends wearing one.
Wednesday, August 29, 2018
Does it make sense for Google to launch Dragonfly
Google withdrew from China in 2010 due to China's insistence on censorship. Recently Google intend to launch Dragonfly in China. Dragonfly is a version of Google that complies to China's censorship. A big backlash has been forming since The Intercept first reported it.
Lets just forget about the opposition to Dragonfly and look at why Google wanted to do it.
Firstly, Google will loose money on such a huge market. China has a population of 1.4 billion according to 2010 census, the largest in the world. 12.44% of the world population speaks Chinese according to Wikipedia. It is the largest spoken language. How could Google ignore such a big market by not being in China?
Secondly, search engines in China is building up rapidly. Baidu (百度), Sogou (搜狗), Easou (宜搜) all are competing for the same turf. They are available internationally. This means that they are eating into the pie while Google sits tight.
Thirdly, Google is a commercial company. It does not make sense to fight against China. It can't afford to. All it wanted is to make money. Yes, its logo is "Do no Evil". But by doing it, it hampers the finance.
Fourthly, Microsoft forms a partnership with Baidu to provide English language search result. Although at times it is also blocked but at least it is in it. Not all of Yahoo sites are being blocked in China blacklist. It is a threat to Google.
Fifthly, China simply wants to censor sensitive news. There are huge search topics that are still allowed. It is a great loss for such a limited topic.
Lastly, it is not just Google search engine. A number of Google products are blacklisted too due to their search capability.
I am not pro Chinese censorship. The above is just a neutral analysis of why Google wants back in China.
Lets just forget about the opposition to Dragonfly and look at why Google wanted to do it.
Firstly, Google will loose money on such a huge market. China has a population of 1.4 billion according to 2010 census, the largest in the world. 12.44% of the world population speaks Chinese according to Wikipedia. It is the largest spoken language. How could Google ignore such a big market by not being in China?
Secondly, search engines in China is building up rapidly. Baidu (百度), Sogou (搜狗), Easou (宜搜) all are competing for the same turf. They are available internationally. This means that they are eating into the pie while Google sits tight.
Thirdly, Google is a commercial company. It does not make sense to fight against China. It can't afford to. All it wanted is to make money. Yes, its logo is "Do no Evil". But by doing it, it hampers the finance.
Fourthly, Microsoft forms a partnership with Baidu to provide English language search result. Although at times it is also blocked but at least it is in it. Not all of Yahoo sites are being blocked in China blacklist. It is a threat to Google.
Fifthly, China simply wants to censor sensitive news. There are huge search topics that are still allowed. It is a great loss for such a limited topic.
Lastly, it is not just Google search engine. A number of Google products are blacklisted too due to their search capability.
I am not pro Chinese censorship. The above is just a neutral analysis of why Google wants back in China.
Sunday, August 12, 2018
SQLITE query hourly data over a date range
There was a request to get monthly summary data in a half hourly period. This is to allow user to view the month's data by the half hour range. For example, user need to know what is the volume of customer coming in at which period so that they could prepare to have enough staff to cater to the inflow.
The following is assuming the date is stored as UnixTimeStamp.
The first task is to get the half hour period using strftime.
strftime('%H',DateCreated,'unixepoch','localtime') as Hour, case when cast(strftime('%M',DateCreated,'unixepoch','localtime') as integer) <30 as="" else="" end="" minute="" p="" then="">
Don't forget to get the count
,count(Customer) as Count
Of course you must define the table
from Customer
Next thing to set is the date range as month.
where strftime('%Y-%m-%d',DateCreated,'unixepoch') between '2018-08-01' and '2018-09-01'
We also want to limit the time to 10am-10pm
and strftime('%H:%M:%s',DateCreated,'unixepoch','localtime') between '10:00:00' and '23:00:00'
Finally group by the hour and minute
group by Hour, Minute
The result is you get 3 columns Hour, Minute, Count like
10 00 5
10 30 1
11 00 95
,..
Obviously, at a certain time, there will be no data thus the specific time period will be missing. A good way is to create an associative array with all the time defined and the value of Count set as 0. Use Hour, Minute as the key like '1000'. Update the count using the keys from the result. In this way a complete list of the period will be available.
30>
The following is assuming the date is stored as UnixTimeStamp.
The first task is to get the half hour period using strftime.
strftime('%H',DateCreated,'unixepoch','localtime') as Hour, case when cast(strftime('%M',DateCreated,'unixepoch','localtime') as integer) <30 as="" else="" end="" minute="" p="" then="">
Don't forget to get the count
,count(Customer) as Count
Of course you must define the table
from Customer
Next thing to set is the date range as month.
where strftime('%Y-%m-%d',DateCreated,'unixepoch') between '2018-08-01' and '2018-09-01'
We also want to limit the time to 10am-10pm
and strftime('%H:%M:%s',DateCreated,'unixepoch','localtime') between '10:00:00' and '23:00:00'
Finally group by the hour and minute
group by Hour, Minute
The result is you get 3 columns Hour, Minute, Count like
10 00 5
10 30 1
11 00 95
,..
Obviously, at a certain time, there will be no data thus the specific time period will be missing. A good way is to create an associative array with all the time defined and the value of Count set as 0. Use Hour, Minute as the key like '1000'. Update the count using the keys from the result. In this way a complete list of the period will be available.
30>
Thursday, August 02, 2018
HTML Table Scrollable Tbody
HTML tables can display rows and columns of data in a nicely excel like layout. With CSS, you can make beautiful tables. With huge rows of data, the header tends to be scrolled out of the screen making it difficult to know what the column represents.
Using CSS, you can actually fix the header and able to scroll the data. The trick is to use THEAD and TBODY with CSS.
For THEAD and TBODB, you need to use Display: Block. For TBODY only you need to use overflow-y: auto so that it could scroll up and down.
The problem with this arrangement is that the column width is uncontrollable especially when a column data is all empty. THEAD columns cannot sync with TBODY. Its really painful to have it working yet not able to align the column widths. I wonder why it is still not fixed.
One way to align the tables is to use Javascript. However, if user set to not allow JavaScript then the display is messed up. Therefore, a CSS way is more proper. The catch is to use fixed width columns. Many designer frown on such idea. There is no choice if you want to scroll.
However, Width:50px, for example, does not work well, the width still self adjusts according to the text length especially when the table size is limited. Putting too big a width also make the table look ugly. I used the following to at least make the width more consistent. It is not a cure but at least it looks more presentable.
The HTML/CSS used is as follows :-
Using CSS, you can actually fix the header and able to scroll the data. The trick is to use THEAD and TBODY with CSS.
For THEAD and TBODB, you need to use Display: Block. For TBODY only you need to use overflow-y: auto so that it could scroll up and down.
The problem with this arrangement is that the column width is uncontrollable especially when a column data is all empty. THEAD columns cannot sync with TBODY. Its really painful to have it working yet not able to align the column widths. I wonder why it is still not fixed.
One way to align the tables is to use Javascript. However, if user set to not allow JavaScript then the display is messed up. Therefore, a CSS way is more proper. The catch is to use fixed width columns. Many designer frown on such idea. There is no choice if you want to scroll.
However, Width:50px, for example, does not work well, the width still self adjusts according to the text length especially when the table size is limited. Putting too big a width also make the table look ugly. I used the following to at least make the width more consistent. It is not a cure but at least it looks more presentable.
The HTML/CSS used is as follows :-
- Assign the table with a class name.
- Set the table width to 100%, Table_Layout: fixed
- use table.classname thead to define display:block
- use table.classname tbody to define display:block and overflow-y:auto
- use table.classname th:nth-child(x), table.classname td:nth-child(x) to define the min-width and other styles.
Item 5 above actually forces both header and body column as defined by x to the same size. Assign a minimum size (min-width) to the column so that it will accommodate the longest single word text in the column (text with spaces will wrap by default). It will take a while to adjust it but at least the columns will align if the tbody cells are empty. Each column must have a corresponding width setting.
Until such a time when W3C solved the scrollable table issue, this is probably the make-do way. Others might have a better solution but this one is an accumulation of various designer's idea.
Subscribe to:
Posts (Atom)