Skip to content

Instantly share code, notes, and snippets.

View jeffersonRibeiro's full-sized avatar
:octocat:
Focusing

Jefferson Ribeiro jeffersonRibeiro

:octocat:
Focusing
View GitHub Profile
@jeffersonRibeiro
jeffersonRibeiro / nextjs-ssr-csr-auth-hoc.js
Last active September 29, 2022 12:14
Nextjs HOC to deal with authentication for SSR and CSR pages
import React from 'react';
import { Router } from 'next-router';
import getAuthSession from 'services/authSession';
function redirect(res) {
if (res) {
// SSR
res.writeHead(302, { Location: '/' });
res.end();
@jeffersonRibeiro
jeffersonRibeiro / gist:f96940fcbf14ad50b4a96d14f80bf1b0
Last active October 25, 2018 17:26
Background aspect-ratio CSS
@media screen and (min-aspect-ratio: 16/9) {
.background {
width: 100%;
height: auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
@jeffersonRibeiro
jeffersonRibeiro / isElection.js
Created October 8, 2018 13:34
remove posição para lista de sistes
/* Remove banner_slb_topo no período de eleição para páginas com régua de apuração */
(function() {
var isElection = false;
console.log('[ADS] Eleicao Ativa:', isElection);
if( isElection && hasElectionHeader() ) {
for(var i = 0; i < desktop_positions_list.length; i++) {
if(desktop_positions_list[i].id === 'banner_slb_topo') {
desktop_positions_list.splice(i, 1);
break;
}
@jeffersonRibeiro
jeffersonRibeiro / nonblock.c
Created September 14, 2018 16:15
nonblock input in C
#include <unistd.h>
#include <stdio.h>
// cc.byexamples.com calls this int kbhit(), to mirror the Windows console
// function of the same name. Otherwise, the code is the same.
bool inputAvailable()
{
struct timeval tv;
fd_set fds;
tv.tv_sec = 0;