Skip to content

Instantly share code, notes, and snippets.

View adewalegeorge's full-sized avatar
😃

Adewale George adewalegeorge

😃
View GitHub Profile
@una
una / links.md
Last active January 13, 2019 01:27
a-css-carol--links
var CommonsPlugin = new require("webpack/lib/optimize/CommonsChunkPlugin");
var webpack = new require("webpack");
module.exports = {
entry: {
home: "./scripts/home.js",
apis: "./scripts/api.js",
app: "./scripts/app.js",
vendor: "./scripts/vendor.js"
},
<?php
function my_enqueue_script() {
wp_enqueue_script(
'requirejs',
plugins_url( '/js/require.js', __FILE__ ),
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_enqueue_script' );
@makenova
makenova / Difference between debounce and throttle.md
Last active February 22, 2023 03:09
Javascript function debounce and throttle

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle

@kerimdzhanov
kerimdzhanov / random.js
Last active June 25, 2024 19:41
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {