Skip to content

Instantly share code, notes, and snippets.

View dylansm's full-sized avatar

Dylan Smith dylansm

View GitHub Profile
@dylansm
dylansm / dnsmasq OS X.md
Created November 17, 2021 00:33 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@dylansm
dylansm / hackTheDom.js
Created March 10, 2019 06:44 — forked from AndreasMadsen/hackTheDom.js
size of TextNode - DOM Hack
// This is the coolest code snippet I (Mr. Mad) have every created
// It will magicly get the size of a textnode, by createing a context
// range and get the client rects of that range.
// It will then combine the rects to one rect, and thereby get the size
// of the text node.
// Note that by any standarts a TextNode has no size.
var range = document.createRange();
range.selectNode(node);
var rect = range.getBoundingClientRect();
Function Check-Spelling()
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=0,ValueFromPipeline=$True)]
[String] $String,
[Switch] $ShowErrors,
[Switch] $RemoveSpecialChars
)
Process{
@dylansm
dylansm / duplicate-row.js
Created March 22, 2018 14:41 — forked from develmaycare/duplicate-row.js
Duplicate a row in Google Sheets.
/* To use this in a Google Sheet:
1. Go to Tools > Script Editor.
2. Save the script.
3. Paste this script and click on the bug symbol.
4. Authorize the script.
5. Refresh the sheet.
*/
// global
var ss = SpreadsheetApp.getActive();
@dylansm
dylansm / postman-hmac-sha512-preq-request.js
Created January 22, 2018 21:37 — forked from ravikiranj/postman-hmac-sha512-preq-request.js
HMAC SHA512 Authentication Pre-request script for Postman
/* Pre-requisite
==================
1) Create an Environment (if you don't already have on) and enable it for your request
2) Add a new Header with key as "Authorization" and value as "{{hmacAuthHeader}}"
3) Add the following Pre-request Script that computes the hmacAuthHeader variable and adds it to the environment
4) Fill your CLIENT_KEY and SECRET_KEY with valid values
*/
function getPath(url) {
var pathRegex = /.+?\:\/\/.+?(\/.+?)(?:#|\?|$)/;
@dylansm
dylansm / webworker-preloader.html
Created January 17, 2018 18:33 — forked from mseeley/webworker-preloader.html
WebWorker Image preloader proof of concept (Tested in Mobile Safari 6.0/IOS 6.1.3 and Chrome 33)
<!DOCTYPE html>
<html>
<head>
<title>WebWorker image preloading</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
</head>
<body>
<div id="output"></div>
<script id="imgloader" type="javascript/worker">
// Not race proof or robust. Proof of concept.
@dylansm
dylansm / gif animation using html5
Created December 21, 2017 20:29 — forked from agektmr/gif animation using html5
How to create gif animation
<html>
<head>
<style>
figure {
width: 200px;
height: 150px;
text-align: center;
float: left;
}
img {
@dylansm
dylansm / tmux.conf
Created October 30, 2017 02:20 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@dylansm
dylansm / figure.html
Created October 12, 2017 17:47 — forked from budparr/figure.html
Hugo "figure" shortcode that works with https://github.com/aFarkas/lazysizes and uses `markdownify` for title and caption #gohugo
<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }} class="lazyload" />
<noscript>
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }}/>
</noscript>
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>{{ if isset .Params "title" }}
@dylansm
dylansm / cloud-config-centos.yml
Created April 10, 2017 02:20
cloud-config for a base-box
#cloud-config
package_upgrade: true
packages:
- curl
- ntp
- wget
- git
- vim
users:
- name: mhutter