Skip to content

Instantly share code, notes, and snippets.

View m4scosta's full-sized avatar

Marcos Costa Pinto m4scosta

  • São José dos Campos, São Paulo
  • 17:50 (UTC -03:00)
View GitHub Profile
@m4scosta
m4scosta / gist:07d8843f714954289f3eaed3c9b54fff
Created March 16, 2018 18:23
Run rubocop for only modified and added files
git status --porcelain | grep -P '^\s?[MA]\s+.*.rb' | cut -c4- | xargs rubocop
warning " > @rails/webpacker@3.0.2" has unmet peer dependency "coffeescript@>= 1.12.7 || >= 2.x".
warning "@rails/webpacker > coffee-loader@0.8.0" has unmet peer dependency "coffeescript@>= 1.8.x".
warning "@rails/webpacker > postcss-cssnext@3.0.2" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning " > bootstrap@4.0.0-beta.2" has unmet peer dependency "jquery@1.9.1 - 3".
warning " > bootstrap@4.0.0-beta.2" has unmet peer dependency "popper.js@^1.12.3".
warning " > babel-jest@21.2.0" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0".
warning " > webpack-dev-server@2.9.7" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "webpack-dev-server > webpack-dev-middleware@1.12.2" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
require 'matrix'
require 'set'
# Minesweeper board cell
class Cell
attr_accessor :bomb, :clicked, :flagged, :neighbor_bombs
def initialize(x, y, bomb = false, neighbor_bombs = 0)
@x = x
// http://stackoverflow.com/a/5624139/6111717
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}

Install dependencies

Install gparted and lilo

sudo apt-get -qy install gparted lilo
sudo liloconfig

Check disk

@m4scosta
m4scosta / docker-compose-install-ubuntu.sh
Created February 8, 2017 01:13
Installs docker and docker-compose on ubuntu machine
sudo curl -L "https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
@m4scosta
m4scosta / async.py
Created January 5, 2017 02:06
Async annotation
from threading import Thread
from functools import wraps
def async(func):
"""
Wraps the func execution with a thread.
Usage:
@m4scosta
m4scosta / consumer.py
Created January 5, 2017 01:41
Redis pubsub python
import redis
import time
def message_handler(message):
print(time.time() - float(message['data']))
def run():
r = redis.StrictRedis()
/* Demonstrates the Goldbach's conjecture - Every even integer greater than 2 can be expressed as the sum of two primes
*
* author: Igor Hercowitz
*
* usage: java Goldbach <number>
* output: the sum of the primes list
*
* ex:
* > java Goldbach 100
* 100 can be writen as: [97+3, 89+11, 83+17, 71+29, 59+41, 53+47]
@m4scosta
m4scosta / fast_rm.sh
Created October 18, 2016 12:05
Fast delete recursively
#!/bin/bash
ROOT=$1
for dir in $(find $ROOT* -maxdepth 5 -type d | sort -z); do
echo "Deleting $dir"
cd $dir
perl -e 'for(<*>){((stat)[9]<(unlink))}'
cd ..
rm -r $dir