Skip to content

Instantly share code, notes, and snippets.

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 / _redirects
Created November 24, 2018 15:48
SPA redirect
/* /index.html 200
@robsonsobral
robsonsobral / .gitignore
Created November 19, 2018 00:14
GitIgnore folder content
# Ignore everything in this directory
*
# Except this file
!.gitignore
{{ 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 / _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
@robsonsobral
robsonsobral / example.html
Last active July 20, 2018 01:14 — forked from raulmangolin/example.html
postMessage example
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>postMessage Example</title>
<script type="text/javascript">
var popup;
function openWindow(){
/*
This function will take the scripts specified and load them in order
asynchronously. It will not continue until the specified type from
each file is loaded.
*/
(function () {
function loadScripts () {
/*
This loadScript function takes the name of the object as it
@robsonsobral
robsonsobral / hugoMarkdownBlock.html
Created December 18, 2017 22:11
hugoMarkdownBlock
{{ $markdown := . | markdownify }}
{{ if not ( strings.Contains $markdown "<p>" ) }}
<p>{{ $markdown }}</p>
{{ else }}
{{ $markdown }}
{{ end }}
@robsonsobral
robsonsobral / unused_img.sh
Created September 4, 2017 16:04
Delete unused image files
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Please supply paths to search under"
exit 1
fi
IMG_PATH=$1
HTML_AND_CSS_PATH=$2
@robsonsobral
robsonsobral / Array.prototype.compare.js
Last active July 19, 2017 18:53 — forked from ain/Array.prototype.compare.js
JavaScript compare() method for Array
Array.prototype.compare = function(array) {
if (!array) {
return false;
}
if (this.length !== array.length) {
return false;
}
for (var i = 0, l = this.length; i < l; i++) {
if (this[i] instanceof Array && array[i] instanceof Array) {
if (!this[i].compare(array[i])) {