Skip to content

Instantly share code, notes, and snippets.

import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
open class SmartDevice(val name: String, val category: String) {
var deviceStatus = "online"
protected set
open val deviceType = "unknown"
@alexaleluia12
alexaleluia12 / compose.kt
Created October 16, 2023 16:14
Composable Kotlin
// source - https://stefma.medium.com/jetpack-compose-remember-mutablestateof-derivedstateof-and-remembersaveable-explained-270dbaa61b8
@Composable
private fun CounterWithDerivedState() {
// salvar stado em caso a activity seja recaregada - rememberSaveable
val counterState = remember { mutableStateOf(0) }
val showHurrayState = remember {
derivedStateOf { counterState.value > 10 }
}
@alexaleluia12
alexaleluia12 / useFetch.js
Created August 7, 2023 00:01
Custon Hook React
import { useState, useEffect } from 'react'
export const useFetch = (url) => {
const [data, setData] = useState([])
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch(url)
const data = await response.json()
@alexaleluia12
alexaleluia12 / install.txt
Created August 6, 2023 16:09
Install stuff from github example | Install Ruby 3 With rbenv
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
I had problem installing ruby +3 using rbenv from apt, I moreved rbenv and staling from source works like a charm
font: https://phoenixnap.com/kb/install-ruby-ubuntu
@alexaleluia12
alexaleluia12 / ifood-dev-week.ipynb
Created June 29, 2023 23:47 — forked from falvojr/ifood-dev-week.ipynb
ifood-dev-week.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexaleluia12
alexaleluia12 / flask_logging_requests.py
Last active November 22, 2024 05:11
Flask Logging (every request)
#/usr/bin/python
# http://exploreflask.com/en/latest/views.html
# https://stackoverflow.com/questions/51691730/flask-middleware-for-specific-route
# https://dev.to/rhymes/logging-flask-requests-with-colors-and-structure--7g1
import logging
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime
@alexaleluia12
alexaleluia12 / stubfs.js
Created June 2, 2019 13:05 — forked from devarajchidambaram/stubfs.js
How to stub fs.readFile functions
const fs = require('fs')
function readFile (filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, 'utf8')
}
throw new Error('Cannot find file ' + filename)
}
describe('mocking individual fs sync methods', () => {
https://codingsans.com/blog/microservice-architecture-best-practices
@alexaleluia12
alexaleluia12 / asyn_callback.js
Last active June 18, 2018 18:47
assync and callback
// promises https://developers.google.com/web/fundamentals/primers/promises
// source: http://2ality.com/2017/05/util-promisify.html
const {promisify} = require('util');
const fs = require('fs');
const readFileAsync = promisify(fs.readFile);
const filePath = process.argv[2];
https://www.ibm.com/support/knowledgecenter/pt-br/SSMNED_5.0.0/com.ibm.apic.toolkit.doc/tutorial_apionprem_security_OAuth.html
https://www.digitalocean.com/community/tutorials/uma-introducao-ao-oauth-2-pt
https://alexbilbie.com/tag/oauth/