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
# SSH to the EC2 instance and run these commands there | |
$ sudo yum update && sudo yum install gcc gcc-c++ make | |
$ sudo yum install git && git clone https://github.com/jedisct1/dsvpn.git && cd dsvpn | |
$ make | |
$ dd if=/dev/urandom of=vpn.key count=1 bs=32 | |
$ base64 < vpn.key | |
# Copy the value obtained as output of the command above and use it on the client side | |
$ sudo ./dsvpn server vpn.key auto 1947 | |
# Run these locally on your machine |
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
// Change SQL client timeout | |
set statement_timeout = '0s'; | |
set statement_timeout = '10s'; | |
// Change timeout globally | |
alter database mentimeter set statement_timeout = '10s'; | |
// Time queries |
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
const base = "https://newsubdomain.example.com" | |
async function handleRequest(request) { | |
// Make a copy to allow mutation. | |
request = new Request(request); | |
// To override default caching mechanism and respect Cache-Control. | |
request.cf.cacheEverything = true; | |
// Extract path from request URL. |
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
# Install wget and AWS CLI and set up your AWS credentials | |
# STEP 1 | |
# Create a mirror of the website and re-write links | |
# --wait specifies that there is a wait of 1 second after each request. | |
# Be gentle with someone else's server. Also you risk being blocked if your request rate is too high | |
# Use -U to spoof user agent to that of an actual browser in case the server is blocking you from making requests | |
wget --mirror --convert-links --html-extension --wait=1 -o log https://aawaara.com/ |
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
curl https://get.acme.sh | sh | |
# Open a new terminal window after executing above command | |
# Create a cloudflare account and get your API key from the profile section | |
export CF_Email=my.cloudflare@example.com | |
export CF_Key=replace_with_cloudflare_api_key | |
# Generate wildcard certificate for *.example.com | |
acme.sh --issue -d example.com -d '*.example.com' --dns dns_cf |
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
// Add the following to your config/bootstrap.js file | |
process.env.TZ = 'UTC'; |
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
// Install required modules as below: | |
npm install -g db-migrate | |
npm install -g db-migrate-mysql | |
// Create a database.json file: | |
{ | |
"development": { | |
"driver": "mysql", | |
"host": "localhost", |
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
{ | |
"Version": "2008-10-17", | |
"Id": "PolicyForCloudFrontPrivateContent", | |
"Statement": [ | |
{ | |
"Sid": "1", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "Enter your CloudFront Origin Access Identity here" | |
}, |
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
ActiveAdmin.register MyModel do | |
filter :custom_field, :as => :string, :label => "Custom Field Display Name" | |
end | |
class MyModel < ActiveRecord::Base | |
search_methods :custom_field_search | |
def self.custom_field_search(name) | |
# This method should return an ActiveRecord::Relation Object with MyModel objects | |
# Put in your complex search logic here |
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
# Loader for infinite time | |
["|", "/", "-", "\\"].each{|v| STDOUT.write "\r#{v}"; sleep 0.5} while 1 | |
# In case you want to run it for a few seconds (~ 20s in the example below) | |
10.times{ ["|", "/", "-", "\\"].each{|v| STDOUT.write "\r#{v}"; sleep 0.5} } | |
# Progress Bar | |
100.times{STDOUT.write "|"; sleep 0.1} | |
# Another kind of loading indicator |
NewerOlder