Skip to content

Instantly share code, notes, and snippets.

View thalesmello's full-sized avatar
💭
Let's data

Thales Mello thalesmello

💭
Let's data
  • Lyft
  • San Fransisco
View GitHub Profile
@thalesmello
thalesmello / close_distractions.js
Created November 22, 2018 09:07
Close distractions using JavaScript for Automation (JXA) for Mac OS
var app = Application.currentApplication()
app.strictParameterType = true
var sitesBlacklist = [
/reddit.com$/,
/youtube.com$/,
]
var appsBlacklist = [
"Slack",
"WhatsApp",
" Settings
set nosmoothscroll
set noautofocus " The opposite of autofocus; this setting stops
" sites from focusing on an input box when they load
let searchlimit = 30
let scrollstep = 70
let barposition = "top"
" alias ':g' to ':tabnew google'
command g tabnew google
convert = (function () {
return {
toString: toString,
toNumber: toNumber,
toArray: toArray,
}
function toString(value) {
if (typeof value === 'undefined' || value === null) return '';
return String(value);
@thalesmello
thalesmello / gist:d6f2083dd53a4b340613
Created July 29, 2014 21:04
google spreadsheets difference
function difference(old_one, new_one){
var difference = [];
new_one.forEach(function(new_el){
var common = false;
old_one.forEach(function(old_el){
if(old_el[0] === new_el[0]){
common = true;
}
});
if(!common){
def histogram(data, bins = 10, length = 100)
min, max = data.minmax
mod = max - min
histog = data.group_by { |v| ((v - min).to_f / mod * bins).to_i }.map { |bin, values| [bin, values.count] }.to_h
max_value = histog.map { |_, value| value }.max
histog_array = [0] * bins
histog = histog.each { |bin, value| histog_array[bin] = (value.to_f / max_value * length).to_i }
puts histog_array.to_s
puts min.to_s + " " * length + max_value.to_s
histog_array.each { |value| puts "*" * value.to_i }
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@thalesmello
thalesmello / thales.ahk
Last active July 22, 2022 17:51
This is the Autohotkey script I use on a daily basis. I use it to play/pause my webplayers, move and resize my windows, add new tasks to Any.do and toggle my windows in fullscreen mode.
#NoEnv
#Include %A_ScriptDir%
#Include VA.ahk
#SingleInstance force
SetTimer,UPDATEDSCRIPT,1000
OnExit, EXITSCRIPT
HomePath = C:\Users\ThalesErnesto
; Media control
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')