Skip to content

Instantly share code, notes, and snippets.

View jmillerdesign's full-sized avatar

J. Miller jmillerdesign

View GitHub Profile
@jmillerdesign
jmillerdesign / gist:11159841
Created April 21, 2014 23:18
Restore default file & folder permissions
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
@jmillerdesign
jmillerdesign / gist:3df27b72a2b7bcd946ed
Last active March 30, 2021 01:55
Embed a YouTube video responsively
<style>
.embed-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
overflow: hidden;
max-width: 100%;
height: auto;
}
.embed-container iframe,
@jmillerdesign
jmillerdesign / slug.php
Created May 10, 2014 05:07
Slugify a string
<?php
/**
* Convert a human-readable string into a slug
*
* 'Sample input string!' gets converted to 'sample-input-string'
*
* @param string Source string
* @return string Slug
* @author Cake Development Corporation (http://cakedc.com)
@jmillerdesign
jmillerdesign / strToInt.js
Last active August 29, 2015 14:01
Convert any string into an integer
/**
* Convert any string into an integer
*
* @param {string} str Input string
* @return {integer} Integer
*/
var strToInt = (function () {
var map = {};
var size = 0;
var hash;
@jmillerdesign
jmillerdesign / convert_to_rgb.sh
Created July 24, 2014 17:18
Convert all images to RGB
sips --matchTo /System/Library/ColorSync/Profiles/Generic\ RGB\ Profile.icc *.jpg
@jmillerdesign
jmillerdesign / download_remote_dir.sh
Last active October 8, 2017 07:53
Download a remote directory locally
# Download a remote directory locally
rsync -zatPe ssh --exclude uploads --exclude files username@example.com:/home/username/path/to/directory/ ~/local/path/to/directory/
# Copy a local directory without removing new files
rsync -zatP /path/to/old/ /path/to/new/
# Copy just one file
scp username@example.com:/home/username/path/to/file.txt ~/local/path/to/file.txt
@jmillerdesign
jmillerdesign / trailing-slash.conf
Created January 17, 2015 22:10
Apache add or remove trailing slash for non-file URLs
# ----------------------------------------------------------------------
# Add trailing slash to (non-file) URLs
# Rewrite "example.com/foo -> example.com/foo/"
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ /$1/ [R=301,L]
</IfModule>
{
"disallowEmptyBlocks": true,
"disallowKeywords": ["with"],
"disallowMixedSpacesAndTabs": "smart",
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineStrings": true,
"disallowQuotedKeysInObjects": "allButReserved",
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforeBinaryOperators": [","],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
if [[ $(service mysql status | grep running | wc -l) != 1 ]];
then
echo "$(date "+%Y-%m-%d %T")" >> /root/keep-mysql-running.log
echo "$(service mysql status)" >> /root/keep-mysql-running.log
service mysql start >> /root/keep-mysql-running.log
fi
@jmillerdesign
jmillerdesign / list-symlinks.sh
Created January 21, 2016 20:19
List all symlinks recursively from current directory