Skip to content

Instantly share code, notes, and snippets.

View vnegrisolo's full-sized avatar

Vinicius Ferreira Negrisolo vnegrisolo

View GitHub Profile
@vnegrisolo
vnegrisolo / github-labels.sh
Last active September 3, 2016 14:53
Add github labels to my repos
#!/bin/bash
read -p $'Github \e[31musername\e[0m: ' user
echo -n $'Github \e[31mpassword\e[0m: '
read -s pass
echo ''
read -p $'Repository \e[31mowner\e[0m: ' owner
read -p $'The \e[31mrepository\e[0m: ' repo
function add_label {
@vnegrisolo
vnegrisolo / ruby_inheritance.rb
Last active September 3, 2016 14:52
Test how Ruby inheritance works and Modules
module ModuleToBeIncludedByParentClass
def parent; puts 'from included module by parent'; super if defined?(super); end
end
module ModuleToBeExtendedByParentClass
def parent; puts 'from extended module by parent'; super if defined?(super); end
end
module ModuleToBeIncludedByChildClass
def child; puts 'from included module by child'; super if defined?(super); end
end
@ggcampinho
ggcampinho / benchmark_match_domain.out
Last active August 29, 2015 14:26
Benchmark between match an email domain in a regexp versus an array
Calculating -------------------------------------
array 45.561k i/100ms
regexp 48.843k i/100ms
-------------------------------------------------
array 711.188k (± 5.8%) i/s - 3.554M
regexp 797.338k (± 5.9%) i/s - 4.005M
Comparison:
regexp: 797337.6 i/s
array: 711187.6 i/s - 1.12x slower
@vnegrisolo
vnegrisolo / mux.sh
Last active February 3, 2017 21:55
Open tmux with sessions and panes
#!/bin/sh
mux() {
if [ -z "$@" ]; then
echo 'usage ./tmux.sh <project_name> [<project2]';
fi
for project in "$@"; do
cd ${project};
@vnegrisolo
vnegrisolo / small-ruby.sh
Last active September 3, 2016 14:54
Create a ruby file and it's test for a small proof of concept
#!/bin/sh
name=$1;
if [ -z "${name}" ]; then
echo 'usage ./small-ruby <name>';
exit 1;
fi
mkdir ${name}
@vnegrisolo
vnegrisolo / elevatorsaga.js
Last active September 3, 2016 14:56
This is a nice logic challenge and a javascript training tool http://play.elevatorsaga.com/
{
Elevator: function(elevator) {
this.bindEvents = function() {
elevator.on("idle", function() {
elevator.goToFloor(0);
});
elevator.on("floor_button_pressed", function(floorNum) {
elevator.goToFloor(floorNum);
});
};
@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"
}
}
@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;
@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 / 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()];