Skip to content

Instantly share code, notes, and snippets.

View patrinhani-ciandt's full-sized avatar

Vinicius Patrinhani patrinhani-ciandt

  • @ciandt-dev
  • Orlando, FL - USA
View GitHub Profile
@patrinhani-ciandt
patrinhani-ciandt / check-load-polyfills.js
Last active March 10, 2017 02:21
Javascript Helper to turn easy to load a polyfill library just if necessary
/*
Usage Example:
window.PolyfillHelpers.loadPolyfillLib(
// Callback condition that says if the polyfill need to be loaded or not
function () { return ('Promise' in window); },
// Polyfill lib path
'/bower_components/es6-promise/es6-promise.auto.min.js', { async: false },
// Polyfill check/load completed
function(polyfillUsed) {
@patrinhani-ciandt
patrinhani-ciandt / time-perf-helper.js
Last active October 19, 2018 07:20
Helper to wrap the console.time adding Google Analytics log functionality
window.PerfHelpers = window.PerfHelpers || {};
;(function(PerfHelpers) {
var timers = {};
PerfHelpers = window.performance || {};
PerfHelpers.now = PerfHelpers.now || function () {};
if ((!console) || (!console.time)) {
console.time = function() {};
console.timeEnd = function() {};
}
@patrinhani-ciandt
patrinhani-ciandt / requestAnimationFrameHandler.js
Created November 8, 2016 04:47
Request animation replacer to use when browser tab is unselected and you need to avoid to page load waiting to tab get focus
(function(root) {
var originalRAF = root.requestAnimationFrame;
var customRAF = function (cb) {
return setTimeout(cb, 1000 / 60);
};
var useOriginal = false;
//overwrite the function only once because other components also overwrite it
//this way, no one will have directly reference to customRAF
root.requestAnimationFrame = function(cb) {
return useOriginal ? originalRAF(cb) : customRAF(cb);
@patrinhani-ciandt
patrinhani-ciandt / moveJenkinsJobToFolder.groovy
Created September 9, 2019 16:48
Jenkins Groovy Script to move jobs to a specific folder
def FOLDER_NAME = 'target/folder/fullName'
def JOBS_FOLDER_NAME = 'jobs/search/folder/fullName'
def JOB_REGEX = 'jobs/search/folder/fullName/someRegexHere[-]([-]?[A-Za-z]+)+'
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
jenkins = Jenkins.instance
@patrinhani-ciandt
patrinhani-ciandt / queryString.js
Created September 13, 2019 16:04
React Hooks and Query String State sync
import qs from "query-string";
const setQueryStringWithoutPageReload = qsValue => {
const newurl =
window.location.protocol +
"//" +
window.location.host +
window.location.pathname +
qsValue;
window.history.pushState({ path: newurl }, "", newurl);