Skip to content

Instantly share code, notes, and snippets.

View Donmclean's full-sized avatar
🎧
Building a fleet of the world's first AI DJs 👨‍💻

Don Mclean Donmclean

🎧
Building a fleet of the world's first AI DJs 👨‍💻
View GitHub Profile
@Donmclean
Donmclean / Javascript_speech_synthesis.js
Created October 4, 2016 13:55
Speech Synthesis for web
function speak (message) {
var msg = new SpeechSynthesisUtterance(message)
var voices = window.speechSynthesis.getVoices()
msg.voice = voices[0]
window.speechSynthesis.speak(msg)
}
speak('hello');
angular.element('body').animate({
scrollTop: 0
}, 800);
// OR
$('body').animate({
scrollTop: 0
}, 800);
@Donmclean
Donmclean / SASS_font-face.scss
Created June 27, 2016 20:46
SASS MIXIN FOR FONT FACE
@mixin fontFace($family,$src,$style: normal,$weight: normal) {
@font-face {
font-family: $family;
src: url('#{$src}.eot'); // IE9 compat
src: url('#{$src}.eot?#iefix') format('embedded-opentype'), // IE8 and below
url('#{$src}.woff') format('woff'), // standards
url('#{$src}.ttf') format('truetype'), // Safari, Android, iOS
url('#{$src}.svg##{$family}') format('svg'); // legacy iOS
font-style: $style;
@Donmclean
Donmclean / Javascript_Angular_loading_nonAngular_dependencies.js
Created June 6, 2016 11:50
Properly integrate non-AngularJS libraries in your AngularJS application
function LodashFactory($window) {
if(!$window._){
// If lodash is not available you can now provide a
// mock service, try to load it from somewhere else,
// redirect the user to a dedicated error page, ...
}
return $window._;
}
// Define dependencies
@Donmclean
Donmclean / CSS_Email_Hide_Class.scss
Created June 1, 2016 15:53
How to display email content in mobile clients only
<style>
/* Media query for displaying content in mobile email clients */
@media only screen and (max-device-width: 480px) {
.hide { max-height: none !important; font-size: 12px !important; display: block !important; }
}
...
/* CSS for hiding content in desktop/webmail clients */
.hide { max-height: 0px; font-size: 0; display: none; }
@Donmclean
Donmclean / JSON_idiomaticJS_jscs_config.json
Created May 29, 2016 18:46
JSCS config JSON for idiomaticJS.
{
"preset": "jquery",
"requireEarlyReturn": true,
"requireSpacesInsideParentheses": {
"all": true,
"ignoreParenthesizedExpression": true,
"except": [ "{", "}", "[", "]", "function", "\"" ]
},
"disallowSpacesInsideParentheses": {
"only": [ "{", "}", "[", "]", "function" ]
@Donmclean
Donmclean / CSS_IE_CSS_HACKS.txt
Created May 23, 2016 19:51
IE CSS hacks - IE6, 7, 8, 9, 10, 11
IE6 Only
==================
_selector {...}
IE6 & IE7
==================
*html or { _property: }
IE7 Only
==================
@Donmclean
Donmclean / CSS_iOS_Devices_media_queries.scss
Last active September 13, 2016 19:17
Media queries for iOS Devices
//iPhone 5 + 5s specific selector
@mixin iPhone-5-and-5s-portrait-query {
@media screen and (device-aspect-ratio: 40/71) {
@content;
}
}
@include iPhone-5-and-5s-portrait-query {
//style goes here
}
@Donmclean
Donmclean / CSS_iPad_Specific_Media_Queries.css
Created May 12, 2016 00:09
iPad Specific Media Queries
@media only screen and (device-width: 768px) {
/* For general iPad layouts */
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
/* For portrait layouts only */
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
/* For landscape layouts only */
@Donmclean
Donmclean / Javascript_window_location_origin_Fix_for_IE.js
Last active May 4, 2016 23:02
window.location.origin Fix for IE
//IE FIX!!!
if (!window.location.origin) {
window.location.origin =
window.location.protocol + "//"
+ window.location.hostname + (window.location.port ? ':' + window.location.port : '');
}