Skip to content

Instantly share code, notes, and snippets.

View defmech's full-sized avatar

David Lochhead defmech

View GitHub Profile
@iamrealfarhanbd
iamrealfarhanbd / ninja_table_search_time_delay_filter.php
Created December 15, 2023 06:42
Code snippet to modify the delay time for Ninja Tables filter functionality.
/**
* Adjust the delay time for Ninja Tables filter functionality.
*
* @param int $delayTime The default delay time in milliseconds.
* @param int $tableId The ID of the Ninja Table.
* @return int The modified delay time.
*/
add_filter('ninja_table_search_time_delay', function ($delayTime, $tableId) {
if ($tableId == 1) {
@denvercoder
denvercoder / roots
Last active February 6, 2023 01:50
My script to setup Roots.io Bedrock and Sage alongside Local by Flywheel
#!/bin/bash
cd ~/Local\ Sites/$1/app/
echo Installing Bedrock... Please Wait
composer create-project roots/bedrock
rm -rf public
@TimvanScherpenzeel
TimvanScherpenzeel / .htaccess
Created May 8, 2019 13:28
Client side routing fix on reload
# BEGIN ROUTING
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
# END ROUTING
@Klerith
Klerith / base64ToBlob.js
Last active February 24, 2023 06:05
JavaScript: Base64 image to Blob
// String base 64 to blob
function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
@DejanBelic
DejanBelic / async await ie11.js
Last active May 11, 2023 15:09
How to use async await in ie11
// Async await func
async function getTimelineData() {
var response = await fetch('/some-api-url')
return response.json()
}
async function populateTimelineInit() {
var data = await getTimelineData();
new vis.DataSet(data);
@companje
companje / map.glsl
Created January 23, 2018 22:46
map() function for GLSL known from Processing & openFrameworks
float map(float value, float min1, float max1, float min2, float max2) {
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}
@jh3y
jh3y / getCursorXY.js
Last active February 26, 2023 23:44
get text cursor position
/**
* returns x, y coordinates for absolute positioning of a span within a given text input
* at a given selection point
* @param {object} input - the input element to obtain coordinates for
* @param {number} selectionPoint - the selection point for the input
*/
const getCursorXY = (input, selectionPoint) => {
const {
offsetLeft: inputX,
offsetTop: inputY,
@nicktesla2011
nicktesla2011 / ViewController.swift
Created September 23, 2017 21:36
WKWebView View Controller for Xcode 9.0/Swift 4/iOS11
//
// ViewController.swift
// Honk
//
// Created by Nick Gressle on 9/23/17.
// Copyright © 2017 nick gressle illustrations llc. All rights reserved.
//
import UIKit
import WebKit
@deanhume
deanhume / clear-cache.js
Created September 20, 2017 08:22
Clear Service Worker Cache
if ('serviceWorker' in navigator) {
caches.keys().then(function(cacheNames) {
cacheNames.forEach(function(cacheName) {
caches.delete(cacheName);
});
});
}
@stolinski
stolinski / keybindings.json
Created June 21, 2017 23:10
VSCode Tab Switching Keybindings
[
{ "key": "ctrl+1", "command": "workbench.action.focusFirstEditorGroup" },
{ "key": "ctrl+2", "command": "workbench.action.focusSecondEditorGroup" },
{ "key": "ctrl+3", "command": "workbench.action.focusThirdEditorGroup" },
{ "key": "cmd+1", "command": "workbench.action.openEditorAtIndex1" },
{ "key": "cmd+2", "command": "workbench.action.openEditorAtIndex2" },
{ "key": "cmd+3", "command": "workbench.action.openEditorAtIndex3" },
{ "key": "cmd+4", "command": "workbench.action.openEditorAtIndex4" },
{ "key": "cmd+5", "command": "workbench.action.openEditorAtIndex5" },
{ "key": "cmd+6", "command": "workbench.action.openEditorAtIndex6" },