Monthly Archives: July 2021

Good bloggers write a lot

I’ve been thinking lately that I am NOT able to blog a lot and I always blame external factors, “Oh I don’t have time” or “oh there’s no pagination in my theme so there’s no point of blogging daily, yet.”

But in reality, turns out I’m just being lazy.

I’ve been reading Jamie Zawinski’s blog for years, via RSS, of course. Couple of days ago I opened it via my web browser, an woah those number hit me hard!

As you can see, there are 366 days in a year but jwz happens to have more posts per year than that! Look at year 2012, there are 870 posts!

I mean, I know that my favorite blogger, Rubenerd blogs a lot, but I never knew how much.

I know he has 10 posts per, and his blog currently says

Page 1 of 758 β†’ Older posts

And I know he started blogging since 2004, so if you do the math using bc,

$ echo '(758 * 10) / (2021 - 2004)' | bc -l
445.88235294117647058823

Actually, lately I’ve learned about expr, it’s very handy in command line scripts!

$ expr \( 758 \* 10 \) / \( 2021 - 2004 \)
445

What I’m trying to say is, I don’t know how people blog regularly, it’s not that I don’t have any ideas in my head, there’s always something to say, something to share, something to write about. If it’s not technical then at least it’s political.

Recently Lilith suggested that I should try to allocate 30 minutes a day to write some posts, even if it would end up into the drafts. This is me trying to do that, while drunk πŸ™‚

That’s all folks!

Reply via email.

Two Colons Equals Modules

Days ago I tweeted a shell function which is part of jailio’s code base. Jailio is a project I’ve been working on for the last 6 months. As the name implies, it’s a container management software for FreeBSD Jails.

It has two unique things compared to other Jail management software. First of all, it has no dependencies, it’s written purely in Shell. You can say the same about BastilleBSD, however, Jailio’s second unique thing is that it uses base tools only and requires the base system only. For example, you need to have bastille_enable in BastilleBSD, it also uses its own config files, etc. In Jailio, you need to have jail_enable, because technically Jailio automates jail.conf files. It also uses my patch to automate the jail.confs in /etc/jail.conf.d.

Anyway, back to our topic about Colons and Modules.

I like modules, I got introduced to them when I started programming in school. In Syria, we learn programming at 7th grade but in our school we started a year early, so 6th grade. We always start with block diagrams and then Turbo Pascal!

Yes, 16-bit Turbo Pascal was my first programming language and it had the concept of modules which we called Units.

And then you have languages like C or Shell which don’t have modules. If you use modules you KNOW that it’s hard not to use modules after that.

While reading the source code of vm-bhyve I learned that you can use two colons (::) as part of the function name, which can give you an amazing new superpower to take over the world write cleaner code.

For me this was a life-changer. I write a LOT of Shell code. I ship them to production too. No, you don’t need to write everything in a fancy new language and run it on kubernetes, you can always use simple languages like Shell and run them in a FreeBSD Jail. Or in my case, write in Shell to automate FreeBSD Jails.

Here’s an example code with “modules” in Shell. Note, this works in FreeBSD’s shell, I have not tested other Shells yet.

main.sh

#!/bin/sh

. ./mod1.sh

mod1::func1

mod1.sh

#!/bin/sh

mod1::func1(){
  printf "Here I am, rock you like a hurricane\n"
}
antranigv@pingvinashen:~ % ./main.sh 
Here I am, Rock you like a hurricane

As you can see it all relies on the concept that the function name itself has two colons in its name.

Here’s the code from jailio that I tweeted.

