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 / BluetoothWriter.h
Last active Aug 29, 2015
Exemplo de código Objective-C
View BluetoothWriter.h
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
@interface BluetoothWriter : NSObject
-(id) initWithPeripheral:(CBPeripheral *) peripheral characteristic:(CBCharacteristic *)characteristic;
- (void) writeString:(NSString *) value;
- (void) writeData:(NSData *) value;
-(void) writeColorWithRed:(int)red withGreen:(int)green withBlue:(int)blue;
View BluetoothWriter.swift
import Foundation
import CoreBluetooth
class BluetoothWriter : NSObject {
private weak var peripheral: CBPeripheral!;
private weak var characteristic: CBCharacteristic!;
init(peripheral : CBPeripheral, characteristic:CBCharacteristic) {
self.peripheral = peripheral;
View AsyncTask.swift
//
// AsyncTask.swift
//
// Created by Douglas Nassif Roma Junior on 08/06/15.
// Copyright (c) 2015 Douglas Nassif Roma Junior. All rights reserved.
//
import Foundation
class AsyncTask<Params, Progress, Result> : NSObject {
@douglasjunior
douglasjunior / exemploJson.php
Last active Jun 22, 2020
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 / CustomAndroidApplication.java
Created Sep 8, 2015
Fix 24hours for android-validation-komensky
View CustomAndroidApplication.java
import android.app.Application;
import eu.inmite.android.lib.validations.form.validators.ValidatorFactory;
/**
* Created by douglas on 06/08/15.
*/
public class CustomAndroidApplication extends Application {
static {
// register the custom validator
@douglasjunior
douglasjunior / AbstractAdapter.java
Last active Sep 10, 2015
Exemplo de uso do Adapter com RecyclerView
View AbstractAdapter.java
import android.content.Context;
import android.content.res.TypedArray;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import java.util.ArrayList;
import java.util.List;
@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 {
@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 / BodyEditorLoader.java
Last active Oct 5, 2015
Fix for JsonParser problem.
View BodyEditorLoader.java
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.OrderedMap;
@douglasjunior
douglasjunior / JsonChildSerializer.java
Last active Oct 8, 2015
Implementação de JsonSerializer para evitar recursividade. Somente o ID dos objetos filhos é serializado.
View JsonChildSerializer.java
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
/**
* Implementação do JsonSerializar customizado para adicionar somente o ID do objeto filho.
*
* Created by douglas on 02/02/15.
You can’t perform that action at this time.