Skip to content

Instantly share code, notes, and snippets.

View guifromrio's full-sized avatar

Guilherme Rodrigues guifromrio

View GitHub Profile
@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 / 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 / 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 / registry-report.coffee
Created February 12, 2015 17:15
Simple report for number of versions for each app in registry.json
_ = require 'underscore'
registry = require './registry.json'
console.log 'Existing packages: ' + Object.keys(registry).length
console.log 'Grouped by appType:'
groupedByAppType = _.groupBy registry, 'appType'
for k, v of groupedByAppType
console.log k, v.length
// View (a template)
<p>First name: <input data-bind=”value: firstName” /></p>
<p>Last name: <input data-bind=”value: lastName” /></p>
<h2>Hello, <span data-bind=”text: fullName”> </span>!</h2>
// ViewModel (diplay data… and logic?)
var ViewModel = function(first, last) {
this.firstName = ko.observable(first);
this.lastName = ko.observable(last);
// View (a template)
<div ng-controller=”HelloController as hello”>
<label>Name:</label>
<input type=”text” ng-model=”hello.firstName”>
<input type=”text” ng-model=”hello.lastName”>
<h1>Hello {{hello.fullName()}}!</h1>
</div>
// Controller
angular.module(‘helloApp’, [])
var Hello = React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
React.render(
<Hello name=”World” />,
document.getElementById(‘container’)
);
var Hello = React.createClass({displayName: "Hello",
render: function() {
return React.createElement("div", null, "Hello ", this.props.name);
}
});
React.render(
React.createElement(Hello, {name: "World"}),
document.getElementById('container')
);
var CommentList = React.createClass({
render: function() {
var commentNodes = this.props.data.map(function (comment) {
return (
<Comment author={comment.author}>
{comment.text}
</Comment>
);
});
return (