Skip to content

Instantly share code, notes, and snippets.

View rmariuzzo's full-sized avatar
🤒
Fighting a cancer.

Rubens Mariuzzo rmariuzzo

🤒
Fighting a cancer.
View GitHub Profile
@rmariuzzo
rmariuzzo / sprintf.js
Created February 2, 2014 01:16
Simple and minimal `sprintf` function in JavaScript.
function sprintf(format) {
var args = Array.prototype.slice.call(arguments, 1);
var i = 0;
return format.replace(/%s/g, function() {
return args[i++];
});
}
@rmariuzzo
rmariuzzo / gapps-shuffle-selected-slides.gs
Created October 19, 2020 14:22
GApps Script / Shuffle selected slides
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex)
currentIndex -= 1
temporaryValue = array[currentIndex]
array[currentIndex] = array[randomIndex]
array[randomIndex] = temporaryValue
}
@rmariuzzo
rmariuzzo / get-special-repos-from-dr.js
Created October 1, 2020 18:47
Get special repos from DR
var repos = await (await fetch('https://developersdo.github.io/opensource-data/repos.json')).json()
console.log(`Repos Total: ${repos.length}`)
var specialRepos = repos.filter(repo => {
var [login, name] = repo.name.split('/')
return login === name
})
console.log(`Special Repos Total: ${specialRepos.length}`)
@rmariuzzo
rmariuzzo / ProfilerInterceptor.java
Last active July 24, 2020 06:24
How to profile Spring MVC request?
package com.mariuzzo.profiler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
#!/bin/bash
git checkout master
git pull origin master
git branch | grep -v "master\|develop" | xargs git branch -D
@rmariuzzo
rmariuzzo / auto-refresh.js
Created May 15, 2019 22:40
Refresh a web page when no mouse activity
// DO NOT COMMIT
(() => {
const keepAwake = () => {
clearTimeout(keepAwake.nod.timeoutId)
keepAwake.nod()
}
keepAwake.nod = () => {
keepAwake.nod.timeoutId = setTimeout(() => {
location.reload()
keepAwake.nod()
mkdir x-script
cd x-script
npm init
@rmariuzzo
rmariuzzo / keyframes-mixin.scss
Created November 14, 2013 19:29
Keyframes. Create a named animation sequence that can be applied to elements later.
/**
* Keyframes.
* Create a named animation sequence that can be applied to elements later.
*
* Usage:
* @include keyframes(fly) {
* from {
* transform: rotate(0deg);
* }
* to {
@rmariuzzo
rmariuzzo / pngcrushall.sh
Created November 11, 2013 03:02
Crush all PNG files in current directory.
#!/bin/sh
for file in *.png ; do pngcrush "$file" "${file%.png}-crushed.png" && mv "${file%.png}-crushed.png" "$file" ; done
@rmariuzzo
rmariuzzo / CustomValidator.php
Created October 8, 2013 04:38
A simple Laravel 4 validator that ensure the field under validation must match the format defined according to the `Carbon\Carbon::createFromFormat` method.
<?php
use Carbon\Carbon;
use Illuminate\Validation\Validator;
class CustomValidator extends Validator {
# carbon_date_format #
public function validateCarbonDateFormat($attribute, $value, $parameters)