This is a guide for aligning images.
See the full Advanced Markdown doc for more tips and tricks
| ziping files/directories examples | |
| Creates the archive data.zip and puts all the files in the current directory in it in compressed form, type: | |
| $ zip data * | |
| Note: No need to add .zip extension or suffix as it is added automatically by zip command. | |
| Use the ls command to verify new zip file: | |
| $ ls |
| # UPDATED 17 February 2019 | |
| # Redirect all HTTP traffic to HTTPS | |
| server { | |
| listen 80; | |
| listen [::]:80; | |
| server_name www.domain.com domain.com; | |
| return 301 https://$host$request_uri; | |
| } | |
| # SSL configuration |
This is a guide for aligning images.
See the full Advanced Markdown doc for more tips and tricks
The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).
If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.
But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:
from
| ### 1: Drop invalid packets ### | |
| /sbin/iptables -t mangle -A PREROUTING -m conntrack --ctstate INVALID -j DROP | |
| ### 2: Drop TCP packets that are new and are not SYN ### | |
| /sbin/iptables -t mangle -A PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP | |
| ### 3: Drop SYN packets with suspicious MSS value ### | |
| /sbin/iptables -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP | |
| ### 4: Block packets with bogus TCP flags ### |
I recently came across the need to spawn multiple threads, each of which needs to write to the same file. Since the file will experience contention from multiple resources, we need to guarantee thread-safety.
NOTE: The following examples work with Python 3.x. To execute the following programs using Python 2.7, please replace threading.get_ident() with thread.get_ident(). As a result, you would need to import thread and not threading.
# threading_lock.py
import threading| #!/bin/env python | |
| # Requires: youtube_dl module | |
| # Requires: ffmpeg | |
| # Usage: | |
| # | |
| # python youtube2mp3.py <URL>, ... | |
| # | |
| # Example: | |
| # | |
| # python youtube2mp3.py https://www.youtube.com/watch?v=dQw4w9WgXcQ |
| # -*- encoding=utf-8 -*- | |
| __all__ = ['HOTP'] | |
| import hashlib | |
| import hmac | |
| import unittest | |
| class HOTP(object): |
| """ | |
| Django ORM Optimization Tips | |
| Caveats: | |
| * Only use optimizations that obfuscate the code if you need to. | |
| * Not all of these tips are hard and fast rules. | |
| * Use your judgement to determine what improvements are appropriate for your code. | |
| """ | |
| # --------------------------------------------------------------------------- |