Skip to content

Instantly share code, notes, and snippets.

View endymion1818's full-sized avatar
🦈
47

Ben Read endymion1818

🦈
47
View GitHub Profile
@endymion1818
endymion1818 / mustardcustard.js
Last active September 5, 2017 09:10
timeout add custard - write these files to the document if conditions for extra custard are met
// Mustard Cutting
if ('querySelector' in document && 'addEventListener' in window) {
// add class to HTML tag
(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement);
// load critical scripts
document.write(unescape("%3Cscript src='assets/js/whatcananimate-criticalscripts.min.js' type='text/javascript' defer%3E%3C/script%3E"));
// add custard if screen size is big enough
@endymion1818
endymion1818 / cdnornot.js
Created September 21, 2016 09:05
If the devide cuts the mustard, add some custard! Write from CDN, or local if that fails (after 1s)
<script type="text/javascript">
// Mustard Cutting
if ('querySelector' in document && 'addEventListener' in window) {
var windowWidth = document.body.clientWidth;
if(windowWidth > 768){
// add class to HTML tag
(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement);
// load scripts - from cdn but with a fallback
@endymion1818
endymion1818 / git config aliases
Last active October 18, 2023 15:00
Just in case my computer blows up, I have all of my git shortcuts here
[push]
autoSetupRemote = true
[user]
name = xxx
email = xxx
[core]
excludesfile = ~/.gitignore
[alias]
sla = log --oneline --decorate --graph --all
whowhen = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@endymion1818
endymion1818 / animationOnPageOut.js
Created March 22, 2016 17:12
This JS adds a delay of 500ms when a user clicks any <a> tag on the page, so that you can fire an animation class
window.onload = function(){
var links = document.getElementsByTagName('a');
for( var i=0,il = links.length; i< il; i ++ ){
links[i].onclick = clickHandler;
}
function clickHandler(event) {
@endymion1818
endymion1818 / anim.scss
Created February 16, 2016 13:48
Animation with a delay between states (sort of)
@-webkit-keyframes fadeInUp {
0% {
opacity: 0;
-webkit-transform: translateY(20px);
transform: translateY(20px);
}
10% {
opacity: 1;
-webkit-transform: translateY(0);
transform: translateY(0);
@endymion1818
endymion1818 / backToTop
Created November 18, 2015 12:28
JavaScript for a back To Top button scrolling nicely
$('.backtotop').click(function () {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});; $(document).scroll(function(){
$('.navbar').toggleClass('scrolled', $(this).scrollTop() > 1);
$('.backtotop').toggleClass('scrolled', $(this).scrollTop() > 1);
});