Skip to content

Instantly share code, notes, and snippets.

View jonasporto's full-sized avatar
⌨️
Working and having fun!

Jonas Porto jonasporto

⌨️
Working and having fun!
  • Rio de Janeiro, Brazil
View GitHub Profile
@jonasporto
jonasporto / optimize.sh
Created January 11, 2018 14:11 — forked from ryansully/optimize.sh
image optimization script (pngcrush & jpegtran)
#!/bin/sh
# script for optimizing images in a directory (recursive)
# pngcrush & jpegtran settings from:
# http://developer.yahoo.com/performance/rules.html#opt_images
# pngcrush
for png in `find $1 -iname "*.png"`; do
echo "crushing $png ..."
pngcrush -rem alla -reduce -brute "$png" temp.png
@jonasporto
jonasporto / README.md
Created March 1, 2018 20:04 — forked from nnarhinen/README.md
Rails-like console with express.js, bookshelf.js and node-repl-promised

Install node-repl-promised: npm install -g repl-promised

Use the repl to list all users

$ node-promised
> var app = require('./app');
undefined
> var Bookshelf = app.get('bookshelf');
undefined
@jonasporto
jonasporto / cloudSettings
Created March 21, 2018 17:00 — forked from pgsill/cloudSettings
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-03-20T18:34:45.265Z","extensionVersion":"v2.9.0"}
@jonasporto
jonasporto / random.md
Created March 26, 2018 14:00 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@jonasporto
jonasporto / rspec_rails_cheetsheet.rb
Created April 22, 2018 14:59 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@jonasporto
jonasporto / capybara.md
Created April 22, 2018 15:00 — forked from steveclarke/capybara.md
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@jonasporto
jonasporto / capybara cheat sheet
Created April 22, 2018 15:02 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@jonasporto
jonasporto / _readme.md
Created April 24, 2018 15:02 — forked from diegoos/_readme.md
Script to deploy gh-pages for Vue (Webpack) projects

Setup

Copy the deploy.sh on root of your project.

Deploy

Just run ./deploy.sh

@jonasporto
jonasporto / _readme.md
Created April 24, 2018 15:02 — forked from diegoos/_readme.md
Script to deploy gh-pages for Vue (Webpack) projects

Setup

Copy the deploy.sh on root of your project.

Deploy

Just run ./deploy.sh

@jonasporto
jonasporto / ruby_rails_windows.md
Created May 3, 2018 12:00 — forked from KelseyDH/ruby_rails_windows.md
Ruby on Rails Microsoft Windows Troubleshooting Tips

Ruby on Rails Windows Troubleshooting Tips & Survival Guide

Intro/Overview

The Ruby on Rails Windows Troubleshooting tips & Survival Guide is a random catalogue of issues I faced working with Ruby on Rails on Windows (Windows 7 specifically). This guide is not exhaustive, but covers many of the challenges that causes Windows Ruby developers to jump ship to Linux or Mac. If you're reading this guide then you're probably new to Ruby/Rails, so also included is more general beginner advice to help you get going.

Personal Side Note

Before you follow this guide, I strongly recommend you consider using Linux or Mac OS X for Ruby Development instead. Looking to prove a point as a challenge, I ignored this strongly given advice while learning Ruby/Rails. While I eventually did succeed in getting Ruby on Rails to work in Windows, it was not easy, and I easily lost 40+ hours on StackOverFlow to Windows/Ruby configuration issues--time I could have devoted to learning more about th