Skip to content

Instantly share code, notes, and snippets.

View david-pm's full-sized avatar
💭
I may be slow to respond.

David McDonald david-pm

💭
I may be slow to respond.
View GitHub Profile
@david-pm
david-pm / rename_files_with_spaces
Created May 30, 2016 20:11
replaces spaces with underscores in file names if rename utility is unavailable
#!/bin/bash
# replace spaces with underscores in file names
ls | while read file
do
mv "$file" "$(echo "$file" | sed -e 's/\ /_/g')"
done
@david-pm
david-pm / ngSwitch
Created July 17, 2015 21:59
ngSwitch
<body ng-controller="MainController">
<h4>Which Star Wars Episodes Were Good/Bad?</h4>
<div ng-switch on="quality">
<div ng-switch-when="bad">
Episodes IV, V ,VI
</div>
<div ng-switch-when="good">
Episodes I, II, III
</div>
@david-pm
david-pm / FileInput
Last active August 29, 2015 14:25
Cross-Browser File Input
<!DOCTYPE html>
<html>
<head>
<meta name="author" content="DAVIDPM 2015, davidpm.io">
<title>Custom Cross-Browser File Input</title>
<style type="text/css">
.wrapper {
margin: 5%;
padding: 5%;
border: 1px solid #aaa;
@david-pm
david-pm / question
Created May 27, 2015 22:01
Interview Question
Question 1
Write a JavaScript snippet that uses console.log to print all the numbers from 1 to 100, with two exceptions. For numbers divisible by 3, print "Fizz" instead of the number, and for numbers divisible by 5 (and not 3), print "Buzz" instead.
When you have that working, modify your program to print "FizzBuzz", for numbers that are divisible by both 3 and 5 (and still print "Fizz" or "Buzz" for numbers divisible by only one of those).
Question 2
Listen for an event on the unordered list in the provided html that uses event propagation correctly. On click, each button should log its inner html to the console.
Use the following html:
<!DOCTYPE html>
<html>
@david-pm
david-pm / fluid
Created March 4, 2015 01:20
fluid iframe
<iframe src="index.html" style="display:block; width:100%!important; height:100%!important;" />
@david-pm
david-pm / style
Created February 19, 2015 23:12
Get Computed Style of Element
window.getComputedStyle(element, null).getPropertyValue(“css-selector”);
@david-pm
david-pm / windowSize
Created February 19, 2015 23:09
Set Browser Window Size (320x480)
javascript:(function(){window.open(document.URL, '','width=320,height=480');})();
@david-pm
david-pm / respimg
Created February 19, 2015 23:07
Responsive Images
.parent { width: 200px; }
.child { max-width: 100%; height: auto; }
@david-pm
david-pm / cover-img
Created February 19, 2015 23:07
Background Cover Img
body {
background: url('img.jpg')no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@david-pm
david-pm / video
Created February 19, 2015 23:04
Responsive Video
.video > .video-wrapper {
position: relative;
width: 100%;
padding-top: 56.25%;
}
.video > .video-wrapper iframe,
.video > .video-wrapper object,
.video > .video-wrapper embed {
position: absolute;
height: 100%;