├── .editorconfig ├── Android development.md ├── Android.md ├── AngularJS.md ├── Animals.md ├── Apache HTTP Server.md ├── Audio.md ├── Browsers.md ├── Business.md ├── Composer (PHP).md ├── Computer networks.md ├── Creativity.md ├── Crowdin.md ├── Domains and DNS.md ├── Eclipse.md ├── Economics.md ├── Education.md ├── Electronics.md ├── Email.md ├── Energy (Germany).md ├── English language.md ├── Fitness.md ├── Food.md ├── Fraud and scams.md ├── Gimp.md ├── Git.md ├── Health.md ├── Heroku.md ├── History.md ├── Home.md ├── IT operations.md ├── Information security.md ├── Java.md ├── JavaScript.md ├── Job interviews.md ├── LICENSE ├── LaTeX.md ├── Law.md ├── Life.md ├── Linux.md ├── Media.md ├── Mobile technology.md ├── MongoDB.md ├── MySQL.md ├── PHP.md ├── PhpStorm.md ├── Politics.md ├── Privacy.md ├── Product design.md ├── Psychology.md ├── README.md ├── RegEx.md ├── SSL and TLS.md ├── Safety.md ├── Science.md ├── Social media.md ├── Software development.md ├── Software.md ├── Startups.md ├── Taxes in Germany.md ├── Travel.md ├── Ubuntu Desktop.md ├── Ubuntu Server.md ├── Ubuntu.md ├── Unix.md ├── Web development.md ├── Windows.md └── Writing.md /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = tab 7 | trim_trailing_whitespace = true 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | indent_style = space 13 | indent_size = 4 14 | -------------------------------------------------------------------------------- /Android development.md: -------------------------------------------------------------------------------- 1 | # Android development 2 | 3 | * Use the `Linkify` class or any `TextView`'s `autoLink` attribute to make links, email addresses and phone numbers clickable in your `TextView`. 4 | * Never change the class name or package name of your default Activity that is started by the launcher. It will break home screen shortcuts. If you really need to change your default Activity's class name or package name, add an alias with the old name for compatibility. 5 | * Always create one keystore per app for signing your APKs. Otherwise, when selling an app, you'll have to hand over the shared keystore. 6 | * The ratio for Android's density buckets from `ldpi` to `*hdpi` is `3:4:6:8:12:16`. 7 | * Apart from the normal `android:textColor`, you can also set `android:textColorHint`, `android:textColorLink` and `android:textColorHighlight` for a `TextView`. 8 | * When using an `ListView` or `GridView` (or any other `AbsListView`) and the `Adapter` has items of varying height, you must set `android:smoothScrollbar="false"` on the `View` in XML. While the scrollbar will not run smoothly anymore, it will have a fixed height and doesn't change its size all the time anymore. 9 | * If you want to make the background of a `View` transparent, either for design or performance reasons, use `android:background="@null"` in XML or `View.setBackgroundDrawable(null)` in Java. 10 | * When adding new permissions into permission groups that have already been accepted by the user, Google Play will not require the user to review the new permissions. [In the Android source code](https://github.com/android/platform_frameworks_base/blob/master/core/res/AndroidManifest.xml), you can look up which permissions belong to the same groups. Just search for the `/build-tools//aapt.exe l -a .apk` and optionally pipe the results to `grep`, etc. 13 | 14 | ## Keystores and APK signing 15 | 16 | ### Requirements 17 | 18 | * Java Development Kit (JDK) with `keytool` 19 | * the command line interface 20 | 21 | ### Guidelines 22 | 23 | * Use the RSA algorithm for the key algorithm (`-keyalg`) 24 | * Use 2048+ bits for the key size (`-keysize`) 25 | * Use 25+ years (convert to days) for the validity (`-validity`) 26 | * Use a unique keystore per app 27 | * Use strong passwords 28 | 29 | ### How-to 30 | 31 | 1. Open the command line interface 32 | 2. Add the `keytool` location to your path or prepend it to the following command 33 | 3. Run `keytool -genkey -v -keystore .keystore -alias -dname "CN=,OU=IT,O=,L=Unknown,ST=Unknown,C=" -keyalg RSA -keysize 2048 -validity 13149` where you replace `` with the name of your app (`[a-z]{1,8}`), `` with the name of your company and `` with your country code (ISO-3166 alpha-2) 34 | 4. Enter your new store password ("outer password") 35 | 5. Enter your new key password ("inner password") 36 | 37 | ### Where do I find the `keytool`? 38 | 39 | * Windows: `\bin\keytool.exe` 40 | 41 | ### Why do I need a secure key? 42 | 43 | > If a third party should manage to take your key without your knowledge or permission, that person could sign and distribute applications that maliciously replace your authentic applications or corrupt them. Such a person could also sign and distribute applications under your identity that attack other applications or the system itself, or corrupt or steal user data. Your reputation as a developer entity depends on your securing your private key properly, at all times, until the key is expired. 44 | 45 | Source: http://developer.android.com/tools/publishing/app-signing.html 46 | 47 | ### What if I lose the key? 48 | 49 | > Your private key is required for signing all future versions of your application. If you lose or misplace your key, you will not be able to publish updates to your existing application. You cannot regenerate a previously generated key. 50 | 51 | Source: http://developer.android.com/tools/publishing/app-signing.html 52 | -------------------------------------------------------------------------------- /Android.md: -------------------------------------------------------------------------------- 1 | # Android 2 | 3 | * Before you sell your used phone or tablet, remember to remove the SD card and perform a factory reset under `Settings` - `Backup & reset`. 4 | * You don't really need antivirus software on your Android device. You are quite safe if you always pay attention to apps' permissions. 5 | * Just switch off your internet connection whenever you want an ad-free experience. Most ads (e.g. AdMob) won't show up then. 6 | * The most popular app stores in China include those from [Baidu](http://app.baidu.com/), [Taobao](http://app.taobao.com/), [Xiaomi](http://app.mi.com/) and [Tencent](http://android.myapp.com/). 7 | -------------------------------------------------------------------------------- /AngularJS.md: -------------------------------------------------------------------------------- 1 | # AngularJS 2 | 3 | ## Preventing the uncompiled site from flashing in the beginning 4 | 5 | While the page is still loading and before AngularJS has kicked in, the uncompiled site with all the AngularJS markup may flash. 6 | 7 | To prevent this, add the following to your page's CSS: 8 | 9 | ``` 10 | [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { 11 | display: none !important; 12 | } 13 | ``` 14 | 15 | Then add the two attributes ` ng-cloak class="ng-cloak"` to the page's `` tag. 16 | 17 | ## Placing AngularJS in `` vs `` 18 | 19 | You can safely reference the AngularJS JavaScript file from the end of ``, i.e. right before the closing `` tag, just as you (should) do with all your other JavaScript files. 20 | 21 | ## Unique IDs inside `ng-repeat` 22 | 23 | Whenever you're using HTML tags with an ID or `` inside `ng-repeat`, append `{{$index}}` to the ID reference in HTML to make sure it is always unique. 24 | 25 | If you have nested `ng-repeat` directives, you may use `{{$parent.$index}}` as well to access the index of the outer `ng-repeat`. 26 | 27 | ## Binding to primitives inside `ng-repeat` 28 | 29 | You cannot bind to primitives directly in `ng-repeat`: 30 | 31 | ``` 32 | // { names: [ "John", "Jane" ] } 33 |
34 | 35 |
36 | ``` 37 | 38 | Instead, you have to reference the value using the parent and the index: 39 | 40 | ``` 41 | // { names: [ "John", "Jane" ] } 42 |
43 | 44 |
45 | ``` 46 | -------------------------------------------------------------------------------- /Animals.md: -------------------------------------------------------------------------------- 1 | # Animals 2 | 3 | * Dolphins sleep without drowning by shutting one eye at a time, i.e. one half of the brain sleeps while the other half remains alert. This is called unihemispheric slow-wave sleep and allows dolphins and other aquatic mammals to surface for breathing. 4 | -------------------------------------------------------------------------------- /Apache HTTP Server.md: -------------------------------------------------------------------------------- 1 | # Apache HTTP Server 2 | 3 | ## Security 4 | 5 | * First, open the server's main configuration. On Ubuntu, for example, the following command does that: 6 | 7 | ``` 8 | $ sudo nano /etc/apache2/apache2.conf 9 | ``` 10 | 11 | Now find the section that configures the `/var/www/` directory. That section will start with the opening tag ``. 12 | 13 | Make sure that there's only *one* line starting with `Options` and edit that line so that it reads as follows: 14 | 15 | ``` 16 | Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch -Includes -ExecCGI 17 | ``` 18 | 19 | This ensures that the server does not show full directory listings when a visitor to your website navigates to a folder without an index page. Further, the server does not follow certain symbolic links (to other users' files) that an attacker might try to create in your application's directory, while still allowing for the use of `mod_rewrite` with `RewriteRule`. Server-side includes using `.shtml` files or the like will be disabled. And finally, execution of CGI scripts using `mod_cgi` will be disabled (which you can leave out if you need CGI support). 20 | 21 | Next, define custom error documents or error messages globally by inserting the following lines somewhere in the configuration file, this new block of lines as a whole surrounded by blank lines: 22 | 23 | ``` 24 | # Define custom error documents or messages 25 | ErrorDocument 400 "(400) Bad Request" 26 | ErrorDocument 401 "(401) Unauthorized" 27 | ErrorDocument 403 "(403) Forbidden" 28 | ErrorDocument 404 "(404) Not Found" 29 | ErrorDocument 410 "(410) Gone" 30 | ErrorDocument 500 "(500) Internal Server Error" 31 | ErrorDocument 503 "(503) Service Unavailable" 32 | ``` 33 | 34 | You may change the message texts, use relative paths to documents on your server (which must start with a `/`), or even define external URLs. 35 | 36 | Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. 37 | 38 | Restart Apache HTTP Server for the changes to take effect: 39 | 40 | ``` 41 | $ sudo service apache2 restart 42 | ``` 43 | 44 | * As a next step, open the server's dedicated security configuration. On Ubuntu, for example, the following command does that: 45 | 46 | ``` 47 | $ sudo nano /etc/apache2/conf-available/security.conf 48 | ``` 49 | 50 | Change `ServerTokens` to `Prod` in order to reduce the server information broadcasted in HTTP headers, error documents, etc. from the more detailed form (e.g. `Apache/2.3.4 (Ubuntu)`) to a minimal form (`Apache`). 51 | 52 | Change `ServerSignature` to `Off` in order to remove the server and hostname information from all sever-generated pages, e.g. error documents. 53 | 54 | Prevent Cross-site tracing (XST) by disabling `HTTP TRACE`. To do so, make sure that `TraceEnable` is set to `Off`. 55 | 56 | Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. 57 | 58 | Restart Apache HTTP Server for the changes to take effect: 59 | 60 | ``` 61 | $ sudo service apache2 restart 62 | ``` 63 | 64 | * Finally, open the SSL/TLS configuration. On Ubuntu, for example, the following command does that: 65 | 66 | ``` 67 | $ sudo nano /etc/apache2/mods-available/ssl.conf 68 | ``` 69 | 70 | Disable support for vulnerable SSL versions. To do so, make sure that the line starting with `SSLProtocol` either says `SSLProtocol all -SSLv2 -SSLv3` or `SSLProtocol all -SSLv3`. 71 | 72 | Press `Ctrl+X` to leave. If you applied any changes, then type `Y` and press `Enter` to save. 73 | 74 | Restart Apache HTTP Server for the changes to take effect: 75 | 76 | ``` 77 | $ sudo service apache2 restart 78 | ``` 79 | 80 | ## Installation 81 | 82 | ### On Ubuntu 83 | 84 | * Run the following command: 85 | 86 | ``` 87 | $ sudo apt-get install apache2 88 | ``` 89 | 90 | * Verify that you can see the "Apache2 Default Page" telling you that "It works!" when navigating to your server's public IP address using a web browser on another machine. 91 | 92 | * Enable usage of `.htaccess` files for additional configuration directives and better portability: 93 | 94 | ``` 95 | $ sudo nano /etc/apache2/apache2.conf 96 | ``` 97 | 98 | In the section that describes ``, change `AllowOverride None` to `AllowOverride All`. 99 | 100 | Somewhere else in the same file, make sure that `AccessFileName` is set to `.htaccess` as follows: 101 | 102 | ``` 103 | AccessFileName .htaccess 104 | ``` 105 | 106 | Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. Then restart Apache for the changes to take effect: 107 | 108 | ``` 109 | $ sudo service apache2 restart 110 | ``` 111 | 112 | * [Create a dedicated user in Ubuntu](Ubuntu%20Server.md) that you will use for day-to-day SSH (and SFTP) access 113 | 114 | ## Setting up Virtual Hosts 115 | 116 | * As a first step, determine your initial set of individual sites that you want to serve. (You will still be able to add more sites later on.) Every domain, subdomain or other site that should get its own application directory will be a “virtual host”. 117 | 118 | **Important:** To that set of hosts, add another one with a name that comes first in alphabetical order, compared to all the other hosts. For example, use a (fictitious) subdomain `000` of your primary domain, e.g. `000.example.com`. That additional host will serve as a default host and will automatically catch any undefined or invalid host requested by users (or attackers). Moreover, it will protect against HTTP header (`Host` request header) injection. If you set up SSL/TLS for any other host later, you must set up SSL/TLS for this default host as well. 119 | 120 | * For each of the individual sites that you want to serve, create a dedicated folder below the `/var/www/` directory: 121 | 122 | ``` 123 | $ sudo mkdir -p /var/www/{my-domain}/public 124 | $ sudo chown -R {sftp-user}:{sftp-user} /var/www/{my-domain} 125 | $ sudo chmod -R 755 /var/www/{my-domain} 126 | ``` 127 | 128 | Replace `{my-domain}` with the domain name of each site, e.g. `example.com`, and `{sftp-user}` with the name of your SFTP user (or any other regular user) that should own the folder. 129 | 130 | * Perhaps add some demo pages by creating simple HTML files in each `public` directory. 131 | 132 | * Create the site-specific configuration files: 133 | 134 | ``` 135 | $ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/{my-domain}.conf 136 | $ sudo nano /etc/apache2/sites-available/{my-domain}.conf 137 | ``` 138 | 139 | Change `ServerAdmin` to a proper email address that you can receive messages at. That mailbox may be hosted *anywhere*, e.g. also with a third-party provider. 140 | 141 | Change `DocumentRoot` so that it points to the `public` directory that you created for the particular site before. 142 | 143 | Add a new line saying `ServerName {my-domain}`. This defines the site's primary domain name. Based on this domain name, this site will be selected. 144 | 145 | Add a new line saying `ServerAlias www.{my-domain}` or give any other *secondary* domain names that should point to the same site. 146 | 147 | The file may now look like this: 148 | 149 | ``` 150 | 151 | ServerName example.com 152 | ServerAlias www.example.com 153 | ServerAdmin admin@example.com 154 | DocumentRoot /var/www/example.com/public 155 | 156 | ErrorLog ${APACHE_LOG_DIR}/error.log 157 | CustomLog ${APACHE_LOG_DIR}/access.log combined 158 | 159 | ``` 160 | 161 | Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. 162 | 163 | * Finally, activate the new site (and disable Apache’s template file): 164 | 165 | ``` 166 | $ sudo a2ensite {my-domain}.conf 167 | $ sudo a2dissite 000-default.conf 168 | $ sudo service apache2 reload 169 | ``` 170 | 171 | * You may now use the `hosts` file on your personal computer or development machine to test the setup with a *temporary* domain entry. 172 | 173 | * In order to publish the site, point the specified domain `{my-domain}` to the server by updating its DNS configuration. 174 | 175 | * Whenever you make changes to these `*.conf` files later, you have to refresh the server again via the following command: 176 | 177 | ``` 178 | $ sudo service apache2 reload 179 | ``` 180 | -------------------------------------------------------------------------------- /Audio.md: -------------------------------------------------------------------------------- 1 | # Audio 2 | 3 | * The human hearing range spans 20Hz to 20kHz. (Christopher Montgomery) 4 | * "[W]e can use low rate 44.1kHz or 48kHz audio with all the fidelity benefits of 192kHz or higher sampling (smooth frequency response, low aliasing) and none of the drawbacks (ultrasonics that cause intermodulation distortion, wasted space). Nearly all of today's analog-to-digital converters (ADCs) and digital-to-analog converters (DACs) oversample at very high rates." (Christopher Montgomery) 5 | * "[T]here are (and always will be) reasons to use more than 16 bits in recording and production. None of that is relevant to playback; here 24 bit audio is as useless as 192kHz sampling. The good news is that at least 24 bit depth doesn't harm fidelity. It just doesn't help, and also wastes space." (Christopher Montgomery) 6 | * "16 bits is enough to span the real hearing range with room to spare. It does not span the entire possible signal range of audio equipment." (Christopher Montgomery) 7 | * "Music is no longer an expression of the soul or the work of an artist; it's a 'product' that is manufactured, packaged, catalogued, distributed, managed, regulated, and above all *sold*." (Christopher Montgomery) 8 | -------------------------------------------------------------------------------- /Browsers.md: -------------------------------------------------------------------------------- 1 | # Browsers 2 | 3 | * By November 1992, there were 26 websites in the world, and the web's domain was mainly academia and large industrial research institutions. 4 | * The Mosaic browser was released in 1993, developed at the National Center for Supercomputing Applications (NCSA). It included buttons like "Home", "Back" and "Forward", as well as bookmark features and image rendering (GIF or HDF). Marc Andreessen was part of the developing team. 5 | * Mosaic and derived browsers drove the explosive growth of the Web to over 10,000 sites by 1995 and millions by 1998. 6 | * Marc Andreessen and Eric Bina left the Mosaic team in 1994 to found Netscape, releasing the new browser Netscape Navigator, with its internal code name "Mozilla". The name was either a blending of "Mosaic" and "Godzilla" or short for "Mosaic Killer". 7 | * Netscape called itself `Mozilla/1.0` in the user-agent string, and it came with new features such as frame support. Website developers invented browser sniffing and sent frames to Netscape and no frames to other browsers. 8 | * When Microsoft launched Internet Explorer, which supported frames as well, they made the browser impersonate Netscape as `Mozilla/1.22 (compatible; MSIE 2.0)` so that it received frames as well. 9 | * In the first "browser war", Internet Explorer defeated Netscape. 10 | * Netscape was reborn as Mozilla, later Firefox, with its Gecko rendering engine. Again due to browser sniffing by website developers, other browsers started adding "Gecko" to their user-agent string. 11 | * "Google built Chrome, and Chrome used Webkit, and it was like Safari, [...] and WebKit pretended to be KHTML, and KHTML pretended to be Gecko, and all browsers pretended to be Mozilla, [...] and the user agent string was a complete mess, and near useless, and everyone pretended to be everyone else." (Aaron Andersen) 12 | -------------------------------------------------------------------------------- /Business.md: -------------------------------------------------------------------------------- 1 | # Business 2 | 3 | * Never talk to potential acquirers of your company just for the sake of checking whether you'll receive an offer too good to refuse. 4 | * When receiving offers from potential acquirers, expect a reasonable valuation. Should they ever be surprising, they'll always be surprisingly low. 5 | * When you receive an offer for a potential acquisition, let the acquirer make the effort, which they will certainly do in case they're really serious. 6 | * A good salesman is never the one to come up with a price first. Try to be the one reacting to the price, not the one proposing it. 7 | * If you're in talks about selling your company and you must come up with a valuation, put it out confidently and high enough for bargaining. 8 | * Get a good lawyer. 9 | * Get a good accountant. 10 | * As the buyer of a company, you'll usually prefer an asset sale, whereas as a seller, you'll probably want a stock sale. 11 | * Sole proprietorships or partnerships cannot be sold as a stock sale, as there is no stock available. 12 | * When selling a company, always keep your business running and growing until it's really not your job anymore. 13 | * "A complex system that works is invariably found to have evolved from a simple system that works." (John Gall) 14 | * Advertising is like the flu. If it's not constantly changing, people develop immunity. 15 | * "Sizing the market for a disruptor based on an incumbent's market is like sizing the car industry off how many horses there were in 1910." (Aaron Levie) 16 | * Don't compare your company to a family -- it's not a lifetime relationship and layoffs are part of the game. You shouldn't (and can't) trust in loyalty blindly. 17 | * Consider your company a professional sports teams: You have a mission and come together with other people to accomplish that mission. The composition of your team changes over time, but your solidarity is based on trust and mutual investment, which results in mutual benefit. All of you have to prioritize team success over individual glory and yet this is the best way to achieve individual success as well. You are going to bring together a disparate team and achieve a common goal -- despite the reality of personnel turnover. That's what all businesses should strive for. (Reid Hoffman, Ben Casnocha, Chris Yeh) 18 | * The main driver of inequality is returns on capital that exceed the rate of economic growth. (Thomas Piketty) 19 | * "Design depends largely on constraints. [O]ne of the few effective keys to the design problem [is] the ability of the designer to recognize as many of the constraints as possible — his willingness and enthusiasm for working within these constraints." (Charles Eames) 20 | * Project management triangle: Fast, cheap, and reliable — choose two. That's all you can get. 21 | * Incentivizing the right behaviors is incredibly important. Rewarding managers with bonuses if their features are part of a final product, for example, can lead to feature bloat. Don't do that. 22 | * "[W]hile manipulating people with incentives seems to work in the short run, it is a strategy that ultimately fails and even does lasting harm. [We should] question our reliance on a theory of motivation derived from laboratory animals." (Alfie Kohn) 23 | * "[T]he more we use artificial inducements to motivate people, the more they lose interest in what we're bribing them to do." (Alfie Kohn) 24 | * "Start with focusing on a small market and dominate that market first." (Peter Thiel) 25 | * "If you don't want to split shares evenly then perhaps you should not be co-founders." (Peter Thiel) 26 | * "I am [...] a fan of the two-person founding team, with one more on the business side and one more on the technical side." (Peter Thiel) 27 | * "We know well [Alibaba hasn't] survived because our strategies are farsighted and brilliant, or because our execution is perfect, but because for 15 years we have persevered in our mission of 'making it easier to do business across the world', because we have insisted on a 'customer first' value system, because we have persisted in believing in the future, and because we have insisted that normal people can do extraordinary things." (Jack Ma) 28 | * The only way to fight knowledge-hiding in the workplace? "Put in incentives to reward people on team outcomes versus solely on individual outcomes." (David Zweig) 29 | * "First-time founders care most about their exit. Every time after that, you focus on legacy." (Unknown) 30 | * "Culture eats strategy for breakfast." (Peter Drucker) 31 | * "Saying yes is so much easier than saying no, but nobody else will ever value your time as much as you do so you need to be a responsible steward of it." (Andrew Bosworth) 32 | * "Look back on your past week and assemble an honest accounting of your attention. Does the time you spent in each area mirror the importance of that area? This exercise is the true test of your ability to prioritize. It will tell you whether you are able to maintain focus on the important or whether you get distracted by the urgent." (Andrew Bosworth) 33 | * In 2014, social media (e.g. Facebook, Twitter) had already become a mature market with little innovation. Private messaging (e.g. WhatsApp, Snapchat) was the new social media. 34 | * The "sharing economy" turned out to be the "rental economy", actually. 35 | * "If you don't have first hand experience of an industry, you're probably wrong about how it works, what problems they have and so how they should be solved. Talk to people." (Ben Dixon) 36 | * "Trying to raise money and apply to accelerators is a full time job. You're probably either building [a product] or fund raising. Not both. If in doubt, choose building." (Ben Dixon) 37 | * Providing free returns to customers in e-commerce has proved profitable. Customers who make use of a free return are far more likely to buy again in the same shop the next time. This easily compensates for the costs of the free return. 38 | * "[P]art of the problem with freemium is that it changes your perception of where the value lies. The user discounts the value of the free component to nothing and only measures the value of the additional functionality that is unlocked with buying the premium portion. A lot of the time, this looks like a ripoff." (scriptman) 39 | * It's easier to lower the price when you don't sell enough than to raise the price on something that is selling well. 40 | * "[A]s far as equity is concerned, it's worth $0 until you exit. There's a potential for millions, but my lottery ticket is also worth potentially millions of dollars. My landlord won't accept my lottery ticket as payment." (Jemaclus) 41 | * "So one way to insider trade is, you work at a bank, and you advise on mergers, and before a merger happens you meet a guy and write the name of the target on a napkin, and the guy reads the napkin, and then he eats it, and then he buys stock in the target, and he makes money, and then you meet in a parking lot and he hands you a bag of cash representing your cut of his profits. There are a lot of variations, many involving golf, but that's the basic structure." (Matt Levine) 42 | * "I swear to you, sitting a throne is a thousand times harder than winning one." (George R. R. Martin) 43 | 44 | ## Salary negotiation 45 | 46 | In job interviews and negotiations, you'll usually get asked about your current salary and your desired salary, often very early in the process. For that situation, Patrick McKenzie and Josh Doody recommend the following: 47 | 48 | * Show confidence, professionalism and competence in your response to the salary question. 49 | * Do not lie in response to the salary question. Do not invent any high salary. Be honest and only *withhold* information. 50 | * Perhaps suggest to get back to the salary question later on, after you've both made sure you're a good fit for each other. If you're the right fit, you'll probably be able to agree on the numbers regarding salary, vacation days and so on. Otherwise, you don't need to worry about the numbers, anyway. They are irrelevant. 51 | * The later in the process you talk about the salary, the better. They will offer and accept higher salaries *after* learning about your skill level, as opposed to the time *before*. Otherwise, you might not even get a chance anymore to demonstrate your strengths. 52 | * If you actually give a number as a response to the salary question, this will immediately cap your range for the negotiation. That means you'll lose out on any higher salary that they might have been willing to offer. So don't do this. *Never* give a number first. 53 | * You might answer that you're not comfortable sharing the requested information and that you'd rather want to focus on the value you might add to the company. 54 | * If they say they need a number in order to move the process forward, they're just lying to you in order to compromise your negotiating position. 55 | * Saying that you want to make a (big) step forward both in terms of responsibility and compensation signals that you're willing to perform (even) better than before and accomplish more, but also want proportionately better compensation. 56 | * Illustrate that only *they* know how they value your skills, how much they pay other people at their company, what their company's needs are, and how much value you'll be adding to their company. So they should suggest a base for the negotiations. 57 | * Explain that they might give you a number and you'll happily tell them whether this is in your accepted range or not. 58 | * Say that you *trust* them to give you a fair offer that is consistent with their standard practices and general compensation in the industry. 59 | * Continue to block requests for a specific number or range, even if they keep pressing you on that number. 60 | * Prior to the negotiation, you should have thought about your minimum acceptable salary. Now, do *not* accept any offer below that number. 61 | * After receiving your first offer from the company, *no matter what number it is*, you're going to negotiate upwards. It's unlikely they have just given you their absolute maximum initially. You *always*, as a matter of policy, negotiate *all* offers. 62 | * Negotiate all the single components of the compensation (e.g. also the vacation days) to get the best possible outcome. 63 | * If they decline to negotiate a single component, you might ask where they suggest there is any flexibility, given that there doesn't seem to be any flexibility on that one component. 64 | * As soon as you have a formal offer, ask for one or two days to think about it. 65 | -------------------------------------------------------------------------------- /Composer (PHP).md: -------------------------------------------------------------------------------- 1 | # Composer (PHP) 2 | 3 | ## What is Composer? 4 | 5 | * Composer is a dependency manager for PHP. 6 | * Almost every PHP application depends on some external libraries in one way or another. These libraries or packages are often produced by third parties. 7 | * Composer helps you install and maintain those libraries with ease. 8 | * Declaring what external packages your application depends on is also an important part of documentation. 9 | * After learning the few commands that you'll need, Composer will start saving you a lot of time and hassle instantly. 10 | * If you know "npm" or "Yarn" from Node.js, "Bower" or "Yarn" from JavaScript, "RubyGems" or "Bundler" from Ruby, or perhaps just "APT" from Debian or "Homebrew" from macOS, that's more or less what Composer is to PHP. 11 | * Composer is multi-platform software and works equally well on Linux, macOS and Windows. 12 | 13 | ## Why should I use Composer? 14 | 15 | | Task | Without Composer | With Composer | 16 | | --- | --- | --- | 17 | | Download a third-party library or your own external module | (1) Try to find a trustworthy source for the package on the web. (2) Download an archive (e.g. ZIP) of the package that contains the source code, ideally over HTTPS. (3) Optionally, verify checksums of the downloaded archive against information on the web. (4) Extract the source code from the archive. | `$ composer require some-vendor/some-package` | 18 | | Move the library or module into the project of your own application | (1) Find a good place in your project where you could put all your external dependencies. (2) Create a meaningful directory structure in that place. (3) Move the downloaded source code to the location you've just chosen. | All packages are automatically stored in the `vendor` directory at the root of your project. | 19 | | Make the components (e.g. classes) of the library or module available in the source code of your own application | (1) Insert a `require` statement in your application that includes the main component that you want to use. (2) Consider whether you really want `require`, or if you rather want `include`, `require_once` or `include_once` instead. (3) Read the error and warning messages telling you that the included component needs other parts of the library or module as well. (4) Figure out which other components to include to make the errors and warnings go away. (5) Sort out the various inclusions to bring them into the correct order, resolving conflicts along the way. (6) Make sure that the list of inclusions is in some path of your application logic that is always executed when the library or module is required. (7) Consider how you can optimize the performance and memory footprint of your application, given that you have now started including many components from the library or module that are not really used for every request or page. | `require __DIR__ . '/vendor/autoload.php';` | 20 | | Update a library or module to a new *patch* version (e.g. from `x.x.6` to `x.x.7`) or *minor* version (e.g. from `x.4.x` to `x.5.x`), e.g. for bug fixes or new features | Repeat the steps of locating the new version of the library on the web, downloading it securely, and replacing the old version in the project of your application. Review whether the update is really safe to install, being backwards-compatible and thus *not* introducing any breaking changes. | `$ composer update some-vendor/some-package` | 21 | | Update a library or module to a new *major* version (e.g. from `2.x.x` to `3.x.x`), e.g. for new features or bug fixes | Repeat the steps of locating the new version of the library on the web, downloading it securely, and replacing the old version in the project of your application. | `$ composer require some-vendor/some-package --update-with-dependencies --sort-packages` | 22 | | Check which libraries or modules have security updates, bug fixes or new features available | (1) Create a list of all libraries or modules that you have imported manually into your project. (2) Locate the official project sites for each of these libraries or modules on the web. (3) On the respective project sites, check for information about new versions. | `$ composer outdated` | 23 | | Create a list of all licenses of the libraries and modules used in your application | (1) Create a list of all libraries or modules that you have imported manually into your project. (2) Locate the official project sites for each of these libraries or modules on the web. (3) On the respective project sites, check for license information. | `$ composer licenses` | 24 | | Keep an exact and reproducible version of the library or module under version control | Keep dozens, perhaps hundreds or thousands of files in your version control which do not actually belong to your project. Update them as needed, which involves checking in many additions, modifications and deletions. | Keep the single file `composer.json` in version control, which just lists the exact name and version of each package. | 25 | 26 | ## How do I install Composer on my workstation? 27 | 28 | ### Linux 29 | 30 | 1. Open the [official download page](https://getcomposer.org/download/) and execute the four commands shown at the top. This needs the `php` executable somewhere in your `PATH`. Otherwise, prepend the full path to that executable on your machine. 31 | 1. Run the following command to make Composer available globally as `composer`: 32 | 33 | ```bash 34 | $ sudo mv composer.phar /usr/local/bin/composer 35 | ``` 36 | 37 | **Note:** If you manage multiple PHP versions on your system, make sure to provide the path to the executable for the desired PHP version to Composer. Otherwise, Composer will be forced to make wrong assumptions about your configuration and may install wrong packages. 38 | 39 | ### macOS 40 | 41 | See “Linux” above 42 | 43 | ### Windows 44 | 45 | 1. Download the [official installer](https://getcomposer.org/Composer-Setup.exe). 46 | 1. Run the installer. 47 | 48 | **Note:** If you manage multiple PHP versions on your system, make sure to provide the path to the executable for the desired PHP version to Composer. Otherwise, Composer will be forced to make wrong assumptions about your configuration and may install wrong packages. 49 | 50 | ## Do I need to install Composer on my web server? 51 | 52 | No. The dependencies will always be managed locally (i.e. on your workstation) and then just transferred to the server when uploading your application, along with all the other source files of your application. 53 | 54 | ## I have a project with an existing `composer.json` file. How do I install the libraries or modules listed in that file? 55 | 56 | 1. Open the root directory of the project where the `composer.json` file is located. 57 | 1. Execute the following command on the command line: 58 | 59 | ```bash 60 | $ composer install 61 | ``` 62 | 63 | ## How do I add a new library or module to my application? 64 | 65 | 1. Open the root directory of the project where the `composer.json` file is located. 66 | 1. Find out the package name of the library or module that you want to install, e.g. `some-vendor/some-package`. 67 | 1. Execute the following command on the command line: 68 | 69 | ```bash 70 | $ composer require some-vendor/some-package 71 | ``` 72 | 73 | ## I have installed some libraries or modules with Composer. How do I make them available in my application? 74 | 75 | Somewhere in your PHP files, usually at the top, *before* the parts where you want to make use of the components, place this line *once*: 76 | 77 | ```php 78 | require __DIR__ . '/vendor/autoload.php'; 79 | ``` 80 | 81 | This imports *all* libraries and modules that are needed, but *only* those that are actually required for the specific page or request. All that happens automatically. 82 | 83 | ## How do I update libraries or modules within my application? 84 | 85 | 1. Open the root directory of the project where the `composer.json` file is located. 86 | 1. Find out the package name of the library or module that you want to update, e.g. `some-vendor/some-package`. 87 | 1. Execute the following command on the command line: 88 | 89 | ```bash 90 | $ composer update some-vendor/some-package 91 | ``` 92 | 93 | If you want to update *all* libraries or modules *at once*, just drop the argument taking the package name: 94 | 95 | ```bash 96 | $ composer update 97 | ``` 98 | 99 | Both commands update the libraries or modules with regard to the version constraints listed in the `composer.json` file. By default, that means patch version updates (e.g. from version `x.x.6` to `x.x.7`) and minor version updates (e.g. from version `x.4.x` to `x.5.x`) are allowed while major version upgrades (e.g. from version `2.x.x` to `3.x.x`) are excluded. 100 | 101 | Major version upgrades may introduce breaking changes which are not backwards-compatible. If you want to change the version constraints, e.g. to perform a major version upgrade, you can do so by simply adding the specific package again with Composer, which will overwrite the old package: 102 | 103 | ```bash 104 | $ composer require some-vendor/some-package --update-with-dependencies --sort-packages 105 | ``` 106 | 107 | Likewise, if you want to document that you *rely* on certain new features from a new *minor* version, you can make Composer update your version constraints while performing the update, targetting a specific version, e.g. version `3.7` as shown below: 108 | 109 | ```bash 110 | $ composer require "some-vendor/some-package:^3.7" --update-with-dependencies --sort-packages 111 | ``` 112 | 113 | ## How do I remove libraries or modules from my application? 114 | 115 | 1. Open the root directory of the project where the `composer.json` file is located. 116 | 1. Find out the package name of the library or module that you want to remove, e.g. `some-vendor/some-package`. 117 | 1. Execute the following command on the command line: 118 | 119 | ```bash 120 | $ composer remove some-vendor/some-package 121 | ``` 122 | 123 | ## How can I list all the libraries or modules that can be updated? 124 | 125 | 1. Open the root directory of the project where the `composer.json` file is located. 126 | 1. Execute the following command on the command line: 127 | 128 | ```bash 129 | $ composer outdated 130 | ``` 131 | 132 | Sometimes, you'll want to *exclude* upgrades to new *major* versions (e.g. from version `2.x.x` to `3.x.x`). These major version upgrades may introduce breaking changes which are not backwards-compatible. To exclude those upgrades, run the following command instead: 133 | 134 | ```bash 135 | $ composer outdated --minor-only 136 | ``` 137 | 138 | ## How do I update Composer itself to a new version? 139 | 140 | ### Linux 141 | 142 | ```bash 143 | $ sudo -H composer self-update 144 | ``` 145 | 146 | ### macOS 147 | 148 | See "Linux" above 149 | 150 | ### Windows 151 | 152 | ``` 153 | $ composer self-update 154 | ``` 155 | 156 | ## I really can't use Composer for some reason. How do I import the required dependencies manually? 157 | 158 | 1. Open the `composer.json` file of the project, which is usually located in the project's root directory. 159 | 1. Find the contents inside the `"require": {}` section. 160 | 1. For every package listed there, use the package name from the list to search for the library or module on [Packagist](https://packagist.org/). 161 | 1. If you have found the library or module on Packagist, follow the link to the respective project site there. 162 | 1. Download the correct version of the library or module, as found in the the `"require": {}` section earlier, from the project site. 163 | 1. Put the downloaded source files somewhere in your project's directory. 164 | 1. Make all required components available in your application via `require` statements. You may have to try different orders and include further components required by those you actually want. 165 | -------------------------------------------------------------------------------- /Computer networks.md: -------------------------------------------------------------------------------- 1 | # Computer networks 2 | 3 | * "NAT" stands for "Network Address Translation". 4 | * On a typical network, you have an IP address like 192.168.0.20, which is a private IP, not your public Internet IP address. 5 | * A NAT router performs intelligent address translations between private and public IP addresses. 6 | * IPv4 and its small address space was the reason NAT had to be invented. 7 | 8 | ## Wi-Fi 9 | 10 | ### Encoding SSID and password as a QR code 11 | 12 | Encode the following text as a QR code, replacing `` and `` with the actual values for your network: 13 | 14 | ``` 15 | WIFI:S:;T:WPA;P:;; 16 | ``` 17 | 18 | For example, that text could be (before encoding): 19 | 20 | ``` 21 | WIFI:S:My-SSID;T:WPA;P:my-password;; 22 | ``` 23 | 24 | Alternatively, use a tool like [QiFi](https://qifi.org/) ([source code](https://github.com/evgeni/qifi)) online. 25 | -------------------------------------------------------------------------------- /Creativity.md: -------------------------------------------------------------------------------- 1 | # Creativity 2 | 3 | * "The most important process underlying strokes of creative genius is cognitive disinhibition — the tendency to pay attention to things that normally should be ignored or filtered out by attention because they appear irrelevant." (Dean Keith Simonton) 4 | * "When Alexander Fleming noticed that a blue mold was killing off the bacteria culture in his petri dish, he could have just tossed the latter into the autoclave like any of his colleagues might have done. Instead, Fleming won the Nobel Prize for his discovery of penicillin, the antibacterial agent derived from the mold *Penicillium notatum*." (Dean Keith Simonton) 5 | -------------------------------------------------------------------------------- /Crowdin.md: -------------------------------------------------------------------------------- 1 | # Crowdin 2 | 3 | ## Verifying translation from proofreading mode 4 | 5 | The following JavaScript bookmarklet can be used to perform automatic quality assurance (QA) checks that highlight possible mistakes in translations, as well as showing a machine translation on Google Translate to verify the user-submitted translation. 6 | 7 | In your browser, just create a bookmark with the following target address: 8 | 9 | ``` 10 | javascript:(function () {var sourceContainer=document.querySelector("#crowdin-editor-wrapper #proofread-view #content #editor-center-layout #phrases #texts_list .proofread-string-wrapper.checked .phrase-left .proofread-string-source-wrapper");if(null!==sourceContainer){var sourceNode=sourceContainer.querySelector(".proofread-string-source .singular.selectable");if(null!==sourceNode){var sourceLang=sourceContainer.lang,sourceText=sourceNode.textContent,translationNode=document.querySelector("#crowdin-editor-wrapper #proofread-view #content #editor-center-layout #phrases #texts_list .proofread-string-wrapper.checked .proofread-string-translations .proofread-string-translation textarea");if(null!==translationNode){var translationLang=translationNode.lang,translationText=translationNode.value,specialsRegex=/(?:<[biu]>)|(?:<\/[biu]>)|(?:%(?:[1-9]\$)?[ds])|(?:&#?[^&#;]+;)|(?:\\{1,2}[nt])/g,sourceSpecials=sourceText.match(specialsRegex),translationSpecials=translationText.match(specialsRegex);if(JSON.stringify(translationSpecials)===JSON.stringify(sourceSpecials)){var googleTranslateUrl=[];googleTranslateUrl.push("https://translate.google.com/?sl="),googleTranslateUrl.push(encodeURIComponent(translationLang)),googleTranslateUrl.push("&tl="),googleTranslateUrl.push(encodeURIComponent(sourceLang)),googleTranslateUrl.push("&text="),googleTranslateUrl.push(encodeURIComponent(translationText.replace(specialsRegex,function(e){return"<"===e.charAt(0)?"":"%"===e.charAt(0)?"\u{1F534}":-1!==e.indexOf("\\n")?"\n":-1!==e.indexOf("\\t")?"\t":e})));var sourceLength=sourceText.length;switch(sourceLang.substring(0,2)){case"ja":case"ko":sourceLength*=2.2;break;case"zh":sourceLength*=3.3}var translationLength=translationText.length;switch(translationLang.substring(0,2)){case"ja":case"ko":translationLength*=2.2;break;case"zh":translationLength*=3.3}translationLength<.25*sourceLength?alert("The translation is suspiciously short!"):4*sourceLength)|(?:<\/[biu]>)|(?:%(?:[1-9]\$)?[ds])|(?:&#?[^&#;]+;)|(?:\\{1,2}[nt])/g; 31 | var sourceSpecials = sourceText.match(specialsRegex); 32 | var translationSpecials = translationText.match(specialsRegex); 33 | 34 | if (JSON.stringify(translationSpecials) === JSON.stringify(sourceSpecials)) { 35 | var googleTranslateUrl = []; 36 | googleTranslateUrl.push("https://translate.google.com/?sl="); 37 | googleTranslateUrl.push(encodeURIComponent(translationLang)); 38 | googleTranslateUrl.push("&tl="); 39 | googleTranslateUrl.push(encodeURIComponent(sourceLang)); 40 | googleTranslateUrl.push("&text="); 41 | googleTranslateUrl.push(encodeURIComponent(translationText.replace(specialsRegex, function (match) { 42 | if (match.charAt(0) === "<") { 43 | return ""; 44 | } 45 | else if (match.charAt(0) === "%") { 46 | return "\u{1F534}"; 47 | } 48 | else if (match.indexOf("\\n") !== -1) { 49 | return "\n"; 50 | } 51 | else if (match.indexOf("\\t") !== -1) { 52 | return "\t"; 53 | } 54 | else { 55 | return match; 56 | } 57 | }))); 58 | 59 | var sourceLength = sourceText.length; 60 | 61 | switch (sourceLang.substring(0, 2)) { 62 | case "ja": 63 | case "ko": 64 | sourceLength *= 2.2; 65 | break; 66 | case "zh": 67 | sourceLength *= 3.3; 68 | break; 69 | } 70 | 71 | var translationLength = translationText.length; 72 | 73 | switch (translationLang.substring(0, 2)) { 74 | case "ja": 75 | case "ko": 76 | translationLength *= 2.2; 77 | break; 78 | case "zh": 79 | translationLength *= 3.3; 80 | break; 81 | } 82 | 83 | if (translationLength < (sourceLength * 0.25)) { 84 | alert("The translation is suspiciously short!"); 85 | } 86 | else if (translationLength > (sourceLength * 4)) { 87 | alert("The translation is suspiciously long!"); 88 | } 89 | 90 | if (translationText.indexOf(" ") !== -1 && sourceText.indexOf(" ") === -1) { 91 | alert("The translation includes consecutive spaces!"); 92 | } 93 | 94 | window.open(googleTranslateUrl.join(""), ""); 95 | } 96 | else { 97 | alert("The translation seems to be in a wrong format!"); 98 | } 99 | } 100 | } 101 | } 102 | })(); 103 | ``` 104 | 105 | When clicked, this will take the selected translation from the proofreading mode in Crowdin, check its format with regard to HTML tags and entities, special symbols and placeholders, and open a new tab with Google Translate showing the reverse translation. 106 | -------------------------------------------------------------------------------- /Domains and DNS.md: -------------------------------------------------------------------------------- 1 | # Domains and DNS 2 | 3 | ## Using Sender Policy Framework (SPF) on Gandi.net 4 | 5 | ### Mails sent from Gandi Mail 6 | 7 | ``` 8 | @ 10800 IN TXT "v=spf1 ip4:217.70.176.0/21 ip6:2001:4b98:c::/48 ptr ?all" 9 | @ 10800 IN SPF "v=spf1 ip4:217.70.176.0/21 ip6:2001:4b98:c::/48 ptr ?all" 10 | ``` 11 | 12 | ### Mails sent from Simple Hosting 13 | 14 | ``` 15 | @ 10800 IN TXT "v=spf1 ip4:217.70.176.0/21 ip6:2001:4b98:c::/48 ip4:217.70.185.10 ip4:173.246.97.150 ip4:217.70.186.165 ptr ?all" 16 | @ 10800 IN SPF "v=spf1 ip4:217.70.176.0/21 ip6:2001:4b98:c::/48 ip4:217.70.185.10 ip4:173.246.97.150 ip4:217.70.186.165 ptr ?all" 17 | ``` 18 | 19 | ### Adding the appropriate records to your DNS 20 | 21 | You can do this [either in expert mode or in normal mode](http://wiki.gandi.net/en/dns/zone/spf-record). 22 | 23 | ## Verifying your Sender Policy Framework (SPF) records 24 | 25 | * Check your records with [this tool](http://www.kitterman.com/spf/validate.html) 26 | * Send an email to your own address from the server that you've set up SPF for. Go to `View original` or `Show source` and search for something like `Received-SPF: ...` or `spf=...` which should say `pass` -- or at least `neutral`. 27 | -------------------------------------------------------------------------------- /Eclipse.md: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | 3 | ## Exporting Android projects as "fat" JARs with dependencies 4 | 5 | 1. Go to one of the `.java` files in your project's package 6 | 2. Add `public static void main(String[] args) { }` somewhere (will be deleted again later) and save the file 7 | 3. Open the "Run as ..." drop-down menu and choose "Run Configurations" 8 | 4. Right-click on the "Java Application" item in the list on the left and choose "New" 9 | 5. Enter a name, usually your project's name 10 | 6. Choose your project by clicking "Browse ..." 11 | 7. Choose *any* of your classes (usually there will only be the one we have edited above) as the "Main class" by clicking "Search ..." 12 | 8. Save the configuration by clicking "Apply" 13 | 9. Remove `public static void main(String[] args) { }` from step two again 14 | 10. Right-click your project and choose "Export ..." 15 | 11. Open section "Java" and choose "Runnable JAR file" 16 | 12. Choose your new launch configuration and some new file `.jar` as the export destination 17 | 13. Click "Finish" and be prepared to ignore *some* warnings 18 | -------------------------------------------------------------------------------- /Economics.md: -------------------------------------------------------------------------------- 1 | # Economics 2 | 3 | * "We have an industrial society that is based on the use of machines and technology, which serve to economize on labor. It would be logical that we should have to work less because we can have all of our needs satisfied with a minimum amount of activity. But what takes place is just the opposite. Today we work much more than ever before." (Anselm Jappe) 4 | * "The great innovations of the past are *now* well understood as being very, very important. It's very obvious. In almost every case, they were not widely understood as such at the time. In fact, I would assert that they were often actually viewed as trivialities or jokes. I don't think it is a new phenomenon to be this dismissive about new technology." (Marc Andreessen) 5 | * "When Thomas Edison was first working on the telephone, the assumption of the use case was the idea that telegraph operators needed to be able to talk to each other. It was considered so implausible that you would have a system that would let any ordinary person pick up the telephone and talk to another person, like that was clearly implausible, that was clearly not going to happen." (Marc Andreessen) 6 | * "It's hard to remember, but the Internet was laughed at. It was heaped with scorn from 1993 to 1997/1998. In fact, those of you who were in the industry at that time will remember that the New York Times had a reporter on staff named Peter Lewis. I'm convinced he was hired by the editors to just write negative stories about the Internet. It was all he did. And it was always 'the Internet is never going to be a consumer medium, the Internet is not nearly as big as these people think, nobody is ever going to trust the Internet for e-commerce." (Marc Andreessen) 7 | * "The car was absolutely viewed as a triviality and a toy when it first emerged. In fact, J.P. Morgan himself refused to invest in Ford Motor Company, with the response that it's 'just a toy for rich people', which is in fact what it was at the time. If you had one of the first cars, you had to be a rich person, which means you also had to have a driver, unless you were a very advanced rich person. You also had to have a stoker with the early cars to keep the engine going, and then you also had to travel with a full-time mechanic cause the thing would break down every three miles. So there were a lot of reasons to doubt the importance of the car." (Marc Andreessen) 8 | * "We have a large computer rust belt, which nobody likes to talk about, but it is companies like Cisco, Dell, Hewlett Packard, Oracle, IBM, where I think the pattern will be to become commodities, no longer innovate, corresspondingly cut their labor force, and cut their profits in the decade ahead." (Peter Thiel) 9 | * "Twitter is instant public global messaging for free. If you think about the impact of that, if you go back into any previous era, the era of telegraphs, the era of telephones, the era of television, and you tell that instead of having the communication technologies you have at the time, I can give you instant public global messaging for free, they would have thought you delivered it straight from heaven, like its the most astonishing communications breakthrough they could have possibly imagined. And we actually have it, and it actually works." (Marc Andreessen) 10 | * The technology-driven economy greatly favors a small group of successful individuals by amplifying their talent and luck, and dramatically increasing their rewards. (Erik Brynjolfsson) 11 | * "Agatha Christie never imagined being rich enough to own a car or poor enough to have no servants. Profound example of tech and social change." (Benedict Evans) 12 | * "Education is the most powerful thing you can do to affect lifetime earnings." (David Autor) 13 | 14 | ## Digital economics 15 | 16 | * Once you've produced a certain product, the cost of making additional copies (marginal cost) tends to zero. 17 | * Advertising allows you to give away your complete product to consumers for free while generating revenue from third parties who purchase ads that are shown to the audience. This has always been a popular business model for radio, TV and the web. 18 | * Tiered pricing allows you to give away some products for free and conversely set higher prices for other parts of the portfolio. Examples for this model include coupons and the freemium model. 19 | * When you bundle products that each individually have almost zero marginal cost, you can sell the whole package as a unit that's worth paying for. For example, movie streaming sites such as Netflix package individual films and series (with very low marginal costs) into a subscription that's worth paying for. 20 | * Larger companies can make single products free to support their overall ecosystem. For example, Google and Apple subsidize their ecosystems with free GPS tools such as maps and navigation. 21 | * Net neutrality prevents "a transformation from a market where innovation rules to one where deal-making rules. Or, a market where firms rush to make exclusive agreements with AT&T and Verizon instead of trying to improve their products." (Tim Wu) 22 | * Regarding net neutrality, "let's think about the nation's highways. How would you feel if [they] announced an exclusive deal with General Motors to provide a special 'rush-hour' lane for GM cars only? That seems intuitively wrong. [...] And if highways really did choose favorite brands, you might buy a Pontiac instead of a Toyota to get the rush-hour lane, not because the Pontiac is actually a good car. As a result, the nature of competition among car-makers would change. Rather than try to make the best product, they would battle to make deals with highways." (Tim Wu) 23 | * "[T]he 700-person start-up Airbnb, which allows users to rent their apartments like hotel rooms, was valued at $10 billion this past spring, about half as much as the Hilton corporation, which employs 152,000 people." (Michael Harris) 24 | -------------------------------------------------------------------------------- /Education.md: -------------------------------------------------------------------------------- 1 | # Education 2 | 3 | * "We are deeply concerned [...] of the very large number of dropouts by schoolchildren. This is a very disturbing situation, because the youth of today are the leaders of tomorrow. Try as much as possible to remain in school, because education is the most powerful weapon which we can use." (Nelson Mandela) 4 | * Don't try to have your children occupied all the time. Boredom is an important source of creativity. 5 | * Teach self control and discipline in as many positive ways as possible. 6 | * Don't try to remove every bit of struggle in your children's life. They need it to grow. When all their toys are always within their reach, why should they start to crawl? 7 | * "[Parents and teachers] often praise the ability, the talent, or the intelligence too much. The opposite of this is the good process praise. This is praise for the process the child engages in — their hard work, trying many strategies, their focus, their perseverance, their use of errors to learn, their improvement. [...] The more [you give] process praise, the more [do] kids ha[ve] a growth mindset and a desire for challenge [...]." (Carol Dweck) 8 | -------------------------------------------------------------------------------- /Electronics.md: -------------------------------------------------------------------------------- 1 | # Electronics 2 | 3 | * While earlier (nickel-based) batteries improved from full draining, newer (lithium-ion based) batteries suffer from that. 4 | * Never let your lithium-ion fully drain. Try to have the battery level above 20% at any time, if possible. 5 | * In the past, an Ethernet crossover cable (twisted pairs) was necessary in order to connect computing devices (of the same type) directly. Today, Auto MDI-X detects the required connection type via autonegotiation. 6 | * Modern (photo)copiers (i.e. digital copiers) have hard disks. In order to copy documents, they scan them first, save them on the hard disk and then print them. In most cases, the copy on the hard disk is either permanent or can be easily recovered later. 7 | * When using a digital camera to take a photo of a digital screen (e.g. TV, computer), you'll usually see a moiré pattern. This unwanted effect is caused by interactions between the pixel grids of the screen and the camera sensors. 8 | * Energy density in modern batteries increases by about five percent per year through incremental improvements from R&D. 9 | * The expression 'more than Moore' refers to the integration of more than just transistors on a chip. One is putting other components on the chips, e.g. analogue components and radio circuits, eclipsing in a system-on-a-chip (SoC). 10 | 11 | ## Screen resolutions 12 | 13 | * Changing a monitor's resolution from its "native" resolution to something else was fine with CRTs, but cannot reasonably be done with LCDs, where it would result in bad picure quality due to their fixed rasters. 14 | * UHD (or 4K) is only worth it if you have a *very* large TV screen (larger than most people would be comfortable with in their room), if you sit very close (which you usually do in a presentation room but not at home). Obviously, all components (video source, connections and TV screen) must support UHD. 15 | * At a distance of 10 cm, the maximum resolution that the human eye can perceive is between 876 dpi/ppi (normal visual acuity) and 2190 dpi/ppi (perfect visual acuity). Thus at the average reading distance of 30 cm, it's only 292 dpi/ppi (normal visual acuity) or 730 dpi/ppi (perfect visual acuity). So printing magazines at 300 dpi is good enough for most people. For computer monitors or TVs at home, divide 88 dpi/ppi (normal visual acuity) or 219 dpi/ppi (perfect visual acuity) by the distance in meters to get the maximum resolution you may actually perceive. Thus, in order to take the most of Full HD on a 50" screen, you'll need to sit 2 m away. For 4K resolution, you must move closer to 1 m or get a 100" screen instead. 16 | -------------------------------------------------------------------------------- /Email.md: -------------------------------------------------------------------------------- 1 | # Email 2 | 3 | * When including links in emails (or other texts), wrap them in angle brackets (`<...>`). This emphasizes where the link starts/ends, and it avoids problems with line wraps and trailing equals signs (`=`) in various client applications. 4 | -------------------------------------------------------------------------------- /Energy (Germany).md: -------------------------------------------------------------------------------- 1 | # Energy (Germany) 2 | 3 | * Having separate utility companies for power and gas usually allows for the cheapest prices. 4 | * Switch your utility companies for both power and gas *every single year* and find new good offerings. 5 | 6 | ## Finding good offerings (fair contracts with cheap prices) 7 | 8 | * Accept special bonuses or extra premiums: no 9 | * Maximum contract duration: 12 months 10 | * Price guarantee 11 | * Minimum scope: everything except for taxes and duties 12 | * Minimum duration: 12 months 13 | * Maximum period of cancellation: 6 weeks 14 | * Maximum automatic contract extension: 1 month 15 | * Maximum size of installment payments: monthly 16 | * Include packaged offerings with specific quantities of energy (in kWh): no 17 | * Show only offerings in accordance with the comparison provider's proprietary guidelines: no 18 | * Show only offerings with certain rating as per the comparison provider's proprietary standards: no 19 | * Maximum number of offerings per utility company: unlimited 20 | -------------------------------------------------------------------------------- /English language.md: -------------------------------------------------------------------------------- 1 | # English language 2 | 3 | * For nouns, you use the singular form only for the number `1` and the plural form otherwise. So it's `0 trains`, `5 trains`, `-1 trains`, but `1 train` or `no train`. 4 | * If you write a headline, you often capitalize everything except for articles, coordinate conjunctions (`and`, `or`), prepositions and `to`. 5 | -------------------------------------------------------------------------------- /Fitness.md: -------------------------------------------------------------------------------- 1 | # Fitness 2 | 3 | * Muscles don't grow during training, muscles grow in the rest time when your body recovers. Always rest 2-3 days after a hard workout. 4 | * In order to grow, muscles need a constant supply of protein, between 80g and 200g per day. Your body can't store reserves of protein. 5 | * In the morning, try to get as much carbohydrates as possible (for energy), and gradually reduce the amount over the course of the day. 6 | * In the evening, you should avoid carbohydrates as far as this is possible. Try to get more protein, instead. 7 | * Fat is not the only thing that lets you put on weight. Carbohydrates can be just as dangerous, if not even more dangerous. 8 | * Sugar is a poor form of carbohydrates and should be avoided whenever possible. It doesn't last long, and is of lower quality. 9 | * "I don't count my sit-ups. I only start counting when it starts hurting, because then it really counts." (Muhammad Ali) 10 | * "I hated every minute of training, but I said: Don't quit. Suffer now and live the rest of your life as a champion." (Muhammad Ali) 11 | * "You can't control how lucky or smart you are, but you can control how hard you work, so that's the first thing." (Michael Bloomberg) 12 | * "If we get on the treadmill together, there's two things: Either you're giving up first, or I'm going to die. Simple, right?" (Will Smith) 13 | * "While it's true that exercising at light intensities uses fat as the dominant source of energy, the overall energy requirement is substantially smaller, so you are burning far fewer calories than you would be if you were exercising at higher intensity. So in terms of achieving weight loss, that's totally counter intuitive." (Chris Easton) 14 | * "One of the biggest health benefits of swimming is that it's non-weight bearing, which means you won't be putting any strain on muscles and joints. Sadly, that same effect might be your downfall if you want to swim to lose weight, because you aren't lifting your own body weight as you are with running, which makes for a comparatively easier workout. [...] [There] is another potential pitfall: swimming can stoke the appetite more than other forms of exercise." (Catherine de Lange) 15 | * You have to truly enjoy your workout, the routine itself. If you love the *results* only, you will be able to stick to your workout for some months or years, but not forever. If you enjoy your *workout* itself, however, you will never suffer from a lack of motivation. 16 | * "I *enjoy* my workouts. They are my peace, my joy — I get my whole head together! I value that time more than my shower! And it really gets me together. But it's a habit." (Terry Crews) 17 | * "[O]ne of the most frustrating parts [...] is [the] overwhelming emphasis on exercise. Because when it comes to reaching a healthy weight, what you don't eat is much, much more important. [...] Moreover, exercise increases one's appetite. After all, when you burn off calories being active, your body will often signal you to replace them. [...] Unfortunately, exercise seems to excite us much more than eating less does." (Aaron E. Carroll) 18 | * "Exercise has many benefits, but there are problems with relying on it to control weight. [...] But I can't say this enough: Exercise has a big upside for health beyond potential weight loss. Many studies and reviews detail how physical activity can improve outcomes in musculoskeletal disorders, cardiovascular disease, diabetes, pulmonary diseases, neurological diseases and depression." (Aaron E. Carroll) 19 | * “Despite the prevailing advice, exercise is pretty unhelpful for weight loss. While 100 percent of the energy we gain comes from food, we can only burn about 10 to 30 percent of it with physical activity each day.” (Julia Belluz and Javier Zarracina) 20 | * “While exercise is hugely important for overall health, how much and what you eat has a much bigger impact on your waistline.” (Julia Belluz and Javier Zarracina) 21 | * “While [...] hunter-gatherers were physically active and lean, they actually burned the same amount of calories every day as the [modern] American or European, even after [...] researchers controlled for body size.” (Julia Belluz and Javier Zarracina) 22 | * “One very underappreciated fact about exercise is that, even when you work out, those extra calories burned only account for a tiny part of your total energy expenditure.” (Julia Belluz and Javier Zarracina) 23 | * “If [you] decide[] to increase food intake or relax more to recover from [...] added exercise, then even less weight [is] lost.” (Kevin Hall) 24 | * “You work hard on that machine for an hour [to lose weight], and that work can be erased with five minutes of eating afterward.” (Kevin Hall) 25 | * “Coca-Cola [...] initiated a strategy of funding scientific research that played down the role of Coke products in the spread of obesity [...] [and] encouraged the public to focus on exercise and worry less about how calories from food and beverages contribute to obesity.” (Anahad O’Connor) 26 | * “[A] focus on energy-out for energy balance is an inadequate and a potentially dangerous approach, because it is liable to encourage people to ignore or underestimate the greater impact of energy-in.” (Sara Kirk and Tarra Penney) 27 | * “Exercise is excellent for health, but it’s not important for weight loss. The two things should never be given equal weight in the obesity debate.” (Julia Belluz and Javier Zarracina) 28 | * “[T]he most important thing a person can do [to lose weight] is to limit calories in a way they like and can sustain, and focus on eating healthfully.” (Julia Belluz and Javier Zarracina) 29 | * “[Y]ou have to do an awful lot more exercise [to lose weight] than most people realise. To burn off an extra 500 calories is typically an extra two hours of cycling. And that’s about two doughnuts.” (Susan Jebb) 30 | * “If you want to lose a pound of body fat, then that requires you to run from Leeds to Nottingham, but if you want to do it through diet, you just have to skip a meal for seven days.” (Paul Gately) 31 | * Concentric muscular contractions are the motions of active muscles when shortening against load. For the biceps, that may be raising a dumbbell as part of a curl, for example. The generated tension is sufficient to overcome the external load. 32 | * Eccentric muscular contractions are the motions of active muscles when lengthening under load. For the biceps, that may be lowering a dumbbell *slowly* as part of a curl, for example. The generated tension is *insufficient* to overcome the external load. 33 | * Isometric muscular contractions mean building up and keeping tension without changing the length of the muscle, e.g. holding a heavy object in place. 34 | * Exercises that include both concentric and eccentric muscular contractions (i.e. a forceful lifting and a controlled lowering of the weight) can produce greater gains in strength than concentric contractions alone. 35 | * Eccentric muscular contractions consume less (chemical) energy than concentric contractions. 36 | * „The body prefers to generate most of its energy using aerobic methods, meaning with oxygen. Some circumstances, however – such as evading the historical saber tooth tiger or lifting heavy weights – require energy production faster than our bodies can adequately deliver oxygen. In those cases, the working muscles generate energy anaerobically.“ (Stephen M. Roth) 37 | * „[L]actate or, as it is often called, lactic acid buildup is not responsible for the muscle soreness felt in the days following strenuous exercise. Rather, the production of lactate and other metabolites during extreme exertion results in the burning sensation often felt in active muscles [...].“ (Stephen M. Roth) 38 | * The main reason for delayed-onset muscle soreness (DOMS) is probably actual, small-scale muscle cell damage (microtrauma). 39 | * „[E]ccentric [muscular] contractions have been shown to result in more muscle cell damage than is seen with typical concentric contractions [...]. Thus, exercises that involve many eccentric contractions, such as downhill running, will result in the most severe DOMS, even without any noticeable burning sensations in the muscles during the event.“ (Stephen M. Roth) 40 | * Stretching or warming up muscles does not prevent delayed-onset muscle soreness (DOMS). 41 | -------------------------------------------------------------------------------- /Food.md: -------------------------------------------------------------------------------- 1 | # Food 2 | 3 | * Food that has been packaged under a modified atmosphere appears fresh and delicious. But this is only an illusion to boost sales. Vacuum-packed food doesn't look as tasty on the supermarket shelf but is actually of better quality. 4 | -------------------------------------------------------------------------------- /Fraud and scams.md: -------------------------------------------------------------------------------- 1 | # Fraud and Scams 2 | 3 | ## Principles used by scammers 4 | 5 | * time principle: the victim is persuaded that they need to act quickly (before they can think rationally and exercise self-control) 6 | * distraction: make the victim focus on something else, e.g. a physically attractive accomplice 7 | * making the victim look at certain things 8 | * directing the victim's mind towards something else 9 | * talking to the victim 10 | * touching the victim's body 11 | * gradually breaking personal space 12 | * attentional overload 13 | * stimulation of deep desires: trick the victim with something they really want, e.g. in online dating 14 | * deference to authority: the victim is tricked into trusting an alleged authority, e.g. through the use of uniforms 15 | * exploit kindness: advantage is taken of the victim's willingness for voluntary (financial) support, e.g. after a natural disaster 16 | * appeal to innate dishonesty: make the victim act criminally themself through their reduced inhibition threshold, e.g. in Nigerian scam 17 | * herd principle: the scam is suggested to be legitimate by making use of people's tendency to act like their friends or people around them 18 | * pig-in-a-poke (information asymmetry): the victim thinks they are buying a "pig" when they are actually buying a "cat" hidden in the bag 19 | 20 | ## Confidence tricks 21 | 22 | ### Short cons (take seconds or minutes) 23 | 24 | * Shell game (sleight of hand) 25 | * scammer has three shells and a small coin 26 | * scammer places coin under one of the shells and shuffles them quickly 27 | * victim from the audience is asked to place a bet on the location of the coin for doubling or losing their bet 28 | * skilled scammer will never lose due to dexterity but must therefore remove coin completely and turn over shells themself 29 | * other people from the audience include 30 | * shills pretending to play the game and allegedly placing genuine bets 31 | * lookouts for the police 32 | * bouncers discouraging an easy exit 33 | * guards intimidating victims who become intractable 34 | * the audience also serves as a protection against photographers 35 | * when the police is approaching, all traces of the game can be removed in seconds 36 | * pickpockets may be part of the game as well so that when the scammers seem to run away from the police they're actually leaving with theft 37 | * Fortune telling 38 | * uses cold reading to trick victims into paying money for alleged fortune telling 39 | * Clip joint 40 | * trick played in an establishment (usually strip club or entertainment bar) 41 | * possibility of sex is often suggested 42 | * victim is tricked into paying money at excessively high prices 43 | * victim receives poor goods/service (e.g. watered-down drinks) — or even none at all 44 | * victim is later ejected 45 | * Dropped Wallet scam 46 | * scammer pretends to unintentionally drop their purse 47 | * victim picks up the purse in good faith and wants to return it to the scammer 48 | * scammer accuses victim of stealing, asks for "stolen" money to be returned and threatens to call the police 49 | * Badger game (extortion) 50 | * the victim (usually a married man) is deliberately coerced into a compromising position (usually a supposed affair) 51 | * the victim is threatened with public exposure unless blackmail money is paid 52 | * Thai gems 53 | * selling jewelry or custom-made suits — both overpriced — telling the victim they will make money by importing it to their home country 54 | * Coin-matching game 55 | * one operator begins the game with the victim 56 | * second operator joins and briefly leaves again 57 | * first operator agrees with victim to cheat on second operator 58 | * when rejoining, the second operator loses and angrily threatens to call the police 59 | * the first operator and the victim agree to pay hush money — later split up between the two operators 60 | * Fiddle game / Glim-dropper (pigeon drop technique) 61 | * first scammer goes to expensive restaurant and after eating finds out they have "forgotten" their purse at home (nearby) 62 | * first scammer leaves expensive and rare good (e.g. musical instrument) as collateral or pledge and goes to get their purse 63 | * second scammer arrives and approaches victim 64 | * second scammer claims they want to buy that rare item for a large amount (e.g. 10,000 USD) 65 | * second scammer "has to" leave abruptly for an appointment but leaves contact information 66 | * victim is to inform potential buyer when the owner returns 67 | * first scammer returns and wants to get back their collateral or pledge — but victim thinks they might make money now 68 | * victim offers the "owner" of the collateral or pledge a considerable amount (e.g. 5,000 USD) 69 | * victim buys the item in good faith *and* greed to make profit by re-selling it to the second scammer — who never returns 70 | * chronology of the discovery of the valuable item and the offer to buy may be swapped when second scammer claims to have lost something 71 | * Lottery fraud by proxy 72 | * scammer fakes an alleged winning ticket but claims not to be eligible for its redemption 73 | * victim buys "winning ticket" from scammer — and will later even be held criminally liable when trying to redeem it 74 | 75 | ### Long cons (take days or weeks) 76 | 77 | * Spanish Prisoner scam / Nigerian scam 78 | * enlisting the victim to aid in retrieving some stolen money from a hidden place 79 | * taking advantage of the victim's greed 80 | * tricking the victim into believing into the existence of the money 81 | * preventing the victim from going to the police by making them act criminally themself which they would have to admit 82 | * luring with faked cheques that have a manipulated recipient but are otherwise genuine 83 | * Romance scam (advance-fee fraud) 84 | * cultivating romantic relationship with victim 85 | * making promises of a future marriage 86 | * beloved person is stuck in a foreign (usually their home) country and lacks the money to leave 87 | * Gandparent scam (fraudulent impersonation) 88 | * grandparent gets a call or message from alleged grandchild in trouble (abroad) 89 | * grandchild may be arrested in another country needing money to pay the bail 90 | * Fake antivirus / Fake support call 91 | * Computer users are unsolicitedly contacted by 92 | * scammers claiming to represent Microsoft etc. 93 | * alleged company behind antivirus software installed on their computer 94 | * scammers tell unsuspecting victim that they have problems/errors on their computer which must be fixed 95 | * victims may be tricked into 96 | * paying money for *no* service 97 | * actually *installing* viruses, malware or spyware 98 | * allow the scammers remote access to the computer 99 | * Fake casting agent scam 100 | * scammer pretends to be casting agent for a modeling agency searching for new talents 101 | * victim is told they need a professional portfolio — which requires an upfront payment 102 | * Fraudulent directory solicitations 103 | * victims (business owners) receive a solicitation from a business directory designed like an invoice 104 | * the scammers hope that the business owners fall victim to them by mistaking the solicitation ... 105 | * ... for an actual invoice and paying it 106 | * ... for updates/corrections that must be made to an existing entry (resulting the victim signing the document) 107 | 108 | ## Online 109 | 110 | * It is [ridiculously easy](http://fusion.net/story/191773/i-created-a-fake-business-and-fooled-thousands-of-people-into-thinking-it-was-real/) to buy fake reviews, likes and followers online. Be suspicious. 111 | -------------------------------------------------------------------------------- /Gimp.md: -------------------------------------------------------------------------------- 1 | # Gimp 2 | 3 | * If you have a pattern that you want to repeat, there is an easier way than copying it time and again: Go to `Filters`, then `Map` and choose `Tile`. Make sure the two scales are connected (i.e. the chain is connected) and switch to percentage unit. Enter multiples of `100` in one of the boxes and press `OK`. 4 | * If you have a texture that you want to turn into a tileable pattern, go to `Filters`, then `Map` and choose `Make seamless`. 5 | -------------------------------------------------------------------------------- /Git.md: -------------------------------------------------------------------------------- 1 | # Git 2 | 3 | ## Installation 4 | 5 | ### Setting up your identity 6 | 7 | Before creating any commits in Git, you should first set your identity in the configuration. This is important because this information will be immutably written into every single commit. Apart from that, note that this information is public. 8 | 9 | ``` 10 | $ git config --global user.name "" 11 | $ git config --global user.email "" 12 | ``` 13 | 14 | ### Remembering (caching) passwords for HTTPS 15 | 16 | When cloning repositories over HTTPS, you authenticate via usernames and passwords, compared to SSH keys for usage over SSH. If you want to let Git remember passwords, run one of the following commands: 17 | 18 | ``` 19 | # On Windows 20 | $ git config --global credential.helper wincred 21 | 22 | # On Ubuntu 23 | $ sudo apt-get install libgnome-keyring-dev 24 | $ cd /usr/share/doc/git/contrib/credential/gnome-keyring 25 | $ sudo make 26 | $ git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring 27 | 28 | # On Mac OS X 29 | $ git config --global credential.helper osxkeychain 30 | ``` 31 | 32 | ### Handling line endings correctly on Windows 33 | 34 | You'll probably want Git to convert line endings to the native Windows line endings (CRLF) on checkout and convert back to simple LF when pushing changes. Define this behavior in the configuration like this: 35 | 36 | ``` 37 | $ git config --global core.autocrlf true 38 | ``` 39 | 40 | ### Using your favorite editor for Git (e.g. when composing a commit message) 41 | 42 | ``` 43 | # e.g. for “gedit” on Ubuntu 44 | $ git config --global core.editor "gedit --wait" 45 | ``` 46 | 47 | ### Checking your settings 48 | 49 | Run the following command to see all your settings and check if they are correct: 50 | 51 | ``` 52 | $ git config --global --list 53 | ``` 54 | 55 | ## Aliases 56 | 57 | ### Receiving updates 58 | 59 | ```bash 60 | # git down 61 | git config --global alias.down '!git pull --rebase --autostash; git submodule update --init --recursive' 62 | ``` 63 | 64 | ### Sending updates 65 | 66 | ```bash 67 | # git up 68 | git config --global alias.up '!git push; git push --tags' 69 | ``` 70 | 71 | ### Undo staging of one or more files 72 | 73 | ```bash 74 | # git unstage 75 | git config --global alias.unstage 'reset HEAD --' 76 | ``` 77 | 78 | ### Tagging releases according to Semantic Versioning (SemVer) 79 | 80 | ```bash 81 | # git release-major 82 | git config --global alias.release-major '!latest=$(git describe --abbrev=0 --tags 2>/dev/null); latest=${latest:-v0.0.0}; set -- $(echo $latest | sed -e s/v// -e "s/\./ /g"); major=$1; minor=$2; patch=$3; major=$((major+1)); minor=0; patch=0; next='v'$major'.'$minor'.'$patch; git tag -a $next -m ""; echo "Previous release:"; echo -n " "; echo $latest; echo "New release:"; echo -n " "; echo $next' 83 | 84 | # git release-minor 85 | git config --global alias.release-minor '!latest=$(git describe --abbrev=0 --tags 2>/dev/null); latest=${latest:-v0.0.0}; set -- $(echo $latest | sed -e s/v// -e "s/\./ /g"); major=$1; minor=$2; patch=$3; minor=$((minor+1)); patch=0; next='v'$major'.'$minor'.'$patch; git tag -a $next -m ""; echo "Previous release:"; echo -n " "; echo $latest; echo "New release:"; echo -n " "; echo $next' 86 | 87 | # git release-patch 88 | git config --global alias.release-patch '!latest=$(git describe --abbrev=0 --tags 2>/dev/null); latest=${latest:-v0.0.0}; set -- $(echo $latest | sed -e s/v// -e "s/\./ /g"); major=$1; minor=$2; patch=$3; patch=$((patch+1)); next='v'$major'.'$minor'.'$patch; git tag -a $next -m ""; echo "Previous release:"; echo -n " "; echo $latest; echo "New release:"; echo -n " "; echo $next' 89 | ``` 90 | 91 | ### Ignoring redundant `git` binary names in commands 92 | 93 | ```bash 94 | # git git status, git git commit, etc. 95 | git config --global alias.git '!cd "$GIT_PREFIX" && git' 96 | ``` 97 | 98 | ### Displaying changelog since latest tag 99 | 100 | ```bash 101 | # git changelog 102 | git config --global alias.changelog '!git log $(git describe --abbrev=0 --tags)..HEAD --no-merges --pretty=oneline --abbrev-commit' 103 | ``` 104 | 105 | ### Detecting remnants and leftovers from development 106 | 107 | ```bash 108 | # git leftover 109 | git config --global alias.leftover '!git grep -P -i -I --untracked "((? 120 | ``` 121 | 122 | 1. Whenever you want to get updates from the forked repository (and push them to your own remote): 123 | 124 | ``` 125 | $ git pull upstream 126 | $ git push origin 127 | ``` 128 | 129 | ### Reset a repository to the forked repository's state (e.g. after denied pull request) 130 | 131 | 1. The first time only, execute the following command to add the forked repository ("upstream") as a remote, otherwise skip it: 132 | 133 | ``` 134 | $ git remote add upstream 135 | ``` 136 | 137 | 1. Whenever you want to reset the repository's state: 138 | 139 | ``` 140 | $ git remote update 141 | $ git reset --hard upstream/ 142 | $ git push origin + 143 | ``` 144 | 145 | ### Show all ignored files for a repository 146 | 147 | ``` 148 | $ git clean -ndX 149 | # or 150 | $ git status --ignored 151 | ``` 152 | 153 | ### Get a list of all remotes for a repository 154 | 155 | ``` 156 | $ git remote -v 157 | ``` 158 | 159 | ### Remove all newly ignored files (which had not been ignored before) 160 | 161 | When you've added a file to `.gitignore` that was previously in the repository already, you may run the following commands to remove the file from the repository, in addition to it being added to `.gitignore`: 162 | 163 | ``` 164 | $ git rm -r --cached . 165 | $ git add . 166 | ``` 167 | 168 | ### Changing the URL of a repository's remote 169 | 170 | ``` 171 | $ git remote set-url 172 | ``` 173 | 174 | ### Discard unstaged changes 175 | 176 | In order to discard *all* unstaged changes, run this command: 177 | 178 | ``` 179 | $ git checkout -- . 180 | ``` 181 | 182 | If you want to discard changes for a specific path only, supply a specific path instead of `.`: 183 | 184 | ``` 185 | $ git checkout -- "" 186 | ``` 187 | 188 | ### Undo a commit that has already been published (safe) 189 | 190 | ``` 191 | $ git checkout HEAD~1 . 192 | $ git commit -m "Undo some commit" 193 | $ git push 194 | ``` 195 | 196 | ### Undo a commit that has already been published (dangerous) 197 | 198 | ``` 199 | $ git reset --hard HEAD~1 200 | $ git push -f 201 | ``` 202 | 203 | ### Undo a local commit (that has not been published yet) 204 | 205 | If you want to keep the changes in your working copy: 206 | 207 | ``` 208 | # Keeping the changes in the working copy 209 | $ git reset --soft HEAD~1 210 | # or 211 | # Simply discarding the changes altogether 212 | $ git reset --hard HEAD~1 213 | ``` 214 | 215 | ### Show changes that have been made to the working copy 216 | 217 | ``` 218 | # Show unstaged changes only 219 | $ git diff 220 | # or 221 | # Show staged changes only 222 | $ git diff --staged 223 | # or 224 | # Show both unstaged and staged changes 225 | $ git diff HEAD 226 | ``` 227 | 228 | ### Delete a branch 229 | 230 | ``` 231 | # Locally 232 | $ git branch -d 233 | # or 234 | # On the remote 235 | $ git push : 236 | ``` 237 | 238 | ### Adding not only a title but also a description to a commit 239 | 240 | Just add another `-m` parameter to the `git commit` command: 241 | 242 | ``` 243 | $ git commit -m "" -m "<DESCRIPTION>" 244 | ``` 245 | 246 | ### Remove all untracked files and directories from a repository 247 | 248 | To show a preview of what will be deleted: 249 | 250 | ``` 251 | # Preview only 252 | $ git clean -ndf 253 | # or 254 | # Actually execute 255 | $ git clean -df 256 | ``` 257 | 258 | ### Show the log in a short version 259 | 260 | ``` 261 | $ git log --pretty=oneline --abbrev-commit 262 | ``` 263 | 264 | ### Create a branch 265 | 266 | ``` 267 | # Create but stay in current branch 268 | $ git branch <NEW_BRANCH_NAME> 269 | # or 270 | # Create and switch to new branch 271 | $ git checkout -b <NEW_BRANCH_NAME> 272 | ``` 273 | 274 | ### Switch to another branch 275 | 276 | ``` 277 | $ git checkout <OTHER_BRANCH_NAME> 278 | ``` 279 | 280 | ### Tagging releases 281 | 282 | You can mark specific points in your repository's history by adding tags. Usually, you'd want to do this for releases, but you can use tags for other purposes as well. 283 | 284 | In order to tag the current point in history, just execute the following two commands. `<TAG_NAME>` is the unique name for this new tag. When tagging releases, you should use the version number and prepend it with a `v`, e.g. `v1.0.4`. For the `<DESCRIPTION>`, you *may* enter a description of the changes. 285 | 286 | ``` 287 | $ git tag -a "<TAG_NAME>" -m "<DESCRIPTION>" 288 | $ git push <REMOTE_NAME> --tags 289 | ``` 290 | 291 | ### Importing commits, pull requests and other changes via patch files 292 | 293 | 1. Get the patch file for the commit, pull request or other change that you want to import into your repository. For GitHub pull requests, you can easily get the patch file by appending `.patch` to the URL of the pull request and following the redirect: 294 | 295 | ``` 296 | $ curl -L https://github.com/<USER>/<REPO>/pull/<ID>.patch 297 | ``` 298 | 299 | 1. Pipe the content of the patch file to `git apply`: 300 | 301 | ``` 302 | $ curl -L https://github.com/<USER>/<REPO>/pull/<ID>.patch | git apply 303 | ``` 304 | 305 | 1. Optionally, make additional changes to the imported code 306 | 307 | 1. Commit the code via `git commit` while mentioning the original author of the imported patch: 308 | 309 | ``` 310 | $ git commit --author "<ORIGINAL_AUTHOR_NAME> <<ORIGINAL_AUTHOR_EMAIL>>" -m "<YOUR_COMMIT_MESSAGE>" 311 | ``` 312 | 313 | ### Copying a branch 314 | 315 | ``` 316 | # Create a local copy of the old branch under the new name 317 | $ git checkout -b <NEW_BRANCH_NAME> <OLD_BRANCH_NAME> 318 | # Push the new copy of the branch to the remote 319 | $ git push -u <REMOTE_NAME> <NEW_BRANCH_NAME> 320 | ``` 321 | 322 | ### Moving a branch 323 | 324 | ``` 325 | # Create a local copy of the old branch under the new name 326 | $ git checkout -b <NEW_BRANCH_NAME> <OLD_BRANCH_NAME> 327 | # Push the new copy of the branch to the remote 328 | $ git push -u <REMOTE_NAME> <NEW_BRANCH_NAME> 329 | # Delete the old branch locally 330 | $ git branch -d <OLD_BRANCH_NAME> 331 | # Delete the old branch on the remote 332 | $ git push origin :<OLD_BRANCH_NAME> 333 | ``` 334 | 335 | ### Clearing a branch and resetting it to empty state 336 | 337 | ``` 338 | # Create a new local branch without parents 339 | $ git checkout --orphan <NEW_BRANCH_NAME> 340 | # Delete all (non-hidden) files in the new branch 341 | $ rm -rf ./* 342 | # Put your new files into the new branch 343 | # ... 344 | # Stage all new files 345 | $ git add . 346 | # Create the initial commit 347 | $ git commit -m "Initial commit" 348 | # Push the new branch to the remote 349 | $ git push -uf <REMOTE_NAME> <NEW_BRANCH_NAME> 350 | ``` 351 | 352 | ### Counting commits on a branch 353 | 354 | ``` 355 | # Total count 356 | $ git rev-list --count <BRANCH_NAME> 357 | # Example: git rev-list --count master 358 | 359 | # or 360 | 361 | # Count per author 362 | $ git shortlog -s -n 363 | ``` 364 | -------------------------------------------------------------------------------- /Health.md: -------------------------------------------------------------------------------- 1 | # Health 2 | 3 | * You don't need to use antibacterial soap at home. Normal soap is just as effective as antibacterial one (almost) and has no disadvantages. 4 | * Your vision does not worsen if you wear (incorrectly adjusted) glasses, but wrong glasses can cause headaches and visual fatigue. 5 | * Your vision does not worsen if you read with too little light, for example. But bad habits can cause headaches and visual fatigue. 6 | * Underarm hair does not cause you to sweat more, but it provides the bacteria with a bigger target, possibly resulting in stronger odor. 7 | * It's not fresh sweat that smells, but older sweat where the bacteria start to cause more and more odor. 8 | * If you have shingles (herpes zoster), see a doctor within 48-72 hours, who will usually give you aciclovir (and paracetamol). 9 | * "Sensations (information delivered by organs like our eyes) can be distinct from perceptions (ideas about sensations formed by our brains)." (Jim Davies) 10 | * "Just as blind people do not sense the color black, we do not sense anything at all in place of our lack of sensations for magnetic fields [unlike geese/birds] or ultraviolet light. [...] When you look at the scene in front of you, it has a boundary. Your visual field extends to each side only so far. If you spread your arms, and draw your hands back until they are no longer visible, [...] [t]his space does not look black. It does not look white. It just isn't." (Jim Davies) 11 | * Exercising makes you emotionally resilient and reduces your risk of getting depression. This is due to raised levels of PGC-1alpha1, producing a substance that breaks down kynurenine. 12 | * There are two ways you can improve your endurance performance: Increasing your oxygen supply (VO2 max) or lowering the oxygen demand by your muscles (running economy). Supply more and demand less. 13 | * "Any patient in a hospital, when we take their clothes away and lay them in a bed, starts to lose identity; after a few days, they all start to merge into a single passive body, distinguishable ... only by the illnesses that brought them there." (Terrence Holt) 14 | * Drinking lots of coffee on a regular basis won't enhance your mental performance. Part of the problem with caffeine is we quickly develop dependency. "Regular caffeine consumers who'd been without caffeine overnight, [are] slower on [a] reaction time task, [are] sleepier and [are] less mentally alert than non-users." They [...] improve after they [get] a caffeine drink, but only up to the level the non-users [achieve] without caffeine. (Peter Rogers) 15 | * "With [so many] office workers in cubicles or open work spaces, it's [...] important to create one's own cocoon of sound. That brings us to a psychological answer: There is evidence that music relaxes our muscles, improves our mood, and can even moderately reduce blood pressure, heart rate, and anxiety. What music steals in acute concentration, it returns to us in the form of good vibes." (Derek Thompson) 16 | * "Seating people with their backs to a high-traffic area leads to a constant sense of unease and vulnerability." (Matt Blodgett) 17 | * If you listen to music with earbuds or headphones at levels that block out normal discourse, you are in effect dealing lethal blows to the hair cells in your ears. (Dr. Michael D. Seidman) 18 | * "Drowning doesn't look like drowning" (Mario Vittone): "Except in rare circumstances, drowning people are physiologically unable to call out for help. The respiratory system was designed for breathing. Speech is the secondary or overlaid function. Breathing must be fulfilled, before speech occurs. [...] Drowning people cannot wave for help. Nature instinctively forces them to extend their arms laterally and press down on the water’s surface. Pressing down on the surface of the water, permits drowning people to leverage their bodies so they can lift their mouths out of the water to breathe. [...] From beginning to end of the Instinctive Drowning Response people’s bodies remain upright in the water, with no evidence of a supporting kick. Unless rescued by a trained lifeguard, these drowning people can only struggle on the surface of the water from 20 to 60 seconds before submersion occurs." (On Scene Magazine - Fall 2006) Drowning people "[a]ppear to be climbing an invisible ladder" (Mario Vittone). 19 | * Hairs around the belly button steal tiny fibres from clothes and deposit them into the navel where they accumulate as "navel fluff". Shaving belly hair prevents the accumulation of that lint. 20 | * “Most adults function best after seven to nine hours of sleep a night. [...] When we get fewer than seven hours, we’re impaired (to degrees that vary from person to person). When sleep persistently falls below six hours per 24, we are at an increased risk of health problems.” (James Hamblin) 21 | * “[W]hen animals are sleep-deprived constantly, they will suffer serious biological consequences. Death is one of those consequences.” (David Dinges) 22 | * “[R]esearchers kept people just slightly sleep deprived – allowing them only six hours to sleep each night – and watched the subjects’ performance on cognitive tests plummet. The crucial finding was that throughout their time in the study, the sixers thought they were functioning perfectly well.” (James Hamblin) 23 | * “Thanks to caffeine, many of us stimulate [a] fight-or-flight response not just occasionally, under dire circumstances, but daily, in our offices.” (James Hamblin) 24 | -------------------------------------------------------------------------------- /Heroku.md: -------------------------------------------------------------------------------- 1 | # Heroku 2 | 3 | ## Sign in 4 | 5 | 1. Right-click into working copy's directory or on desktop if there is no project directory yet 6 | 2. Select `Git Bash` from the context menu 7 | 3. `heroku login` 8 | 4. Type your username and hit `Enter` 9 | 5. Type your password and hit `Enter` 10 | 11 | ## Set up your SSH keys 12 | 13 | This must only be done once in order to set up Heroku on a new computer. 14 | 15 | 1. `cd ~/.ssh` 16 | 2. `ssh-keygen -t rsa -C "<YOUR_EMAIL_ADDRESS>"` 17 | 3. For the location just press `Enter` which will create `id_rsa` (private key) and `id_rsa.pub` (public key) 18 | 4. `heroku keys:add` 19 | 5. When asked for the index of the key to choose, enter the number that is shown for `id_rsa.pub` 20 | 21 | ## Create a new app/repository 22 | 23 | 1. Create a new app in Heroku's web interface 24 | 2. `cd ~/Desktop` 25 | 3. `git clone git@heroku.com:<APPNAME>.git -o heroku` 26 | 4. You have now cloned into the repository `<APPNAME>` which has caused a folder named `<APPNAME>` to be created in your current directory 27 | 5. `cd <APPNAME>` 28 | 6. You are now in the local folder for your project 29 | 7. `git remote add heroku git@heroku.com:<APPNAME>.git` 30 | 8. Add some files to the local folder 31 | 9. `git add .` 32 | 10. `git commit -m 'initial commit'` 33 | 11. `git push heroku master` 34 | 35 | ## Get a new working copy of your app/repository 36 | 37 | If you want to get a new working copy of your app on your computer, you just have to clone into the repository again. 38 | 39 | 1. `git clone git@heroku.com:<APPNAME>.git -o heroku` 40 | 2. `cd <APPNAME>` 41 | 42 | ## Publish changes to your app/repository 43 | 44 | You don't need to sign in to heroku via `heroku login` when you want to publish changes to your app. Normal Git usage is sufficient when the repository has been set up already. 45 | 46 | 1. `git commit -m '<DESCRIPTION_OF_CHANGES>'` 47 | 2. `git push heroku master` 48 | 49 | ## Show basic app information 50 | 51 | `heroku info` -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | # History 2 | 3 | * "The familiar Ancient Greek and Roman statues were not the grey, stone figures we know today. They were actually painted in bright colours and inlaid with jewels." (James Robertson) 4 | * "Egyptian pyramids have [not] remained the way they were at the time of their construction. Actually, their outside was made of white limestone, which concealed the layer of bricks underneath." (Saarthak Jajoria) 5 | * The Anglicised name prefixes "Mc" and "Mac" mean "son (of)" while the prefix "O'" means "descendant (of)" or "grandson (of)". 6 | -------------------------------------------------------------------------------- /Home.md: -------------------------------------------------------------------------------- 1 | # Home 2 | 3 | * In order to prevent mold formation in your dishwasher, it's sufficient to run the dishwasher on a temperature of 60°C or more twice a month. This does also eliminate grease and fat residues. 4 | -------------------------------------------------------------------------------- /IT operations.md: -------------------------------------------------------------------------------- 1 | # IT operations 2 | 3 | * When a mail client/server is submitting an email to be routed by a mail server, it should always use port `465` for submission with SSL/TLS or port `587` using STARTTLS. 4 | * Ansible, Puppet and Chef are configuration management tools which system administrators can use for IT automation. The tools allow for scripted, documented and replicatable servers. Ansible is the easiest to get started with while Chef is the hardest. 5 | * Email transfer is done by Mail Transfer Agents (MTAs) such as Postfix. They use the SMTP protocol. 6 | * Email delivery is done by Mail Delivery Agents (MDAs) such as Dovecot. They use the IMAP and POP3 protocols. 7 | * "Monitoring should never require a human to interpret any part of the alerting domain." (Dan Luu) 8 | * "[There are] [t]hree valid kinds of monitoring output: Alerts [are when a] human needs to take action *immediately*. Tickets [are when a] human needs to take action *eventually*. Logging [is when] *no* action [is] needed. Note that, for example, graphs are a type of log." (Dan Luu) 9 | * "[I]f a user is on a smartphone with 99% reliability, they can't tell the difference between 99.99% and 99.999% reliability [of your application]." (Dan Luu) 10 | * "Reliability isn't linear in cost. It can easily cost 100x more to get one additional increment of reliability." (Dan Luu) 11 | * Backups from a server must always be *pulled*, or, if they really need to be pushed, this needs to be done with append-only permissions. Otherwise, the server must necessarily have credentials with full write access to the backup location. If the server is compromised, that write access can be used to attack the backup repository. 12 | -------------------------------------------------------------------------------- /Information security.md: -------------------------------------------------------------------------------- 1 | # Information security 2 | 3 | * Don't trust user input. 4 | * Don't do client-side only checks on information that is processed by the server. 5 | * Don't roll your own crypto(graphy). It must be designed by experts and undergo peer review. 6 | * "Most people don't realize how fiendishly difficult it is to devise an encryption algorithm that can withstand a prolonged and determined attack by a resourceful opponent." (Phil Zimmermann) 7 | * "You can't build a 'back door' that only the good guys can walk through. Encryption protects against cybercriminals, industrial competitors, the Chinese secret police and the FBI. You're either vulnerable to eavesdropping by any of them, or you're secure from eavesdropping from all of them." (Bruce Schneier) 8 | 9 | ## SSL/TLS 10 | 11 | * If you have problems establishing an SSL connection from a single device while other devices are working, check your system time. SSL verification depends on proper time settings in the operating system. 12 | 13 | ### CSR (Certificate Signing Request) 14 | 15 | #### Generating with OpenSSL 16 | 17 | ``` 18 | openssl req -nodes -newkey rsa:2048 -sha256 -keyout private.key -out public.csr 19 | ``` 20 | 21 | You will be asked to enter responses to several questions. Of those, you should at least answer the following: 22 | 23 | * `Common Name`: the domain name that you want to protect (must be an exact match), e.g. `www.example.org` 24 | * `Organization Name`: the owner's (full legal) name, e.g. `MyCompany, Inc.` 25 | * `Organization Unit`: `IT` 26 | 27 | ## Two-factor authentication (2FA) 28 | 29 | ### Clock out of sync causing two-factor authentication to fail 30 | 31 | If you have enabled two-factor authentication and your local clock is out of sync, this might cause 2FA to fail -- even if it's just a minute. Two-factor authentication requires that your local time is always perfectly in sync, so try updating your local time from the network. 32 | -------------------------------------------------------------------------------- /Java.md: -------------------------------------------------------------------------------- 1 | # Java 2 | 3 | * Always use `@Override` annotations when overriding a method. Due to typos or implementation changes you could end up inadvertently adding a new method instead of overriding an existing one, otherwise. Let your IDE show warnings for methods that you have not marked with `@Override`. 4 | * Always make methods static when possible, i.e. when they don't access instance variables and methods. Let your IDE show warnings for methods that should be made static. 5 | * When classes have supertypes, they use `extends`. Likewise, when interfaces have supertypes, they use `extends`. Only when a connection crosses the line from interfaces to classes, the class `implements` the interface. 6 | -------------------------------------------------------------------------------- /JavaScript.md: -------------------------------------------------------------------------------- 1 | # JavaScript 2 | 3 | * Initialize all variables at the beginning of a function, and list them in alphabetical order. Use only one `var` keyword and give an extra line to each variable. 4 | * Always use `===` and `!==` instead of `==` and `!=`. 5 | * When using `for ... in` loops, always filter the contents with `hasOwnProperty` first. 6 | * For anonymous functions, add a space between the `function` keyword and the parentheses, e.g. `this.someFunc = function () { ... };` 7 | * Use `unshift(...)` to *add* an element to the beginning of an array. Use `shift()` to *remove and return* the first element from there. 8 | * Use `push(...)` to *add* an element to the end of an array. Use `pop()` to *remove and return* the first element from there. 9 | * There are (at least) two ways to cause a redirect: If you want to simulate someone clicking a link, use `window.location.href = "..."`. If you want to simulate a HTTP redirect, use `window.location.replace("...")`. 10 | * Any `Number` is internally stored as a 64-bit floating point (double), according to the IEEE-754 standard. 11 | * The range for integers is `-9007199254740991` (`-(2^53 - 1)`) to `9007199254740991` (`2^53 - 1`), or `Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER.` 12 | * The range for numbers in general is approximately `5e-324` to `1.79E+308`, or `Number.MIN_VALUE` to `Number.MAX_VALUE`. 13 | * JavaScript cryptography is only secure when used in a signed, local application (e.g. a browser extension), or when distributed over HTTPS. In the latter case, it can only ever be as secure as the HTTPS connection it relies on to distribute the JavaScript source, of course. But JavaScript cryptography can provide something that HTTPS alone can't provide: encrypted information that the server can't decrypt. 14 | 15 | # "Static classes" in JavaScript for namespaced utilities 16 | 17 | If you want to create a "static class" in JavaScript, so that you can call functions like `MyClass.format(param)`, proceed as follows: 18 | 19 | ``` 20 | // create an object for our namespace only if there is none yet 21 | if (typeof MyClass !== "object") { 22 | MyClass = {}; 23 | } 24 | // add the methods in a closure to prevent the creation of global variables 25 | (function () { 26 | // create the function on our object only if there is none yet 27 | if (typeof MyClass.format !== "function") { 28 | MyClass.format = function (param) { 29 | // do something 30 | }; 31 | } 32 | })(); 33 | ``` 34 | -------------------------------------------------------------------------------- /Job interviews.md: -------------------------------------------------------------------------------- 1 | # Job interviews 2 | 3 | * The impression made in the first 10 seconds of a job interview can predict the outcome of the interview. As an interviewer, we spend the rest of the interview trying to confirm our initial impression by looking for more reasons that support our judgement. This makes job interviews less efficient. 4 | * "Performance on [brainteasers] is at best a discrete skill that can be improved through practice, eliminating their utility for assessing candidates. At worst, they rely on some trivial bit of information or insight that is withheld from the candidate, and serve primarily to make the interviewer feel clever and self-satisfied. They have little if any ability to predict how candidates will perform in a job." (Laszlo Bock) 5 | * "The best predictor of how someone will perform in a job is a work sample test (29 percent). This entails giving candidates a sample piece of work, similar to that which they would do in the job, and assessing their performance at it." (Laszlo Bock) 6 | * "The second-best predictors of performance are tests of general cognitive ability (26 percent). In contrast to case interviews and brainteasers, these are actual tests with defined right and wrong answers, similar to what you might find on an IQ test." (Laszlo Bock) 7 | -------------------------------------------------------------------------------- /LaTeX.md: -------------------------------------------------------------------------------- 1 | # LaTeX 2 | 3 | * `\mathbb{...}` prints the enclosed text as "blackboard bold", i.e. how you would write bold letters if you had to do this on a blackboard. This can be used for uppercase letters only and usually results in vertical or near-vertical lines being doubled. On a typewriter, they would be *double-struck* with a small offset. 4 | * `\mathcal{...}` prints the enclosed text in calligraphic font, giving form to the text in an expressive manner. 5 | 6 | ## Mathematics 7 | 8 | * For number sets such as integers or natural numbers, use `\mathbb{...}`, e.g. `\mathbb{Z}` or `\mathbb{N}`. 9 | * Use `\mathcal{P}(...)` for the power set of a given set, e.g. `\mathcal{P}(X)`. 10 | -------------------------------------------------------------------------------- /Law.md: -------------------------------------------------------------------------------- 1 | # Law 2 | 3 | * Copyright protects the expression of an idea, not the idea itself. The idea itself may be protected through patents. 4 | * "The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying." (John Carmack) 5 | * "If we don't believe in freedom of expression for people we despise, we don't believe in it at all." (Noam Chomsky) 6 | * "[Copyright] [r]egistration does offer some significant benefits [...]. But it is not required in order for you to mark your proprietary works of authorship with the appropriate notice. [Even] [t]he notice is not required in order to have protection. However, the notice [...] puts others on notice that you claim protection [of] a particular work. Once a party is on notice of your claim, they can be liable for wilful infringement and treble damages. Copyright in the US and most of the world is automatic upon fixation of an original work of authorship in a tangible medium of expression." (Robert B. Dellenbach) 7 | 8 | ## Software 9 | 10 | * The case Oracle v. Google has been about copyright and patent claims, where Oracle argues that Google infringed by copying the Java API. In May 2012, a United States District Court decided that Google did not infringe. Judge William Haskell Alsup started learning Java solely for the purpose of getting a better understanding of the case. The Circuit Court then, however, reversed the decision in May 2014, finding that Google *did* infringe on Oracle's Java API. In October 2014, Google then asked the U.S. Supreme Court to decide the copyright fight. 11 | -------------------------------------------------------------------------------- /Life.md: -------------------------------------------------------------------------------- 1 | # Life 2 | 3 | * Surround yourself with smart and inspiring people, and if you're the smartest person in the room, maybe it's time to move on. 4 | * Don't promise when you're happy. Don't reply when you're angry. Don't decide when you're sad. 5 | * Nothing is worth more than your personal health. Live a healthy lifestyle, and go to annual check-ups if possible. 6 | * Get enough sleep every night. Sleep is really important to so many facets in life, be it regeneration, attentiveness or physical health. 7 | * Getting up 15-30 minutes earlier every morning is not that much, but the effect on your available time in the morning is great! 8 | * Don't waste any time on jealousy. 9 | * What other people think about you is none of your business. 10 | * Don't be afraid to ask someone if you're not sure, no matter what topic, what time or place. 11 | * Finish one project before you start another. 12 | * Smile often, even to complete strangers. 13 | * Apologize when you should. 14 | * Be curious. This is certainly more important than just being intelligent. 15 | * Either at work or in your freetime, do something that makes you proud. 16 | * "I can accept failure, everyone fails at something. But I can't accept not trying." (Michael Jordan) 17 | * Make peace with your past so it won't disturb your present. 18 | * Don't compare your life to others'. 19 | * Don't text with your mobile phone when you're drunk. 20 | * "A ship is safe in harbor, but that's not what ships are for." (William G. T. Shedd) 21 | * A calm sea does not make a skilled sailor. 22 | * "People will forget what you said, people will forget what you did, but people will never forget how you made them feel." (Maya Angelou) 23 | * "Man cannot discover new oceans unless he has the courage to lose sight of the shore." (André Gide) 24 | * "Be yourself; everyone else is already taken." (Oscar Wilde) 25 | * "No one can make you feel inferior without your consent." (Eleanor Roosevelt) 26 | * "Be the change you want to see in the world." (Mahatma Gandhi) 27 | * Success is like being pregnant, everybody congratulates you, but nobody knows how many times you have been fucked. 28 | * "Many of life's failures are people who did not realize how close they were to success when they gave up." (Thomas Edison) 29 | * "Everyone can be taught to sculpt: Michelangelo would have had to be taught not to. So it is with great people in all fields." (Unknown) 30 | * "Count your blessings, not your troubles." (Dale Carnegie) 31 | * "Man only likes to count his troubles, but he does not count his joys." (Fyodor Dosteoevsky) 32 | * "Give a man a fish, and you feed him for a day; show him how to catch fish, and you feed him for a lifetime." (Proverb) 33 | * "I always wonder why birds stay in the same place when they can fly anywhere. Then I ask myself the same question." (Harun Yahya) 34 | * "People become what they believe themselves to be. If I believe I can't do something, it makes me incapable of doing it." (Mahatma Gandhi) 35 | * "You can't connect the dots looking forward; you can only connect them looking backwards." (Steve Jobs) 36 | * "Monotony collapses time; novelty unfolds it." (Joshua Foer) 37 | * "Creating new memories stretches out psychological time, and lengthens our perception of our lives." (Joshua Foer) 38 | * Journalistic principle: If a (newspaper) headline asks a question, the answer is usually 'no'. (Andrew Marr) 39 | * "I am a great believer in luck, and I find the harder I work, the more I have of it." (Thomas Jefferson) 40 | * When you are teaching or explaining something, never say "just do" or "it's easy". It's confusing and alienating to new learners. 41 | * "Opportunists have always been held in disrepute -- especially by those who had the same opportunities and didn't take them." (Rhett Butler) 42 | * "The journey of a thousand miles begins with a single step." (Laozi) 43 | * "Determination is really two separate things: resilience and drive. Resilience keeps you from being pushed backwards. Drive moves you forwards." (Jessica Livingston) 44 | * "[W]e see our future selves as strangers. Though we will inevitably share their fates, the people we will become in a decade, quarter century, or more, are unknown to us. This impedes our ability to make good choices on their — which of course is our own—behalf. [...] We might choose to procrastinate, and let some other version of our self deal with problems or chores. Or, as in the case of [a] smoking boy, we can focus on that version of our self that derives pleasure, and ignore the one that pays the price." (Alisa Opar) 45 | * "Part of being optimistic is keeping one's head pointed toward the sun, one's feet moving forward. [...] I would not and could not give myself up to despair. That way lays defeat and death." (Nelson Mandela) 46 | * "I learned that courage was not the absence of fear, but the triumph over it." (Nelson Mandela) 47 | * "The greatest glory in living lies not in never falling, but in rising every time we fall." (Nelson Mandela) 48 | * "There is nothing like returning to a place that remains unchanged to find the ways in which you yourself have altered." (Nelson Mandela) 49 | * "The first step isn't as hard as we make it out to be. ['Just do it']. Stop over-thinking it." (Jon Bell) 50 | * McDonald's Theory: "[W]hen we're trying to decide where to eat for lunch and no one has any ideas, I recommend McDonald's. An interesting thing happens. Everyone unanimously agrees that we can't possibly go to McDonald's, and better lunch suggestions emerge. [...] It's as if we've broken the ice with the worst possible idea. [...] [P]eople are inspired to come up with good ideas to ward off bad ones. [...] The second step is easier than the first." (Jon Bell) 51 | * "Wise men learn more from fools than fools from the wise." (Cato the Elder) 52 | * "Have the argument clear in your mind; the words will follow naturally." (Cato the Elder) 53 | * "We pave the sunlit path toward justice together, brick by brick." (Tim Cook) 54 | * "In the realm of ideas everything depends on enthusiasm ... in the real world all rests on perseverance." (Johann Wolfgang von Goethe) 55 | * "Perseverance is the hard work you do after you get tired of doing the hard work you already did." (Newt Gingrich) 56 | * "Perseverance is failing 19 times and succeeding the 20th." (Julie Andrews) 57 | * "No one succeeds without effort ... Those who succeed owe their success to perseverance." (Ramana Maharshi) 58 | * "Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." (Antoine de Saint-Exupéry) 59 | * Learn to distrust your negative emotions. Later, they usually seem overstated or unfounded. (Giovanni Tirloni) 60 | * "You work in the sales department of your own career. Sell your ability to solve problems." (duggan) 61 | * "Don't spend your precious time asking 'Why isn't the world a better place?'. It will only be time wasted. The question to ask is 'How can I make it better?' To that there is an answer." (Leo Buscaglia) 62 | * "Don't cry because it's over, smile because it happened." (Theodor "Dr. Seuss" Seuss Geisel) 63 | * "The greater part of human activity is designed to make permanent those experiences and joys which are only lovable because they are changing." (Alan Watts) 64 | * "The only way to make sense out of change is to plunge into it, move with it, and join the dance." (Alan Watts) 65 | * "A person who thinks all the time has nothing to think about except thoughts. So he loses touch with reality, and lives in a world of illusion." (Alan Watts) 66 | * "Existence, [Alan Watts] says, is fundamentally *playful*. It's less like a journey, and more like a piece of music or a dance. And the point of dancing isn't to arrive at a particular spot on the floor; the point of dancing is simply to dance." (Kevin Simler) 67 | * "I always thought of myself as a humanities person as a kid, but I liked electronics ... then I read something that one of my heroes, Edwin Land of Polaroid, said about the importance of people who could stand at the intersection of humanities and sciences, and I decided that's what I wanted to do." (Steve Jobs) 68 | * "Before cofounding GitHub I applied for an engineering job at Yahoo and didn't get it. Don't let other people discourage you." (Chris Wanstrath) 69 | * Survivorship bias, a type of selection bias, is the error of concentrating on subjects that "survived" some process or selection and thereby overlooking all the others due to their lack of visibility. 70 | * If you believe that music in the past was better than today's music, it may be because only the most popular music from one generation "survives" and, in a form of survivorship bias, distorts the comparability for you. 71 | * In the area of highly competitive careers (e.g. with singers, movie stars and athletes), one does generally overlook the myriad of people that may have been similarly skilled and determined as the victorious ones, but who did ultimately fail because they were not as lucky. This causes a survivorship bias. 72 | * "Once you've accepted your flaws, no one can use them against you." (George R. R. Martin) 73 | * "A bruise is a lesson ... and each lesson makes us better." (George R. R. Martin) 74 | * "We shouldn't be looking for heroes, we should be looking for good ideas." (Noam Chomsky) 75 | * "[As an astronaut, you] develop an instant global consciousness, a people orientation, an intense dissatisfaction with the state of the world, and a compulsion to do something about it. From out there on the moon, international politics look so petty. You want to grab a politician by the scruff of the neck and drag him a quarter of a million miles out and say, 'Look at that, you son of a bitch'." (Edgar D. Mitchell) 76 | * "Adulthood is emailing 'sorry for the delayed response!' back and forth until one of you dies." (Marissa Miller) 77 | * "Inherit (or luck into) a large fortune, and give a couple million to a good cause -- never mind that it will affect your quality of life not at all -- and you'll be lionized as a hero. The great and the good will invite you onto their podiums -- but a poor person who takes in a foster kid gets virtually no recognition, even if fostering involves real sacrifice on their part." (Cory Doctorow) 78 | * "Don't forget that most men with nothing would rather protect the possibility of becoming rich than face the reality of being poor." (John Dickinson ("1776")) 79 | * "Meritocracy is a tautology, of course. There's no objective measure of *merit* so there's no way to know whether your society is meritocratic or not. Every famous, powerful, rich person owes their status to a combination of skill, luck, and persistence. The best luck of all is to be born to fortunate circumstances, well fed and well educated and well loved. We know for a fact that billions lack some or all of these forms of luck, and among those people are innumerable potential Stephen Hawkings and Steve Jobses and Albert Einsteins. The fact that Jobs was born to a Syrian refugee and that Hawking struggles with a debilitating illness just shows you how fickle luck is -- unless you believe that evolution produced exactly one brilliant tech entrepreneur in the ranks of Syrian refugees and one brilliant scientist with ALS, then you have to believe that the others just didn't get quite so lucky." (Cory Doctorow) 80 | * The "Rule of 72" allows you to estimate the effect of growth rates: Divide `72` by the growth rate as an integer (i.e. the actual rate multiplied by `100`) and you'll get the number of years it takes the base quantity to double. 81 | * It's easy to complain, blame, resent, judge and take. It's hard to inspire, teach, trust, love and believe. Do the hard work. (Vala Afshar) 82 | * "Service is supposed to be about making the world a better place or helping people who are less fortunate, but [when] it's done for the resume, it really just becomes about yourself." (William Deresiewicz) 83 | * "The bitterness of poor quality remains long after the sweetness of low price is forgotten." (Unknown) 84 | * If you can't pay cash, you can't afford it. 85 | * "[W]ages and income are about what the job is worth, not the individual. [...] Your income potential isn't about what you need or what the employer can afford; it's about the value of what you do." (Ron Rule) 86 | * “Plans are of no particular value, but planning is indispensable.” (Dwight D. Eisenhower, 1950) – or – “Plans are worthless, but planning is everything.” (Dwight D. Eisenhower, 1957) 87 | -------------------------------------------------------------------------------- /Linux.md: -------------------------------------------------------------------------------- 1 | # Linux 2 | 3 | ## Bash 4 | 5 | ### Text processing and string manipulation 6 | 7 | * Converting standard input's text to uppercase: 8 | 9 | ```bash 10 | tr "[:lower:]" "[:upper:]" 11 | ``` 12 | 13 | * Converting standard input's text to lowercase: 14 | 15 | ```bash 16 | tr "[:upper:]" "[:lower:]" 17 | ``` 18 | 19 | ### Universally unique identifiers (UUIDs) 20 | 21 | * Generating random UUIDs (i.e. UUID v4): 22 | 23 | ```bash 24 | uuidgen -r 25 | ``` 26 | 27 | * Generating UUIDs based on the current date and time and on the local machine's MAC address (i.e. UUID v1): 28 | 29 | ```bash 30 | uuidgen -t 31 | ``` 32 | 33 | ### Verifying CDs and DVDs against source ISO images 34 | 35 | The checksum for an ISO image can easily be calculated in the standard way: 36 | 37 | ```bash 38 | sha256sum ISO_IMAGE_PATH 39 | ``` 40 | 41 | However, calculating a checksum of a *CD* or *DVD* using 42 | 43 | ```bash 44 | sha256sum /dev/cdrom 45 | ``` 46 | 47 | usually does not produce the expected result due to trailing blank space on the disk. Instead, you should detect the exact size of the ISO image in bytes and then run the following: 48 | 49 | ```bash 50 | dd if=/dev/cdrom bs=1 count=ISO_IMAGE_SIZE_BYTES | sha256sum 51 | ``` 52 | 53 | You can speed this up by finding a larger proper divisor of the size in bytes, such as 2048, 2324 or 2336, and then using that for the `bs` argument while dividing the `count` argument by the same number. 54 | 55 | ### Reverse lines (in a file) 56 | 57 | ```bash 58 | $ tac <FILE> 59 | # or 60 | $ echo <STRING> | tac 61 | ``` 62 | 63 | ### Reverse characters (in every line of a file) 64 | 65 | ```bash 66 | $ rev <FILE> 67 | # or 68 | $ echo <STRING> | rev 69 | ``` 70 | 71 | ### Cutting a video file using start and end time without re-encoding 72 | 73 | ```bash 74 | $ ffmpeg -i $INPUT_FILENAME -ss $START_TIME_SECONDS -to $END_TIME_SECONDS -c:v copy -c:a copy $OUTPUT_FILENAME 75 | # e.g.: ffmpeg -i "input.mp4" -ss 412 -to 23910 -c:v copy -c:a copy "output.mp4" 76 | ``` 77 | 78 | ### Converting a video file to use a different video and audio codec 79 | 80 | ```bash 81 | $ ffmpeg -i $INPUT_FILENAME -c:v $VIDEO_CODEC_NAME -c:a $AUDIO_CODEC_NAME $OUTPUT_FILENAME 82 | # e.g.: ffmpeg -i "input.mp4" -c:v libx264 -c:a aac "output.mp4" 83 | ``` 84 | 85 | ### Rotating a video file using only metadata changes to prevent re-encoding 86 | 87 | ```bash 88 | $ ffmpeg -i $INPUT_FILENAME -metadata:s:v:0 rotate=$ANGLE_CLOCKWISE_MULTIPLE_OF_90 -c:v copy -c:a copy $OUTPUT_FILENAME 89 | # e.g.: ffmpeg -i "input.mp4" -metadata:s:v:0 rotate=270 -c:v copy -c:a copy "output.mp4" 90 | ``` 91 | 92 | ### Rotating a video file by re-encoding the actual video stream 93 | 94 | ```bash 95 | # ANGLE_IDENTIFIER="transpose=1" # 90 degrees clockwise 96 | # or 97 | # ANGLE_IDENTIFIER="vflip,hflip" # 180 degrees 98 | # or 99 | # ANGLE_IDENTIFIER="transpose=2" # 270 degrees clockwise 100 | 101 | $ ffmpeg -i $INPUT_FILENAME -vf $ANGLE_IDENTIFIER -c:v $VIDEO_CODEC_NAME -c:a copy $OUTPUT_FILENAME 102 | # e.g.: ffmpeg -i "input.mp4" -vf "transpose=1" -c:v libx264 -c:a copy "output.mp4" 103 | ``` 104 | 105 | ### Removing sound from a video file by dropping the audio stream 106 | 107 | ```bash 108 | $ ffmpeg -i $INPUT_FILENAME -c:v copy -an $OUTPUT_FILENAME 109 | # e.g.: ffmpeg -i "input.mp4" -c:v copy -an "output.mp4" 110 | ``` 111 | 112 | ### Converting a video file to audio only (e.g. MP3) 113 | 114 | ```bash 115 | $ ffmpeg -i video.webm -b:a 320K -vn music.mp3 116 | # or 117 | $ for i in *.webm; do ffmpeg -i "$i" -b:a 320K -vn "$(basename "${i/.webm}").mp3"; done; 118 | ``` 119 | 120 | ### Wiping or overwriting unallocated (remaining free) disk space 121 | 122 | Write zeros to a temporary file named `zero.file`, which will be deleted as soon as the disk has been filled completely: 123 | 124 | ```bash 125 | cat /dev/zero > zero.file; sync; rm zero.file 126 | ``` 127 | 128 | ### Finding the IP addresses of all devices connected to the local network (LAN) 129 | 130 | ```bash 131 | for ip in 192.168.0.{1..254}; do ping -c 1 -W 1 $ip | grep "64 bytes"; done 132 | ``` 133 | -------------------------------------------------------------------------------- /Media.md: -------------------------------------------------------------------------------- 1 | # Media 2 | 3 | * The world's most famous photo is (arguably) "Guerrillero Heroico" by Alberto Korda from 1960, showing the then 31-year-old revolutionary Che Guevara. The photographer did not receive (or claim) any payments for his picture, which also helped the photo become so popular. 4 | * "A showrunner's duties often combine those traditionally assigned to the writer, executive producer and script editor. Unlike films, where directors are in creative control of a production, in episodic television, the showrunner outranks the director." (Wikipedia, various authors) 5 | * While Spotify doesn't pay owners of recordings, publishers, songwriters and artists *per stream*, an effective "per stream" average can be calculated. It's between 5.00 USD and 8.00 USD per 1,000 streams. 6 | * "Rihanna is often described as a 'manufactured' pop star, because she doesn't write her songs, but neither did Sinatra or Elvis. She embodies a song in the way an actor inhabits a role -- and no one expects the actor to write the script." (John Seabrook) 7 | * Depending on the type of ads shown (e.g. pre-roll or banner ads), whether ads are paid for on a per-click (CPC) or per-view (CPM) basis, and depending on the audience (e.g. demographics and geographical origin), YouTube videos can, on average, generate between 0.80 USD and 5.00 USD of revenue per 1,000 views for users. 8 | * "The contention of Frantz Fanon, the 20th century revolutionary, [was] that 'the aim of terrorism is to terrify'. How do the media help do that? By hyping the threat from terrorism." (David R. Henderson) 9 | * "The current system of ad-supported news leads to clickbait and sensationalism. We need to pay for good journalism." (Andrew Ng) 10 | -------------------------------------------------------------------------------- /Mobile technology.md: -------------------------------------------------------------------------------- 1 | # Mobile technology 2 | 3 | * Every feature phone, smartphone -- or even tablets with 3G, LTE, etc. -- has a baseband processor that runs proprietary, closed software. That software implements standards and uses code from the '80s and '90s. Thus it has weak security measures, is missing a lot of checks and often trusts data received from base stations blindly, resulting in the presence of many bugs and vulnerabilities -- over the air! It is often possible to enable auto-answer, turn on microphones or cameras, send SMS or execute arbitrary code. But this component of modern devices is not only poorly understood and really low-level, it does also require certification and is protected by lots of patents. 4 | * Would people want to put your app on their home screen? If yes, you should build a native app for the particular platform. If not, you should build a website. Most often, this is true when the customer needs occasional connections to the business, such as finding the opening hours. People will search for that information on the web, they don't want to install an app just to find that piece of information once. 5 | * Do you need a good estimate of your app's potential ad revenue? For an estimate *per month*, try: `({DAU} * 365 / 12) * ({SESSION_LENGTH} * (60 / 30)) * ({E_CPM} / 1000)`. Replace `{DAU}` with the average number of daily active users (DAU) for your app. `{SESSION_LENGTH}` is the time in minutes that users spend in your app on average. Finally, for `{E_CPM}`, insert the expected CPM (eCPM) for your ad network, which may be 0.50 USD, for example. The currency of your eCPM value does also define the currency of the result, of course. 6 | * "Mobile was always bigger than PCs, but separate, and not really part of the computing market. Smartphones broke down that wall." (Benedict Evans) 7 | * "An iPhone 6 CPU has 625 times more transistors than a 1995 Pentium." (Benedict Evans) 8 | * "In 2007, Nokia was the biggest and most fashionable name in cell phones, with an unassailable lead in hand-held technology. Things had been so good for so long that company executives saw little chance for any competitive challenge -- phones were a tough business, they said, and Nokia was reaping the harvest of decades of hard work that no one else could hope to match. That June, Steve Jobs introduced the iPhone. And seven years later, Nokia -- worth a quarter of a trillion dollars at its apex -- abjectly sold off its much-diminished phone division to Microsoft. The price was $7 billion, less than 3% of its former value." (Steve LeVine) 9 | -------------------------------------------------------------------------------- /MongoDB.md: -------------------------------------------------------------------------------- 1 | # MongoDB 2 | 3 | * If you want to search for string values with a regular expression, write `db.collection.find({ "name": { "$regex": "^a"})`, for example. This will find all records that have a `name` beginning with `a`. An index can only be used if you search for a prefix using `^`. You can even search on the `_id` field, but only if you're using plain strings there and no auto-generated `ObjectId` values. 4 | -------------------------------------------------------------------------------- /MySQL.md: -------------------------------------------------------------------------------- 1 | # MySQL 2 | 3 | ## Security 4 | 5 | * For each (web) application that needs access to a database, create a separate, application-specific user in MySQL, restricted to host `localhost` and protected by a strong password. That user should have minimal privileges, i.e. perhaps no administrative privileges at all but only table-specific read/write privileges, such as `SELECT`, `INSERT`, `UPDATE`, `DELETE` and `LOCK TABLES`. 6 | * Restrict access to your MySQL instance to `localhost`, i.e. don't expose it to the public. Your firewall may keep port `3306` closed as well. 7 | 8 | * Use an SSH tunnel (e.g. via the terminal on Linux or macOS or via PuTTy on Windows) from local port `3306` or `33060` (to avoid conflicts) to remote port `3306`. 9 | 10 | On Linux, for example, execute the following command in a terminal: 11 | 12 | ``` 13 | $ ssh -p <SSH_PORT> -L <LOCAL_MYSQL_PORT>:localhost:<REMOTE_MYSQL_PORT> user@server 14 | # Example: ssh -p 22 -L 3306:localhost:3306 john@127.0.0.1 15 | ``` 16 | 17 | This way, you can safely connect to your database on `localhost` on the specified port using *locally* installed tools such as "MySQL Workbench" or "phpMyAdmin". 18 | 19 | * Don't install web-based administration tools such as "phpMyAdmin" on the *remote* server. 20 | 21 | ## Installation 22 | 23 | ### On Ubuntu 24 | 25 | * Run the following commands to install the package: 26 | 27 | ``` 28 | $ sudo apt-get update 29 | $ sudo apt-get install mysql-server 30 | ``` 31 | 32 | Enter a strong password for the MySQL `root` user when asked during installation, e.g. one of 32 characters, and confirm it afterwards. 33 | 34 | * Run the following command to apply more secure defaults and to remove users and tables intended only for testing: 35 | 36 | ``` 37 | $ sudo mysql_secure_installation 38 | ``` 39 | 40 | Reply to all questions as you wish, but generally that should be `y` for every question, except when asked whether you want to change the root password again. 41 | 42 | * Now log in to MySQL as `root`: 43 | 44 | ``` 45 | $ mysql -u root -p 46 | ``` 47 | 48 | When asked, enter the password for `root` that you set up before. If the password was correct, there should now be a `mysql` prompt. 49 | 50 | * Type the following to list all user accounts currently available: 51 | 52 | ``` 53 | SELECT User, Host, HEX(authentication_string), plugin FROM mysql.user; 54 | ``` 55 | 56 | There shouldn't be any user left that has no name or no password. If there is, either remove that user or set a password. 57 | 58 | * Now initialize MySQL's data directory: 59 | 60 | ``` 61 | $ sudo mysqld --initialize 62 | ``` 63 | 64 | You may see the following response, however, which means that this task has already been taken care of for you: 65 | 66 | ``` 67 | --initialize specified but the data directory has files in it. Aborting. 68 | ``` 69 | 70 | * Finally, check if MySQL is running correctly: 71 | 72 | ``` 73 | $ sudo service mysql status 74 | ``` 75 | 76 | You should see the following response: 77 | 78 | ``` 79 | Active: active (running) 80 | ``` 81 | 82 | ## Backups 83 | 84 | For the filenames of your backups, you may want to use `"$(date -u +"%Y%m%dT%H%M%SZ").sql"` on Linux or something similar on other platforms, which uses the current UTC time in ISO 8601 format, safe for filenames on most operating systems. 85 | 86 | ### Exporting data 87 | 88 | ``` 89 | $ mysqldump --add-locks --complete-insert --create-options --default-character-set=utf8mb4 --disable-keys --extended-insert --lock-tables --order-by-primary --password --protocol=tcp --quick --quote-names --set-charset --skip-add-drop-table --skip-comments --skip-triggers --tz-utc --host=127.0.0.1 --port=3306 --user="my-username" --result-file="my-output-filename.sql" "my-database-name" 90 | ``` 91 | 92 | 1. Make sure that your MySQL user has at least the `SELECT` and `LOCK TABLES` privileges on all tables that you want to export. 93 | 1. Change the value of the `--user` option to the name of your MySQL user. 94 | 1. Change the value of the `--result-file` option to the filename that you wish your output file to have. 95 | 1. Change the value of the main argument to the name of the database that you want to export. 96 | 1. Optionally, adjust the value of the `--host` and `--port` options in order to connect to another machine or on a different port. 97 | 1. Optionally, if you wish to export the table *structure* only, add the `--no-data` option. 98 | 1. Optionally, if you wish to export the table *data* only, add the `--no-create-info` option. 99 | 1. Optionally, if you wish to export certain tables only, simply append the table names to the end of the command, separated by spaces. 100 | 1. Execute the (modified) command, either on the database server or on a remote machine (e.g. using an SSH tunnel). 101 | 1. After executing the command, you will be prompted for your MySQL user's database password. 102 | 1. Find your export file in the current working directory, with the name specified using `--result-file`. 103 | 104 | ## Geographic coordinates 105 | 106 | ### Storing data 107 | 108 | Save your geographic coordinates (latitude and longitude) in a `Point` column and add a `SPATIAL` index on that column. Insert values into that column as `Point(lat_dec, lon_dec)`, e.g. `Point(52.518611111111, 13.408333333333)`. 109 | 110 | ### Querying with a distance search 111 | 112 | In order to get all rows with a `Point` in `point_column` that are within `$radius` kilometers of `($lat, $lon)`, use the following condition: 113 | 114 | ``` 115 | WHERE 116 | MBRContains( 117 | LineString( 118 | Point( 119 | $lat - $radius / 111.133, 120 | $lon - $radius / 111.320 / COS(RADIANS($lat)) 121 | ), 122 | Point( 123 | $lat + $radius / 111.133, 124 | $lon + $radius / 111.320 / COS(RADIANS($lat)) 125 | ) 126 | ), 127 | point_column 128 | ) 129 | ``` 130 | 131 | ### Selecting distances 132 | 133 | In order to calculate an approximation of the distance between the `Point` in `point_column` and `($lat, $lon)`, use the following expression: 134 | 135 | ``` 136 | SELECT 137 | SQRT(POW((X(point_column) - $lat) * 111.133, 2) + POW((Y(point_column) - $lon) * 111.320 * COS(RADIANS($lat)), 2)) AS distance 138 | ``` 139 | -------------------------------------------------------------------------------- /PHP.md: -------------------------------------------------------------------------------- 1 | # PHP 2 | 3 | * "PHP has one data structure to rule them all. The *array* is a complex, flexible, master-of-none, hybrid data structure, combining the behaviour of a *list* and a *linked map*. But we use it for everything, because PHP is pragmatic: [...] An array gets the job done, even though you wouldn't study it in a Computer Science course." (Rudi Theunissen) 4 | 5 | * Functions and language constructs that may start external scripts or processes include `exec`, `shell_exec`, `passthru`, `system`, `proc_open`, `popen` and the backtick operator (`` `...` ``). As a regular expression, that is (collectively): 6 | 7 | ``` 8 | ((?:^|[^a-zA-Z0-9_])(exec|shell_exec|passthru|system|proc_open|popen)(?:[^a-zA-Z0-9(_]*)\()|(`[^`]+`) 9 | ``` 10 | 11 | ## Security 12 | 13 | * If you don't know where to find your `php.ini` configuration file, create a PHP file with the content `<?php phpinfo();` and view it in your browser. The entry `Loaded Configuration File` should show you the correct file path, e.g. `/etc/php/7.0/apache2/php.ini`. 14 | 15 | * Open your PHP configuration by running the following command with the path to the `php.ini` that you found: 16 | 17 | ``` 18 | $ sudo nano {path} 19 | ``` 20 | 21 | That is, for example: 22 | 23 | ``` 24 | $ sudo nano /etc/php/7.0/apache2/php.ini 25 | ``` 26 | 27 | * Make sure that the following keys have the values listed next to them. In addition to that, the respective lines must not be commented out, of course. These directives represent reasonable default values for maximum security and compatibility: 28 | 29 | ``` 30 | allow_url_include = Off 31 | display_errors = Off 32 | display_startup_errors = Off 33 | error_reporting = E_ALL 34 | expose_php = Off 35 | html_errors = Off 36 | log_errors = On 37 | mail.add_x_header = Off 38 | max_execution_time = 30 39 | max_input_time = 30 40 | post_max_size = 8M 41 | request_order = "GP" 42 | session.auto_start = 0 43 | session.cookie_domain = 44 | session.cookie_httponly = 1 45 | session.cookie_path = / 46 | session.cookie_secure = 0 47 | session.name = session_v1 48 | session.use_cookies = 1 49 | session.use_only_cookies = 1 50 | session.use_trans_sid = 0 51 | short_open_tag = Off 52 | track_errors = Off 53 | variables_order = "GPCS" 54 | ``` 55 | 56 | * If you don't need to open external files and URLs from your server, consider setting the value for the following directive as well: 57 | 58 | ``` 59 | allow_url_fopen = Off 60 | ``` 61 | 62 | * Another directive that should be modified is the `memory_limit` that is measured per script. Try a lower value such as `32M` first and only increase the limit as needed. When your application stops working correctly due to the memory limit, double it until you have a sufficient value. 63 | 64 | ``` 65 | memory_limit = 32M 66 | ``` 67 | 68 | * If users don't need to be able to upload files in your application, set 69 | 70 | ``` 71 | file_uploads = Off 72 | ``` 73 | 74 | to disable file uploads completly for security reasons. 75 | 76 | Otherwise, if you need file upload capabilities, set the following values and relax the limits only when required: 77 | 78 | ``` 79 | file_uploads = On 80 | max_file_uploads = 4 81 | upload_max_filesize = 2M 82 | ``` 83 | 84 | You may also have to adjust your values for `max_execution_time`, `max_input_time` and `post_max_size` if you need large file uploads or heavy file processing. 85 | 86 | * Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. 87 | 88 | * Finally, restart the web server: 89 | 90 | ``` 91 | $ sudo service apache2 restart 92 | ``` 93 | 94 | ## Installation 95 | 96 | ### On Ubuntu 97 | 98 | * Run the following command: 99 | 100 | ``` 101 | $ sudo apt-get install libapache2-mod-php 102 | ``` 103 | -------------------------------------------------------------------------------- /PhpStorm.md: -------------------------------------------------------------------------------- 1 | # PhpStorm 2 | 3 | * Remove trailing whitespace automatically 4 | 1. `File` 5 | 2. `Settings` 6 | 3. `IDE Settings` 7 | 4. `Editor` 8 | 5. Set `Strip trailing spaces on Save` to `All` 9 | * Make sure that every file ends with a line feed 10 | 1. `File` 11 | 2. `Settings` 12 | 3. `IDE Settings` 13 | 4. `Editor` 14 | 5. Check `Ensure line feed at file end on Save` 15 | -------------------------------------------------------------------------------- /Politics.md: -------------------------------------------------------------------------------- 1 | # Politics 2 | 3 | * "A critical, independent and investigative press is the lifeblood of any democracy. The press must be free from state interference. It must have the economic strength to stand up to the blandishments of government officials. It must have sufficient independence from vested interests to be bold and inquiring without fear or favour. It must enjoy the protection of the constitution, so that it can protect our rights as citizens." (Nelson Mandela) 4 | * "'Socialism' is no more an evil word than 'Christianity'. Socialism no more prescribed Joseph Stalin and his secret police and shuttered churches than Christianity prescribed the Spanish Inquisition. Christianity and socialism alike, in fact, prescribe a society dedicated to the proposition that all men, women, and children are created equal and shall not starve." (Kurt Vonnegut) 5 | * "The story of *meritocracy* -- a society that migrates wealth, status, and decision-making power into the hands of the most capable -- is seductive. Rich people love the idea of meritocracy, because the alternative is that their lion's share is unfair, the product of luck, or, worse, cheating. But many of meritocracy's losers love it, too. In the [disputed] words of John Steinbeck, 'Socialism never took root in America because the poor see themselves not as an exploited proletariat but as temporarily embarrassed millionaires.'" (Cory Doctorow) 6 | * "[Some] states are on the verge of reversing decades-old laws about homosexual relationships and marijuana use. If the old laws could have been perfectly enforced through surveillance, society would never have reached the point where the majority of citizens thought those things were okay. There has to be a period where they are still illegal yet increasingly tolerated, so that people can look around and say, 'You know, that wasn't so bad.' Yes, the process takes decades, but it's a process that can't happen without lawbreaking. [...] The perfect enforcement that comes with ubiquitous government surveillance chills this process. We need imperfect security -- systems that free people to try new things [...]. Freedoms we now take for granted were often at one time viewed as threatening or even criminal by the past power structure. Those changes might never have happened if the authorities had been able to achieve social control through surveillance. This is one of the main reasons all of us should care about [...] surveillance, even if we are not personally chilled by its existence. We suffer the effects because people around us will be less likely to proclaim new political or social ideas, or act out of the ordinary. If J. Edgar Hoover's surveillance of Martin Luther King Jr. had been successful in silencing him, it would have affected far more people than King and his family." (Bruce Schneier) 7 | * "What is [...] damaging -- and [...] engaging, and thus lucrative for Facebook -- is all of us in our own virtual neighborhoods of our own making, liking opinions that tell us we're right instead of engaging with viewpoints that make us question our assumptions." (Ben Thompson) 8 | * "As Cass Sunstein and others have shown, people become more extreme when they're around others who share their beliefs. [...] [T]he internet makes it easy to settle in a virtual neighborhood with people who agree with you. Polarization is going to get a lot worse before it starts getting better." (Ezra Klein) 9 | * "No woman in a burqa (or a hijab or a burkini) has ever done me any harm. But I was sacked (without explanation) by a man in a suit. Men in suits missold me pensions and endowments, costing me thousands of pounds. A man in a suit led us on a disastrous and illegal war. Men in suits led the banks and crashed the world economy. Other men in suits then increased the misery to millions through austerity. If we are to start telling people what to wear, maybe we should ban suits." (Henry Stewart) 10 | * "No country is immune from terrorism. It's easy to terrorize. Government and law enforcement have to be correct 24 hours a day, 7 days a week, 365 days a year." (John Kerry) 11 | * "Throughout history, reliance on terrorism has been the tactic of movements that were weak and had little popular support. The goal of terrorist attacks is always to provoke an overreaction that will increase support for the terrorist's cause." (Greg G.) 12 | * "Disillusionment and cynicism have become natural byproducts of everyday journalism. [...] As a result, what audiences see beyond their direct experience is a world of unchecked pathology, and it makes it all too easy to fear and demonize others. It shapes people's behaviors and choice of leaders." (David Bornstein and Tina Rosenberg) 13 | * "Since the early 1970s, surveys conducted annually have revealed that trust and confidence in virtually all American institutions -- government, corporations, banks, medicine, education, organized religion and, yes, the press -- have been declining steadily." (David Bornstein and Tina Rosenberg) 14 | * "[M]any Americans today have difficulty imagining, valuing or even believing in the promise of incremental system change, which leads to a greater appetite for revolutionary, smash-the-machine change [...]." (David Bornstein and Tina Rosenberg) 15 | * "The best defense against the fear-mongering of the demagogue is to reveal the decency, competence and courage of people determined to fix their society." (David Bornstein and Tina Rosenberg) 16 | -------------------------------------------------------------------------------- /Privacy.md: -------------------------------------------------------------------------------- 1 | # Privacy 2 | 3 | * "If I can read your newspaper from orbit, what is public? If I can tell where you are in your house by imaging through the wall, what is public?" (Dan Geer) 4 | * The digital age and the internet take away the natural right to be forgotten. You are no longer able to fully reinvent yourself. 5 | * "Since 1851, Amsterdam had a registry that recorded the following innocent pieces of data about the residents: name, date of birth, address, marital status, parents, profession, religion, previous addresses and date of death if deceased. [...] What we do know is that [a] little field caused untold thousands of people to die once the occupiers decided to use it to locate Jewish people." (Jacques Mattheij) 6 | * "Arguing that you don't care about the right to privacy because you have nothing to hide is no different than saying you don't care about free speech because you have nothing to say." (Edward Snowden) 7 | * Mass surveillance can be used against journalists, whistleblowers and human rights activists. So even if you think that 'if you have nothing to hide, you have nothing to fear', people who represent your political beliefs *may* have something to fear. 8 | * "Show me the man, and I will find you the crime." (Lavrentiy Pavlovich Beria) 9 | 10 | ## Technology 11 | 12 | * Privacy-preserving contact discovery remains an unsolved problem in practice. You can't hash contact identifiers before transmitting them because the space of pre-hash identifiers is usually too small, especially for phone numbers. Furthermore, you can't salt the identifiers. One might use bloom filters but this does not work for large lists of possible contacts. (Moxie Marlinspike) 13 | 14 | ### Web browser 15 | 16 | * Disable the HTTP "referer" in your web browser. In Firefox, type `about:config` in the address bar and set `network.http.sendRefererHeader` to `0` to do so. 17 | * Block trackers, analytics services etc. You can do this by installing the free [uBlock Origin](https://github.com/gorhill/uBlock) extension in your web browser. 18 | * Block all *third-party* cookies, i.e. cookies which are served from sites other than the one you're currently visiting. In Firefox, go to `Settings`, open the `Privacy` tab and go to section `History`. Define that Firefox will `use custom settings for history` and uncheck `Accept third-party cookies`. 19 | -------------------------------------------------------------------------------- /Product design.md: -------------------------------------------------------------------------------- 1 | # Product design 2 | 3 | * Sales is talking to a small number of people who are seriously interested in the product you're building. Marketing is talking to a broad audience that is generally indifferent. They're two ends of a spectrum. 4 | * Unless you are in one of the winner-takes-all markets (e.g. social networks), focus on the product first and only then on growth. Talk to early adopters individually and shape your product. If you fail to do so by advertising a mediocre product, you will not only have unsustainable growth (or none at all), but you will never get the feedback that you need to improve the product. You will have fewer users than expected and be blind to all your product's shortcomings. 5 | * "Focusing on the problem you want to solve will keep you from getting blinded by your enthusiasm for a single solution." (hatchery.io) 6 | * "Requiring login or account creation too early in a site experience can be detrimental to conversion. [...] Before offering their personal information, users want to browse content and get a sense of what a site has to offer." (Pete LePage) 7 | * "Offer the option to check out as a guest, and encourage registration with tangible benefits." (Pete LePage) 8 | * "[T]he effort required to design something is inversely proportional to the simplicity of the result." (Roy T. Fielding) 9 | * "Above all else, align with customers. Win when they win. Win only when they win." (Jeff Bezos) 10 | * "Design is not just what it looks like and feels like. Design is how it works." (Steve Jobs) 11 | * "I've been amazed at how often those outside the discipline of design assume that what designers do is decoration. Good design is problem solving." (Jeffery Veen) 12 | * "Design is the fundamental soul of a human-made creation that ends up expressing itself in successive outer layers of the product or service." (Steve Jobs) 13 | * "Visual appearance is one of the most effective variables for quickly differentiating one application from another." (Bob Baxley) 14 | * "As far as the customer is concerned, the interface is the product." (Jef Raskin) 15 | * "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." (Richard Buckminster Fuller) 16 | * "The ability to simplify means to eliminate the unnecessary so that the necessary may speak." (Hans Hofmann) 17 | * "One of the things I've learned is that every time you offer a choice, you paralyse some people who can't decide if that's what they want to do or not. [...] It's the 'Paradox of Choice', the jam experiment -- you put strawberry, apricot and blackberry jam in the supermarket aisle and you can persuade half the people coming down the aisle to taste the jam and maybe buy one. But if you decide to add lemon, orange, blueberry and grapefruit, by adding the choices you don't increase the number of people choosing one, but in fact you go the other way. Fewer people choose anything at all." (Neil Hunt) 18 | * "Things are packages of emphasis. Some things are emphasized in a product, some things are not done as well in a product, some things are chosen not to be done at all in a product. And so different people make different choices." (Steve Jobs) 19 | 20 | ## Growth 21 | 22 | * User retention is always more important than virality and fast user acquisition. You can pour a lot of water into a leaky bucket and it won't really fill. But as soon as you have mended the holes, the bucket will be filling gradually. Thus focus on retention first and foremost, which will result in sustainable growth and make all subsequent efforts more efficient. You just have to pour in enough water to find out all the leaks. 23 | * At the early stage of your business, start small and narrow: Do sales, not marketing. Talk to a small number of users only. This is invaluable market research that helps you find product/market fit. And you can ... enough power to reach out to a broader audience. Airbnb started by meeting with its first hosts personally, teaching them about the product and even being referred to potential new hosts, who they met in person as well. Stripe signed up its first users manually and installed the product for them. Pinterest began by recruiting users manually as well, going into cafes in Palo Alto and asking random people to try out Pinterest while gathering feedback over their shoulders. 24 | 25 | ## Validating your business ideas (online) 26 | 27 | Test whether there exists a certain problem and you have the solution that your target audience is willing to pay for. Don't ask your target audience what they want. *You* have to know what they might want and validate that idea. 28 | 29 | Four simple steps (hatchery.io): 30 | 31 | 1. Talk to your potential customers about the problem in an informal setting and ask: "I believe [target group] has a problem/need achieving [goal] because [problem/need]. By [solution] we will help them to [benefit]. We will offer the solution for [pricing]. Are you interested?" 32 | 2. Put together a landing page for the product that does not even exist yet and advertise it online, e.g. via Google AdWords. Just see if people are interested and perhaps get some email addresses of people who want to be notified on product launch. 33 | 3. Built a minimum viable product (MVP): Offer your audience the solution they expected in the most simple and basic form that is possible. 34 | 4. Get valuable insights, talk to your audience again and again, and find product/market fit — or dismiss your idea. 35 | 36 | Always remember: 37 | 38 | * Throughout the process, question hard whether the people you talk to are really representative of your target audience and whether they are willing and able to pay for it. 39 | * If you can't get anybody to give you an email address, then you'll never get them to give you any money. 40 | -------------------------------------------------------------------------------- /Psychology.md: -------------------------------------------------------------------------------- 1 | # Psychology 2 | 3 | * "The reason we struggle with insecurity is because we compare our behind-the-scenes with everyone else's highlight reel." (Steven Furtick) 4 | * "It is difficult to get a man to understand something, when his salary depends upon his not understanding it." (Upton Beall Sinclair) 5 | * "[H]appiness [is] the most attractive female emotion expression, and one of the least attractive in males. In contrast, pride show[s] the reverse pattern; it [is] the most attractive male expression, and one of the least attractive in women." (Jessica L. Tracy and Alec T. Beall) 6 | * "Because it is always possible, after the fact, to come up with a story about why things worked out the way they did -- that the first 'Harry Potter' really was a brilliant book, even if the eight publishers who rejected it didn't know that at the time -- our belief in determinism is rarely shaken, no matter how often we are surprised." (Duncan J. Watts) 7 | * "[W]hen people tend to like what other people like, differences in popularity are subject to what is called 'cumulative advantage', or the 'rich get richer' effect. This means that if one object happens to be slightly more popular than another at just the right point, it will tend to become more popular still." (Duncan J. Watts) 8 | * "All over the place, from the popular culture to the propaganda system, there is constant pressure to make people feel that they are helpless, that the only role they can have is to ratify decisions and to consume." (Noam Chomsky) 9 | * "We all know that knowledge workers work best by getting into 'flow', also known as being 'in the zone', where they are fully concentrated on their work and fully tuned out of their environment. They lose track of time and produce great stuff through absolute concentration. This is when they get all of their productive work done. Writers, programmers, scientists, and even basketball players will tell you about being in the zone." (Joel Spolsky) 10 | * "It's when we have no firsthand information and must rely on the news that the world gets scary." (David Bornstein and Tina Rosenberg) 11 | * "We know from psychological research that a steady diet of news about violence, corruption and incompetence leads to increased fear, learned helplessness, hopelessness, cynicism, depression, isolation, hostility, contempt and anxiety. The journalist Walter Lippmann wrote: 'The way in which the world is imagined determines at any particular moment what men will do.'" (David Bornstein and Tina Rosenberg) 12 | 13 | ## Learning 14 | 15 | * "Instead of studying, a student goes to a movie the night before an exam. If he performs poorly, he can attribute his failure to a lack of studying rather than to a lack of ability or intelligence. On the other hand, if he does well on the exam, he may conclude that he has exceptional ability, because he was able to perform well without studying." (Edward Hirt) 16 | * "The kids who race ahead in the readers without much supervision get praised for being smart. What are they learning? They're learning that being smart is not about overcoming tough challenges. It's about *finding work easy*. When they get to college or graduate school and it starts being hard, they don't necessarily know how to deal with that." (Carol Dweck) 17 | * "[A] science survey class [...] consists almost entirely of the theories that turned out to be right -- not the folks who believed in the mythical 'N-rays', declared that human beings had forty-eight chromosomes, or saw imaginary canals on Mars. [...] The people who believed in them frequently come across as ludicrous yokels, even though many of them were distinguished scientists who made real contributions to their fields." (Megan McArdle) 18 | * The most important lesson kids should learn is "the ability to learn from their mistakes, to be knocked down and to pick themselves up -- the ability, in other words, to fail gracefully." (Megan McArdle) 19 | * "I think about ninety percent of the problem in teaching, or maybe ninety-eight percent, is just to help the students get interested." (Noam Chomsky) 20 | 21 | ## Motivation 22 | 23 | * "Work finally begins when the fear of doing nothing exceeds the fear of doing it badly." (Alain de Botton) 24 | * "If your job is to eat a frog, eat it first thing in the morning, and if your job is to eat two frogs, eat the big one first." (Mark Twain) 25 | * "No one 'builds a house'. They lay one brick again and again and the end result is a house. Procrastinators are great visionaries -- they love to fantasize about the beautiful mansion they will one day have built -- but what they need to be are gritty construction workers, who methodically lay one brick after the other, day after day, without giving up, until a house is built." (Tim Urban) 26 | * "But the best thing [to fight procrastination] is to recognize that you don't have to be in the mood to do a certain task -- just ignore how you feel and get started." (Ana Swanson) 27 | * 28 | 29 | ## Social psychology 30 | 31 | * Milgram experiment 32 | * One of the most famous social science experiments of all time 33 | * Showed that most people will obey an authority figure even if the authority gives orders that conflict with the subject's morals. 34 | * Milgram wanted to prove that Germans have a stronger willingness to obey to authorities. Being the child of two eastern-European Jews, survivor's guilt after the Holocaust was probably one part of Milgram's motivation. 35 | * Milgram's work followed the Asch conformity experiments (where participants make judgments about drawn lines) but Milgram wanted to turn it "into a more humanly significant experiment". 36 | * The subjects were ordered to to give allegedly painful electric shocks to other people, who were in fact actors. 37 | * First tried on Americans in New Haven, the experiment showed subjects to be far more obedient than expected, so Milgram knew the German comparison wouldn't matter anymore. 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Knowledge 2 | 3 | Random pieces of knowledge — with anecdotes and quotes 4 | 5 | ## Contributing 6 | 7 | All corrections and improvements are welcome! Additions cannot be accepted for reasons of scope, unfortunately. 8 | 9 | If you wish to contribute, please create an issue first so that your remark, problem or question can be discussed. 10 | 11 | ## License 12 | 13 | ``` 14 | Copyright (c) delight.im <info@delight.im> 15 | 16 | Except where otherwise noted, all content is licensed under a 17 | Creative Commons Attribution 4.0 International License. 18 | 19 | You should have received a copy of the license along with this 20 | work. If not, see <http://creativecommons.org/licenses/by/4.0/>. 21 | ``` 22 | -------------------------------------------------------------------------------- /RegEx.md: -------------------------------------------------------------------------------- 1 | # RegEx 2 | 3 | * Instead of `.*` (greedy), you should almost always use `.*?` (lazy) to reduce the amount of backtracking needed. 4 | * If you want to escape a string for use as a literal pattern, just wrap it inside `\Q` and `\E`. In Java, you can call `Pattern.quote(...)`. 5 | * In most languages, look-behinds and look-aheads must have an obvious length, i.e. `+` and `*` are off-limits. 6 | * Most metacharacters (e.g. `.` and `*`) lose their special meaning when inside a character class. Thus you don't have to escape them anymore. The only characters you have to escape there are `[`, `]`, `-` and `^`. Even better, you don't have to escape `-` when at the very beginning or end of the character class, and `^` must only be escaped when it comes first in the class. 7 | 8 | ## Lookarounds 9 | 10 | * Lookarounds are atomic groups, i.e. they are non-capturing. 11 | * Wrapped in parentheses and starting with a question mark, lookarounds have the basic form `(?...)` that is not complete yet. 12 | * Lookaheads add a `=` if they "want" a certain group to follow (positive) or a `!` if they "don't want" a certain group to follow. 13 | * Lookbehinds work like lookaheads, but they add an additional `<` after the question mark and let you check what **precedes**, not follows. 14 | * The positive lookahead `a(?=b)` does only match `a` characters that are followed by a `b`. 15 | * The negative lookahead `a(?!b)` matches all `a` characters that are **not** followed by a `b`. 16 | * The positive lookbehind `(?<=b)a` does only match `a` characters that are preceded by a `b`. 17 | * The negative lookbehind `(?<!b)a` matches all `a` characters that are **not** preceded by a `b`. 18 | 19 | ## JavaScript 20 | 21 | * If you want to match all characters including newlines, you have to use the negative empty selection (`[^]`) instead of the dot (`.`). 22 | * JavaScript doesn't know lookbehinds, neither positive `(?<=)` nor negative `(?<!)`. 23 | -------------------------------------------------------------------------------- /SSL and TLS.md: -------------------------------------------------------------------------------- 1 | # SSL and TLS 2 | 3 | ## Automatic and free certificates via "Let's Encrypt" 4 | 5 | ### Ubuntu 6 | 7 | * Download the "Let's Encrypt" client: 8 | 9 | ``` 10 | $ sudo apt-get install python-letsencrypt-apache 11 | ``` 12 | 13 | * Get a new SSL certificate by running 14 | 15 | ``` 16 | $ sudo letsencrypt --apache -d example.com -d www.example.com 17 | ``` 18 | 19 | where you replace `example.com` with your domain name and optionally add even more subdomains after `-d` options. 20 | 21 | * Check if your site is available via HTTPS now and perhaps also [check your configuration using an online tool](https://www.ssllabs.com/ssltest/) 22 | 23 | * [Set up a cron job](https://github.com/delight-im/Knowledge/blob/master/Ubuntu.md) in the `root` user's crontab to attempt automatic renewal of the certificate twice a day (at *random* times), e.g.: 24 | 25 | ``` 26 | 14 1,11 * * * export PATH=/usr/sbin:/usr/bin:/sbin:/bin && letsencrypt renew > /path/to/log-file.log 2>&1 27 | ``` 28 | -------------------------------------------------------------------------------- /Safety.md: -------------------------------------------------------------------------------- 1 | # Safety 2 | 3 | * Always use the rear hobs of your cooker and make the handles of your pots point to the rear as well if you have small children. 4 | * Never put out a grease fire by quenching it with water. Instead, extinguish it by choking it, i.e. cover it with a lid or blanket. 5 | * When serving warm dishes or beverages to small children, always check the temperature again by tasting the food. 6 | * Never leave the control for water temperature at 'hot'. The next person using the water may scald or burn themself. 7 | * Secure your water faucets with a thermostat that limits the maximum temperature to 50°C. 8 | * On New Year's Eve, never reignite unexploded fireworks but leave them untouched or render them harmless with water. 9 | * Never keep firecrackers in your (trouser) pockets. They may ignite due to the friction and cause serious burns. 10 | * Never use liquid fire accelerants such as ethanol. These evaporate heavily and cause highly explosive vapor. Instead, use solid barbecue lighters, e.g. cubes. 11 | * After the barbecue, let the fire and the glowing embers extinguish and cool down completely. During that period, don't leave the barbecue device unattended. 12 | * If you expect that you might need to extinguish a fire, have a bucket of sand or a fire blanket readily available. 13 | * For burns, the most important emergency aid is cooling down the burnt places with water (about 15°C) for 10 to 15 minutes. 14 | -------------------------------------------------------------------------------- /Science.md: -------------------------------------------------------------------------------- 1 | # Science 2 | 3 | * "You have as much computing power in an Apple iPhone as was available at the time of the Apollo missions. But what is it being used for? It's being used to throw angry birds at pigs; it's being used to send pictures of your cat to people halfway around the world; it's being used to check in as the virtual mayor of a virtual nowhere while you're riding a subway from the nineteenth century." (Peter Thiel) 4 | * "Nixon's 1974 call for full energy independence by 1980 has given way to Obama's 2011 call for one-third oil independence by 2020." (Peter Thiel) 5 | * "The Golden Gate Bridge was built in three-and-a-half years in the 1930s. It's taken seven years to build an access road that costs more than the original bridge in real dollars." (Peter Thiel) 6 | * Deep water does not freeze as easily because (a) it takes colder temperatures to freeze water under pressure (b) existing ice will always float at the top and prevent exchange (c) there's geothermal energy from the ocean bed. 7 | * "Computing devices have been consistently multiplying in power [...] from the mechanical calculating devices used in the 1890 U.S. census, to Turing's relay-based machine that cracked the Nazi enigma code, to the vacuum tube computer that predicted Eisenhower's win in 1952, to the transistor-based machines used in the first space launches, to the integrated-circuit-based personal computer." (Ray Kurzweil) 8 | * "Moore's law" is the observation and forecast (and not a physical or natural law) by Intel co-founder Gordon E. Moore from 1965, revised in 1975, noticing that over the history of computing hardware, the number of transistors in a dense integrated circuit doubles approximately every two years. 9 | * "[C]himps and bonobos in particular take pride of place as our nearest living relatives, sharing approximately 99 percent of our DNA, with gorillas trailing at 98 percent. Yet that tiny portion of unshared DNA makes a world of difference: it gives us, for instance, our bipedal stance and the ability to plan missions to Mars." (Kate Wong) 10 | * There are five Nobel Prizes that had been established by Alfred Nobel in his will. Four of those are awarded by Swedish bodies while the Nobel Peace Prize is awarded by a 5-person committee from Norway. 11 | * Radar (*radio* detection and ranging), Lidar (*light* detection and ranging) and Sonar (*sound* navigation and ranging) are systems for object detection and similar purposes. 12 | * The Doppler effect is the change in frequency of periodic data (e.g. radio waves) that you see when an observer and a source move relatively to each other. You can witness it when an ambulance with a siren approaches (higher frequency), passes (normal frequency), and then departs again (lower frequency). 13 | * Making use of the Doppler effect, you can measure the speed of a target with Radar, Lidar and Sonar. 14 | * "The difference between weather and climate is a measure of time. Weather is what conditions of the atmosphere are over a short period of time, and climate is how the atmosphere 'behaves' over relatively long periods of time. [...] Some scientists define climate as the average weather for a particular region and time period, usually taken over 30 years." (NASA) 15 | -------------------------------------------------------------------------------- /Social media.md: -------------------------------------------------------------------------------- 1 | # Social Media 2 | 3 | * Apart from SixDegrees.com, which lasted from 1997 to 2001 only, Friendster, which was founded in 2002, is considered one of the original social networks. It was copied by MySpace (2003) due to the high user engagement and great potential for ad sales. MySpace, then again, while acquired for $580m by News Corporation in 2005, was overtaken by and ultimately lost to Facebook (2004) around 2009. 4 | 5 | ## Twitter 6 | 7 | ### Downloading photos and videos 8 | 9 | ```javascript 10 | // Browser bookmarklet (minified): 11 | 12 | javascript:!function(){var e=document.querySelector("meta[property='og:video:url']");null===e&&(e=document.querySelector("meta[property='og:image']"));var t=e.content,o=document.querySelector("meta[property='og:url']").content.split("/").pop(),r=document.querySelector("meta[property='og:title']").content.replace(" on Twitter",""),n=document.createElement("a");n.href=t,n.download=r+"("+o+").jpg",n.innerHTML="",n.style.display="none",document.body.appendChild(n),n.click()}(); 13 | 14 | // or 15 | 16 | // Original JavaScript function: 17 | 18 | (function () { 19 | var metaElement = document.querySelector("meta[property='og:video:url']"); 20 | 21 | if (metaElement === null) { 22 | metaElement = document.querySelector("meta[property='og:image']"); 23 | } 24 | 25 | var url = metaElement.content; 26 | var id = document.querySelector("meta[property='og:url']").content.split("/").pop(); 27 | var title = document.querySelector("meta[property='og:title']").content.replace(" on Twitter", ""); 28 | 29 | var downloadLink = document.createElement("a"); 30 | downloadLink.href = url; 31 | downloadLink.download = title + "(" + id + ").jpg"; 32 | downloadLink.innerHTML = ""; 33 | downloadLink.style.display = "none"; 34 | 35 | document.body.appendChild(downloadLink); 36 | 37 | downloadLink.click(); 38 | })(); 39 | ``` 40 | 41 | ## Instagram 42 | 43 | ### Downloading photos and videos 44 | 45 | ```javascript 46 | // Browser bookmarklet (minified): 47 | 48 | javascript:!function(){var e=Object.values(window.__additionalData)[0].data.graphql.shortcode_media,d=e.video_url||e.display_url,a=e.id,n=e.owner.username,o=e.owner.id,i=document.createElement("a");i.href=d,i.download=n+"_-_"+o+"_-_"+a+".jpg",i.innerHTML="",i.style.display="none",document.body.appendChild(i),i.click()}(); 49 | 50 | // or 51 | 52 | // Original JavaScript function: 53 | 54 | (function () { 55 | var data = Object.values(window.__additionalData)[0].data.graphql.shortcode_media; 56 | var mediaUrl = data.video_url || data.display_url; 57 | var mediaId = data.id; 58 | var ownerName = data.owner.username; 59 | var ownerId = data.owner.id; 60 | 61 | var downloadLink = document.createElement("a"); 62 | downloadLink.href = mediaUrl; 63 | downloadLink.download = ownerName + "_-_" + ownerId + "_-_" + mediaId + ".jpg"; 64 | downloadLink.innerHTML = ""; 65 | downloadLink.style.display = "none"; 66 | 67 | document.body.appendChild(downloadLink); 68 | 69 | downloadLink.click(); 70 | })(); 71 | ``` 72 | -------------------------------------------------------------------------------- /Software.md: -------------------------------------------------------------------------------- 1 | # Software 2 | 3 | * If you need easy-to-use software for video editing, you might find [VLMC](https://www.videolan.org/vlmc/) useful. It can open and export almost any appropriate file format. 4 | * If you need software for 3D modeling, animated films, visual effects or video editing, you may want to use the free and open-source [Blender](https://www.blender.org/). 5 | -------------------------------------------------------------------------------- /Startups.md: -------------------------------------------------------------------------------- 1 | # Startups 2 | 3 | ## Pivots 4 | 5 | ### Flickr 6 | 7 | *Flickr* started in 2002 as the “web-based massively multiplayer online game” [*The Game Neverending*](https://web.archive.org/web/20021017070327/http://www.gameneverending.com:80/) by Stewart Butterfield’s company [*Ludicorp*](https://web.archive.org/web/20021003074542/http://www.ludicorp.com/about/default.asp). In 2004, “a Flash application that was mainly just a chat environment with real-time photo sharing” ([Eric Costello](https://web.archive.org/web/20160610133433/http://adaptivepath.org/ideas/e000519/)) was being [spun out](https://web.archive.org/web/20040328021212/http://flickr.com:80/) as “a stripped-down *Game Neverending* interface, with photos instead of game objects” ([Costello](https://web.archive.org/web/20160610133433/http://adaptivepath.org/ideas/e000519/)). You could “open a Flash-based chat window in your browser[,] upload images from your PC and drag them into a chat room for all to see” ([Dan Tynan](https://www.pcworld.com/article/116576/article.html)). By 2005, it had become a “[w]eb app for photo sharing we now call *Flickr*” ([Costello](https://web.archive.org/web/20160610133433/http://adaptivepath.org/ideas/e000519/)), allowing for asynchronous [photo management and sharing](https://web.archive.org/web/20040627020530/http://www.flickr.com:80/). 8 | 9 | ### Instagram 10 | 11 | Instagram started as the “location-based iPhone app […] Burbn [that] let users check in at particular locations, make plans for future check-ins, earn points for hanging out with friends, and post pictures of the meet-ups” ([Megan Garber](https://www.theatlantic.com/technology/archive/2014/07/instagram-used-to-be-called-brbn/373815/)) – but soon [focused](https://web.archive.org/web/20101012055741/http://www.instagr.am/) on photo sharing. 12 | 13 | ### Slack 14 | 15 | *Slack* started in 2011 as [*Glitch*](https://web.archive.org/web/20100213054636/http://glitch.com:80/), “a puzzle-heavy, [w]eb-based social MMO” ([Daniel Terdiman](https://web.archive.org/web/20111008054850/http://news.cnet.com/8301-13772_3-10449721-52.html)) by Stewart Butterfield’s company [*Tiny Speck*](https://web.archive.org/web/20100212104855/http://tinyspeck.com:80/), which had been founded in 2009. By 2013, what had started as “a communication tool [the] team had developed for internal use, a chat-based tool for [the] remote team” ([Reid Hoffman](https://mastersofscale.com/stewart-butterfield-the-big-pivot/)) during the development of *Glitch*, had turned into [*Slack*](https://web.archive.org/web/20130730004000/https://slack.com/go/infinite-brain), a searchable team communication and knowledge management tool. 16 | 17 | ### WhatsApp 18 | 19 | WhatsApp [started](https://web.archive.org/web/20090914114259/http://www.whatsapp.com/) as a way to broadcast tiny pieces of text to your friends as status updates. “Jan [Koum] was showing me his address book. His thinking was it would be really cool to have statuses next to individual names of the people.” ([Alex Fishman](https://www.forbes.com/sites/parmyolson/2014/02/19/exclusive-inside-story-how-jan-koum-built-whatsapp-into-facebooks-new-19-billion-baby)) “The statuses would show if you were on a call, your battery was low, or you were at the gym.” ([Parmy Olson](https://www.forbes.com/sites/parmyolson/2014/02/19/exclusive-inside-story-how-jan-koum-built-whatsapp-into-facebooks-new-19-billion-baby)) 20 | 21 | ### YouTube 22 | 23 | YouTube [started](https://web.archive.org/web/20050428014715/http://www.youtube.com/) as an online dating site. “We always thought there was something with video there, but what would be the actual practical application? We thought dating would be the obvious choice.” ([Steve Chen](https://www.cnet.com/news/youtube-started-as-an-online-dating-site/)) “The idea was for single people to make videos introducing themselves and saying what they were looking for.” ([Richard Nieva](https://www.cnet.com/news/youtube-started-as-an-online-dating-site/)) 24 | 25 | ### Groupon 26 | 27 | Groupon [started](https://web.archive.org/web/20081120190241/http://www.thepoint.com/) as “an online activism platform called The Point”. Having “worked on it a year”, they instead tried “a coupon for pizza at a pizzeria located in their building lobby”, “loaded up coupons and hand-emailed them to people” ([Adam L. Penenberg](https://www.fastcompany.com/1778706/eric-ries-lean-startup-machine)), which [became](https://web.archive.org/web/20090706213736/http://groupon.thepoint.com/) [Groupon](https://web.archive.org/web/20101126025438/http://www.groupon.com/boston/). 28 | 29 | ### Android 30 | 31 | Working on “a camera platform with a cloud portion for storing photos online” ([Jay Alabaster](https://www.pcworld.com/article/2034723/android-founder-we-aimed-to-make-a-camera-os.html)) and pitching to investors [in 2004](https://www.pcworld.com/article/2034723/android-founder-we-aimed-to-make-a-camera-os.html), *Android*, started by [Andy Rubin](https://web.archive.org/web/20060103183730/http://www.android.com:80/), was [acquired](https://www.pcworld.com/article/2034723/android-founder-we-aimed-to-make-a-camera-os.html) by *Google* in 2005. Due to declining growth, the team “decided digital cameras wasn’t actually a big enough market” ([Andy Rubin](https://www.pcworld.com/article/2034723/android-founder-we-aimed-to-make-a-camera-os.html)). Focusing on the market for mobile handsets instead, and considering “its product to be a platform for selling other services and products, the company aimed for growth, not per-unit income” ([Jay Alabaster](https://www.pcworld.com/article/2034723/android-founder-we-aimed-to-make-a-camera-os.html)), ultimately [releasing](https://web.archive.org/web/20071107073026/http://www.openhandsetalliance.com/android_overview.html) *Android* as part of the [*Open Handset Alliance*](https://web.archive.org/web/20071107080329/http://www.openhandsetalliance.com:80/) in 2007. 32 | 33 | ### Twitter 34 | 35 | Twitter [started](https://web.archive.org/web/20060930214639/http://www.twitter.com/) as a way to use text messages (SMS) to communicate not just with individuals but with a small group of people. It was used mostly for short status updates. The service was [spun off](https://web.archive.org/web/20060802094251/http://www.twttr.com/) from Odeo, a podcasting company. “There was this path of discovery with something like that, where over time you figure out what it is. Twitter actually changed from what we thought it was in the beginning, which we described as status updates and a social utility.” ([Evan Williams](https://www.inc.com/issie-lapowsky/ev-williams-twitter-early-years.html)) 36 | 37 | ### Shopify 38 | 39 | [Started](https://web.archive.org/web/20060117061426/http://shopify.com:80/) by [*Jaded Pixel*](https://web.archive.org/web/20051001063225/http://jadedpixel.com:80/) in 2005 and [launched](https://web.archive.org/web/20060701014531/http://shopify.com:80/) to the [public](https://web.archive.org/web/20060618024147/http://www.snowdevil.ca:80/) in [2006](https://www.theglobeandmail.com/report-on-business/rob-magazine/meet-our-ceo-of-the-year/article21734931/), *Shopify* originally began as [*Snowdevil*](https://web.archive.org/web/20050203192352/http://www.snowdevil.ca:80/), “an online store to sell some high-end snowboards from small snowboard companies” ([Trevor Cole](https://www.theglobeandmail.com/report-on-business/rob-magazine/meet-our-ceo-of-the-year/article21734931/)), in late [2004](https://signalvnoise.com/posts/2378-profitable-proud-shopify). 40 | 41 | ### Facebook 42 | 43 | Facebook [started](https://web.archive.org/web/20040212031928/http://www.thefacebook.com/) as an online directory of people with their names and photos, an online version of the traditional [face books](https://en.wikipedia.org/wiki/Face_book), for students at Harvard University. 44 | -------------------------------------------------------------------------------- /Taxes in Germany.md: -------------------------------------------------------------------------------- 1 | # Taxes in Germany 2 | 3 | * For all your income above 8,354 EUR per year, you have to pay Einkommenssteuer, which is between 14% and 45% and always paid yearly. 4 | * If you work as a freelancer, you have to pay Gewerbesteuer in addition to your personal Einkommenssteuer, unless you are a Freiberufler. 5 | * Gewerbesteuer must be paid for a Gewerbe's income above 24,500 EUR per year and is 3.5% multiplied by the Gemeinde's Hebesatz (e.g. 400%). 6 | * The share capital for an Unternehmergesellschaft (UG), required by law, is 1 EUR. 7 | * The share capital for a Gesellschaft mit beschränkter Haftung (GmbH), required by law, is 25,000 EUR. 8 | * The share capital for an Aktiengesellschaft (AG), required by law, is 50,000 EUR. 9 | -------------------------------------------------------------------------------- /Travel.md: -------------------------------------------------------------------------------- 1 | # Travel 2 | 3 | * The best place to see the Hollywood sign is near Lake Hollywood Park, i.e. 3204 Canyon Lake Drive, Los Angeles, CA 90068. You can even get to the place above the sign with a great view. It's a three hour round-trip hike from Bronson Canyon where there's plenty of parking. (Alissa Walker) 4 | -------------------------------------------------------------------------------- /Ubuntu Desktop.md: -------------------------------------------------------------------------------- 1 | # Ubuntu Desktop 2 | 3 | ## Security 4 | 5 | ### General 6 | 7 | * Always have some up-to-date backup of your data. If possible, it should be encrypted. Apart from that, consider storing it off-site. 8 | * Use a password manager to store all your passphrases digitally in encrypted form. 9 | * Rather than choosing easily remembered but weak passphrases, consider writing down your passphrases on paper and storing them in a safe place. 10 | * Whenever leaving your device (for a longer time), either shut it down or at least hibernate it. Never just suspend it or leave it running. 11 | 12 | ### Hardware 13 | 14 | * Use hardware that supports UEFI and Secure Boot. 15 | * Buy a computer that comes with a TPM chip, if possible. 16 | * Get a device without FireWire, PCMCIA, PC Card, ExpressCard or Thunderbolt. 17 | 18 | ### Boot 19 | 20 | * Enable UEFI boot mode as opposed to legacy BIOS mode. 21 | * Enable Secure Boot in your UEFI settings if you can go without unsigned third-party drivers. 22 | * Set up an administrator passphrase that is required in order to enter the UEFI configuration. 23 | * Possibly, set up a user passphrase in UEFI as well, which is required to boot the device. 24 | * Disable booting from floppy, CD-ROM or network in your UEFI settings. Whenever you need one of these devices, e.g. to install the operating system, enable it temporarily. 25 | 26 | ### Operating system 27 | 28 | * Only use distributions that still get *regular* and *timely* security updates from the vendor. 29 | * Get a distribution that comes with SELinux, AppArmor, etc. 30 | * Make sure your distribution has native support for full disk encryption. 31 | * Only use a distribution that has support for UEFI and Secure Boot. Ideally, you shouldn't have to import keys for Secure Boot yourself. 32 | * Set up software-based full disk encryption during setup of your operating system, e.g. using LUKS. Make sure to choose a strong passphrase. 33 | * If you have a larger budget, consider getting a drive with hardware-based full disk encryption. 34 | * Choose a strong passphrase for the `root` user, if asked for this. In most cases, it may be the same as your password for full disk encryption. 35 | * Set up an unprivileged account as your primary account for daily usage. Set up a strong passphrase for this account. This account should, however, be part of the administrator group so that you may elevate privileges using `sudo` at any time. 36 | * Enable automatic security updates after installation. 37 | * Make sure that the `sshd` daemon is disabled by default after installation: 38 | 39 | ```bash 40 | $ sudo systemctl disable sshd.service 41 | $ sudo systemctl stop sshd.service 42 | ``` 43 | 44 | * Make sure that the `ufw` firewall is installed: 45 | 46 | ```bash 47 | $ sudo apt-get update 48 | $ sudo apt-get install ufw 49 | ``` 50 | 51 | * Enable the `ufw` firewall and block all incoming connections by default: 52 | 53 | ```bash 54 | $ sudo ufw enable 55 | $ sudo ufw status verbose 56 | ``` 57 | 58 | ## Usage 59 | 60 | ### Creating shortcuts 61 | 62 | * Press `Ctrl` and `Shift`, drag the file or folder to its target location and drop it to create a new shortcut at that target location. 63 | 64 | ### Opening SSH tunnels to a remote server 65 | 66 | ```bash 67 | $ ssh -p <SSH_PORT> -L <LOCAL_SOURCE_PORT>:localhost:<REMOTE_TARGET_PORT> user@server 68 | # Example: ssh -p 22 -L 3306:localhost:3306 john@127.0.0.1 69 | ``` 70 | 71 | ### Adding exFAT support to the system 72 | 73 | ```bash 74 | $ sudo apt-get update 75 | $ sudo apt-get install exfat-utils exfat-fuse 76 | ``` 77 | 78 | ### Adding 7z support to the system 79 | 80 | ```bash 81 | $ sudo apt-get update 82 | $ sudo apt-get install p7zip-full 83 | ``` 84 | 85 | ### Finding duplicate files 86 | 87 | ```bash 88 | $ sudo apt-get update 89 | $ sudo apt-get install fdupes 90 | $ man fdupes 91 | ``` 92 | 93 | ### Backups 94 | 95 | #### Using archives 96 | 97 | ##### Discarding file ownership and permissions 98 | 99 | ```bash 100 | # Create backup of <DIRECTORY> in <ARCHIVE>.tar.gz 101 | $ sudo tar --create --gzip --no-same-owner --no-same-permissions --file <ARCHIVE>.tar.gz <DIRECTORY> 102 | 103 | # Restore backup from <ARCHIVE>.tar.gz into <DIRECTORY> 104 | $ mkdir <DIRECTORY> 105 | $ tar --extract --gzip --no-same-owner --no-same-permissions --file <ARCHIVE>.tar.gz -C <DIRECTORY> --strip-components=1 106 | ``` 107 | 108 | ##### Preserving file ownership and permissions 109 | 110 | ```bash 111 | # Create backup of <DIRECTORY> in <ARCHIVE>.tar.gz 112 | $ sudo tar --create --gzip --same-owner --same-permissions --file <ARCHIVE>.tar.gz <DIRECTORY> 113 | 114 | # Restore backup from <ARCHIVE>.tar.gz into <DIRECTORY> 115 | $ mkdir <DIRECTORY> 116 | $ sudo tar --extract --gzip --same-owner --same-permissions --file <ARCHIVE>.tar.gz -C <DIRECTORY> --strip-components=1 117 | ``` 118 | 119 | ### Disabling saving of Bash history to file system 120 | 121 | Open `.bashrc` in your home folder (`~`) and change the value for `HISTFILESIZE` to `0`. 122 | 123 | ### Uninstalling bundled or pre-installed applications (“bloatware”) 124 | 125 | ```bash 126 | # Email, RSS and newsgroup client with integrated spam filter 127 | sudo apt-get purge thunderbird && sudo apt-get autoremove 128 | 129 | # Music player and organizer 130 | sudo apt-get purge rhythmbox && sudo apt-get autoremove 131 | 132 | # Tool to take pictures and videos from your webcam 133 | sudo apt-get purge cheese && sudo apt-get autoremove 134 | 135 | # Mahjongg (classic Eastern tile game) 136 | sudo apt-get purge gnome-mahjongg && sudo apt-get autoremove 137 | 138 | # Minesweeper (popular puzzle game) 139 | sudo apt-get purge gnome-mines && sudo apt-get autoremove 140 | 141 | # Sudoku (popular puzzle game) 142 | sudo apt-get purge gnome-sudoku && sudo apt-get autoremove 143 | 144 | # Control Center account plugin for single sign-on with Facebook 145 | sudo apt-get purge account-plugin-facebook && sudo apt-get autoremove 146 | 147 | # Control Center account plugin for single sign-on with Flickr 148 | sudo apt-get purge account-plugin-flickr && sudo apt-get autoremove 149 | 150 | # Control Center account plugin for single sign-on with Google 151 | sudo apt-get purge account-plugin-google && sudo apt-get autoremove 152 | 153 | # Control Center extension for single sign-on 154 | sudo apt-get purge unity-control-center-signon && sudo apt-get autoremove 155 | ``` 156 | 157 | ### Mounting TrueCrypt volumes 158 | 159 | 1. Run the following command to open the encrypted TrueCrypt partition or container: 160 | 161 | ```bash 162 | $ sudo cryptsetup open --type tcrypt <DRIVE_PATH> <CUSTOM_UNIQUE_NAME> 163 | # Example: sudo cryptsetup open --type tcrypt /dev/sdb1 my-truecrypt-drive 164 | ``` 165 | 166 | 1. Enter your `sudo` password if asked for this 167 | 168 | 1. Enter the passphrase for the TrueCrypt volume 169 | 170 | 1. Ubuntu will automatically mount the new volume 171 | 172 | 1. Work with the volume ... 173 | 174 | 1. If you're done, unmount the volume again using Ubuntu's GUI 175 | 176 | 1. Finally close the encrypted TrueCrypt partition or container again: 177 | 178 | ```bash 179 | $ sudo cryptsetup close <CUSTOM_UNIQUE_NAME> 180 | # Example: sudo cryptsetup close my-truecrypt-drive 181 | ``` 182 | 183 | ### Using optical character recognition (OCR) to convert images to searchable PDF documents 184 | 185 | ```bash 186 | $ sudo apt-get install tesseract-ocr tesseract-ocr-eng 187 | # and (for other languages, e.g. French) 188 | $ sudo apt-get install tesseract-ocr-fra 189 | 190 | # Single image: image.png to image.pdf 191 | $ tesseract image.png image -l eng+fra pdf 192 | 193 | # Multiple images: *.png to images.pdf 194 | $ ls *.png | tesseract - images -l eng+fra pdf 195 | ``` 196 | 197 | ### Resizing a batch of images to the same size 198 | 199 | ```bash 200 | # WIDTH=1920 201 | # HEIGHT=1080 202 | # BACKGROUND=white 203 | $ mogrify -auto-orient -resize "${WIDTH}x${HEIGHT}" -gravity center -background "${BACKGROUND}" -extent "${WIDTH}x${HEIGHT}" *.jpg 204 | ``` 205 | 206 | ### Combining images to a slideshow 207 | 208 | ```bash 209 | # SECONDS_PER_IMAGE=10 210 | # INPUT_FILES=*.jpg 211 | # OUTPUT_FPS=25 212 | # OUTPUT_FILENAME=output.mp4 213 | $ ffmpeg -framerate "1/${SECONDS_PER_IMAGE}" -pattern_type glob -i "${INPUT_FILES}" -r "${OUTPUT_FPS}" -c:v libx264 -pix_fmt yuv420p "${OUTPUT_FILENAME}" 214 | ``` 215 | 216 | ### Downloading audio content from YouTube as an MP3 file 217 | 218 | ```bash 219 | $ youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 <VIDEO_URL> 220 | ``` 221 | 222 | ### Creating copies of multiple files while adding a new suffix to each filename 223 | 224 | ```bash 225 | $ sed -i<SUFFIX_TO_ADD> '' <FILES_TO_COPY> 226 | # Example: sed -i.bak '' * 227 | ``` 228 | 229 | ### Replacing substrings in the names of multiple files 230 | 231 | ```bash 232 | $ rename 's/<OLD_SUBSTRING_ESCAPED>/<NEW_SUBSTRING>/' <FILES_TO_RENAME> 233 | # Example: rename 's/\.jpg\.bak/.original.jpg/' * 234 | ``` 235 | -------------------------------------------------------------------------------- /Ubuntu Server.md: -------------------------------------------------------------------------------- 1 | # Ubuntu Server 2 | 3 | ## Security 4 | 5 | ### Users and groups 6 | 7 | * Provided that password authentication is enabled for the `root` user, the first thing you should do is change that phrase to some new and really strong password. To do that, open the terminal and run 8 | 9 | ``` 10 | $ sudo passwd root 11 | ``` 12 | 13 | which will ask you for the new `root` password. Type or paste the new password and then press `Enter`. Repeat this for the verification. If you access the `root` account remotely via SSH only, consider using an extremely long password, e.g. with 128 or 196 characters, and storing that password in a password manager on a remote machine, e.g. your personal computer or a development machine. 14 | 15 | * If you can only log in as `root` so far, add a new user other than `root` as the next step. To do so, open the terminal and run 16 | 17 | ``` 18 | $ adduser {my-username} 19 | ``` 20 | 21 | where you replace `{my-username}` with the desired name for your account. Type or paste the desired password and confirm with `Enter`. Then repeat this for the verification. Again, if you're going to access this new account remotely via SSH only, consider using an extremely long password, e.g. with 128 or 196 characters, and storing that password in a password manager on the remote machine. 22 | 23 | When asked for additional user information, just leave the fields empty by pressing `Enter` each time. When asked whether all information is correct, type `Y` and press `Enter` to confirm. 24 | 25 | Add the new user to the `sudo` group by running 26 | 27 | ``` 28 | $ gpasswd -a {my-username} sudo 29 | ``` 30 | 31 | where you replace `{my-username}` with the new username again. 32 | 33 | From now on, you should always sign in via SSH as `{my-username}` instead of `root` and prefix commands on the terminal with `sudo` if you need more privileges. Try logging out and then signing back in with the new account now. 34 | 35 | * Allow `su` command to be used by administrators only: 36 | 37 | ``` 38 | $ sudo dpkg-statoverride --update --add root sudo 4750 /bin/su 39 | ``` 40 | 41 | ### SSH 42 | 43 | * Do you have the SSH server `sshd` installed and enabled? In that case, the SSH configuration must be adjusted for enhanced security. Open a terminal and run 44 | 45 | ``` 46 | $ sudo nano /etc/ssh/sshd_config 47 | ``` 48 | 49 | Change the port that the server will listen on for SSH connections. You may want to use a port number between `1` and `1022` as `{my-ssh-port}`, one that has [*not* been officially registered with the IANA](https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers) yet: 50 | 51 | ``` 52 | Port {my-ssh-port} 53 | ``` 54 | 55 | This does not actually improve security but prevents masses of automated scripts and bots from making login attempts on the default SSH port. Remember to specify the changed port when connecting via SSH the next time. 56 | 57 | Limit the maximum duration of unauthenticated SSH sessions, i.e. the time before the server will disconnect if no successful login has been detected. To do so, change the value for `LoginGraceTime`, which is specified in seconds: 58 | 59 | ``` 60 | LoginGraceTime 20 61 | ``` 62 | 63 | Prevent *anybody* from logging in as `root` over SSH, now that you have a separate user in the `sudo` group. For this modification, edit the value of `PermitRootLogin`: 64 | 65 | ``` 66 | PermitRootLogin no 67 | ``` 68 | 69 | Somewhere below, but *before* any line that starts with `Match`, add the following settings by inserting new lines. 70 | 71 | Restrict SSH logins to a specified set of users that have strong authentication credentials set and can be trusted: 72 | 73 | ``` 74 | AllowUsers {my-username} 75 | ``` 76 | 77 | Replace `{my-username}` with the intended username. If you want to specify more than one user, separate the single usernames with spaces. 78 | 79 | Hide the version name of the distribution from the initial SSH handshake: 80 | 81 | ``` 82 | DebianBanner no 83 | ``` 84 | 85 | This does not actually improve security but prevents some minor information leakage in this place. 86 | 87 | Limit the number of authentication attempts per connection: 88 | 89 | ``` 90 | MaxAuthTries 2 91 | ``` 92 | 93 | Reduce the permitted number of multiplexed sessions per connection: 94 | 95 | ``` 96 | MaxSessions 2 97 | ``` 98 | 99 | Finally, press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. Then restart SSH for the changes to take effect: 100 | 101 | ``` 102 | $ sudo service ssh restart 103 | ``` 104 | 105 | ### Updates 106 | 107 | * Install updates for packages: 108 | 109 | ``` 110 | $ sudo apt-get update 111 | $ sudo apt-get upgrade 112 | $ sudo apt-get dist-upgrade 113 | $ sudo apt-get autoremove 114 | ``` 115 | 116 | You should repeat this regularly. 117 | 118 | * Configure your system to install security updates automatically. You may not like this and prefer to install updates manually -- this is fine. But you have to do it often and *regularly*. Otherwise, consider automatic updates, where the advantages outweigh the disadvantages: 119 | 120 | ``` 121 | $ sudo apt-get install unattended-upgrades update-notifier-common 122 | ``` 123 | 124 | After the two packages have been installed, adjust their configuration: 125 | 126 | ``` 127 | $ sudo nano /etc/apt/apt.conf.d/10periodic 128 | ``` 129 | 130 | Make sure that the content of this file has the following lines: 131 | 132 | ``` 133 | APT::Periodic::Update-Package-Lists "1"; 134 | APT::Periodic::Download-Upgradeable-Packages "1"; 135 | APT::Periodic::AutocleanInterval "7"; 136 | APT::Periodic::Unattended-Upgrade "1"; 137 | ``` 138 | 139 | Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. 140 | 141 | There is another configuration file that needs some more options changed: 142 | 143 | ``` 144 | $ sudo nano /etc/apt/apt.conf.d/50unattended-upgrades 145 | ``` 146 | 147 | In the 148 | 149 | ``` 150 | Unattended-Upgrade::Allowed-Origins { 151 | ``` 152 | 153 | section, make sure that only 154 | 155 | ``` 156 | "${distro_id}:${distro_codename}-security"; 157 | ``` 158 | 159 | is listed and uncommented. 160 | 161 | Next, uncomment the following line: 162 | 163 | ``` 164 | Unattended-Upgrade::MinimalSteps "true"; 165 | ``` 166 | 167 | Further down, uncomment the line saying 168 | 169 | ``` 170 | Unattended-Upgrade::Remove-Unused-Dependencies "false"; 171 | ``` 172 | 173 | and change its value to `true` so that it looks like this: 174 | 175 | ``` 176 | Unattended-Upgrade::Remove-Unused-Dependencies "true"; 177 | ``` 178 | 179 | Likewise, uncomment the line saying 180 | 181 | `Unattended-Upgrade::Automatic-Reboot "false";` 182 | 183 | and change its value to `true`. That line should then look like this: 184 | 185 | ``` 186 | Unattended-Upgrade::Automatic-Reboot "true"; 187 | ``` 188 | 189 | As a last step, uncomment the line saying 190 | 191 | ``` 192 | Unattended-Upgrade::Automatic-Reboot-Time "02:00"; 193 | ``` 194 | 195 | and leave its value unchanged, unless you want to change the reboot time from that reasonable default to something else. 196 | 197 | Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. 198 | 199 | ### IPv6 200 | 201 | * Disable IPv6 support unless you need it *and* have firewall rules set up for it: 202 | 203 | ``` 204 | $ sudo nano /etc/sysctl.conf 205 | ``` 206 | 207 | At the very end, insert the following three lines: 208 | 209 | ``` 210 | net.ipv6.conf.all.disable_ipv6 = 1 211 | net.ipv6.conf.default.disable_ipv6 = 1 212 | net.ipv6.conf.lo.disable_ipv6 = 1 213 | ``` 214 | 215 | Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. 216 | 217 | Now reload all settings from `sysctl.conf` by running 218 | 219 | ``` 220 | $ sudo sysctl -p 221 | ``` 222 | 223 | and then verify that IPv6 has successfully been disabled by running 224 | 225 | ``` 226 | $ cat /proc/sys/net/ipv6/conf/all/disable_ipv6 227 | ``` 228 | 229 | which should return `1`. 230 | 231 | ### Firewall 232 | 233 | * Install UFW in case it's not already installed: 234 | 235 | ``` 236 | $ sudo apt-get install ufw 237 | ``` 238 | 239 | * Accept incoming SSH connections and throttle those connections: 240 | 241 | ``` 242 | $ sudo ufw allow {my-ssh-port}/tcp 243 | $ sudo ufw limit {my-ssh-port}/tcp 244 | ``` 245 | 246 | Remember to replace `{my-ssh-port}` with your port number from the SSH configuration. 247 | 248 | * If you want to run a public web server, accept HTTP and HTTPS traffic as well: 249 | 250 | ``` 251 | $ sudo ufw allow 80/tcp 252 | $ sudo ufw allow 443/tcp 253 | ``` 254 | 255 | * Finally, activate the firewall: 256 | 257 | ``` 258 | $ sudo ufw enable 259 | ``` 260 | 261 | ## Installation 262 | 263 | * Set a proper timezone: 264 | 265 | ``` 266 | $ sudo dpkg-reconfigure tzdata 267 | ``` 268 | 269 | Select your region and city with the arrow keys and continue by pressing `Enter` each time. 270 | 271 | ## Updates 272 | 273 | * In order to update packages, run 274 | 275 | ``` 276 | $ sudo apt-get update 277 | $ sudo apt-get upgrade 278 | ``` 279 | 280 | and review the list of packages that will be updated. If everything is fine, confirm by entering `Y` and pressing `Enter`. 281 | 282 | * If after running 283 | 284 | ``` 285 | $ sudo apt-get upgrade 286 | ``` 287 | 288 | you see the message 289 | 290 | ``` 291 | The following packages have been kept back: 292 | package1 293 | package2 294 | ... 295 | ``` 296 | 297 | just run 298 | 299 | ``` 300 | sudo apt-get install package1 package2 ... 301 | ``` 302 | 303 | as well, afterwards. This updates the packages that need some dependencies added or removed. 304 | 305 | ## Cron jobs 306 | 307 | * Ensure that `cron` is installed and enabled: 308 | 309 | ``` 310 | $ sudo apt-get update 311 | $ sudo apt-get install cron 312 | ``` 313 | 314 | * Add a new cron job using 315 | 316 | ``` 317 | $ sudo crontab -e 318 | ``` 319 | 320 | for an entry in the `root` user's crontab or 321 | 322 | ``` 323 | $ crontab -e 324 | ``` 325 | 326 | for an entry in your own crontab. 327 | 328 | Choose `nano` or any other editor you prefer if you are asked. Then add a new line at the end of the file, preserving the trailing newline. Specify both the time schedule and the command to run. 329 | 330 | An entry like `* * * * * my-command` would run `my-command` *every minute*. Replacing the asterisks with single numbers (or comma-separated numbers or ranges) restricts the schedule to certain minutes, hours, days, months or days of the week, in that order. You can redirect or append the command's output to a file using `>` or `>>` at the end, or ignore it using ` > /dev/null 2>&1`. 331 | 332 | Press `Ctrl+X`, then type `Y` and press `Enter` to save and leave. This will write to a temporary file and the tool will update the crontab automatically. 333 | 334 | * Check if your new cron job has been added successfully by running 335 | 336 | ``` 337 | $ sudo crontab -l 338 | ``` 339 | 340 | or 341 | 342 | ``` 343 | $ crontab -l 344 | ``` 345 | 346 | ## SSH 347 | 348 | ### Viewing key fingerprints for verification 349 | 350 | ``` 351 | # For RSA 352 | $ sudo ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_rsa_key.pub 353 | # or 354 | $ sudo ssh-keygen -l -E sha256 -f /etc/ssh/ssh_host_rsa_key.pub 355 | 356 | # For ECDSA 357 | $ sudo ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_ecdsa_key.pub 358 | # or 359 | $ sudo ssh-keygen -l -E sha256 -f /etc/ssh/ssh_host_ecdsa_key.pub 360 | 361 | # For EdDSA (Ed25519) 362 | $ sudo ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_ed25519_key.pub 363 | # or 364 | $ sudo ssh-keygen -l -E sha256 -f /etc/ssh/ssh_host_ed25519_key.pub 365 | ``` 366 | 367 | ## Backups 368 | 369 | ### Time-based filenames 370 | 371 | The expression `$(date -u +"%Y%m%dT%H%M%SZ")` expands to the current UTC time in ISO 8601 format, safe for filenames on most operating systems, and is thus ideal for usage in filenames, as in `"Backup_$(date -u +"%Y%m%dT%H%M%SZ").tar.gz"`. 372 | -------------------------------------------------------------------------------- /Ubuntu.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 2 | 3 | ## Usage 4 | 5 | ### Decoding a QR code to text 6 | 7 | ```bash 8 | # sudo apt-get install zbar-tools 9 | zbarimg --raw <INPUT_IMAGE_FILENAME> 10 | # e.g. zbarimg --raw my-qr-code.png 11 | ``` 12 | 13 | ### Encoding a QR code from text 14 | 15 | ```bash 16 | # sudo apt-get install qrencode 17 | qrencode --size=<SIZE> --margin=<MARGIN> --foreground=<FG_RRGGBBAA> --background=<BG_RRGGBBAA> --output=<OUTPUT_IMAGE_FILENAME> <TEXT> 18 | # e.g. qrencode --size=16 --output=my-qr-code.png "my text" 19 | # e.g. cat my-file.txt | qrencode --size=12 --output=my-qr-code.png 20 | # e.g. echo -n "my text" | qrencode --output=my-qr-code.png 21 | ``` 22 | -------------------------------------------------------------------------------- /Unix.md: -------------------------------------------------------------------------------- 1 | # Unix 2 | 3 | * `fork()` is a system call that is used for process creation. The calling process first creates a copy of itself (i.e. the child process) which may be followed by a call to `exec()`. 4 | * `fork()` may fail and returns `-1` in that case. 5 | * When calling `kill()`, first check if your `pid` is valid. If you treat `-1` as a valid `pid`, you're going to kill *all* processes "for which the calling process has permission to send signals, except for process 1 (init)". 6 | 7 | ## Bash 8 | 9 | * If you see the error message `/bin/sh^M: bad interpreter`, your file has DOS line endings (CRLF) and must thus be converted to Unix line endings (LF) first. 10 | 11 | ## Detecting DNS resolver (recursive DNS server) used by local machine 12 | 13 | ```bash 14 | $ dig whoami.ds.akahelp.net TXT +short 15 | # or 16 | $ dig whoami.akamai.net A +short 17 | ``` 18 | -------------------------------------------------------------------------------- /Web development.md: -------------------------------------------------------------------------------- 1 | # Web development 2 | 3 | * Always have two versions of your CSS stylesheet files: `style.css` and `style.min.css` (minified), the latter being generated automatically. 4 | * Always have two versions of your JavaScript files: `script.js` and `script.min.js` (minified), the latter being generated automatically. 5 | * Minifiy your CSS and JavaScript files by removing unnecessary characters (white spaces, new lines etc.) without changing the functionality. 6 | * You can use the free online tool "cssminifier.com" if you want to minify your CSS stylesheets. 7 | * You can use the free online tool "jscompress.com" or the library "UglifyJS" if you want to minify your JavaScript files. 8 | * Always set the HTTP header "Cache-Control" to something like "max-age=604800" for CSS, JS and other assets to enable long-time caching. 9 | * If you make use of client-side caching of resources, you should version your file references in HTML like this: "style.css?v=123". 10 | * If you have versioned your referenced resources in HTML, you can just increase the version number to invalidate the cached file for users. 11 | * Use the free tool OptiPNG to post-process your PNG files. It does significantly shrink your file sizes and is a lossless optimization. 12 | * If you don't enable client-side caching of resources, the browser always checks for modifications, returning with status code 200 or 301. 13 | * In your server-side code, check whether the HTTP request header `Accept-Encoding` contains `gzip` or `deflate` (or the newer `br`) and return compressed resources accordingly. In most cases, your server software should do that automatically. 14 | * Try to give every part of your website, every entity, a unique and permanent URL (permalink) for sharing and search engine optimization. 15 | * Usually, you only need a single font per website. Never use more than two different fonts, unless you have an exceptional reason for that. 16 | * Don't use too small objects, graphics, texts and menus. Be generous with spacing, for reasons of visual design and ease of use. 17 | * Use common design patterns from the web wherever possible, and repeat them across your pages. Users like simplicity more than creativity. 18 | * Never make your full website that wide that the browser has to add horizontal scrollbars. When users scroll, they scroll vertically. 19 | * Use loading graphics (e.g. rotating circles) for all asynchronous requests that are started by the client to make the progress visual. 20 | * Use as little audio as possible: It is expected almost only in videos and on music sites, and you can never rely on audio to be switched on. 21 | * Make clickable things visually different from the rest of the page: Special coloring, hover effects, pointer symbol for mouse cursor. 22 | * For desktop computers, limit the maximum width of your content. Nobody likes to read texts that flow from the very left to the very right. 23 | * Don't make use of special browser plugins (Flash, Silverlight, Java, etc.) if possible. There are good alternatives in almost every case. 24 | * Always set your pages' charset, the same both in your server-side code and in your HTML markup. There are very few reasons not to use UTF-8. 25 | * Always set a favicon for your website. Users will see it in their tab lists and in their bookmarks, and will recognize your website. 26 | * If you don't have any favicon (yet), at least provide an empty icon using `<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==">`. This prevents the additional requests by each client resulting in `404 Not Found` only. 27 | * Never store any credentials or secrets in your client-side code. 28 | * Enabling SSL/TLS on your site may cut your AdSense revenue in half because Google cannot show ads from any non-HTTPS ad server. 29 | * You should check [whether Google thinks you're web pages are mobile-optimized](https://www.google.com/webmasters/tools/mobile-friendly/) because such pages receive a ranking boost in Google's search results on mobile devices. 30 | * Read [Google's guidelines for mobile-optimized websites](https://developers.google.com/webmasters/mobile-sites/mobile-seo/) to see what you can do to ensure a great mobile experience on your website. 31 | * Always add `rel="nofollow"` to links in user-generated content to make spam useless to the spammers. 32 | * You may put static content up on a separate domain (*not* a subdomain) without cookies to speed up delivery of content. 33 | * Use HTTP caching (e.g. via the `Cache-Control` header) and understand what to cache and what *not* to cache. Usually, you'll want to cache media files, CSS and JavaScript resources. This will help you improve page load times and save bandwidth. 34 | * *Never* trust user input, i.e. you must always filter, validate or escape it. 35 | * Make as few separate HTTP request as possible. 36 | * Always put CSS and JavaScript code into separate files (from the HTML) so that they can be cached. 37 | * "By 'hypertext', I mean non-sequential writing — text that branches and allows choices to the reader, best read at an interactive screen. As popularly conceived, this is a series of text chunks connected by links which offer the reader different pathways." (Ted Nelson) 38 | * "[Users] said they were more likely to believe Web sites that looked professionally designed." (The Stanford Web Credibility Project) 39 | * If you don't want to exclude any pages as per robots exclusion standard, at least include an empty `robots.txt` file to prevent recurring `404 Not Found` errors. 40 | 41 | ## HTML 42 | 43 | * Every HTML page should start with the lines 44 | 45 | ```html 46 | <!DOCTYPE html> 47 | <html lang="{pageLanguage}"> 48 | <head> 49 | <meta charset="{charset}"> 50 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> 51 | <meta name="viewport" content="width=device-width, initial-scale=1"> 52 | ``` 53 | 54 | in exactly that order, where `{pageLanguage}` is an [ISO 639](https://de.wikipedia.org/wiki/ISO_639) or [BCP47](http://www.ietf.org/rfc/bcp/bcp47.txt) code, e.g. `en` or `de`, and `{charset}` is the character encoding that the page uses, e.g. `utf-8`. 55 | 56 | ## CSS 57 | 58 | * If you want to use native fonts on Android, iOS/Mac and Windows, with reliable fallback fonts, you may try this: `font-family: "Roboto", -apple-system, "San Francisco", "Segoe UI", "Helvetica Neue", sans-serif;` 59 | 60 | ## Domains 61 | 62 | * Domain extensions (TLDs) that Google treats as *generic*, i.e. suitable for international applications that are not targeted at a specific country, are the gTLDs `.aero`, `.biz`, `.cat`, `.com`, `.coop`, `.edu`, `.gov`, `.info`, `.int`, `.jobs`, `.mil`, `.mobi`, `.museum`, `.name`, `.net`, `.org`, `.pro`, `.tel` and `.travel`, among more recent additions, and the ccTLDs `.ad`, `.as`, `.asia`, `.bz`, `.cc`, `.cd`, `.co`, `.dj`, `.eu`, `.fm`, `.io`, `.la`, `.me`, `.ms`, `.nu`, `.sc`, `.sr`, `.su`, `.tv`, `.tk` and `.ws`. 63 | 64 | ## RESTful APIs 65 | 66 | * "Objects in a typical REST system are addressable by URI and interacted with using verbs in the HTTP protocol. An HTTP GET to a particular URI fetches an object and returns a server-specified set of fields. An HTTP PUT edits an object; an HTTP DELETE deletes an object; and so on." (Nick Schrock) 67 | * Whenever you have successfully created a new resource via `POST`, send a `201 Created` response code and a `Location` header specifying where new new resource is located. 68 | * "Fetching complicated object graphs [from REST systems] require[s] multiple round trips between the client and server to render single views. For mobile applications operating in variable network conditions, these multiple roundtrips are highly undesirable." (Nick Schrock) 69 | * "REST endpoints are usually weakly-typed and lack machine-readable metadata. [...] Developer[s] deal with systems that lack this metadata by inspecting frequently out-of-date documentation and then writing code against the documentation." (Nick Schrock) 70 | 71 | ## Forms 72 | 73 | * "Literally including the phrase 'optional' after a label is much clearer than any visual symbol you could use to mean the same thing." (Luke Wroblewski) 74 | 75 | ## Protecting your email address from address harvesting bots 76 | 77 | Any [solution](http://en.wikipedia.org/wiki/Address_munging) that is used by lots of people will be [defeated](http://en.wikipedia.org/wiki/Email_address_harvesting). But it's easy to combine single techniques or to vary techniques with slightly different markup or phrases. As a last resort, you could use more rigorous techniques such as hiding addresses behind captchas, but they're (even less) accessible. Whatever you decide to do, get a decent spam filter. 78 | 79 | * Use CSS pseudo elements: 80 | 81 | ```html 82 | <style scoped style="text/css"> 83 | span.email::before { 84 | content: attr(data-local-part) "@"; 85 | } 86 | span.email::after { 87 | content: attr(data-domain-part); 88 | } 89 | </style> 90 | 91 | <span class="email" data-domain-part="example.org" data-local-part="user"></span> 92 | ``` 93 | 94 | * Change text direction via CSS: 95 | 96 | ```html 97 | <style scoped style="text/css"> 98 | span.email { 99 | unicode-bidi: bidi-override; 100 | direction: rtl; 101 | -webkit-user-select: none; 102 | -moz-user-select: none; 103 | -ms-user-select: none; 104 | user-select: none; 105 | } 106 | </style> 107 | 108 | <span class="email">gro.elpmaxe@resu</span> 109 | ``` 110 | 111 | * Use HTML entities (decimal or hex): 112 | 113 | ```html 114 | user@example.org 115 | 116 | <!-- or --> 117 | 118 | user@example.org 119 | ``` 120 | 121 | * Inject elements that are hidden via CSS: 122 | 123 | ```html 124 | <style scoped style="text/css"> 125 | span.rubbish { 126 | display: none; 127 | } 128 | </style> 129 | 130 | user<span class="rubbish">info</span>@<span class="rubbish">example</span>example<span class="rubbish">site</span>.<span class="rubbish">com</span>org 131 | ``` 132 | 133 | * Write using a joined array in JavaScript: 134 | 135 | ```html 136 | <script type="text/javascript"> 137 | document.write(['user', /* some */ '@', /* confusing */ 'example', /* words */ '.', /* here */ 'org'].join('')); 138 | </script> 139 | ``` 140 | 141 | * Write using ROT-13 in JavaScript: 142 | 143 | ```html 144 | <script type="text/javascript"> 145 | function rot13(str) { 146 | return str.replace(/[a-zA-Z]/g, function(c) { 147 | return String.fromCharCode((c <= 'Z' ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26); 148 | }); 149 | } 150 | 151 | document.write(rot13('hfre@rknzcyr.bet')); 152 | </script> 153 | ``` 154 | 155 | * Write (using concatenated strings) in JavaScript: 156 | 157 | ```html 158 | <script type="text/javascript">document.write('user' + '@' + 'example.org');</script> 159 | ``` 160 | 161 | * Disassemble with descriptive terms: 162 | 163 | ```html 164 | user [at] example [dot] org 165 | ``` 166 | 167 | * Place HTML comments in-between: 168 | 169 | ```html 170 | user<!-- some -->@<!-- 'confusing' -->example<!-- words -->.<!-- here -->org 171 | ``` 172 | 173 | * Inject phrases to be removed by the user: 174 | 175 | ```html 176 | userREMOVE_THIS@example.org 177 | ``` 178 | -------------------------------------------------------------------------------- /Windows.md: -------------------------------------------------------------------------------- 1 | # Windows 2 | 3 | * In most applications, you can copy things (files, text, images, etc.) with `Ctrl+C` and paste them somewhere else with `Ctrl+V`. 4 | * If you want to move things (files, text, images etc.) instead of copying them, use `Ctrl+X` and `Ctrl+V`. 5 | * Lots of applications allow you to undo things with `Ctrl+Z`. 6 | * The program that you view websites with is called `web browser`, or just `browser`. 7 | * Some good free web browers are Google Chrome, Mozilla Firefox and Safari. 8 | * If you want to write simple texts without formatting and design, use Windows' Editor or WordPad instead of complex Microsoft Word etc. 9 | * You can take a photo of the full screen by pressing the `Print` button (screen capture). Afterwards, paste the image (`Ctrl+V`) somewhere. 10 | * For basic graphics editing, the free Paint.NET is very good. For more complex work, try the free Gimp or commercial Adobe Photoshop. 11 | * In order to pack and unpack collections of files or archives, use the free 7-Zip. 12 | * In order to start the command prompt for a certain location quickly, just navigate to the desired folder in `Explorer`. Then press `Shift` and right-click on the background of the `Explorer` window. You should be able to launch the command prompt by clicking `Open command window here` then. 13 | * If you want to have a file name start with a dot (`.`), it works only if you add another dot at the end of the file name as well. The trailing dot will be removed automatically. 14 | * In order to create a file without a file extension (e.g. `LICENSE`), just type the desired file name and append a trailing dot. The void in the place of the file extension causes the file to be created without an extension. 15 | * If you want to use cURL from the command line, you should just get Git for Windows which includes GNU Bash. 16 | * If you don't want GNU Bash from Git for Windows to save a history of the most recent commands, this can be prevented easily: In your user directory, i.e. `%USERPROFILE%`, create (or append to) a file named `.bashrc`. Put `HISTFILESIZE=0` in a new line and save the file. 17 | * If you want Notepad++'s search (and replace) history of recent entries to be cleared (or at least trimmed) whenever you exit the program, this can be easily done in its configuration files: Open `%APPDATA%\Notepad++\config.xml` with `notepad.exe` (!). In that file, find the opening `FindHistory` tag. Among that tag's attributes, change `nbMaxFindHistoryPath` and `nbMaxFindHistoryFilter` from `10` to `1`, and `nbMaxFindHistoryFind` and `nbMaxFindHistoryReplace` from `10` to `0`. You may enter any values you like, but these are reasonable defaults for clearing the lists. 18 | 19 | ## Keyboard shortcuts 20 | 21 | * `Ctrl` + `A`: select all items in a list, select the full text in a text field, select the full image in an image editing application 22 | * `Ctrl` + `C`: copy the selected content 23 | * `Ctrl` + `V`: paste the most recently copied content 24 | * `Ctrl` + `X`: cut out (as opposed to copying) the selected content so that it will be relocated and not copied while pasting 25 | * `Print`: copy a screenshot of the full screen (may be pasted in an image editing application, for example) 26 | * `Tab`: jump to the next control or input field 27 | * `Shift` + `Tab`: jump to the previous control or input field 28 | * `Ctrl` + `Z`: reverse the latest action 29 | * `Ctrl` + `Y`: repeat (un-reverse) the latest action 30 | * `End`: jump to the end of the current line in an input field 31 | * `Pos1`: jump to the beginning of the current line in an input field 32 | * `Alt` + `Tab`: switch between windows that have been opened 33 | * `Win` + `D`: switch to the desktop 34 | * `Win` + `L`: lock the computer 35 | * `Ctrl` + `Alt` + `Del`: open the task manager (e.g. to force an application to be closed) 36 | 37 | ## PowerShell 38 | 39 | * Run `ii .` or `explorer.exe .` to open an explorer window for the current directory. 40 | 41 | ## Java 42 | 43 | * If you use the `java` command to run a program and want UTF-8 output on the console, add the option `-Dfile.encoding=UTF-8`. 44 | 45 | ## Extracting the license key from an existing Windows installation 46 | 47 | On the same computer, i.e. with the same hardware and drives present, boot from a Ubuntu live DVD. Then open a terminal window and run the following command: 48 | 49 | ```bash 50 | $ sudo cat /sys/firmware/acpi/tables/MSDM | strings 51 | ``` 52 | 53 | Alternatively, having located the Windows drive in Ubuntu’s file manager (“Other Locations”), you may try the following set of commands: 54 | 55 | ```bash 56 | # sudo add-apt-repository universe 57 | # sudo apt-get update 58 | # sudo apt-get install chntpw 59 | $ chntpw -e /path/to/drive/Windows/System32/config/SOFTWARE 60 | $ dpi \Microsoft\Windows NT\CurrentVersion\DigitalProductId 61 | ``` 62 | 63 | ## Detecting DNS resolver (recursive DNS server) used by local machine 64 | 65 | ``` 66 | nslookup -type=TXT whoami.ds.akahelp.net 67 | REM or 68 | nslookup -type=A whoami.akamai.net 69 | ``` 70 | 71 | ## Saving screenshots, screen captures or thumbnails from a video file 72 | 73 | ``` 74 | vlc.exe <VIDEO_FILENAME> --start-time=<START_TIME_SECONDS_OR_MINUS_1> --stop-time=<STOP_TIME_SECONDS_OR_MINUS_1> --rate=<PROCESSING_SPEED> --video-filter=scene --vout=dummy --aout=dummy --scene-format=<IMAGE_FORMAT> --scene-ratio=<CAPTURE_EVERY_NTH_FRAME> --scene-width=<IMAGE_WIDTH> --scene-height=<IMAGE_HEIGHT> --no-scene-replace --scene-prefix=<IMAGE_FILENAME_PREFIX> --scene-path=<IMAGE_OUTPUT_PATH> vlc://quit 75 | REM e.g.: vlc.exe "input.mp4" --start-time=-1 --stop-time=-1 --rate=1 --video-filter=scene --vout=dummy --aout=dummy --scene-format=png --scene-ratio=30 --scene-width=-1 --scene-height=-1 --no-scene-replace --scene-prefix=thumb_ --scene-path=./thumbs vlc://quit 76 | REM e.g.: vlc.exe "input.mp4" --start-time=24 --stop-time=2397 --rate=1 --video-filter=scene --vout=dummy --aout=dummy --scene-format=png --scene-ratio=300 --scene-width=1920 --scene-height=1080 --no-scene-replace --scene-prefix=thumb_ --scene-path=./thumbs vlc://quit 77 | ``` 78 | 79 | ## Wiping or overwriting unallocated (remaining free) disk space 80 | 81 | Download “SDelete” from Sysinternals [here](http://web.archive.org/web/20140902022253/http://download.sysinternals.com/files/SDelete.zip) or [here](https://docs.microsoft.com/en-us/sysinternals/downloads/sdelete). Then use it to write zeros to drive “C:” until it’s filled completely: 82 | 83 | ``` 84 | sdelete -z c: 85 | ``` 86 | 87 | ## Finding the IP addresses of all devices connected to the local network (LAN) 88 | 89 | ``` 90 | for /L %i in (1,1,254) do ping -4 -n 1 -w 1000 192.168.0.%i | findstr -l -i "bytes=32" 91 | ``` 92 | -------------------------------------------------------------------------------- /Writing.md: -------------------------------------------------------------------------------- 1 | # Writing 2 | 3 | * "Show, don't tell": This enables the reader to experience the story implicitly through actions and feelings, and not explicitly through the author's summarizations. The goal is not to drown the reader in heavy-handed adjectives, but rather to allow readers to interpret significant details themselves. 4 | * Telling may be used as a shortcut, since showing requires more words. Telling may cover a greater span of time more concisely. 5 | * "Sometimes a writer tells as a shortcut, to move quickly to the meaty part of the story or scene. Showing is essentially about making scenes vivid. If you try to do it constantly, the parts that are supposed to stand out won't, and your readers will get exhausted." (James Scott Bell) 6 | * "The warning against telling leads to a confusion that causes novice writers to think that everything should be acted out ... when in fact the responsibility of showing should be assumed by the energetic and specific use of language." (Francine Prose) 7 | --------------------------------------------------------------------------------