I learnt about this awesome project this week, if you code or use the command line at all you may find it helpful.
Cheat.sh is a project which aims to provide cheat sheets for command line tools and programming languages.
It can be used on the command line as long as you have a HTTP client like curl
or wget
installed. E.g.,
$ curl cht.sh/pwd
cheat:pwd
# Show the absolute path of your current working directory:
pwd
tldr:pwd
# pwd
# Print name of current/working directory.
# Print the current directory:
pwd
# Print the current directory, and resolve all symlinks (i.e. show the "physical" path):
pwd -P
It can also be used from a browser by visiting https://cht.sh
, or there is a command line client and integrations for several editors.
It also has sheets for many programming languages. E.g.,
$ curl cht.sh/c/strcmp
/*
* c - Implementation of strcmp
*
* Uhm.. way too complicate. Go for this one:
*/
int strCmp(const char* s1, const char* s2)
{
while(*s1 && (*s1 == *s2))
{
s1++;
s2++;
}
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
}
/*
* It returns <0, 0 or >0 as expected
*
* You can't do it without pointers. In C, indexing an array is using
* pointers.
*
* Maybe you want to avoid using the * operator? :-)
*
* [Gianluca Ghettini] [so/q/34873209] [cc by-sa 3.0]
*/
or ask it questions, for example
$ curl cht.sh/python/parallel-programming
# question_id: 20548628
# You can use the [multiprocessing](http://docs.python.org/2/library/mul
# tiprocessing.html) module. For this case I might use a processing
# pool:
from multiprocessing import Pool
pool = Pool()
result1 = pool.apply_async(solve1, [A]) # evaluate "solve1(A)" asynchronously
result2 = pool.apply_async(solve2, [B]) # evaluate "solve2(B)" asynchronously
answer1 = result1.get(timeout=10)
answer2 = result2.get(timeout=10)
# This will spawn processes that can do generic work for you. Since we
# did not pass `processes`, it will spawn one process for each CPU core
# on your machine. Each CPU core can execute one process simultaneously.
#
# If you want to map a list to a single function you would do this:
args = [A, B]
results = pool.map(solve1, args)
# Don't use threads because the
# [GIL](https://wiki.python.org/moin/GlobalInterpreterLock) locks any
# operations on python objects.
#
# [Matt Williamson] [so/q/20548628] [cc by-sa 3.0]
$
(it searches stack overflow for you!)
or even
$ curl cht.sh/matlab/:learn | more
if you’re into that sort of thing