Skip to content

Instantly share code, notes, and snippets.

View miquelbeltran's full-sized avatar

Miguel Beltran miquelbeltran

View GitHub Profile
abstract class Beverage {
open val description: String = "Unknown Beverage"
abstract val cost: Double
}
abstract class CondimentDecorator : Beverage() {
abstract override val description: String
}
class Espresso: Beverage() {
import "dart:async";
class SynchronousError<T> implements Future<T> {
final Object _error;
SynchronousError(this._error);
@override
Stream<T> asStream() {
final StreamController controller = StreamController<T>();
@miquelbeltran
miquelbeltran / pre-push
Created June 4, 2019 07:18
Flutter pre-push hook that runs analyze and test
#!/bin/sh
# To use add to `.git/hooks/`
# Should be named `pre-push`
# Make executable with `chmod +x`
# stash any unstaged changes
git stash -q --keep-index
# run Flutter analyze + test
flutter analyze
@miquelbeltran
miquelbeltran / Accordion.java
Created April 10, 2019 19:03
Code I wrote in 2010 as an attempt to create a solitarie game, decompiled from a classes.dex, do not take as example of how to do things
package com.miquelbeltran.accordion;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class Accordion extends Activity {
private static final int MENU_NEW_GAME = 1;
@miquelbeltran
miquelbeltran / AndroidManifest.xml
Created February 20, 2019 12:51
install referrer data on Android
<!-- Used for Google Play Store Campaign Measurement -->
<receiver
android:name=“.broadcastreceivers.CampaignTrackingReceiver”
android:enabled=“true”
android:exported=“true”>
<intent-filter>
<action android:name=“com.android.vending.INSTALL_REFERRER” />
</intent-filter>
</receiver>
fun provideGetCollectionUseCase(): GetCollectionUseCase {
return GetCollectionUseCaseImpl(provideService())
}
val collectionKoinModule = module {
single { provideGetCollectionUseCase() }
viewModel { CollectionViewModel(get()) }
}
// ML Kit Input
val inp = arrayOf(FloatArray(784) { 0f })
// Read our Bitmap
val bitmap = BitmapFactory.decodeStream(assets.open("three.bmp"))
// Read pixels
val intValues = IntArray(784)
bitmap.getPixels(intValues, 0, bitmap.width, 0, 0, bitmap.width, bitmap.height)
// Input is a 1x784 Tensor
val inputDims = intArrayOf(1, 784)
// Output is a 1x10 Tensor
val outputDims = intArrayOf(1, 10)
from keras import backend as K
custom_input_tensor = tf.placeholder(tf.float32, shape=(1, 784))
output_tensor = model(custom_input_tensor)
frozen_graph = freeze_session(K.get_session(), output_names[output_tensor.op.name])
tflite_model = tf.contrib.lite.toco_convert(frozen_graph,[custom_input_tensor], [output_tensor])
open("app/src/main/assets/nmist_mlp.tflite", "wb").write(tflite_model)