Awesome List Updates on Jan 27, 2015
3 awesome lists updated today.
🏠 Home · 🔍 Search · 🔥 Feed · 📮 Subscribe · ❤️ Sponsor
1. Awesome Artificial Intelligence
Courses
- Intro to Artificial Intelligence - Learn the Fundamentals of AI. Course run by Peter Norvig
- EdX Artificial Intelligence - The course will introduce the basic ideas and techniques underlying the design of intelligent computer systems
- The Emotion Machine: Commonsense Thinking, Artificial Intelligence, and the Future of the Human Mind - In this mind-expanding book, scientific pioneer Marvin Minsky continues his groundbreaking research, offering a fascinating new model for how our minds work
- Artificial Intelligence: A New Synthesis - Beginning with elementary reactive agents, Nilsson gradually increases their cognitive horsepower to illustrate the most important and lasting ideas in AI
2. Htaccess
Rewrite and Redirection
What we are doing here is mostly collecting useful snippets from all over the interwebs (for example, a good chunk is from Apache Server Configs (⭐3k)) into one place. While we’ve been trying to credit where due, things might be missing. If you believe anything here is your work and credits should be given, let us know, or just send a PR.
Note: It is assumed that you have mod_rewrite
installed and enabled.
Rewrite and Redirection / Force www
Force www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
Rewrite and Redirection / Force www in a Generic Way
Force www in a Generic Way
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
This works for any domain. Source
Rewrite and Redirection / Force non-www
Force non-www
It’s still open for debate whether www or non-www is the way to go, so if you happen to be a fan of bare domains, here you go:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Rewrite and Redirection / Force HTTPS
Force HTTPS
RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# Note: It’s also recommended to enable HTTP Strict Transport Security (HSTS)
# on your HTTPS website to help prevent man-in-the-middle attacks.
# See https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security
<IfModule mod_headers.c>
# Remove "includeSubDomains" if you don't want to enforce HSTS on all subdomains
Header always set Strict-Transport-Security "max-age=31536000;includeSubDomains"
</IfModule>
Rewrite and Redirection / Force Trailing Slash
Force Trailing Slash
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
Security / Deny All Access
Deny All Access
## Apache 2.2
Deny from all
## Apache 2.4
# Require all denied
But wait, this will lock you out from your content as well! Thus introducing...
Security / Deny All Access Except Yours
Deny All Access Except Yours
## Apache 2.2
Order deny,allow
Deny from all
Allow from xxx.xxx.xxx.xxx
## Apache 2.4
# Require all denied
# Require ip xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
is your IP. If you replace the last three digits with 0/12
for example, this will specify a range of IPs within the same network, thus saving you the trouble to list all allowed IPs separately. Source
Now of course there's a reversed version:
Security / Allow All Access Except Spammers'
Allow All Access Except Spammers'
## Apache 2.2
Order deny,allow
Deny from xxx.xxx.xxx.xxx
Deny from xxx.xxx.xxx.xxy
## Apache 2.4
# Require all granted
# Require not ip xxx.xxx.xxx.xxx
# Require not ip xxx.xxx.xxx.xxy
Security / Disable Directory Browsing
Disable Directory Browsing
Options All -Indexes
Security / Disable Image Hotlinking
Disable Image Hotlinking
RewriteEngine on
# Remove the following line if you want to block blank referrer too
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://(.+\.)?example.com [NC]
RewriteRule \.(jpe?g|png|gif|bmp)$ - [NC,F,L]
# If you want to display a “blocked” banner in place of the hotlinked image,
# replace the above rule with:
# RewriteRule \.(jpe?g|png|gif|bmp) http://example.com/blocked.png [R,L]
Security / Disable Image Hotlinking for Specific Domains
Disable Image Hotlinking for Specific Domains
Sometimes you want to disable image hotlinking from some bad guys only.
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^https?://(.+\.)?badsite\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^https?://(.+\.)?badsite2\.com [NC,OR]
RewriteRule \.(jpe?g|png|gif|bmp)$ - [NC,F,L]
# If you want to display a “blocked” banner in place of the hotlinked image,
# replace the above rule with:
# RewriteRule \.(jpe?g|png|gif|bmp) http://example.com/blocked.png [R,L]
Security / Password Protect a Directory
Password Protect a Directory
First you need to create a .htpasswd
file somewhere in the system:
htpasswd -c /home/fellowship/.htpasswd boromir
Then you can use it for authentication:
AuthType Basic
AuthName "One does not simply"
AuthUserFile /home/fellowship/.htpasswd
Require valid-user
Security / Password Protect a File or Several Files
Password Protect a File or Several Files
AuthName "One still does not simply"
AuthType Basic
AuthUserFile /home/fellowship/.htpasswd
<Files "one-ring.o">
Require valid-user
</Files>
<FilesMatch ^((one|two|three)-rings?\.o)$>
Require valid-user
</FilesMatch>
Miscellaneous / Turn eTags Off
Turn eTags Off
By removing the ETag
header, you disable caches and browsers from being able to validate files, so they are forced to rely on your Cache-Control
and Expires
header. Source
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None
Miscellaneous / Set PHP Variables
Set PHP Variables
php_value <key> <val>
# For example:
php_value upload_max_filesize 50M
php_value max_execution_time 240
Miscellaneous / Custom Error Pages
Custom Error Pages
ErrorDocument 500 "Houston, we have a problem."
ErrorDocument 401 http://error.example.com/mordor.html
ErrorDocument 404 /errors/halflife3.html
3. Awesome Perl
List Manipulation / NoSQL Databases
- Array::Unique - Tie-able array that allows only unique values
- List::Compare - Compare elements of two or more lists
- List::Gen - Provides functions for generating lists
- List::Util - A selection of general-utility list subroutines
- Prev: Jan 28, 2015
- Next: Jan 26, 2015