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
@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);
});
};
@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()];
@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 / 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