package main
import("fmt"; "math")
func Sqrt(x float64) (z float64) {
z, delta := 1.0, 1.0
for delta > 1e-4 {
z0 := z
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Sqrt(x float64) float64 { | |
z := 1.0 | |
for i := 1; i <= 100; i++ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BIND_NETWORK="192.168.5.0" | |
SHARED_VIP="192.168.5.30" | |
apt-get update | |
apt-get install -y pacemaker ntp | |
# Configure Corosync | |
echo "START=yes" > /etc/default/corosync | |
sed -i "s/bindnetaddr: 127.0.0.1/bindnetaddr: $BIND_NETWORK/g" /etc/corosync/corosync.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This will be fixed by | |
find /var/www -type d -exec chmod 755 {} \; | |
find /var/www -type f -exec chmod 644 {} \; |
TL;DR
Create a backup:
pg_dumpall > mybackup.sql
Perform the upgrade:
sudo pg_dropcluster 9.4 main --stop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT name, current_setting(name), source, sourcefile, sourceline FROM pg_settings WHERE (source <> 'default' OR name = 'server_version') AND name NOT IN ('config_file', 'data_directory', 'hba_file', 'ident_file'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Order by one indexed column (FAST) | |
newsdesk_production=# explain analyze select * from pressreleases order by published_at DESC limit 100; | |
QUERY PLAN | |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
Limit (cost=0.00..249.91 rows=100 width=1207) (actual time=26.070..716.453 rows=100 loops=1) | |
-> Index Scan Backward using pressreleases_published_at_index on pressreleases (cost=0.00..964766.62 rows=386042 width=1207) (actual time=26.067..716.343 rows=100 loops=1) | |
Total runtime: 716.709 ms | |
(3 rows) | |
- Order by two separately indexed columns (SLOW) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y | |
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'" | |
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'" | |
sudo su - postgres -c "service postgresql stop" | |
sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://wiki.postgresql.org/wiki/Using_pg_upgrade_on_Ubuntu/Debian for more information and warning! | |
# Check first | |
/usr/lib/postgresql/11/bin/pg_upgrade \ | |
-b /usr/lib/postgresql/9.6/bin \ | |
-B /usr/lib/postgresql/11/bin \ | |
-d /var/lib/postgresql/9.6/main \ | |
-D /var/lib/postgresql/11/main \ | |
-o ' -c config_file=/etc/postgresql/9.6/main/postgresql.conf' \ | |
-O ' -c config_file=/etc/postgresql/11/main/postgresql.conf' \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
def get_master_volume(): | |
proc = subprocess.Popen('/usr/bin/amixer sget Master', shell=True, stdout=subprocess.PIPE) | |
amixer_stdout = proc.communicate()[0].split('\n')[4] | |
proc.wait() | |
find_start = amixer_stdout.find('[') + 1 | |
find_end = amixer_stdout.find('%]', find_start) | |
return float(amixer_stdout[find_start:find_end]) |
OlderNewer