Skip to content

Instantly share code, notes, and snippets.

View wilsonsilva's full-sized avatar

Wilson Silva wilsonsilva

View GitHub Profile
@bizz84
bizz84 / macOS-Podfile
Last active October 5, 2023 01:42
macOS Podfile template for Flutter apps
# Set the platform at the top
platform :osx, '10.15'
# Rest of the pod file
# Update post_install step
post_install do |installer|
# Ensure pods use the minimum deployment target set above
# https://stackoverflow.com/a/64385584/436422
pods_project = installer.pods_project
module ArrayColumns
extend ActiveSupport::Concern
class_methods do
def array_columns_sanitize_list(values = [])
return [] if values.nil?
values.select(&:present?).map(&:to_s).uniq.sort
end
def array_columns(*column_names)
@eseidel
eseidel / flutter_companies.md
Last active November 13, 2023 14:28
List of companies serving Flutter developers

This is a list of companies serving Flutter developers who replied to my Twitter thread on June 14th, 2023.

This does not include companies using Flutter (there are simply too many to list!), only those offering products or services for Flutter developers.

Presence on this list is not imply any endorsement of the company or its products (other than Shorebird, of course, I endourse my own company).

@baweaver
baweaver / block_transform_ast.rb
Last active August 3, 2023 22:53
Pattern matching applied to ASTs, defining the transformation between shorthand and standard block format.
require "rubocop"
# Useful for debugging and seeing how the nodes deconstruct
def deep_deconstruct(node)
return node unless node.respond_to?(:deconstruct)
node.deconstruct.map { deep_deconstruct(_1) }
end
def block_to_shorthand?(a, b)
@zorbash
zorbash / changes.rb
Last active February 8, 2022 16:02
Fetch changelogs of updatable gems
require 'bundler'
require 'net/http'
require 'json'
require 'uri'
def fetch_gem(gem_name)
URI("https://rubygems.org/api/v1/gems/#{gem_name}.json").
then(&Net::HTTP.method(:get)).
then(&JSON.method(:parse))
rescue JSON::ParserError
@amirrajan
amirrajan / main.rb
Last active November 20, 2023 07:25
DragonRuby Game Toolkit - Shadows (https://amirrajan.itch.io/shadows) (https://youtu.be/wQknjYk_-dE)
# demo gameplay here: https://youtu.be/wQknjYk_-dE
# this is the core game class. the game is pretty small so this is the only class that was created
class Game
# attr_gtk is a ruby class macro (mixin) that adds the .args, .inputs, .outputs, and .state properties to a class
attr_gtk
# this is the main tick method that will be called every frame the tick method is your standard game loop.
# ie initialize game state, process input, perform simulation calculations, then render
def tick
defaults
@avosalmon
avosalmon / firebase_token.rb
Last active March 4, 2024 06:54
Verify Firebase auth JWT token
require 'base64'
require 'httparty'
require 'jwt'
class FirebaseToken
JWT_ALGORITHM = 'RS256'.freeze
PUBLIC_KEY_URL = 'https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com'.freeze
def initialize(token)
@token = token
@baweaver
baweaver / DependencyInjectionInRuby.md
Last active March 7, 2023 04:43 — forked from blairanderson/DependencyInjectionInRuby.md
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache. (I wanted headers, so fork it is)

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?

def source(generator, target:, name: nil)
Ractor.new(generator, target, name: name) do |generator, target|
loop do
target.send generator.next
end
end
end
def buffer
Ractor.new do
@mehagar
mehagar / brakeman.yml
Last active July 2, 2020 14:42
How to use pronto-brakeman as a Github Action
name: Pronto
on: [pull_request]
jobs:
pronto:
runs-on: ubuntu-latest
steps:
- name: Checkout code