?

Log in

No account? Create an account
Shlomif's Technical Posts Community [entries|archive|friends|userinfo]
Shlomif's Technical Posts Community

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| Shlomi Fish's Homepage Main Journal Homesite Blog Planet Linux-IL Amir Aharoni in Unicode open dot dot dot ]

Tech Tip: Opening a new kate buffer in a new window [Jun. 26th, 2018|05:59 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Mood |productive]
[Current Music |The Bangles - Eternal Flame]

Kate is a text editor that I sometimes prefer to use. Normally, saying kate [optional file path here] from the command line opens a new buffer as a new tab in an existing window. However, one can instruct it to open in a new window using the -n command line flag.

Cheers!

Licence

Copyright by Shlomi Fish, 2018.

You can reuse this entry under the Creative Commons Attribution 4.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Nested Tmux Session [Jun. 21st, 2018|06:23 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Mood |relievedrelieved]
[Current Music |Dr. Hook - Who the **** is Alice?]

One can use the following command-line to start a new tmux session with a different hotkey than the default one (e.g.: for use as a nested session after su/sudo or in a nested ssh session, so both sessions can be controlled):

tmux new-session \; set-option prefix C-a

Replace "C-a" with the hotkey of your choice.

Licence

Copyright by Shlomi Fish, 2018.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

The Despair of a Static Site Generator Creator [Dec. 21st, 2017|08:48 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , ]
[Current Mood |productive]
[Current Music |Cimorelli - Problem]

TL;DR

The main take-away from this essay is that I cannot in good conscience recommend against writing your own custom/ad-hoc/home-grown static site generator ("SSG") based on some lower-level tools, rather than going through the trouble of learning an existing open source one. Feel free to publish your own creation as open source as well, but you should anticipate that it is most probably not going to be popular.

Introduction

(A crowded room in a support group session:)

Me: Hi all! My name is Shlomi and I wrote several of my own static site generators!

The others: Hello, Shlomi! We all love you!

(By inspiration from Kilmo.)

Yes, I wrote several static site generators (follow this link to learn more about SSGs in general and the motivation for them), and while they have served me mostly well, I suspect few people use them except me. They all were built on existing preprocessors or template systems, some of which could be considered static site gens in their own right.

In this essay, I'd also like to give some historical perspective.

Requirements for a static site generator

Your static site generator should have:

  1. A good preprocessor, generator, or template system.

  2. A good build system, but one that could be ad-hoc and hacked together in a dynamic language or similar.

  3. The other best practices related to software dev, such as using version control, or CI.

How it started

I originally learned how to write HTML from an article in an Internet magazine that my father bought me back around 1995. In 1996, I started working as a web developer for Cortext Web Design where I wrote HTML or CGI scripts generating it server-side in Perl 5 and learned some other technologies.

After a while, I set up my own web site consisting of several hand-maintained HTML pages and maintained it for many years this way. You can find an old 1998 snapshot of it.

A bit later while working on the Israeli Group of Linux Users' site, I wrote my first static site generator, in PHP (version 3 if I recall correctly) where it used PHP to preprocess the pages offline and generate a static site. While it worked, the use of PHP for that seemed suboptimal.

The birth of Latemp

Website META Language or WML for short was a relatively early and open source offline HTML preprocessing toolkit that proved to be somewhat popular. I learnt about it in a news digest that one of the Linux-Israel members posted, and eventually decided to try it out. After writing some smaller projects with it, I ended up converting most of my sites to it. This resulted in some duplicate code, which I decided to extract into Latemp (a play on "Template" and LaTeX), which was a static site generator that was marketed as an “offline content management system”, which in turn caused me to be contacted by some people seeking a server-side CMS such as Drupal. To be fair: at that point, I wasn't aware that "static site generator" was the more conventional term.

WML and Latemp proved to be powerful and flexible, but on the other hand, were relatively slow in comparison to other alternatives.

I should note that I ended up becoming the maintainer of WML.

Facing some criticism

Back in the early to mid-200xs, a fellow Linux-IL worker kept telling me that I should not generate static HTML sections of our sites and instead should use PHP on the server side, implying that static HTML was no longer a valid approach.

