Skip to content

Instantly share code, notes, and snippets.

View guifromrio's full-sized avatar

Guilherme Rodrigues guifromrio

View GitHub Profile
@guifromrio
guifromrio / nodejs-ubuntu-bind-port-80.md
Last active January 10, 2024 22:47
Allow Node.js to bind to privileged ports without root access on Ubuntu

How to: Allow Node to bind to port 80 without sudo

TL;DR

Only do this if you understand the consequences: all node programs will be able to bind on ports < 1024

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node

Important: your node location may vary. Use which node to find it, or use it directly in the command:

@guifromrio
guifromrio / compress-pdf-with-gs.md
Created August 30, 2013 14:39
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@guifromrio
guifromrio / teamcity-agent-ubuntu.md
Last active October 21, 2022 12:35
Instructions to Setup Teamcity Agent on EC2 Ubuntu 12.04.2 Linux with NodeJS and PhantomJS
@guifromrio
guifromrio / stateless-component-typescript.tsx
Created May 4, 2017 23:44
How to write a React stateless (functional) component in TypeScript
import * as React from 'react'
const Button: React.StatelessComponent<{}> = ({children}) => (
<button
className="f4 br2 grow no-underline ph5 pv3 dib white bg-dark-pink bn shadow-3 w-100 w-auto-ns b">
{children}
</button>
)
export default Button
@guifromrio
guifromrio / front-end-brasil.md
Last active July 15, 2017 12:20
O estado da comunidade brasileira de front end

Para onde caminha a comunidade brasileira de front end?

Hoje algo cômico e surreal aconteceu na comunidade FrontEnd Brasil. Algo chocante a ponto de desanimar o mais engajado dos participantes.

Após postar um Gist sobre moment com um código bastante didático, Berger foi rechaçado pelo moderador da comunidade, Jean Carlo Nascimento. Ao notar que o gist era escrito em CoffeeScript, o moderador comentou uma piadinha:

Prefiro usar moment a coffee.

A comunidade não gostou e reagiu, criticando o comentário infeliz e prezando o autor por compartilhar um código útil. Não satisfeito, as agressões sobre o uso de CoffeeScript continuaram.

@guifromrio
guifromrio / stateless-component-typescript-error.tsx
Last active May 4, 2017 23:43
How to write a React stateless (functional) component in TypeScript
import * as React from 'react'
const Button = ({children}) => (
<button
className="f4 br2 grow no-underline ph5 pv3 dib white bg-dark-pink bn shadow-3 w-100 w-auto-ns b">
{children}
</button>
)
export default Button

VTEX Render - Straight to React

Production-ready Universal React Apps in 5 minutes

Publishing a fast, production-ready server side rendered React app takes a lot of effort. Platforms, build servers, CI, CD, CSS frameworks... So many choices, so little time.

VTEX Render is a web framework that let's you go "Straight to React"®. You just need an editor and a small CLI to sync your files. Updates are blazing-fast and it even does hot module replacement. By using GraphQL for data fetching, functional CSS for styling and a robust component library, developers create beautiful apps in hours, not weeks. Not only that: non-technical users can customize VTEX Render apps in a beautiful WYSIWYG interface.

VTEX Render is a refreshingly simple approach to building scalable web apps, fast.

Keybase proof

I hereby claim:

  • I am firstdoit on github.
  • I am firstdoit (https://keybase.io/firstdoit) on keybase.
  • I have a public key whose fingerprint is E635 402F DFAB 17A0 D560 C3AC A0DA EDB7 003A C77F

To claim this, I am signing this object:

_.chain(students)
.filter(isApproved)
.pluck('grades')
.flatten()
.min() // Can you guess what this does?
.value()
// 6
_.every(studentsByClass["A"], isApproved) // false
_.every(studentsByClass["B"], isApproved) // true