Skip to content

Instantly share code, notes, and snippets.

View deepfriedmind's full-sized avatar

Andreas Wahlqvist deepfriedmind

View GitHub Profile
@deepfriedmind
deepfriedmind / showcolors.sh
Created August 3, 2015 21:34
Output text strings in all 8 base colors + their light/bold variant (tested in bash on OS X)
#!/bin/bash
i=30
for color in "black" "red" "green" "yellow" "blue" "purple" "cyan" "white" ; do
for attr in 0 1; do
if [[ $attr == 1 ]]; then
prefix="bold/light "
else
prefix=""
fi
@deepfriedmind
deepfriedmind / htpgen.sh
Created August 29, 2014 09:01
HTPGen – Quickly generate .htpasswd / .htaccess files for basic Apache authentication. To be able to run `htpgen.sh` from anywhere, place the file somewhere that's included in your `PATH`, e.g. `/usr/local/bin` or `/usr/bin`.
#!/bin/bash
read -p "Enter username: " -r ht_username
read -p "Enter password: " -sr ht_password
echo -en "\n"
read -p "Enter full path to where .htpasswd will be placed on the web server: " -r ht_path
htpasswd -nb $ht_username $ht_password > .htpasswd
echo "AuthType Basic
@deepfriedmind
deepfriedmind / debug.css
Created August 25, 2014 17:19
Add different colored backgrounds to all elements for debug purposes.
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
@deepfriedmind
deepfriedmind / Media-Query-Matcher.coffee
Last active August 29, 2015 14:03
Media Query Matcher. Match a specific breakpoint using Modernizr.mq() (example breakpoints are Bootstrap defaults) – Requires Modernizr, obviously.
class MediaQueries
breakpoints =
screenXS: '(min-width: 480px)'
screenXSmax: '(max-width: 767px)'
screenSM: '(min-width: 768px)'
screenMD: '(min-width: 992px)'
screenLG: '(min-width: 1200px)'
errorMsg = 'Invalid or no breakpoint specified.'
if Object.keys? then errorMsg += " Valid arguments: #{Object.keys(breakpoints)}"
@deepfriedmind
deepfriedmind / toggleTouchScroll.js
Created October 1, 2013 16:43
A simple JavaScript function I wrote to toggle between enabling/disabling scrolling on mobile touch devices.
var toggleTouchScroll = function() {
var d = document;
if (typeof d.ontouchmove === 'object') return d.ontouchmove = function() {
return false;
};
if (typeof d.ontouchmove === 'function') return d.ontouchmove() ? d.ontouchmove = function() {
return false;
} : d.ontouchmove = function() {
return true;
};