Skip to content

Instantly share code, notes, and snippets.

View 7LayersDesign's full-sized avatar

Andy Hutchins 7LayersDesign

View GitHub Profile
@7LayersDesign
7LayersDesign / regex_patterns.txt
Created September 16, 2013 23:15
Various regular expressions patterns. This is just a place I dump them as I find them. You are urged to use these with caution and verify they do what you need.
//replace all but links
/<(?!\/?a(?=>|\s.*>))\/?.*?>/g
//validate url
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \?=.-]*)*\/?$/
//Validate US phone number
/^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/
//Test if a password is strong
@7LayersDesign
7LayersDesign / remote_compare.sh
Created September 16, 2013 23:18
Compare local file with remote file via ssh.
ssh username@servername.com 'cat /path/to/file.txt' | sdiff - /path/to/file.txt
ab -k -c 10 -n 100 http://site.to.test
@7LayersDesign
7LayersDesign / ssh_remote_copy.sh
Created September 20, 2013 14:14
Copy a directory to local machine over SSH using SCP.
scp -r user@hostname:path/to/remote ~/Path/to/local
@7LayersDesign
7LayersDesign / ulive.css
Created September 20, 2013 16:10
uLive fix.
div[itemscope] {
background: #fffbe0 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA8AAAAABCAYAAAARiscXAAAAGklEQVR42u3BAQEAAAABIP9PM0SVAgAAwIEBmTTx01NZasoAAAAASUVORK5CYII=') repeat-y 50% top;
}
@7LayersDesign
7LayersDesign / install_subl.sh
Created September 25, 2013 14:10
Install Sublime Text 3 CLI tool subl.
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
@7LayersDesign
7LayersDesign / date_format_symbols.md
Last active December 23, 2015 22:09
Date format codes for Python, but mostly compatible in other languages too.

Python Date Format Codes

%a Locale’s abbreviated weekday name.
%A Locale’s full weekday name.
%b Locale’s abbreviated month name.
%B Locale’s full month name.
%c Locale’s appropriate date and time representation.
%d Day of the month as a decimal number [01,31].
%f Microsecond as a decimal number [0,999999], zero-padded on the left %H Hour (24-hour clock) as a decimal number [00,23].

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto

  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
  • super+shift+p: command prompt
  • ctrl+g: go to line
@7LayersDesign
7LayersDesign / script_loader.js
Created September 27, 2013 14:39
Javascript script loaded function. Thanks to Nicholas C. Zakas. See http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/
function loadScript(url, callback){
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState){ //IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" ||
script.readyState == "complete"){
script.onreadystatechange = null;
@7LayersDesign
7LayersDesign / vagrant_bootstrap.sh
Created September 29, 2013 20:44
Provisioner for Vagrant development boxes. Meant for Laravel, but may be used with anything.
#!/usr/bin/env bash
# Update the box
# --------------
# Downloads the package lists from the repositories
# and "updates" them to get information on the newest
# versions of packages and their dependencies
apt-get update
# Install Vim