Furthermore, when a different contributor volunteered to create a site and I told him to use static HTML and not depend on PHP, he asked me if he could use HTML frames. Turns out that despite his years of experience in PHP, he didn't realise that static HTML can be generated from templates, something I had realised years ago.

Nowadays, with the advent of Jekyll and other popular SSGs, many clueful web-developers are more informed about them, but OTOH, someone recently argued that Jekyll was the only valid alternative to server-side PHP, and not SSG in general.

Recent developments

Some time after GitHub started, it started offering the “GitHub pages” service for hosting static HTML sites, and shortly afterwards Jekyll and other SSGs emerged and made the concept of SSG more well-known. GitHub also allows previewing files in several formats as rich text HTML directly from the repository view.

I tried using Jekyll for Vim-Begin and ended up not liking it out of finding it too opaque and hard to use. As a result, I ended up creating a new SSG for Vim-Begin based on Template Toolkit. Later, I used it for the www.linux.org.il site. One possible indication of its ease-of-use is that it received some pull-requests from other contributors on GitHub.

Moreover, it seems it is much faster than Latemp, as well.

My sites now incorporate such industry best practices as using version control, having an automated test suite, and using a Continuous Integration service. They should also be mostly valid HTML/XHTML markup. However, the Latemp-based one take a while to build and sometimes involve quite a few levels of indirection and preprocessing. So I cannot recommend using Latemp, due to this and because WML is quite complex.

I also found the hybrid approach of both an SSG and a server-side CMS taken by ikiwiki appealing and used git repositories containing markdown files for a good effect.

Like I said earlier, I find that writing your own custom SSG is not hard, and probably less hard than learning an existing one. Also see this. So I expect more of them to emerge in the future.

Someone on chat told me he believed that SSGs wont survive the trend towards component-based client-side frameworks (such as React.js or Vue.js) but I'm skeptical of such predictions and in my time saw several similar ones not materialise. Also see this funny critique of modern JS.

So static site generation has proven to be a valid approach in the past and into the near future. However, I maintain several sites using my own custom ones (with all their quirks) and don't expect them to be of much interest to anyone except me and future maintainers of the sites. And here lies my despair.

Licence

You can reuse this entry under the Creative Commons Attribution Noncommercial 3.0 Unported licence, or at your option any later version. See the instructions on how to comply with it.

LinkLeave a comment

Cython: Report and Tips [Jun. 4th, 2017|02:41 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Music |unreal_dm - Reach out]

Cython allows one to compile code written using a superset of the Python programming language into C code for improved performance. I recently tried it in an attempt to speed up my solution to a Project Euler problem, which was ran slowly, even by pypy. After some amount of work, the cython-based solution outperformed the pure-Python code, without me having to reimplement it all in C or C++ or similar. So you too should consider using it, if you need the extra performance.

The rest of this post contains some Cython tips for using it well that I discovered in my (so far relatively limited) experimentation with it.

  1. I noticed that cdef int i; for in xrange(0, mymax) does not get optimised while cdef int i; for i in range(mymax); does.

  2. cdef int arr[100][100] declares a local array of 100*100 elements , and keeps copying it, which is likely not what you want. On the other hand, cdef int [100] * ptr generates a pointer.

  3. “cdef” cannot be used inside loops.

  4. It is a good idea to declare the C types as late as possible - only right before the time-critical code when you absolutely need to use them. One can initialize them from dynamically-typed python data structures.

  5. One can copy+paste the compiler's invocation command on the command line and edit it to apply better optimisation flags. There may be a way to customise the compilation command by editing the “setup.py” file, but I didn't bother to figure it out yet.

  6. One can and should inspect the generated .c file to see the resultant C code to see if anything is done sub-optimally.

Licence

Copyright by Shlomi Fish, 2017.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Why E-mail is not only a Todo list [Apr. 7th, 2017|02:58 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, ]
[Current Location |Home]
[Current Mood |happyhappy]
[Current Music |Amir Gelman vs. Bertycox - The Signal]

This is a essay that aims to be a correction to what Paul Graham wrote:

Email was not designed to be used the way we use it now. Email is not a messaging protocol. It's a todo list. Or rather, my inbox is a todo list, and email is the way things get onto it. But it is a disastrously bad todo list.

I'm open to different types of solutions to this problem, but I suspect that tweaking the inbox is not enough, and that email has to be replaced with a new protocol. This new protocol should be a todo list protocol, not a messaging protocol, although there is a degenerate case where what someone wants you to do is: read the following text.

While it seemed to have made a little sense at first, I eventually realised that there are other resources whose functionality I use as a to-do list aside from email. For example:

  1. My browser's bookmarks’ menu where I bookmark links to deal with.

  2. My home directory and other directories on my file system where I put non-permanent files.

  3. Non-committed files in version control repositories.

  4. Bug trackers / issue trackers.

  5. Actual to-do lists I keep and manage.

However, there are other aspects for their use aside from serving as a to-do list, and they are all different from one another.

As a result, while trying to create an alternative to E-mail is commendable, I suspect that trying to replace E-mail with a to-do-list-like protocol will not prove to be popular, because like those - E-mail is not exclusively a to-do list.

Licence

Copyright by Shlomi Fish, 2017.

You can reuse this entry under the Creative Commons Attribution-Non commercial 4.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Saving hard disk space on Amazon AWS Linux Instances [Feb. 22nd, 2017|10:44 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |productive]
[Current Music |One Thing cover by Cimorelli]

By default, AWS' EC2 machines are given a hard disk of only 8 GB of space, and each extra gigabyte costs extra, even if you rent a machine with much more RAM than that. Some options you can try if you don't want to enlarge the hard disk are:

  1. Remove unnecessary system packages (using the “apt remove” command on Ubuntu/Debian VMs or equivalents. From my experience, the default Ubuntu VMs ship with a lot of junk preinstalled.

  2. Remove packages that you installed and no longer need (e.g: gcc).

  3. One can also try to do “rm -fr /usr/share/man /usr/share/doc” and other unnecessary directories that are cheaper to use on local VMs or host systems.

  4. Consider using S3 or similar instead of the local hard disk, which should be much cheaper.

Good luck!

Licence

Copyright by Shlomi Fish, 2017.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: How to Make Pidgin’s Incoming Messages Icon Animated [Dec. 15th, 2016|01:45 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |happyhappy]
[Current Music |Harry Belafonte - Banana Boat Song (Day-O)]

Pidgin is an open source chat client. If you want to make its incoming messages system tray icon animated, simply right click on the icon, and select “Blink on new messages”. This way it will be harder to miss and that is what I was used to having.

Licence

Copyright by Shlomi Fish, 2016.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Nullifying/Resetting/Overriding a Remote Git Repository's Branch History [Jul. 16th, 2016|07:46 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Music |Nethis - Gimin]

If you have a branch in a remote repository of the Git version control system which you need to reset/nullify/override its history, you can do it by setting up a brand new branch with the same name (say starting in an empty repository) and then pushing it from there to the remote while specifying the --force flag. Thanks to the people from #git on Freenode for enlightening me.

Licence

Copyright by Shlomi Fish, 2016.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Disabling the Touchpad/Trackpad on Linux [Jul. 6th, 2016|04:54 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |productive]
[Current Music |Len - Steal My Sunshine]

If your touchpad/trackpad (= the built-in mouse control found in some laptops) is a Synaptic one, then you can disable it on Linux systems by issuing the command synclient TouchpadOff=1 (you may need to install synclient first. I originally learned of it from this link on kde-apps.org.

Licence

Copyright by Shlomi Fish, 2016.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

Tech Tip: Checking the Latest Build in Travis CI [May. 27th, 2016|03:43 pm]
Shlomif's Technical Posts Community

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Mood |lazylazy]
[Current Music |Shania Twain - You win my love]

If you are using Travis CI, you can check the latest build after a failed build by going to the “Build History” tab in your project’s main page (= https://travis-ci.org/shlomif/fc-solve or equivalent), and selecting the new commit.

Licence

Copyright by Shlomi Fish, 2016.

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version of it. See the instructions on how to comply with it.

LinkLeave a comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]