This is old, but if you haven't seen it (like I did) then check it out:
Just stop that, guys. Unreadable text does not make your website look cooler.
Ironically, this website has a low contrast. It seems like it is acceptable for black backgrounds? White text on black background shines like a light bulb, you do not want that.
In one of my previous posts (2014-09-27 Sand in the Butt) I mentioned my urge to do at least one commit every day. This lasted for quite some time, until the lack of resources actually made me skip one day. And then another one. And then a whole week… Well, take a look yourself:
I am not sure if I liked this experience of committing something every day. Yes, I was very productive during this period, but let's see if anything changes once I stop following this rule.
Somehow I feel that the current education system does more harm than good. I have not checked my sleep graph yet, but I will not be surprised if it was the worst time during the last two years.
Do hard work by marking as many of these cute penguins as you can.
Note: there is a high chance that you already know some of that stuff. In that case just skip to the next point, sorry for spending two seconds of your life.
And don't forget to be conscious. The problem with degrees, time and calendar could have been solved hundreds of years ago.
In this post I will be calling it “free hardware”. It's a pity, but writing or pronouncing “Free Digital Hardware Designs” is just too much. Sorry.
There is a new article about free hardware by Richard Stallman, check it out:
I am quite surprised that RMS wrote something about free hardware. Previously he stated that free hardware is a bit too much for him (not that it is a wrong thing, but we have to solve our problem with software first). Also, in one of his talks he pointed out that free software principles cannot be applied to hardware, and even said that it is a dumb thing to try to do so. And there is an article On “Free Hardware” (1999, by Richard Stallman) where he expressed some doubts about free hardware.
It is great to know that these things are being rethought. Perhaps the latest success of 3D printers makes us all understand that it is not too hard to share the design of something. However, I believe that free hardware is mostly about electronic devices and not 3D-printed solid objects in first place. That is, schematics and PCB layouts (and also firmware, but that's on the free software side).
Luckily there is a plenty of software to help you with that.
Try Kicad! Works so great for schematics and PCB layouts. You can put your project files into git and it will work just fine. Don't expect complex merges to work (although they sometimes do). Most importantly, such approach allows working on the same project in a team, and you also get a history of every change since the beginning without too much of an overhead. Git is so great at storing the source code and since Kicad is using plain text files, the whole thing just works (although I have a feeling that it was not intended to be used with git).
We've been doing this for quite some time and we are pretty much satisfied. I know, it is a bit tricky for electronics engineers to get into git (since they are not programmers in the first place), but I believe that it pays off in a long run.
Previously it felt like doing free hardware is something weird. Hopefully it will get more natural after this article.
See also a blog post by Olimex: https://olimex.wordpress.com/2016/01/13/open-source-hardware-oshw-why-it-matters-and-what-is-pseudo-oshw/
It is such a pity that there is no unified list of free hardware projects. Let's list some of the lists:
This post was extracted from https://alexschroeder.ch/wiki/Comments_on_2014-06-23_Oddmuse_Migration
It all started like a simple bash refactoring, but look! This time was special because someone decided to post a link to google style guide and claimed that it is a "nice resource". Well... I just had to explain everything. At first, I didn't think that my answer is worth a blog post. But hey, it seems like a lot of people worship these guides... So I decided to extract it into my blog.
It is plain bullshit.
Well, I can quickly go through most of the mistakes:
for dir in ${dirs_to_cleanup}; do
Clearly $dirs_to_cleanup is not quoted, this indicates that there is something wrong. Better use array and "${dirs_to_cleanup[@]}"
.
Also, what is the point of using curlies like ${var}
everywhere??? They'd better teach to put quotes everywhere. Such style is propagated only by Google style guide (a guide written by people who think that you're stupid enough not to understand the two exceptions when ${} is actually required, but at the same time these guys don't even know how to quote variables correctly). If that made any sense then we would be doing the same thing in perl and php, but we don't.
rm "${dir}/${ORACLE_SID}/"*
That's rm without --
. Well, not a huge issue, but that's a styleguide or what?
if [[ "$?" -ne 0 ]]; then
Funny. Left side of the expression is quoted when it does not have to be. But even if it had to be quoted, what would be the benefit to quote $?
? It is always an integer. Oh, and if it is an integer, then it would be better to use (( ))
for arithmetic expressions, like: if (( $? != 0 )); then
case "${expression}" in
Does not have to be quoted, actually, but at least it does not hurt.
while read f; do
echo "file=${f}"
done < <(ls -l /tmp)
WHOA! Holy sh...!!! That's amazing... Bash pitfall #1, parsing ls, read without -r. It just couldn't be worse.
# -z (string length is zero) and -n (string length is not zero) are
# preferred over testing for an empty string
if [[ -z "${my_var}" ]]; then
do_something
fi
But hey, it is as simlpe as if [[ ! $my_var ]]; then
, why would they complicate things so much?
# Instead of this as errors can occur if ${my_var} expands to a test
# flag
if [[ "${my_var}" ]]; then
do_something
fi
What??? Which error?? Am I missing something?
zip_version="$(dpkg --status zip | grep Version: | cut -d ' ' -f 2)"
A rule of thumb is that you should never pipe any of these commands together: sed, awk, grep, perl, cut and some others. The reason is that we usually need such functionality that is present in most of them, and indeed with a little trickery these tools will usually do each others' job. However, they use completely different approaches.
In this particular case you can use grep with -P flag (perl regexes! Woohoo!). Like this:
zip_version=$(dpkg --status zip | grep -Pom1 'Version: \K.*')
But there are other solutions as well.
if ! mv "${file_list}" "${dest_dir}/" ; then
Just look at that variable. It says "file list". Aha, sure, this would definitely work.
addition=$((${X} + ${Y}))
Stupidity all over the place. This should be:
((addition = X + Y))
At least that "$file_list"
example will give me a good laugh for the next few days. 😂
Also, I feel like this post is lacking some image. Well, you can look at this image, if you wish.
Bash is hard, but that's not an excuse.
Every time I see something like this:
echo Please copy your files to $FOLDER
read > /dev/null # wait for Enter
sleep 1 &
wget -Out http://link.org
if [[ $num1 > $num2 ]]
then
echo 'Error!'
clear
fi
PATH=data/stuff;
cd $PATH;
sudo echo $'Script started' >> /etc/mylog
echo "Math test: 0 + 2 = ${0+2}"
rm -rf $FOLDER
I feel horrible. It is like my insides are falling out! ARGH!
Is it so hard to go through the list on BashPitfalls page? I don't think so. However, most people would much rather follow retarded Google style gu-fucking-ides than learn the language they are using.
I post comments like this from time to time:
https://alexschroeder.ch/wiki/Comments_on_2014-06-23_Oddmuse_Migration
But look, this time was special because someone decided to post a link to google style guide and claimed that it is a "nice resource". I've extracted my comment into 2015-03-14 The Downsides of Free Food, please check it out.
Yes, get yourself a steel pipe.
Joking aside, lets start something interesting now! I will pick a pseudo-random open-source project every week (or at least every month) and refactor it. I will document everything on this blog. Later, if there are enough refactored projects and if this stuff becomes interesting to people, I will extract it to a separate wiki. Of course, every time I will do a pull request with all of the changes.
Although I try to make the code perfect, sometimes it is not possible to do it fully. Things for you to note:
The goal of this project is to spread the knowledge about bash pitfalls and improve the quality of open-source projects.
Please be conscious.
A lot of people ask me, "how did you spend your summer?". Well, here is how:
Yes, I had a lot more fun than those dumbasses who were exposing their bodies to the sun radiation.
Seriously, what's the point? Why would somebody want to do that? Some people claim that they require rest. Well, okay, a rest from what? That's a shitty excuse for your procrastination. My body requires constant intellectual activities and learning. Shame on you if your doesn't.
Maybe I can understand that if you were doing something useful for the whole year, you might want to take your female/male somewhere and spend a day or two together, just enjoying your lives and doing something fun and interesting. But shit, three months? That's ridiculous! And why summer? You can do that on any weekend.
It does not represent any precise information about my productivity (for example, it does not show commits to the projects that do not use github), but I still like that graph. I don't find it necessary to fill every block of the graph, it is just a good motivation to make at least something small every day. Sometimes I don't feel like doing anything at all, but after I make a few simple changes just to fill this graph, I get caught on it and end up programming for the whole night. Well, sometimes I don't, but even small changes to readmes and help messages or tiny refactorings are better than no progress at all.
Even if you're not a software developer, you can use that trick for anything else. Like "do at least one push-up every day" or "read at least one page of a book". You can keep the same graph on a paper calendar, if you wish. In that sense github is a bit better because it is more strict, it will not allow you to fill missed days without any dirty tricks.
Please be conscious.
I was challenged by Anatoli Belski. Here is the video:
I nominate Steve Jobs, Osama bin Laden and Jesus Christ. Remember, you have only 24 hours.
While morally unprepared people from all over the world are washing their raw heads with cold water, I am trying to cope with my sadness about the disaster we are all heading for.
Sure, I am glad for researchers, scientists and thieves who will get this raised money, and I have no doubt that this is going to have a positive impact on ALS research too. But how is this going to help globally?
And why ALS? Lets look at what they say:
"It is estimated that ALS is responsible for nearly two deaths per hundred thousand population annually."
Oh, that's why it is so important.
Wait...
2/100000 ?
That's 0.002%, right?
Don't get me wrong, I am glad that some people who usually spend hundreds of dollars on computer games will now donate 10 bucks for ALS research. But I am not sure if this low-efficiency short-term trend will cause more benefit than harm in a long run. Just imagine, all these noncaring heaps of meat now have a justification for their lives. They've done something potentially useful, now they can peacefully procrastinate till their deaths. It is like no one can shame them anymore.
But shame is good. It makes us not to do silly stuff and for some people it is a great motivation to start doing something smart.
However, some people have no shame:
Surprisingly, all of these videos were removed. What a coincidence.
https://www.youtube.com/watch?v=4EnqAHbUViE – completely or partially naked chicks showing off their breasts
https://www.youtube.com/watch?v=54aWEQjSRwA – partially naked chicks showing off their breasts
https://www.youtube.com/watch?v=Y0UaUTdiSsE – partially naked chicks showing off their breasts
And some people are just plain stupid:
https://www.youtube.com/watch?v=WQlvW0aFnKo – lots of people hurting themselves. Because it is so damn hard to turn a bucket over.
https://www.youtube.com/watch?v=YEGZXT5SLvE – lots of people hurting themselves. Because it is so damn hard to turn a bucket over.
I thought that the days of chain letters are over, but it seems like I did not take into account that there is a new generation of youngsters who don't even know what is a "letter".
Please be conscious.
Hahaha.
-- AlexSchroeder 2014-09-12 15:38 UTC