Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie Hamel‑Smith jamiehs

View GitHub Profile
@jamiehs
jamiehs / 01-modal_content.html
Last active Aug 29, 2015
Assuming the below HTML with the video class on the modal and the video URL as the data attribute on the video content.
View 01-modal_content.html
<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>
View Contract Killer 3.md

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 Feb 26, 2014
Recursively download a directory listing structure, filtering specific file types.
View recursive-download.sh
wget -r -A=jpeg,jpg,bmp,png,gif,tiff,xpm,ico http://www.somesite.com/
@jamiehs
jamiehs / functions.php
Created Mar 3, 2014
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)
View functions.php
<?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 Aug 29, 2015
Setup a new Raspberry Pi Dashing board based on cloned image of "raspberrypi2"
View Pi setup
# 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 Mar 19, 2014
Simple version of MySQL find and replace for WOrdPress database migration.
View update-domain-name-2.sql
# 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 Aug 29, 2015
Magical mixins with trees
View sass-mixins.scss
@mixin gallery-items($size) {
.item {
float: left;
.thumbnail {
margin-bottom: $size/4;
text-align: center;
width: $size;
height: $size;
View popup_function.js
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 Apr 24, 2014
Recursively loop over all files, then use simple string replacements.
View find-and-replace.sh
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 Sep 23, 2014
jQuery Scroll To with history.pushState support for using the back button and the location bar: http://stackoverflow.com/a/16732655
View scrollto-pushstate.js
$(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;