Skip to content

Instantly share code, notes, and snippets.

View vnegrisolo's full-sized avatar

Vinicius Ferreira Negrisolo vnegrisolo

View GitHub Profile
defmodule Finder do
def run do
"find . | grep 'lib/' | grep -v 'deps/'"
|> cmd()
|> String.split("\n")
|> Enum.filter(&String.ends_with?(&1, ".ex"))
|> Enum.map(&find_test_file/1)
|> Enum.map(&find_tests/1)
|> Enum.filter(&has_missing_tests/1)
|> Map.new()
defmodule MixTests do
@commands [
"git diff --name-only",
"git diff --cached --name-only",
"git diff --name-only ..develop",
"git ls-files --others --exclude-standard",
]
def files_to_run do
@commands
@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 .
\set QUIET 1
\pset null 'ø'
\x auto
\set QUIET 0
@vnegrisolo
vnegrisolo / ruby-memoizer.rb
Created February 3, 2017 21:52
ruby-memoizer.rb
module Memoizable
module ClassMethods
@@memoizable = Hash.new
def memoize(method_name, &block)
define_method(method_name) do |*args|
puts @@memoizable
@@memoizable["#{self.class.name}|#{method_name}|#{args}"] ||= block.call(*args)
end
end
@vnegrisolo
vnegrisolo / ruby-code-reader.rb
Created February 3, 2017 21:51
ruby-code-reader.rb
class Code
class << self
def print(clazz, class_method: nil, instance_method: nil)
method = class_method ? clazz.method(class_method) : clazz.instance_method(instance_method)
puts read_method(*method.source_location)
end
private
def read_method(path, line)
@vnegrisolo
vnegrisolo / brew-update-all-packages.sh
Created September 19, 2016 18:16
brew-update-all-packages.sh
brew update;
brew outdated;
brew upgrade;
@vnegrisolo
vnegrisolo / jqueyless.js
Last active July 11, 2019 14:01
Because sometimes we don't need jquey, but still like query style
function $(selector) {
return document.querySelectorAll(selector);
}
@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();
});
});