Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Greuter ludder

View GitHub Profile
@ludder
ludder / slideDown.js
Created Dec 6, 2012
Vanilla JavaScript slideUp and slideDown functions
View slideDown.js
/*
Element to slide gets the following CSS:
max-height: 0;
opacity: 0;
overflow: hidden;
transition: max-height 0.4s ease 0s;
*/
/**
* Like jQuery's slideDown function - uses CSS3 transitions
@ludder
ludder / fadeInSection.js
Created Feb 4, 2020
Fade in React elements when scrolling in view
View fadeInSection.js
// https://dev.to/selbekk/how-to-fade-in-content-as-it-scrolls-into-view-10j4
import React from "react";
import styled from "styled-components";
const Section = styled.div`
opacity: 0;
transform: translateY(20vh);
visibility: hidden;
transition: opacity 1200ms ease-out, transform 600ms ease-out,
visibility 1200ms ease-out;
@ludder
ludder / getParentByTagName.js
Created Nov 9, 2012
getParentByTagName - Get parent node for given tagname
View getParentByTagName.js
/**
* Get parent node for given tagname
* @param {Object} node DOM node
* @param {String} tagname HTML tagName
* @return {Object} Parent node
*/
function getParentByTagName(node, tagname) {
var parent;
if (node === null || tagname === '') return;
parent = node.parentNode;
View ios-hacks.js
/*! A fix for the iOS orientationchange zoom bug.
Script by @scottjehl, rebound by @wilto.
MIT / GPLv2 License.
Source: https://github.com/scottjehl/iOS-Orientationchange-Fix
Explanation: http://adactio.com/journal/4470/
*/
// No code, check source above
@ludder
ludder / .bashrc
Created Nov 1, 2016
Open ios simulator from command line in OSX
View .bashrc
# Add to .bashrc
alias ios='open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'
@ludder
ludder / grep-search
Last active Dec 28, 2015
Simple grep command looking for string in files in (sub)directories
View grep-search
@ludder
ludder / Running Grunt or Codeception on Git pre-commit hook
Last active Dec 27, 2015
Running Grunt or Codeception on Git pre-commit hook
View Running Grunt or Codeception on Git pre-commit hook
echo "Start Git pre commit hook"
#!/bin/sh
# stash unstaged changes, run release task, stage release updates and restore stashed files
NAME=$(git branch | grep '*' | sed 's/* //')
# don't run on rebase
if [ $NAME != '(no branch)' ]
then
View hasNextElementSibling.js
/*
Returns true if element has next sibling (of type element)
*/
function hasNextSibling(node) {
var bln = false;
while( (node = node.nextSibling) !== null ) {
if (node.nodeType !== 1) {
continue;
}
bln = true;
@ludder
ludder / classList.js
Created Dec 6, 2012
Backwards compatible classList functions
View classList.js
/**
* Check element has a certain classname
* We cannot use classList yet because of browser support
* @param {Object} ele DOM element
* @param {String} cls Classname
* @return {Boolean} True is classname is found
*/
function hasClass(ele,cls) {
if (ele === null || cls === '') return false;
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
@ludder
ludder / pre-commit
Created Feb 13, 2015
Update package.json version number on git commit
View pre-commit
#!/bin/sh
#
npm version patch
git add package.json
exit 0
You can’t perform that action at this time.