Skip to content

Instantly share code, notes, and snippets.

View jesselima's full-sized avatar
📱
Coding for mobile...

Jesse Lima jesselima

📱
Coding for mobile...
View GitHub Profile
@netsmertia
netsmertia / main.dart
Created May 4, 2018 13:53
flutter image drawing in canvas
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
import 'package:flutter/services.dart' show rootBundle;
import 'dart:async';
import 'dart:typed_data';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
  • Existem diversas discussões sobre qual deve ser o tamanho de uma função.
  • Mas algo mais importante é se perguntar: "Quando devemos envolver um código na sua própria função?"
  • Algumas pessoas se guiam por:
    • tamanho - uma função não deve ser tão grande que não caiba na tela
    • reuso - qualquer código utilizado mais de uma vez deve ser colocado em uma função, caso contrário, deve ser deixado inline
  • Uma abordagem interessante é separação entre intenção e implementação.
  • Se você tiver que se esforçar ao olhar um fragmento de código para entender o que ele faz, o código deve ser extraído para um função e a função nomeada.
  • Quando você ler o código novamente, o propósito da função ficará explícito sem a necessidade de entender o seu funcionamento internamente.
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active June 3, 2026 00:00
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@florina-muntenescu
florina-muntenescu / Data.kt
Last active June 9, 2026 12:21
Using RoomDatabase#Callback to pre-populate the database - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@codediodeio
codediodeio / index.js
Last active January 23, 2021 17:06
Transactional Email Firebase Cloud Function with Sendgrid
var functions = require('firebase-functions');
const sendgrid = require('sendgrid')
const client = sendgrid("YOUR_SG_API_KEY")
function parseBody(body) {
var helper = sendgrid.mail;
var fromEmail = new helper.Email(body.from);
var toEmail = new helper.Email(body.to);
var subject = body.subject;
@vuhung3990
vuhung3990 / ImageSliderAdapter.java
Last active August 1, 2019 08:05
simple image slider for android
public class ImageSliderAdapter extends FragmentPagerAdapter {
private final List<Fragment> fragmentList = new ArrayList<>();
public ImageSliderAdapter(@NonNull FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
@petterh
petterh / MainActivity.java
Last active June 30, 2020 09:34 — forked from alexjlockwood/MainActivity.java
Sample usage of the "android.app.Application.ActivityLifecycleCallbacks" class.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// Always register before calling into the super class.
getApplication().registerActivityLifecycleCallbacks(new MyActivityLifecycleCallbacks(this));
super.onCreate(savedInstanceState);
}
@passsy
passsy / KIntent.kt
Last active May 10, 2026 21:28
Kotlin extension functions to start a generic Activity
package com.pascalwelsch.extensions
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
/**
* Extensions for simpler launching of Activities
@demixdn
demixdn / ApiModule.java
Last active November 8, 2019 16:23
Retrofit with self signed https certificate
package <you_package>.data.api;
import android.content.Context;
import android.support.annotation.NonNull;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;