Skip to content

Instantly share code, notes, and snippets.

View 5iDS's full-sized avatar
💭
@ease with the Source

Max 5iDS

💭
@ease with the Source
View GitHub Profile
@5iDS
5iDS / index.html
Created June 11, 2026 14:00
Scroll Map, Split-Screen & Expandable
<section id="s">
<svg class="map" viewBox="0 0 1500 1500" preserveAspectRatio="xMidYMid slice" fill="none">
<g class="pov">
<g stroke="#223e6b" stroke-linecap="round" stroke-linejoin="round">
<image href="https://assets.codepen.io/721952/chs_map.jpg" width="1500" height="1500"/>
<path class="path" stroke-width="4" d="m741.6 937 18-52 2-28 1.7-25-25.7 3.7-1-24-41 8.3-36.7 4.4-51.3 5.3 10.3 19.7 2.7 26.3 98.7-13.2-3-35"/>
<circle class="dot-start" r="4" fill="#fff" stroke-width="2.4" cx="741.6" cy="937"/>
<circle class="dot" r="4" fill="#fff" stroke-width="2.4"/>
</g>
@5iDS
5iDS / getImageLightness.js
Created September 7, 2018 09:46
This function will convert each color to gray scale and return average of all pixels, so final value will be between 0 (darkest) and 255 (brightest).
function getImageLightness(imageSrc,callback) {
var img = document.createElement("img");
img.src = imageSrc;
img.style.display = "none";
document.body.appendChild(img);
var colorSum = 0;
img.onload = function() {
// create canvas
var Scheduler = (function () {
var tasks = [];
var minimum = 10;
var timeoutVar = null;
var output = {
add: function (func, context, timer, once) {
var iTimer = parseInt(timer);
context = context && typeof context === 'object' ? context : null;
if(typeof func === 'function' && !isNaN(iTimer) && iTimer > 0) {
tasks.push([func, context, iTimer, iTimer * minimum, once]);
@5iDS
5iDS / removeClass.js
Created April 28, 2017 08:10
Vanilla JS function to remove class from DOM elements
function removeClass(elements, myClass) {
// if there are no elements, we're done
if (!elements) { return; }
// if we have a selector, get the chosen elements
if (typeof(elements) === 'string') {
elements = document.querySelectorAll(elements);
}
@5iDS
5iDS / AddClass.js
Last active April 28, 2017 08:11
Vanilla JS function to add class on DOM elements.
function addClass(elements, myClass) {
// if there are no elements, we're done
if (!elements) { return; }
// if we have a selector, get the chosen elements
if (typeof(elements) === 'string') {
elements = document.querySelectorAll(elements);
}
@5iDS
5iDS / angular.preloadder.js
Created November 14, 2016 12:58
Directive for Preloader
/*
* Define UI Elements
* ------------------------------------------------*/
Application.Directives.uiPreloader = function () {
return {
restrict: 'AE',
scope: {},
transclude: true,
template: '<div data-ng-transclude></div>',
// ref: http://stackoverflow.com/a/1293163/2343
// This will parse a delimited string into an array of
// arrays. The default delimiter is the comma, but this
// can be overriden in the second argument.
function CSVToArray( strData, strDelimiter ){
// Check to see if the delimiter is defined. If not,
// then default to comma.
strDelimiter = (strDelimiter || ",");
@5iDS
5iDS / WPSingleUserLoggin.php
Created June 8, 2016 10:11
Wordpress Single Login Session Per User
<?php
/*
Plugin name: Single user login
Plugin URI:
Description:
Author: Ben May
Author URI: http://benmay.org/wordpress/single-user-wordpress/
Version: 0.1
*/
if( !class_exists( 'WPSingleUserLoggin' ) )
function _validate_passport( passport ) {
//Utils._strict( [ String ], arguments ); // Thirdparty Function
//trim
passport = passport.replace( /(^\s+|\s+$)/g, '' );
var passport_characters = passport.split('');
if( passport_characters.length == 9 ) {
@5iDS
5iDS / PHP Week dates
Created March 23, 2016 11:46
Return beginning and end dates of current week.
function getStartAndEndDate($week, $year)
{
$time = strtotime("1 January $year", time());
$day = date('w', $time);
$time += ((7*$week)+1-$day)*24*3600;
$return[0] = date('Y-n-j', $time);
$time += 6*24*3600;
$return[1] = date('Y-n-j', $time);
return $return;