Skip to content

Instantly share code, notes, and snippets.

View davidverhage's full-sized avatar

Monoquo davidverhage

View GitHub Profile
@davidverhage
davidverhage / functions.php
Created November 16, 2021 09:10
Wordpress Tip: keep your function.php file clean
<?php
//Loading all php files from the functions/ folder
//this keeps your wordpress functions file clean
//and you can split up your function build up by parsing functionality in different files.
$folder = get_template_directory()."/functions/";
$files = glob($folder."*.php"); // return array files
foreach($files as $phpFile){
require_once("$phpFile");
}
@davidverhage
davidverhage / id-to-name.js
Created October 29, 2021 15:58
Proud to be lazy Form namer
/*
* Doemela | PROJECT070
* Clean function to use id as name for form inputs
*/
function setNameAttribute(){
var inputs = document.getElementById("deathnotice").elements;
// Iterate over the form controls
for (let i = 0; i < inputs.length; i++) {
// for the current found input collect the input ID
let id = inputs[i].id;
@davidverhage
davidverhage / CsvArr.php
Created September 3, 2020 09:34
Associative array from CSV
<?php
/* Thanks to http://steindom.com/articles/shortest-php-code-convert-csv-associative-array */
ini_set('auto_detect_line_endings', TRUE);
$rows = array_map('str_getcsv', file('myfile.csv'));
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta description="Lang leve de lol">
<meta keywords="javascript,les,101,">
<title>Title</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"
@davidverhage
davidverhage / scrollon-off.js
Created November 19, 2018 19:38
Very handy function to avoid overflow on pages that are not to be scrolled
function reloadScrollBars() {
document.documentElement.style.overflow = 'auto'; // firefox, chrome
document.body.scroll = "yes"; // ie only
}
function unloadScrollBars() {
document.documentElement.style.overflow = 'hidden'; // firefox, chrome
document.body.scroll = "no"; // ie only
}
@davidverhage
davidverhage / change-class-on-scroll.html
Created January 25, 2018 09:44 — forked from ohiosveryown/change-class-on-scroll.html
Vanilla JS – change/add class based on scroll position.
<div id="header"></div>
<style>
#header {
position: fixed;
background: pink;
height: 72px;
width: 100%;
opacity: 0.2;
transition: all 300ms ease;
@davidverhage
davidverhage / sniffer.js
Created January 8, 2018 20:34
Dirty Mobile Sniffer
/**
* Quick & dirty browser sniff to detect mobile devices.
*/
var html = document.getElementsByTagName('html')[0];
var staticClass = 'static-site'
var dynamicClass = 'dynamic-site'
if (
navigator.userAgent.match(/Android/i) ||
/**
* Modify the parts you need to get it working.
*/
var should = require('should');
var request = require('../node_modules/request');
var io = require('socket.io-client');
var serverUrl = 'http://localhost';
$(document).ready(function() {
$.ajaxSetup({ cache: true });
$.getScript('//connect.facebook.net/en_US/sdk.js', function(){
FB.init({
appId: '{your-app-id}',
version: 'v2.7' // or v2.1, v2.2, v2.3, ...
});
$('#loginbutton,#feedbutton').removeAttr('disabled');
FB.getLoginStatus(updateStatusCallback);
});
<noscript>
Om deze site optimaal te gebruiken is het noodzakelijk om Javascript aan te zetten.
</noscript>