Skip to content

Instantly share code, notes, and snippets.

View therealkevinard's full-sized avatar
🎯
Focusing

Kevin Ard therealkevinard

🎯
Focusing
View GitHub Profile
@therealkevinard
therealkevinard / .htaccess
Created December 12, 2016 14:01
Force www or no-www
# only use one of these.
#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301,NC]
#Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.site\.com [NC]
@therealkevinard
therealkevinard / awk-to-file.sh
Created October 22, 2016 14:17
Dead-simple awk log file for regex match, and write new file with results. Probably doesn't deserve a gist, but I like gisting.
#!/usr/bin/env bash
# example: awk a clamav logfile (clamout.log) and write new file(awklog.txt) of lines that have "Empty file"[case-sensitive] in them
awk '/Empty file/{ print $0 }' clamout.log.txt > awklog.txt
$text-color: #e4a923;
$font-main: 'Oswald', sans-serif;
@mixin font-geometry-base($font-size) {
font-size: $font-size;
line-height: $font-size * 1.667;
}
.countdown-outer {
.heading {
# force ssl
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://site.com/$1 [R,L]
</IfModule>
@therealkevinard
therealkevinard / .htaccess
Last active July 25, 2016 16:57
dev-to-live 301: after launching dev domain 301 all requests to the live domain. Don't rely on this for link-fixing. Rather, use it after link-fixing to catch any edge cases.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^dev.domain.net [NC]
RewriteRule ^(.*)$ http://www.livedomain.com/$1 [L,R=301,NC]
</IfModule>
@therealkevinard
therealkevinard / .htaccess
Created July 8, 2016 17:54
.htaccess tricks: browser caching and gzip delivery.
# browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
@therealkevinard
therealkevinard / .htaccess
Created July 8, 2016 17:53
htaccess tricks: CORS list. allows a list of domains to allow resource-sharing. Domain list is by way of regex OR syntax.
# CORS list
<IfModule mod_headers.c>
SetEnvIf Origin "http(s)?://(www\.)?(domainone\.com|domaintwo\.com)$" AccessControlAllowOrigin=$0
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
</IfModule>
@therealkevinard
therealkevinard / mig-dirs-to-sql.py
Last active August 29, 2015 14:26
A simple python script that takes a directory of organized images, parses the structure into sql inserts and a re-organized directory for upload. useful for migrating websites that have huge image galleries.
#!/usr/bin/python
import sys
import getopt
import os
import shutil
basedir = ''
outputdir = ''
sqlpath = ''