jail::get_next_id(){
  expr $(
    ( grep -s '$id' /etc/jail.conf.d/* || echo '$id = "0";' ) |
    awk -F '[="]' '{print $3}' |
    sort -h |
    tail -1
  ) + 1
}

After tweeting the code above Annatar replied that this should NOT work elsewhere and that’s how I got introduced to The Heirloom Project which provides traditional implementations of the original Unix tools from the original Unix source code.

Hopefully, I will see more people using “modules” in Shell scripts. Hopefully this trick works in other Shell implementations like Bash and zsh.

That’s all folks.

Reply via email.

The OS App vs The Browser OS

I like listening to online radios like anonradio and DeepHouseRadio, instead of me trying to organize my local library or listening the same music over and over again on Deezer, I get lazy and just use their HTTP link.

Like a sane person, I would use a media player to “open” these HTTP radio links. On my FreeBSD machine, all I need to do is mplayer http://the.domain/path/to/content, but on macOS it would not be that simple.

The default media player on macOS is QuickTime. Here is where my problems start. I open QuickTime Player, I set the location to the HTTP link and it all works fine. Until it doesn’t. A small network lag and it stops playing completely.

I am usually connected to the internet via a cable in my office or the house, but when I go wireless, there’s a blind spot in one of the rooms. My FreeBSD laptop with mplayer handles it all fine, but QuickTime? Not so much.

So I decided to use the “other” “Operating System” in macOS, also known as a browser, in this case Firefox. I open the link and it all works fine. Even if there’s a network lag, Firefox would handle it fine.

It’s sad funny how browsers are handling things better than native desktop programs these days.

While writing this blog-post I realized that macOS has another media player known as Music.app, so will try with that as well, let’s see how it will handle it.

That’s all folks.

Reply via email.

Barcamp EVN21, or why we don't build more products

The year was 2021, the month, July, the day was the 10th and I was very happy. It was Barcamp Yerevan again, the new year of the tech industry, the day we all share knowledge, the day people come NOT to listen to talks but to take stickers and t-shirts instead, because it’s free, as in beer as well as in speech.

Not all people are like that, some of them give talks. I’ve been giving talks since Barcamp Yerevan 2016. Since it’s a free unConference, we get a lot of sponsors, from small outsourcing companies to large ISPs and Gambling-as-a-Service providers.

Usually, during an unConference such as this, there are 1) sponsored talks, by the sponsors, 2) selected talks, by individuals, which are selected by a committee and 3) unConference talks, where people just write on a wall “Talk about X at room Y, ZZ PM” and whoever is interested goes there to listen.

Usually, there’s this habit, that if the unconference talk is not good, then people leave the room by smashing the door on the way out. Usually, the selected talks are good, because good job committee, usually the sponsored talks are good, because sponsors don’t want to send an engineer who’d give a bad talk.

But this year was not a usual one. This year was the exact opposite.

The uncoference talks were awesome, people from random companies were talking about how to work remotely, how to work from outside the heart and the capital of Armenia, Yerevan. People were talking about how to start a community. People were talking about audio system and audio engineering.

The selected/sponsored talks were the… I’m not sure I know how to describe this, but, they were what they are supposed to be, sponsored talks by sponsors.

Here is an example. A system engineer fellow talks about infrastructure automation, how tools like Terraform are cool, what is an automat… no sorry, he did NOT talk about the benefits of an automated infrastructure nor what problems it solves. I wondered why.

At the end of the talk someone asked “so have you implemented this at YOUR company?” and the fellow answered “Well, not really, some bits here and there”, and I got the answer to my why question.

He did not know, because he was not talking from experience. That’s why there was no storytelling, there was no “sharing” of experience. It was only a talk, which is what the sponsored company was aiming for anyway.

Now for me, a systems engineer, I can see BS lack of experience like that in a minute, but I asked my friends if ALL the talks were the same, the marketing ones, the media ones, the ones about “how to grow your company,” and guess what, all of my expert friends in other fields agreed with me.

We also had panels. I was on one of those panels, I think it was called “Security Panel” which was supposed to be about… Security, as in InfoSec. But instead we talked about the war and the post-war status of the “cyber” security field in the country.

Last but not least, the guests, they were awesome, all of them, they shared a LOT of knowledge with the audience, which I hope will have an impact long-term.

Alas, that’s the pain of running a free, corporate-sponsored (un)conferences. You give voice to people who have the money, which not necessarily have the knowledge nor the experience. And this is why we don’t have more product companies in Armenia. We are not producers, we don’t have the experience. We are consumers, we are not part of open-source communities, and if a fellow is then everyone will point out as if it’s some god-ish action to contribute to software.

Hopefully, next year will be better.

P.S. Every year I give the last talk on the last day, since people stick around and ask me questions and I don’t like to ignore questions or free the room for the next speaker. All my previous talks are on my personal page on the new Barcamp Yerevan website. This year I was at 10:30AM… Most of the organizers who knew me personally were afraid that I’d oversleep. Luckily, such disaster was averted thanks to Syuneci.

That’s all folks.

Reply via email.