Skip to content

Instantly share code, notes, and snippets.

View wilsonsilva's full-sized avatar

Wilson Silva wilsonsilva

View GitHub Profile
@wilsonsilva
wilsonsilva / Get Title and URL.applescript
Created May 23, 2023 00:02 — forked from vitorgalvao/Get Title and URL.applescript
AppleScript and JavaScript for Automation to get frontmost tab’s url and title of various browsers
-- AppleScript --
-- This example is meant as a simple starting point to show how to get the information in the simplest available way.
-- Keep in mind that when asking for a `return` after another, only the first one will be output.
-- This method is as good as its JXA counterpart.
-- Chromium variants include "Google Chrome", "Chromium", "Opera", "Vivaldi", "Brave Browser", "Microsoft Edge".
-- Specific editions are valid, including "Google Chrome Canary", "Microsoft Edge Dev".
-- "Google Chrome" Example:
tell application "Google Chrome" to return title of active tab of front window
library test_framework;
import 'package:unittest/unittest.dart';
// RSpec like framework
typedef Closure();
class Example {
String name;
Closure body;
@wilsonsilva
wilsonsilva / describe.sh
Created March 30, 2023 13:04
Describe code to ChatGPT
#!/bin/bash
# This script will describe the code of a Flutter app
# Get the path to the Flutter app
app_path=$(pwd)/lib
# Navigate to the app directory
cd $app_path
@wilsonsilva
wilsonsilva / nostr.rb
Created February 24, 2023 08:49
Ruby Nostr example usage
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'nostr'
require 'pry'
client = Nostr::Client.new
subscription = nil
@wilsonsilva
wilsonsilva / exs.sh
Last active May 13, 2022 05:11
Submit an exercise on Exercism without typing the filename
alias exs='exercism submit ${$(basename $PWD.go)//-/_}'
@wilsonsilva
wilsonsilva / install.sh
Created December 16, 2021 04:55
Install the latest Ruby version through asdf
brew update && \
asdf plugin update ruby && \
asdf install ruby 3.0.3
@wilsonsilva
wilsonsilva / attach.sh
Created October 23, 2020 11:08
Attach to running docker container by name
# Replace api_app_1 with the name of your container
docker inspect --format="{{.Id}}" api_app_1
@wilsonsilva
wilsonsilva / zeller.rb
Created June 18, 2020 22:47
Zeller's congruence algorithm in Ruby
# day is Numeric
# month is String
# year us Numeric
def zeller(day,month,year)
days = ['Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday']
case month
when 'January'
@wilsonsilva
wilsonsilva / install_gem_in_production_console.rb
Last active June 16, 2020 10:33
Install and use gem in production rails console
# Install the gem
`gem install hirb`
# Find the gem's location
gem_path = ENV['GEM_HOME'] + '/gems/hirb-0.7.3/lib'
$: << gem_path
# Require it
require 'hirb'
# Download the alpine image, which is more than 50% smaller than the base image
docker pull postgres:12.3-alpine
# macros is a the name of your app. My app is called "macros".
# One volume per app ensures that we can isolate and back it up independently
docker volume create macros
docker run --name postgres \
-e POSTGRES_PASSWORD=postgres -d -p 5432:5432 \
-v macros:/var/lib/postgresql/data postgres:12.3-alpine