Skip to content

Instantly share code, notes, and snippets.

@vahidk
vahidk / colorTransform.js
Last active July 9, 2024 15:48
Convert RGB to HSL and vice versa in Javascript.
// This code is based on https://en.wikipedia.org/wiki/HSL_and_HSV
// Free to use for any purpose. No attribution needed.
function rgbToHsl(r, g, b) {
r /= 255; g /= 255; b /= 255;
let max = Math.max(r, g, b);
let min = Math.min(r, g, b);
let d = max - min;
let h;
if (d === 0) h = 0;
@sliceofbytes
sliceofbytes / txt-to-google-keep-notes.py
Created February 14, 2018 22:16
Add Text Files as Google Keep Notes
#Import a directory of text files as google keep notes.
#Text Filename is used for the title of the note.
import gkeepapi, os
username = 'username@gmail.com'
password = 'your app password'
keep = gkeepapi.Keep()
success = keep.login(username,password)
@ECHO OFF
ECHO ----------------------------------------------------------
ECHO Google Drive FS - Silent Change Mountpoint Utility v0.0001
ECHO ----------------------------------------------------------
REM Scripted: Marc Vandael - 25/01/2018
REM Change the var _mountpoint to whatever driveletter you would like.
REM If the letter is in use, the next free one will be used.
REM This attempts to write to HKLM & HKCU so admin rights are needed for this to work.
@yairEO
yairEO / jQuery.ajaxRetry.js
Last active January 12, 2022 14:55
jQuery AJAX smart retry
// enhance the original "$.ajax" with a retry mechanism
$.ajax = (($oldAjax) => {
// on fail, retry by creating a new Ajax deferred
function check(a,b,c){
var shouldRetry = b != 'success' && b != 'parsererror';
if( shouldRetry && --this.retries > 0 )
setTimeout(() => { $.ajax(this) }, this.retryInterval || 100);
}
return settings => $oldAjax(settings).always(check)