Skip to content

Instantly share code, notes, and snippets.

View stmoerman's full-sized avatar

Stephan Moerman stmoerman

View GitHub Profile
function unmute() {
var vid = document.getElementById("video");
var aud = document.getElementById("audio");
aud.currentTime = vid.currentTime;
aud.play();
}
Rack::Attack.throttle('logins/email', :limit => 6, :period => 60.seconds) do |req|
req.params['email'] if req.path == '/login' && req.post?
end
@stmoerman
stmoerman / .htaccess
Created May 1, 2018 00:39
.htaccess non-www to www & http to https 301 redirect
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@stmoerman
stmoerman / .htaccess
Last active April 13, 2018 23:07
Apache2 redirect non-www to www and http to https through .htaccess with mod_rewrite
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
<?php
// Set Variables
$LOCAL_ROOT = "/var/www/kreynation.com";
$LOCAL_REPO_NAME = "public_web";
$LOCAL_REPO = "{$LOCAL_ROOT}/{$LOCAL_REPO_NAME}";
$REMOTE_REPO = "git@github.com:devbowser/kreynation.com.git";
$BRANCH = "master";
if ( $_POST['payload'] ) {
// Only respond to POST requests from Github
@stmoerman
stmoerman / .gitignore
Created April 5, 2018 18:33
Grav .gitignore
# Composer
.composer
vendor/*
!*/vendor/*
# Sass
.sass-cache
# Grav Specific
backup/*
@stmoerman
stmoerman / index.html
Created March 26, 2018 21:44
Testing address validation using the Google Maps API
<html>
<head>
<title>Example Form </title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<form>
<label for="Name">Name</label>
require 'active_record'
require 'activerecord-import'
require 'benchmark'
require 'pg'
include ActiveRecord
Base.establish_connection adapter: 'postgresql',
encoding: 'unicode',
pool: 5,

Setup Windows 10 for Modern/Hipster Development

A fresh Windows isn't entirely ready for modern development, but all the tools you need are available. A good terminal, popular bash tools, Git, a decent package manager - when properly setup, modern development on Windows can be a lot of fun. In particular, this document outlines how to configure your Windows in such a way that it can easily handle most development tasks usually run on a Mac OS X or a Linux distro.

A Word about Ubuntu Linux on Windows

☝️ While Bash on Windows isn't perfect yet, it's an amazing tool that can make development a lot easier - especially when you're dealing with Bash scripts, Ruby, or Ubuntu binaries. I would currently (January 2017) not recommend it as a replacement for Git, Node, or Go - mostly because those tools are already pretty performant on Windows itself. However, they run just fine in Bash, so if you feel like moving most of your development over, go

Keybase proof

I hereby claim:

To claim this, I am signing this object: