Installing mysql2 gem errors on MacOS Mojave.
Make sure openssl is installed on Mac via Homebrew.
brew install openssl
| #!/bin/bash | |
| # Copyright © 2017 Google Inc. | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
| # Drop other people's session | |
| SELECT pg_terminate_backend(pid) | |
| FROM pg_stat_activity | |
| WHERE datname = current_database() AND pid <> pg_backend_pid(); | |
| # Change passwd | |
| ALTER USER user_name WITH PASSWORD 'new_password'; | |
| ALTER ROLE migrator CREATEDB; |
| #!/bin/bash | |
| yum install -y jq curl | |
| while sleep 5; do | |
| if [ -z $(curl -Isf http://169.254.169.254/latest/meta-data/spot/instance-action) ]; then | |
| /bin/false | |
| else | |
| EC2_INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
| EC2_AVAIL_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone` |
| require 'cgi' | |
| require 'json' | |
| require 'active_support' | |
| def verify_and_decrypt_session_cookie(cookie, secret_key_base) | |
| cookie = CGI::unescape(cookie) | |
| salt = 'encrypted cookie' | |
| signed_salt = 'signed encrypted cookie' | |
| key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000) | |
| secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len] |
SSH into your EC2 instance. Run the following:
$ sudo yum install gcc This may return an "already installed" message. That's OK.
$ wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make
Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'
Example: To get json record having _id equal 611
cat my.json | jq -c '.[] | select( ._id | contains(611))'Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)
| #!/bin/bash | |
| # get the latest linux kernel at http://kernel.ubuntu.com/~kernel-ppa/mainline/ | |
| wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14-rc6/linux-image-4.14.0-041400rc6-generic_4.14.0-041400rc6.201710230731_amd64.deb | |
| # install the kernel | |
| dpkg -i linux-image-4.*.deb | |
| # update grub | |
| # for linode, change kernel in boot settings to GRUB 2 |
| #!/bin/sh | |
| ## backup each mysql db into a different file, rather than one big file | |
| ## as with --all-databases. This will make restores easier. | |
| ## To backup a single database simply add the db name as a parameter (or multiple dbs) | |
| ## Putting the script in /var/backups/mysql seems sensible... on a debian machine that is | |
| ## Create the user and directories | |
| # mkdir -p /var/backups/mysql/databases | |
| # useradd --home-dir /var/backups/mysql --gid backup --no-create-home mysql-backup | |
| ## Remember to make the script executable, and unreadable by others |