Skip to content

Instantly share code, notes, and snippets.

Avatar
⚛️
Writing React components.

Douglas Nassif Roma Junior douglasjunior

⚛️
Writing React components.
View GitHub Profile
@douglasjunior
douglasjunior / exemploJson.php
Last active Jan 12, 2021
Exemplo de consulta no banco de dados e retorno de JSON utilizando PHP e MySQL.
View exemploJson.php
<?php
header('Content-Type: application/json');
header('Character-Encoding: utf-8');
// recebe os parâmetros
$QTD = (int) filter_input(INPUT_GET, 'qtd', FILTER_VALIDATE_INT);
$LAT = (float) filter_input(INPUT_GET, 'lat', FILTER_VALIDATE_FLOAT);
$LNG = (float) filter_input(INPUT_GET, 'lng', FILTER_VALIDATE_FLOAT);
if ($LAT && $LNG) {
@douglasjunior
douglasjunior / CustomMaterialSpinner.java
Created Sep 30, 2015
Override to fix enable/disable problem.
View CustomMaterialSpinner.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner;
/**
* Created by Douglas Nassif Roma Junior on 30/09/15.
*/
public class CustomMaterialSpinner extends MaterialBetterSpinner {
@douglasjunior
douglasjunior / IOSWifiManager.h
Last active Mar 26, 2020 — forked from rbresjer/IOSWifiManager.h
Programatically join Wi-Fi network on iOS with React Native wrapper for NEHotspotConfiguration
View IOSWifiManager.h
// Created by Rutger Bresjer on 10/10/2017
// Notes:
// - Be sure to enable "Hotspot Configuration" capability for the iOS target
// - Make sure the NetworkExtension framework is linked to the target
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
@interface IOSWifiManager : NSObject <RCTBridgeModule>
@douglasjunior
douglasjunior / TUTORIAL_LETSENCRYPT_GLASSFISH4.md
Last active Jan 19, 2020
Tutorial de instalação do Lets Encrypt no Glassfish 4.x
View TUTORIAL_LETSENCRYPT_GLASSFISH4.md

Tutorial de instalação do Lets Encrypt no Glassfish 4.x

Gerando certificado Lets Encrypt

Para gerar o certificado Lets Encrypt é muito simples, aqui as instruções estão baseadas em um tutorial publicado pela Locaweb. (Web archive)

Primeiro vamos criar um diretório para isso:

@douglasjunior
douglasjunior / config.fish
Last active Oct 28, 2019
Configure seu Fishshell para exibir informações sobre o repositório Git, assim como no Zsh.
View config.fish
set normal (set_color normal)
set magenta (set_color magenta)
set yellow (set_color yellow)
set green (set_color green)
set red (set_color red)
set gray (set_color -o black)
# Fish git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
@douglasjunior
douglasjunior / applyHighlight.js
Last active Aug 21, 2019
Função para destacar partes de um texto usando React
View applyHighlight.js
/**
* Função para destacar partes de um texto
* @param {string} text Texto
* @param {string|RegExp} highlight Parte do texto a ser destacada
* @param {object} options Propriedades do <span> para as partes destacadas
* @return {Array} Array de elementos React
*/
function applyHighlight(text, highlight, options = {}) {
if (text && highlight) {
const regex = highlight instanceof RegExp ? highlight : new RegExp(highlight, "gmi");
@douglasjunior
douglasjunior / OnItemSelectedListener.java
Last active Jan 20, 2019
Implementação de Adapter genérico para utilizar no com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner (ver comentários)
View OnItemSelectedListener.java
package com.youtproject.util;
import android.text.Editable;
import android.text.TextWatcher;
/**
* Listener used to capture "on selected item" event on MaterialBetterSpinner.
* Created by douglas on 22/09/15.
*/
public abstract class OnItemSelectedListener implements TextWatcher {
View EscPosHelper.java
import android.graphics.Bitmap;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
* Created by douglas on 29/05/17.
* Adapted from http://new-grumpy-mentat.blogspot.com.br/2014/06/java-escpos-image-printing.html
*/
@douglasjunior
douglasjunior / MyActivity.java
Last active Oct 11, 2018
Allows RecyclerView work like a FlowLayout.
View MyActivity.java
public class MyActivity extends Activity {
public void onCreate(...){
RecyclerView rv = findViewByIdCast(R.id.rv);
// 2 is the number of columns
rv.setLayoutManager(new GridLayoutManager(this, 2));
// Calculates the width of the "CardView" dynamically.
int cardViewWidth = getResources().getDimension(R.dimen.my_cardview_width) + getResources().getDimension(R.dimen.my_cardview_margin) * 2;
rv.getViewTreeObserver().addOnGlobalLayoutListener(new OnFlowLayoutListener(rv, cardViewWidth));
}
@douglasjunior
douglasjunior / flex-box.html
Created Aug 14, 2018
Exemplo de layout com flexbox.
View flex-box.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Layout com Flexbox</title>
<style>
html,
body {