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 / 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()
@isthatcentered
isthatcentered / DeepPartial.ts
Last active June 19, 2020 05:26
Typescript - Deep Partial
https://stackoverflow.com/questions/45372227/how-to-implement-typescript-deep-partial-mapped-type-not-breaking-array-properti/49936686#49936686
export type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U>
? Array<DeepPartial<U>>
: T[P] extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: DeepPartial<T[P]>
};
@nathansmith
nathansmith / [1] Render.js
Last active October 13, 2021 17:13
React component to conditionally (not) render child components.
/*
// Used like so…
<Render if={isUserAuthenticated}>
<p>
Super secret UI.
</p>
</Render>
*/
import React from 'react';
@branneman
branneman / count-lint-errors.js
Last active July 31, 2023 17:59
Group-By-Count ESLint errors
// :: (String, String) => String
const spawn = require('child_process').spawnSync;
// :: String => [String]
const getRules = raw => raw
.split('\n')
.map(line => line.trim())
.filter(line => !!line)
.filter(line => line[0] !== '/' && line[0] !== '✖')
.map(line => line.match(/[a-z-]+$/)[0]);
@ryan0x44
ryan0x44 / Terraform-Blue-Green-AWS.md
Created November 19, 2015 21:57
Blue-Green AWS Auto Scaling Deployments with Terraform

A quick note on how I'm currently handling Blue/Green or A/B deployments with Terraform and AWS EC2 Auto Scaling.

In my particular use case, I want to be able to inspect an AMI deployment manually before disabling the previous deployment.

Hopefully someone finds this useful, and if you have and feedback please leave a comment or email me.

Overview

I build my AMI's using Packer and Ansible.

@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;
// ----
// 1. natural spacing
var foo = 'foo';
var bar = 'bar';
var superCalaFragilistic = '...';
// ----
// 2. aligning the `=` sign
...
// _repository is a GenericRepository<Villa>.
var villas = _repository
.Get(
q => q.Select(s => new VillaDto {
Id = s.PodId,
Name = s.Name,
Price=s.Price,
# Debugging Android Stock Browser using Weinre and Ngrok
This doc will show how to debug any mobile browser that doesn't have a good debug tool.
If your local website can be exposed to your device, you don't need install the Ngrok.
## Step-by-step
- Install the weinre app: `sudo npm -g install weinre`
@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++];
});
}