Skip to content

Instantly share code, notes, and snippets.

View vnegrisolo's full-sized avatar

Vinicius Ferreira Negrisolo vnegrisolo

View GitHub Profile
@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@vnegrisolo
vnegrisolo / Dockerfile.erd
Last active October 16, 2017 08:31
ERD from text file
FROM haskell:7.8.4
RUN apt-get update && apt-get --assume-yes install graphviz vim curl git
RUN cabal update && cabal install graphviz parsec text && cabal install erd
COPY graph.in .
@vnegrisolo
vnegrisolo / markdown-code-highlighter-logger.js
Last active September 27, 2016 03:34
I created my own solarized theme colors for my blog with markdown code snippets. This is used to list all colors used by css class and lang, so I can adjust the colors used.
Array.prototype.uniq = function(){ return $.unique(this.sort()); };
log = (msg, bg, c)=> console.log('%c'+msg, 'background: '+bg+'; color: '+c);
classes = $('.highlighter-rouge pre code span').map((_,x)=> $(x).attr('class')).toArray().uniq();
languages = $('.highlighter-rouge .header').map((_,x)=> $(x).data('lang')).toArray().uniq();
classes.forEach(function(css){
log('=> '+css+' ','#eee8d5','#268bd2');
languages.forEach(function(lang){
log(' '+lang+' ', '#eee8d5','#2aa198');
nodes = $('.highlighter-rouge.language-'+lang+' pre code span.'+css);
texts = nodes.map((_,x)=> $(x).text()).toArray().uniq();
@vnegrisolo
vnegrisolo / clicker.js
Created September 3, 2016 14:30
Sometimes you want to click them all. Find all elements using css selector and click them every 1 sec. I used to download all code samples from chrome extensions documentation.
var selector = 'h2 a';
var list = document.querySelectorAll(selector);
console.log('#elements to click', list.length);
list.forEach(function(el, i){
new Promise((resolve) => setTimeout(resolve, 1000*i)).then(() => {
console.log(i, el);
el.click();
});
});
@vnegrisolo
vnegrisolo / ruby_memory.rb
Last active September 3, 2016 14:56
Inspect memory used by a Ruby process
MEM = "ps ax -o pid,rss | grep -E '^[[:space:]]*#{$$}' | awk '{print $2}'"
def mem
`#{MEM}`.strip.to_i
end
@vnegrisolo
vnegrisolo / time-travel.js
Created June 20, 2016 20:02
Time travel feature to be used in tests. This overrides `new Date()` to use the specified date, otherwise will call the original implementation.
// usage:
// import { travelTo, travelToPresent } from '../helpers/time-traveling';
//
// beforeEach() { travelTo(2016, 6, 10); },
// afterEach() { travelToPresent(); }
//
const DateOriginal = Date;
export function travelToPresent() {
window.Date = DateOriginal;
@vnegrisolo
vnegrisolo / date-monkey-patches.js
Created June 20, 2016 19:56
Some Date monkey patches, because I don't need to use `moment js` and javascript Date is as useful as airplane horn
Date.prototype.advanceDays = function(days) {
let d = new Date(this);
return new Date(d.setDate(this.getDate() + days));
};
Date.prototype.beginningOfWeek = function() {
return this.advanceDays((this.getDay() == 0 ? -6 : 1) - this.getDay());
};
Date.prototype.getWeekName = function() {
return ['S', 'M', 'T', 'W', 'T', 'F', 'S'][this.getDay()];
@vnegrisolo
vnegrisolo / update-ember-versions.sh
Last active September 3, 2016 14:51
How to update ember, ember-data, npm packages and bower packages
# https://www.npmjs.com/package/npm-check-updates
bower install --save ember#release
npm install --save-dev emberjs/data#release
npm outdated
ncu
ncu -a
ncu -u
npm install
@vnegrisolo
vnegrisolo / backup.sh
Last active September 3, 2016 14:56
Simple backup script
# remove unwanted files:
find . -type f -name 'index.html' -print0 | xargs -0 echo
for f in * ; do echo "f='${f}'"; tar -czf ${f}.tar.gz ${f}; done;
@chrismccord
chrismccord / 1.js
Created April 7, 2016 02:50 — forked from net/1.js
Adding Bootstrap to Phoenix using NPM
// 1. Add Bootstrap as a dependency in package.json
{
...
"dependencies": {
...
"bootstrap": "~3.3.6"
}
}