14. Nov 2019 |

Järjehoidja endale – IT-ametite päev

Hea video IT õppimisest neile, kes veel mõtlevad. Ago juhib hästi tähelepanu sellele, kuidas natuke eksitavalt kommunikeeritakse IT õppimise “lihtsust”. Samas, minu arust natuke liiga palju räägib “suurtest palkadest” ja “lahedatest kontoritest”, mis kumbki väga ei päästa, kui töö ikka üldse ei meeldi 🙂 Väljalangemiste asi on minu jaoks muidugi ikka müstika (23-24% juures paistab graafikul olevat). Et kas või kuidas saavad mingid asjad mingil hetkel osutuda ületamatult raskeks VÕI kas tegelikult ka inimesed lähevalt lihtsalt tööle poole õpingu pealt. Samas ma ei taju hästi ka enda puhul hetkel, kui realistlik selle õppekava läbimine üldse on. Aga noh, mõtlen, et kui asjadega tegeleda, siis ju peaks olema küll.

Inimeste lugusid oli küll huvitav kuulata selles videos. Lauri Greenbaum SEBst meeldis sellise suurkorporatsiooni protsesside vaatega ning tegelikult ka näiteks Marek Õunpuu – kuidas kuu ajaga saad Omniva Java junior arendajaks (ja samal ajal see 23-24% väljalangemine IT õppes). Ühtlasi soovitan Algorütm podcasti, mis natuke annab veel IT töö ja hariduse teemale vaatenurga kolme tippjuhi poolelt.

9. Nov 2019 |

Bulk delete WooCommerce products by category using WP-CLI

If you would like to know how to bulk delete posts from a specific category using the WP-CLI then here it is.

WP-CLI is command line interface for maintenance of WordPress. This is something I try to figure out.

Deleting one product

This deletes 1 product. 1157 is product ID. Without –force it does not work, because posts of type ‘product’ do not support being sent to trash.
So you need to use –force flag to skip trash and delete them permanently.

wp post delete 1157 --force

Deleting 100 products

Now I try to figure out how can I delete all products within category. This allows to delete 100 products at a time.

wp post delete $(wp wc product list --user=1 --format=ids --category=64) --force

Deleting specific number of products

wp post delete $(wp wc product list --user=1 --format=ids --category=64 --per_page=10) --force

By specifying –per_page you can limit how many products will be deleted with one execution. But it only works between 1 and 100 products.

Reason is that WooCommerce commands are implement as REST API requests and they are limited to a maximum of 100 results per request. This is a limitation that comes from WooCommerce, not WP-CLI. It’s unfortunate they have limited it that way, as it seriously lessens the benefits of having CLI commands in the first place.

Final solution that works (tested with 5000+ products)

for run in {1..2}; do wp post delete $(wp wc product list --user=1 --format=ids --category=64 --per_page=10) --force; done

This line does the job. Loops I found here and here. This sample deletes 20 products by using two runs, 10 products each.

Delete products by product tag

Another one is here. tag is product tag ID.

wp post delete $(wp wc product list --user=1 --format=ids --tag=82 --per_page=2) --force

Deleting revisions

It is not uncommon sites to have multiple revisions on their pages. This is simply due editing and updating content. Let’s say for example a site has 700 pages or posts with 150 revisions on each, this would be over 100,000 entries in the database. To delete unnecessary revisions you can use the following command line:

wp post delete $(wp post list --post_type='revision' --format=ids) --force

I have posted the question also to WordPress.org forum here for discussion and #cli channel. Hopefully someone comes up with the answer 🙂 Also sent it to Eric. Maybe he knows.

1. Nov 2019 |

How to remember

When I do coding tasks for school I find really cool solutions and wonderful workarounds from time to time. I wonder how should I remember all this. How should I archive and structure all this knowledge. Should it be like learning a language where I should prepare learing cards (for vocabulary) to remember basic things by heart. Like what goes where when I need to append something to a list.

 

29. Oct 2019 |

php does not work on website

For the first time I tried to build simple php template for my own website. I read this and this. Header, body and footer. And in the body I wanted to have additional php scripts (to define meta description and title for every site). But it did not work at first and it took me few hours to fint that:

If it does not work then change this…

<?php echo file_get_contents("html/body.php"); ?>

to this..

<?php include 'html/body.php';?>

And everything works.

18. Oct 2019 |

Finding descriptive statistics about IT studies in TalTech

Good statistics about school and subjects are really difficult to find even though we are quite often talked about the importance of high-quality data. But I found some here: ÕIS – Üldinfo – Statistika – Õppekavad – Õppeainete statistika. Quite… huh.

This is the picture of autumn semester results in the year 2018/2019 on my curriculum IADB17/17. These all are not the first-year subjects! I highlighted the subjects that I study in this first year’s first semester. I wonder what is going on with the basics of programming (ITI0102) where there are 441 students in the beginning but only 271 in the end (out of which 95% get a positive result). Our teacher Ago commented that the drop-out is ~30% and it is significant among session students (which is something I understand).

Also, an interesting finding for me is that the subject named “Sets, relations, systems” (of which I have already written here) seems to be the real gourmet subject. Out of hundreds of students, only 26 have decided to study it. And it also has the second-lowest average grade out of this selection of subjects.

I still have not found anything to use for the graduation rate.

Random things that need sharing

The canteen of IT College has its own Spotify playlist. Because why not. And I like these soundproof phone booths in TalTech Library. I like that doors open themselves. Very effective solution for minimizing the spread of viral infections though minimizing the contact with highly likely contaminated surfaces (like door handles).

12. Oct 2019 |

10,000-Hour Rule – key to success in coding?

Practice will make you better. Don’t expect it to make you perfect.

Malcolm Gladwell, the author of “Outliers” explains the key to success in any field is simply a matter of practicing a specific task that can be accomplished with 20 hours of work a week for 10 years (which makes 10 000 hours).

I started using Toggl to track the time that I spend on different tasks. It is a very good tool for this. For better reporting, I used TalTech as a client and subjects as projects. My tasks mainly include maintaining my online stores and doing work for school. So for reporting it is good to use TalTech as a client filter. This week I see that have spent 12 hours and 46 minutes on Python after school. It is Saturday at the moment so I expect it to reach 15+ hours coding weekly. At some point this week it made 10x what I have spent on a second subject in school.

Week 6 at school – most of the time it is coding after school only.

If we say, that I started coding this week, then 12.75 hours would make 0.13% of my learning path (10 000 hours). So I say, doing it feels like a lot. Like I am always in PyCharm. But thinking that professionals do it 8 hours a day which makes 40 hours a week – it is more than 3 times what I have done this week 😀

Toggl is far from… or not

Toggl is not the one to blame. Update from week 7 is that I very often forget to turn Toggl on or off. But I think, despite the gaps in tracking I got around 35 hours of independent after school work. Most of it for “Sets, relations, systems” (all Thurdsay and Friday) because I had the test on Friday evening. Python got its 14 hours this week.

Read more:

Vox, Wikipedia

7. Oct 2019 |

It is EU Code Week 5-20 October 2019

EU Code Week is a grassroots initiative which aims to bring coding and digital literacy to everybody in a fun and engaging way.

The last part of this EU Code Week aim is somewhat non-relatable. Because I just debugged my WP store like 6 hours (to make stock syncs faster) on Saturday and at the moment struggling with entry-level Python tasks for school. So, I can say this period of “fun and engaging” is very short in the learning curve 🙂 In my previous profession in the pharmaceutical industry it was called misleading communication and it was not allowed.

Or, I may be doing something wrong.