Skip to content

Instantly share code, notes, and snippets.

View the-dagger's full-sized avatar
🚀
To Boldly Go Where No Man Has Gone Before

Harshit Dwivedi the-dagger

🚀
To Boldly Go Where No Man Has Gone Before
View GitHub Profile
override fun onCreate(savedInstanceState: Bundle?) {
//...
inputOutputOptions = FirebaseModelInputOutputOptions.Builder()
.setInputFormat(0, FirebaseModelDataType.FLOAT32, intArrayOf(1, 224, 224, 3))
.setOutputFormat(0, FirebaseModelDataType.FLOAT32, intArrayOf(1, 149))
.build()
//...
}
override fun onCreate(savedInstanceState: Bundle?) {
//...
//Load a cloud model using the FirebaseCloudModelSource Builder class
val cloudSource = FirebaseCloudModelSource.Builder("pokedex") //name of the model created in Firebase Console
.enableModelUpdates(true)
.build()
//Registering the cloud model loaded above with the ModelManager Singleton
FirebaseModelManager.getInstance().registerCloudModelSource(cloudSource)
dependencies {
// ...
implementation 'com.google.firebase:firebase-ml-model-interpreter:16.0.0'
}
@the-dagger
the-dagger / LandmarkDetector.kt
Last active July 15, 2018 17:59
Code to get landmarks from cloud
private fun getLandmarkFromCloud(bitmap: Bitmap) {
val image = FirebaseVisionImage.fromBitmap(bitmap)
val detector = FirebaseVision.getInstance()
.visionCloudLandmarkDetector
detector.detectInImage(image)
.addOnCompleteListener {
//The completion listener returns a list of detected landmarks
for (firebaseVisionLandmarks in it.result) {
//get the name of the landmark
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//Check and request permission to write external storage
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_DENIED) {
ActivityCompat.requestPermissions(this, Array<String>(1) { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 12345)
//If there is no permission, disable the onClickListener on the FAB
fab_take_photo.setOnClickListener(null)
} else {
fab_take_photo.setOnClickListener(this)
import 'dart:async';
import 'dart:html';
void main() {
final InputElement input = querySelector('input');
final DivElement div = querySelector('div');
div.innerHtml = "Enter a valid email";
final emailValidator =
private fun showNotification(channelID: String) {
val stopSelf = Intent(this, CopieService::class.java)
stopSelf.putExtra(INTENT_EXTRA, true)
val startApp = Intent(this, MainActivity::class.java)
val stopPendingIntent = PendingIntent.getService(this, 0, stopSelf, FLAG_CANCEL_CURRENT)
val openAppPendingIntent = PendingIntent.getActivity(this, 0, startApp, FLAG_CANCEL_CURRENT)
startForeground(1995, NotificationCompat.Builder(this, channelID)
.setSmallIcon(R.drawable.ic_paste)
.setContentTitle("Copie is online")
.setContentText("Touch to open")
package com.codingblocks.bottomnavigation;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
import 'package:flutter/material.dart';
import 'package:http/http.dart' show post;
import 'package:login_stateful/src/mixins/validation_mixin.dart';
class LoginScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return LoginScreenState();
}
}
private fun getQRCodeDetails(bitmap: Bitmap) {
...
detector.detectInImage(image)
.addOnSuccessListener {
for (firebaseBarcode in it) {
...
when (firebaseBarcode.valueType) {
//Handle the URL here
FirebaseVisionBarcode.TYPE_URL -> firebaseBarcode.url
// Handle the contact info here, i.e. address, name, phone, etc.