I don't know how to use awk, but I have a problem which I know it suits for.
I want to sum up memory usage data that come out from executing the command ps aux. I learned 2 usages of awk from this lesson.
Print value of a column with: awk '{ print $COLUMN_NUMBER }'
Sum value of a column with: awk '{ temp = temp + $COLUMN_NUMBER }END{ print temp }'
So I can get sum of memory usage of processes with certain name pattern like this: $ ps aux | grep NAME_PATTERN | awk '{temp = temp + $6}END{ print temp }'
I still don't know awk, but at least I'm incrementally learning it.
Just append && say "Done"
For example;
$ sleep 10 && say "Done"
This trick could be useful if you are running some tasks and want switch to work on something else while it's running but also want to get back to it immediately after it finished.
Because future-cancel will send interrupt signal to the future, Thread/interrupted will be changed to true.Now your future-cancel should work as expected.
At some point in development, you may want to make a copy of your existing development database to play with an unstable new feature. Postgres makes it super trivial to do that by allow us to create a new database by using existing database as a template.
In postgres console, run
=# CREATE DATABASE new_database_name WITH TEMPLATE original_database_name;
In programming, there's time when we have 2 arrays and we want values at the same index of both arrays to have operation on each other producing an array of result. In imperative style, we have to setup a temporary counter variable to store index the current operation is on, increment it until reaching the last value of an array. For example, we want to sum values of each index.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In functional style, there's a function called 'zip' (Haskell, Ruby) which allows us to pair up values of each index preparing to apply operation on each pair later.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Haskell, there's even 'zipWith' which apply operation on the pair immediately instead of producing an intermediate array.
But when it comes to Clojure, I wasn't be able to find a function in its standard library with the same behavior. The closest I could find is 'zipmap' that returns back a map which is not exactly what I want. We definitely can work around a little bit to get a vector.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I think, I overlooked this solution because in Ruby, the language the I'm most comfortable with, 'map' can only operate on only one array.
Learning that Clojure's map can takes any number of collections is an aha moment for me. So now I can sum elements of more than 2 vectors easily.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Since the second argument can accept any function, creating Clojure records is as easy as this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Axel is a command line file downloading tool that can create multiple connection to download parts of the file and combine them later after the download finish. It's perfect replacement for cURL or Wget in downloading a big file.
To use it, as simple as;
axel -n 10 http://url/big-file
10 is number of connections
It's available through Homebrew, agt-get and other OS package managers, I suppose.
Using this tool always reminds me to FlashGet and Download Accelerator which I had used more than 10 years ago.
When a branch is removed from your git central server, remote branch on your machine won't get removed automatically. You might already know popular command to clean those removed branches, which is
git remote prune origin
But also you could give --prune or -p argument to fetch or pull to do the pruning for you after it's done with its normal behavior. For example,
git fetch -p
git pull -p
If you are in the habit of using remote prune that's fine. These prune arguments just save you one extra step if you just put them in to help cleanup once in a while.
You have a command to start a long running process but it doesn't create a pidfile for you to write a script to start/stop it. start-stop-daemon could help that.
Use `Eval: Cancel evaluation for the current client` or `Editor: Disconnect clients attached to editor` from the command bar credit: How to interrupt eval?
You get SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) or similar error when trying to request to a https endpoint but no any other people solutions you have found through googling seems to be able to fix it.
What I have found is that those blog posts and stackoverflow answers led me to the wrong direction. The problem is neither Ruby's false nor you misconfigured it. Instead, missing intermediate CA certificate is the cause of the problem.
To verify that you are having the same cause of problem that I had, try running these command and compare the results
If you get back proper result for the first command and get the same error for the second command. That's the same problem I had. If you get errors on both commands, this post won't help solving you problem.
What's happening is that Ruby doesn't have a certificate of the intermediate CA that is used to issue certificate of the server you are requesting to
Compare Certificate chain section of the result of these 2 commands
In github's server case, you will get 0 and 1. On the other hand, in your web server case, you probably get only 0. SSL certificate chains section of this nginx documentation page has a good explanation of the chain.
If you own that web server or has an access to it, go fix that and your ssl issue should be resolved. For nginx web server, the fix is described in the previous link.