Skip to content

Instantly share code, notes, and snippets.

View richarddewit's full-sized avatar
🗿
〰️〰️〰️〰️

Kerani richarddewit

🗿
〰️〰️〰️〰️
View GitHub Profile
@richarddewit
richarddewit / hostsmanager.sh
Last active March 8, 2019 00:24 — forked from irazasyed/manage-etc-hosts.sh
Bash script to manage /etc/hosts file, adding/removing hostnames.
#!/usr/bin/env bash
if [ "$1" != "add" ] && [ "$1" != "remove" ] || [ -z "$2" ]; then
[ -z "$2" ] && echo "Missing hostname" || echo "Unknown option '$1'"
echo "Unknown option '$1'"
echo "Usage:"
echo " $0 add <hostname>"
echo " $0 remove <hostname>"
exit 1
fi
@richarddewit
richarddewit / vagrant-sudoers-arch-fedora.sh
Last active January 2, 2019 07:27 — forked from elvetemedve/Arch Linux, Fedora
Allow Vagrant usage without providing sudo password
#
# Arch Linux / Fedora sudoers entries
#
sudo tee /etc/sudoers.d/vagrant > /dev/null << EOL
# Allow passwordless startup of Vagrant with vagrant-hostsupdater.
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts
%wheel ALL=(root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE
@richarddewit
richarddewit / randomIBANs.py
Last active January 15, 2019 10:13
Generate X random IBANs for Dutch bank ABN
#!/usr/bin/env python
import sys
import random
def main():
try:
count = int(sys.argv[1])
if count <= 0:
raise ValueError

How to trust a local development Root CA

(this guide focuses on Laravel's development server, Homestead)

For example; Homestead by default creates SSL certificates for your local websites, however you have to always click "Proceed/Trust/Make exception" or trust every website's certificate manually before being able to visit the site. By installing the Root CA (roughly: the certificate which is used to create the website certificates), you instantly trust all certificates that are derived from it.

Getting the Root CA

Normally on an Nginx webserver (e.g. on Homestead) the certificates are stored in the /etc/nginx/ssl folder. You see all the certificates that are generated for your local websites, including 3 crucial files:

  • ca.homestead.homestead.cnf
  • ca.homestead.homestead.crt
var copyBtn = document.querySelector('.js-copy-button');
var originalContent = copyBtn.innerHTML;
copyBtn.addEventListener('click', function(event) {
var copyContents = document.querySelector('.js-copy-contents');
// Clear selection first
window.getSelection().removeAllRanges();
// Select the contents
var range = document.createRange();
.check-visible {
opacity: 0;
transform: translateY(30px);
transition-duration: .3s;
transition-timing-function: ease;
transition-property: opacity, transform;
}
.check-visible.is-visible {
opacity: 1;
@richarddewit
richarddewit / _aspect-ratio.scss
Last active April 18, 2018 08:05
Aspect ratio
@mixin aspect-ratio($width, $height, $content-selector: '.content') {
position: relative;
&:before {
display: block;
content: '';
width: 100%;
padding-top: ($height / $width) * 100%;
}
@richarddewit
richarddewit / nearest-whole-aspect-ratio.js
Last active April 1, 2019 10:40
Calculate nearest whole size on aspect ratio
// Paste this in your JavaScript console:
var width = 1440;
var height = 500;
var minWidth = 1000;
var maxWidth = 1500;
var ar = height / width;
for (var i = minWidth; i < maxWidth; i++) {
if (ar * i % 1 === 0) {
console.log(i + 'x' + (i * ar));
@richarddewit
richarddewit / throttled-resize-event.js
Last active April 18, 2018 08:10
Throttled resize/scroll events
var resizing = false;
$(window).on('resize', function() {
if (!resizing) {
resizing = true;
if (!window.requestAnimationFrame) {
setTimeout(onResizeFunction, 250);
} else {
requestAnimationFrame(onResizeFunction);
}
@richarddewit
richarddewit / slugify.php
Last active March 15, 2019 08:49
Slugify a string
<?php
/**
* Converts text from
* "thing + (Beep) $%^boop"
* to
* "thing-beep-boop"
*
* @author Richard de Wit
* @link https://gist.github.com/richarddewit/06692629a1503f931ff9d54002ffc14e
*