Skip to content

Instantly share code, notes, and snippets.

View herber's full-sized avatar
🦄
Focusing

Tobias Herber herber

🦄
Focusing
View GitHub Profile
@oaluna
oaluna / index.html
Created December 8, 2020 18:43
Stripe Website Gradient Animation
<html>
<head>
<title>Stripe Gradient</title>
</head>
<body>
<canvas id="gradient-canvas" data-js-darken-top data-transition-in>
<!--
Remove data-js-darken-top to keep the same brightness in the upper part of the canvas
-->
</canvas>
@Pragalbha-Patil
Pragalbha-Patil / script.js
Created August 11, 2019 14:46
A javascript Tic-tac-toe using Minimax algorithm
var origBoard;
const huPlayer = 'O';
const aiPlayer = 'X';
const winCombos = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
@herber
herber / container
Last active November 12, 2016 14:49
a simple node js container platform
const execFile = require('child_process').execFile;
var portSet = function(port, fn) {
var net = require('net')
var tester = net.createServer()
.once('error', function (err) { if (err.code != 'EADDRINUSE') return fn(err); fn(null, true) })
.once('listening', function() {
tester.once('close', function() { fn(null, false) })
.close()
})
@jjmu15
jjmu15 / in_viewport.js
Created January 27, 2014 10:19
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible 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)
);