Skip to content

Instantly share code, notes, and snippets.

@TheBojda
TheBojda / getUserByToken.php
Created April 1, 2020 17:26
Firebase Auth - Verify ID token, and get user info in PHP with CURL
function getUserByToken($token)
{
$data = array("idToken" => $token);
$data_string = json_encode($data);
$ch = curl_init('https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=' . API_KEY);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
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
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
import numpy as np
import tensorflow as tf
# Load TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path="converted_model.tflite")
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
package org.tensorflow.lite.examples.digitclassifier
import android.content.Context
import android.content.res.AssetManager
import android.graphics.Bitmap
import android.util.Log
import com.google.android.gms.tasks.Task
import com.google.android.gms.tasks.Tasks.call
import java.io.FileInputStream
import java.io.IOException
@TheBojda
TheBojda / todo_react.js
Created February 9, 2020 16:23
Simple TODO react native app
// Simple TODO react native app
// based on https://codeburst.io/todo-app-with-react-native-f889e97e398e
import React, { Component } from 'react';
import { StyleSheet, Text, View, FlatList, TextInput, Keyboard, Button } from 'react-native';
const isAndroid = Platform.OS == "android";
export default class App extends Component {
import React, { Component } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
export default class App extends Component {
constructor() {
super()
this.state = {text: 'Hello World!'}
}
import {Cifar10} from './data.js';
async function load () {
const data = new Cifar10()
await data.load()
const model = await tf.loadLayersModel('./model/model.json');
//tfvis.show.modelSummary({name: 'Model Architecture'}, model);
const class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer',
import {Cifar10} from './data.js';
async function load () {
const data = new Cifar10()
await data.load()
const [train_images, train_labels] = data.nextTrainBatch();
const [test_images, test_labels] = data.nextTestBatch();
console.log(train_images, train_labels, test_images, test_labels);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TensorFlow.js Tutorial</title>
<!-- Import TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js"></script>
@TheBojda
TheBojda / minst_gan_batch_train.py
Created January 25, 2020 20:43
MINST GAN Example
# MINST GAN Example
# based on https://www.tensorflow.org/tutorials/generative/dcgan
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.keras import layers, models
import time
BUFFER_SIZE = 60000