Skip to content

Instantly share code, notes, and snippets.

View jamiehs's full-sized avatar

Jamie Hamel‑Smith jamiehs

View GitHub Profile
@jamiehs
jamiehs / 01-modal_content.html
Last active August 29, 2015 13:55
Assuming the below HTML with the video class on the modal and the video URL as the data attribute on the video content.
<a data-toggle="modal" data-target=".bs-modal-lg">Open Modal</a>
<div class="modal fade bs-modal-lg video" tabindex="-1" role="dialog" aria-labelledby="VideoModal" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" data-video-url="//player.vimeo.com/video/84747519?portrait=0&amp;byline=0&amp;title=0&amp;autoplay=1">
<div class="fve-video-wrapper fve-image-embed fve-thumbnail-image youtube" style="padding-bottom:56.25%;">
<iframe src="" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
</div>

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

@jamiehs
jamiehs / recursive-download.sh
Created February 26, 2014 17:59
Recursively download a directory listing structure, filtering specific file types.
wget -r -A=jpeg,jpg,bmp,png,gif,tiff,xpm,ico http://www.somesite.com/
@jamiehs
jamiehs / functions.php
Created March 3, 2014 05:07
Allows WordPress' importer to import media assets from one localhost site to another www.site1.dev to www.site2.dev (localhost sites). It seems that the WordPress wp_http_validate_url() function disallows the opening of URLs from the same host (127.0.0.1)
<?php
add_filter( 'http_request_host_is_external', 'explicitly_allow_same_host_requests_for_import' );
function explicitly_allow_same_host_requests_for_import(){
return true;
}
@jamiehs
jamiehs / Pi setup
Last active August 29, 2015 13:57
Setup a new Raspberry Pi Dashing board based on cloned image of "raspberrypi2"
# Find listening port 22 on the network
nmap -T5 -n -p 22 --open --min-parallelism 100 192.168.0.0/24
# edit hostname and hosts to change the hostname.
sudo nano /etc/hostname
sudo nano /etc/hosts
# edit the static IP address in the interfaces file.
sudo nano /etc/network/interfaces
@jamiehs
jamiehs / update-domain-name-2.sql
Created March 19, 2014 17:38
Simple version of MySQL find and replace for WOrdPress database migration.
# Update wp_options table
UPDATE wp_options SET option_value = REPLACE(option_value,'example.com','example.dev');
# Update wp_posts table
UPDATE wp_posts SET guid = REPLACE(guid,'example.com','example.dev');
@jamiehs
jamiehs / sass-mixins.scss
Last active August 29, 2015 13:57
Magical mixins with trees
@mixin gallery-items($size) {
.item {
float: left;
.thumbnail {
margin-bottom: $size/4;
text-align: center;
width: $size;
height: $size;
function openPopup(href, title, width, height){
var left = screen.availLeft + screen.width/2 - width/2,
top = screen.height/2 - height/2;
window.open(href, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);
};
@jamiehs
jamiehs / find-and-replace.sh
Created April 24, 2014 18:06
Recursively loop over all files, then use simple string replacements.
find . -type f -name "file-pattern*" -exec sh -c 'echo mv "$0" "${0/find/replace}"' '{}' \;
#Remove the echo when you're sure this does what you want.
@jamiehs
jamiehs / scrollto-pushstate.js
Created September 23, 2014 17:32
jQuery Scroll To with history.pushState support for using the back button and the location bar: http://stackoverflow.com/a/16732655
$(document).on('click', 'a[href*=#]', function(event){
event.preventDefault();
var targetId = this.hash;
var theTarget = $(targetId);
var customOffset = 0;
switch( targetId ){
case '#target1':
case '#target2':
customOffset = -80;