Skip to content

Instantly share code, notes, and snippets.

View codecandies's full-sized avatar
😸
Pffffft.

Nico Brünjes codecandies

😸
Pffffft.
View GitHub Profile
@codecandies
codecandies / isInViewport.js
Created March 13, 2017 08:47
determing if an element is in the viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
}
@codecandies
codecandies / eventlistener.js
Created March 13, 2017 08:46
plain vanilla js event listener example
// Select all links
var links = document.querySelectorAll("a");
// For each link element
[].forEach.call(links, function(el) {
// Add event listener
el.addEventListener("click", function(event) {
event.preventDefault();
alert("You clicked");
@codecandies
codecandies / network_home.md
Created January 30, 2017 08:05
Wordpress Network Home URL

Use network_home_url( $path = '', $scheme = null ).
You can see it in /wp-includes/link-template.php.
Examples:

// Root of main site
$network_home = network_home_url();

// About page on main site
$network_about = network_home_url( 'about/' );
@codecandies
codecandies / test_wait_for_pageload.py
Created January 27, 2017 15:41
Selenium wait for page to load complete
old_page = browser.find_element_by_tag_name('html')
browser.find_element_by_link_text('my link').click()
try:
WebDriverWait(driver, 20).until(
expected_conditions.staleness_of(old_page))
assert True
except TimeoutException:
assert False
@codecandies
codecandies / zon-menu.txt
Created September 13, 2016 09:02 — forked from thomaspuppe/zon-menu.txt
ZEIT Speiseplan. This serves as data source for our SlackBot
Tage;Essen1;Nachtisch1;Essen2;Nachtisch2;Essen3
05.10.2015;Lasagne mit Rinderhack und Gemüse Tomaten-Soße Gurkensalat;Erdbeerquark;Pakoras gebackenes Gemüse mit verschiedenen Dips ;Granatapfelcreme;Orientalischer Salat mit Ingwer, Chili, Wakame-Algen, Sushi-Rolls, Wasabi-Dip Soja-Soße, Kroepoek
06.10.2015;Rheinischer Sauerbraten* vom Rind, Rosinensoße, Rotkohl, Kartoffelklöße;Schokoladencreme mit Birnenkompott;Paprikaschoten mit Tofu-Gemüse-Füllung Möhrensoße gebackene Kartoffelwürfel;Quarkklöße mit Pflaumenröster;Herbstlicher Salat mit Chicoree, Papaya, Soja-Limetten-Dressing und gebratener Hähnchenbrust, Baguette
07.10.2015;Linseneintopf mit Kochwurst;Spanischer Mandelkuchen;Kartoffel-Sellerie-Puffer mit Apfelschmand, Rote Bete-Salat;Banane und Kiwi;Blumenkohl-Broccoli-Salat mit Tomaten, Kürbiskernen, Kerbel-Vinaigrette, Zwiebelkuchen und Sour Cream
08.10.2015;Hechtklöße, Blattspinat, Safransoße*, Pariser Kartoffeln;Mandarinen-Vanille-Creme;Auberginenschnitzel in einer Parmesan-Eihülle, Kräuterquark, Pellk
@codecandies
codecandies / inline-svg.html
Created April 6, 2016 12:54
Inline SVG Code
<svg class="svg-symbol" role="img" aria-labelledby="title-suche" viewBox="0 0 16 16" width="16" height="16" preserveAspectRatio="xMinYMin meet">
<title id="title-suche">Suche</title>
<path d="M15.32 13.34l-4.17-4.203a5.62 5.62 0 0 0 .835-2.944C11.985 3.076 9.45.54 6.332.54S.68 3.076.68 6.193s2.536 5.653 5.653 5.653c.95 0 1.844-.238 2.63-.653L13.2 15.46l2.12-2.12zM2.68 6.19c0-2.014 1.64-3.652 3.653-3.652s3.653 1.64 3.653 3.652c0 2.015-1.64 3.653-3.653 3.653S2.68 8.207 2.68 6.192z"/>
</svg>
@codecandies
codecandies / clamp.js
Created November 19, 2015 10:13
Clamp
var clamp = function (n, min, max) {
return Math.max(min, Math.min(max, n));
};
@codecandies
codecandies / pulse.sass
Created October 7, 2015 12:54
Pulsating div
+keyframes(smoothPulse)
to
background-color: rgba(#eee, 0.6)