Skip to content

Instantly share code, notes, and snippets.

View cesartalves's full-sized avatar

César t. Alves cesartalves

View GitHub Profile
corrected = []
File.open('original.txt', 'r').each_line do |date|
new_date = Time.parse(date, '%Y-%m-%d %H%M%S')
if new_date.month == 6 && new_date.year == 2021
corrected << new_date.next_month.beginning_of_month
next
end
@cesartalves
cesartalves / .env
Last active April 13, 2021 09:44
Rails Conf k8s quick setup
# https://github.com/ddollar/forego
ASSET_HOST=localhost:3000
APPLICATION_HOST=localhost:3000
BCRYPT_COST=12
PORT=3000
RACK_ENV=development
RACK_MINI_PROFILER=0
SECRET_KEY_BASE=development_secret
EXECJS_RUNTIME=Node
@cesartalves
cesartalves / i_hate_flashapp.js
Created March 2, 2021 17:55
F* flash app card password
// use this on FlashApp website console to reset your password in case you forgot it
// as their support absolutely sucks
// ps: this is just for entertaining / learning purposes
function tryPass(pass) {
return fetch("https://api.flashapp.com.br/p/person/graphql", {
"headers": {
"accept": "application/json, text/plain, */*",
"accept-language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6,ru;q=0.5",
"authorization": "put your bearer token here",
@cesartalves
cesartalves / main.go
Created January 17, 2021 19:17
Golang Mongo Search example
package main
import (
"context"
"fmt"
"log"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
@cesartalves
cesartalves / ngrok.md
Last active December 17, 2020 19:43 — forked from ilgityildirim/ngrok.md
ngrok subdomain

ngrok http -host-header=rewrite [your-custom-local-domain]:[port]

Exemplo:

ngrok http -host-header=rewrite teste.lvh.me:3000

class NilObjectUnderstadingStrategy
def self.can_talk_to?(character)
true
end
end
class HumanCharacterUnderstandingStrategy
def self.can_talk_to?(character)
character.is_a? Human
end
@cesartalves
cesartalves / Dockerfile
Last active May 26, 2020 18:10
Sidekiq image (crontab + whenever)
FROM ruby:2.5.7
RUN apt-get update && apt-get install -y cron
RUN apt-get install -y nano
COPY Gemfile* /usr/src/app/
WORKDIR /usr/src/app
ENV BUNDLE_PATH /gems
@cesartalves
cesartalves / crontab
Created April 8, 2020 13:20
health-check-crontab
# * * * * * DISPLAY=:0 /usr/bin/zenity --info --text="stretch" --title="reminder"
# * * * * * /bin/echo "cron works" >> /tmp/file
# * * * * * /usr/bin/zenity --notification --text="stretch" --title="reminder" --display=:0.0
# this one on top doesn't work unless we do as below
DISPLAY=:0.0
# * * * * * eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)"; /usr/bin/notify-send "TEST" "Crons work!"
40 * * * * eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)"; /usr/bin/notify-send "REMINDER" "Check posture!"
30 10,14,17 * * * eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)"; /usr/bin/notify-send "REMINDER" "Take a break! (stretch, coffee, etc)"
@cesartalves
cesartalves / StrategyPattern.php
Created March 15, 2020 16:10
Strategy Pattern real world example
<?php
class Product1 {
public function sendToMarketplace(){
if ($this->marketplace == 'Amazon') {
//huge code block
} elseif ($this->marketplace == 'Via Varejo') {
//huge code block
} elseif ($this->marketplace == 'Magalu') {
@cesartalves
cesartalves / StatePatternExample.php
Last active March 15, 2020 15:57
Real world State pattern example php
<?php
class Order {
public function sendToEcommerce(){
switch($this->status){
case 'created':
$params["access_token"] = "### Chave de Acesso ###";
$data["Order"]["status_id"] = $this->status_id;