Skip to content

Instantly share code, notes, and snippets.

@robsonsobral
robsonsobral / _headers
Last active August 10, 2023 21:08
Netlify headers
/*
# Only connect to this site and subdomains via HTTPS for the next one year
Strict-Transport-Security: max-age=31536000; includeSubDomains
# Block site from being framed with X-Frame-Options and CSP
Content-Security-Policy: frame-ancestors 'self'
# X-Frame-Options tells the browser whether you want to allow your site to be framed or not. By preventing a browser from framing your site you can defend against attacks like clickjacking.
X-Frame-Options: SAMEORIGIN
{{ with .Lastmod }}
<meta http-equiv="Last-Modified" content="{{ .Format "2006-01-02T15:04:05-0700" }}" />
{{ end }}
{{ $packageJson := getJSON "./package.json" }}
{{ with $packageJson.version }}
<meta name="version" content="{{ . }}">
{{ end }}
@robsonsobral
robsonsobral / .gitignore
Created November 19, 2018 00:14
GitIgnore folder content
# Ignore everything in this directory
*
# Except this file
!.gitignore
@robsonsobral
robsonsobral / _redirects
Created November 24, 2018 15:48
SPA redirect
/* /index.html 200
function getQueryString() {
var url = arguments.length > 0 && arguments[0] !== undefined ?
arguments[0] :
window.location.search;
var queryString = url.indexOf('?') !== -1 ?
url.split('?')[1] :
url;
var queries = queryString.indexOf('&') !== -1 ?
@robsonsobral
robsonsobral / gist:1df6bb51ef0c04dc5fcc0afd5b36bddf
Created January 9, 2019 18:32
Hugo query string cachebusting
<script src="{{ $script.RelPermalink }}?mtime={{ (os.Stat "/static/scripts/index.js" ).ModTime.Unix }}"></script>
@robsonsobral
robsonsobral / pageant-autoload-keys-at-startup.txt
Created January 21, 2019 23:13 — forked from chunter/pageant-autoload-keys-at-startup.txt
Make Pageant autoload keys at startup
To make Pageant automatically run and load keys at startup:
- Find the location of pageant.exe
- Windows key + R to open the 'run' dialog box
- Type: 'shell:startup' in the dialog box
- Create a shortcut to the pageant.exe and put into this startup folder.
@robsonsobral
robsonsobral / paste.js
Created December 4, 2019 13:34 — forked from cesarfigueroa/paste.js
Paste onto a [contenteditable] element as plain text
document.querySelector('[contenteditable]').addEventListener('paste', function (event) {
event.preventDefault();
document.execCommand('inserttext', false, event.clipboardData.getData('text/plain'));
});
@robsonsobral
robsonsobral / cloudflare-ip.sh
Created April 25, 2020 03:29 — forked from jschpp/cloudflare-ip.sh
script to add all cloudflare IPs to iptables
#!/bin/sh
exec > /var/log/cloudflare.log 2>&1
set -x
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do /usr/sbin/iptables -I INPUT -p tcp -m multiport --dports http,https -s "$ip" -j ACCEPT; done
for ip in $(curl -s https://www.cloudflare.com/ips-v6); do /usr/sbin/ip6tables -I INPUT -p tcp -m multiport --dports http,https -s "$ip" -j ACCEPT; done
@robsonsobral
robsonsobral / cloudflare.sh
Created April 25, 2020 03:29 — forked from Manouchehri/cloudflare.sh
Allow CloudFlare only
# Source:
# https://www.cloudflare.com/ips
# https://support.cloudflare.com/hc/en-us/articles/200169166-How-do-I-whitelist-CloudFlare-s-IP-addresses-in-iptables-
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ip6tables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
# Avoid racking up billing/attacks
# WARNING: If you get attacked and CloudFlare drops you, your site(s) will be unreachable.
iptables -A INPUT -p tcp -m multiport --dports http,https -j DROP