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 / ruby.json
Created March 28, 2017 17:50
Debug with pry in VSCODE
{
// Place your snippets for Ruby here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Debug with pry": {
"prefix": "pry",
"body": [
@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;
@evandrojr
evandrojr / monit_noosfero
Last active March 21, 2016 22:07
cat /etc/monit.d/*
check process npm
matching "npm"
start program = "/bin/su designer -lc 'cd /home/designer/angular-theme && npm start' "
stop program = "/usr/bin/killall -9 npm"
if cpu usage > 95% for 10 cycles then restart
# log to monit.log
set logfile /var/log/monit.log
@evandrojr
evandrojr / oo.rb
Created September 2, 2015 18:16
Ruby OO
class myTask < Task # myTask is a subclass of Task
end
module Foo
def foo
puts 'heyyyyoooo!'
end
end
@evandrojr
evandrojr / index.html
Last active August 29, 2015 14:27 — forked from anonymous/index.html
Saúde de Aço // source https://jsbin.com/yuhoze
<!DOCTYPE html>
<html ng-app="SaudeDeAco">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
<meta charset="utf-8">
<title>Saúde de Aço</title>
</head>
<body ng-controller="mainCtrl">
<h3>Semana atual: {{currentWeek}} </h3>