Skip to content

Instantly share code, notes, and snippets.

debounce = function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
anonymous
anonymous / funcs.js
Created January 6, 2016 15:49
7 js function
debounce = function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
@crazy4groovy
crazy4groovy / database-connections.groovy
Last active October 17, 2016 20:39 — forked from jpertino/databaseConnection.groovy
several database connectors and drivers
// PostgreSQL
@GrabConfig(systemClassLoader=true)
@Grab('postgresql:postgresql:9.4-1211.jdbc4')
def sql = groovy.sql.Sql.newInstance(
"jdbc:postgresql://host.example.org/database",
"username", "password", "org.postgresql.Driver")
// MySQL
@GrabConfig(systemClassLoader=true)
@crazy4groovy
crazy4groovy / g-images-bookmarklet.js
Last active July 14, 2017 13:45
Scrape Google images search results
!function(document) {
var d = document.createElement('div');
d.style.cssText='position: fixed; top: 1em; left: 1em; z-index: 1000; background-color: rgba(188,188,88,.5); padding: 1em; border-radius: 1em; max-height: 50%; max-width: 50%; overflow: scroll;'
d.ondblclick=d.remove;
document.body.appendChild(d);
var matches = [];
function eachEl(selector, cb) {
[].forEach.call(document.querySelectorAll(selector), cb);
}
var delay = +prompt('delay in ms', '250');
@paulirish
paulirish / what-forces-layout.md
Last active April 24, 2025 09:45
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@paulirish
paulirish / bling.js
Last active February 18, 2025 14:08
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
@lukehedger
lukehedger / ffmpeg-compress-mp4
Last active April 25, 2025 04:01
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@nocturnalgeek
nocturnalgeek / MailinatorAliases
Last active August 21, 2024 01:58
A list of alternate domains that point to @mailinator.com
@binkmail.com
@bobmail.info
@chammy.info
@devnullmail.com
@letthemeatspam.com
@mailinater.com
@mailinator.net
@mailinator2.com
@notmailinator.com
@reallymymail.com
@soheilhy
soheilhy / nginxproxy.md
Last active April 11, 2025 06:29
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@ysb33r
ysb33r / build.gradle
Created May 17, 2014 09:53
HOWTO ignore spock tests when gradle is run offline
// Check whether --offline was passed to gradle and set it in the test configuration's system properties
test {
if(gradle.startParameter.isOffline()) {
systemProperties 'TESTS.ARE.OFFLINE' : '1'
}
}