Skip to content

Instantly share code, notes, and snippets.

View evandrojr's full-sized avatar
🤗
Studying Go

Evandro Magalhães Leite Júnior evandrojr

🤗
Studying Go
View GitHub Profile
@evandrojr
evandrojr / counter.dart
Last active July 2, 2020 01:03
Flutter state management. RxDart + BehaviorSubject + Singleton
import 'package:rxdart/rxdart.dart';
class Counter {
Counter._();
static final _instance = Counter._();
factory Counter() {
return _instance;
}
BehaviorSubject _counter =
@evandrojr
evandrojr / StreamProviderExample.dart
Created July 1, 2020 23:59
StreamProviderExample
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() => runApp(StreamProviderExample());
/// *****************************************************
/// *****************************************************
/// *****************************************************
/// Something important to understand here is that there's a
/// fundamental difference between using this StreamProvider
@evandrojr
evandrojr / emails_extractor.cr
Last active August 13, 2018 00:26
Extract all emails from files inside a directory. Writen in Crystal lang
dir = "msgs/"
emails = Set(String).new
errors_count = 0
msgs = Dir.entries(dir)
msgs.each { |msg|
next if msg == "." || msg == ".."
begin
texto = File.read(dir + msg)
matches = texto.scan(/[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,64}/)
p matches[0][0]
@evandrojr
evandrojr / mixin.js
Created February 11, 2017 21:37
Mixin example in JS
// vastly simplified `mixin(..)` example:
function mixin( sourceObj, targetObj ) {
for (var key in sourceObj) {
// only copy if not already present
if (!(key in targetObj)) {
targetObj[key] = sourceObj[key];
}
}
return targetObj;
@evandrojr
evandrojr / arrow_functions.js
Last active February 11, 2017 21:37
Using arrow functions
const dragonEvents = [
{type: 'attack', value: 40, victim: 'dorkman'},
{type: 'sleep', value: 10},
{type: 'attack', value: 20, victim: 'aquaman'},
{type: 'attack', value: 40, victim: 'dorkman'},
]
const v = 'dorkman';
const field = 'victim';
const selectVictim = (e) => e[field] === v;
@geddski
geddski / config.fish
Created October 3, 2014 19:42
useful fish config for git
##----GIT------
alias gs='clear ;and git status'
alias gb='git branch'
alias gbranch='git rev-parse --abbrev-ref HEAD' #get current branch name
alias gl="clear ;and git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gt='git tag'
alias grm='git rm'
alias gps='git push'
alias gbi='git bisect'
alias gbg='git bisect good'