Skip to content

Instantly share code, notes, and snippets.

View lamvann's full-sized avatar

Eli Ivann Ruiz lamvann

View GitHub Profile
@lamvann
lamvann / biometricAuthenticationInJ.ijs
Created October 19, 2017 20:02
This J program triggers a executable (Leap.exe) using the Leap motion sensor C++ SDK to read bone length from the user's hand, saves info as a vector profile and stores it. It is also capable of comparing a new reading against existing profiles and returns the model's best estimates of whose hand the readings are.
NB. Some utilities written by me were loaded at started to make this program work. Will upload definitions later as definitions.ijs
load'csv'
load'jd'
jdadmin'Leap'
NB.Nouns
P =. 'C:\Users\Ivann\Documents\FIU\Fall 2016\Security IoT\Leap\file.csv'
P1 =. 'C:\Users\Ivann\Documents\Visual Studio 2015\Projects\Leap\Leap\'c
TABLE=. readcsv p
@lamvann
lamvann / scrapingVerbs.ijs
Created October 19, 2017 20:09
At some point in 2016 I was interested in figuring out what car would have the highest ROI if I were to rent it on the internet. This J file analyzes a CSV file returned by a web scraper, cleans up the data, links renters to cars and tallies the number of times each vehicle gets rented over time.
NB. Additional Helper Verbs
jdw1 =. (i(0 0 f) i (1 0 f) jd o ('reads count w1 from make where w1 = "'c , ] , '"'c))
space =. (>o[,' 'c,>o])/
getCSV =. i readcsv H,'/CSV/'c,],'.csv'c
shape20 =. (],(' 'c)#~(20 c)-$o])
isVerb =. 4!:0&bo
s =.(]$~1:,#)
NB.All Header Operations
removeTrashHdrs =.(}.o],~(1:,#o{.o])$(]-.(a. c)-.'-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'c) e o {.)
replaceHdrs =. (}.o],~(1:,#o{.o])$(('null'c)`(rtb"1 o (1 0 f) o jd o ('reads new from headers where old = "'c,],'"'c))@.((0 0 f) o (1 0 f) o (jd o ('reads count old from headers where old = "'c , ] , '"'c))))e o {.)
@lamvann
lamvann / linear.ijs
Created October 19, 2017 20:10
Some useful utilities to do linear algebra in J.
dot =. (+/ . *)
ma =.%: @: (+/ @: *:)
ca =. (([:-/ @: *: (ma x) , ([:ma [-]) , ma y ) % (2: * (ma x) * (ma y)))
class PopularMoviesActivity : BaseActivity(), PopularMoviesContract.View {
private val tvMainText: TextView by bindView(R.id.mainText)
private val btnMainButton: Button by bindView(R.id.mainButton)
lateinit var presenter: PopularMoviesPresenter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
class PresentationApp : DaggerApplication() {
override fun applicationInjector() = DaggerAppComponent.builder().application(this).build()
}
@Component(
modules = [
ApiModule::class,
ContractModule::class,
ActivityBindingModule::class,
AndroidSupportInjectionModule::class
]
)
@Singleton
interface AppComponent : AndroidInjector<PresentationApp> {
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation "com.google.dagger:dagger:2.23.2"
implementation "com.google.dagger:dagger-android-support:2.22.1"
kapt "com.google.dagger:dagger-compiler:2.22.1"
kapt "com.google.dagger:dagger-android-processor:2.22.1"
@Module
abstract class PopularMoviesActivityModule {
@Binds
abstract fun bindBaseActivity(activity: PopularMoviesActivity) : BaseActivity
}
@Module
abstract class ActivityBindingModule {
/*
Binds PopularMoviesActivity in another module as a BaseActivity so that BaseActivity can be injected
with the objects that its subclasses will use.
Such as the AutoDisposable
*/
@ContributesAndroidInjector(modules = [MovieActivityModule::class])
abstract fun bindMovieActivity(): PopularMoviesActivity
}
@Module
abstract class ContractModule {
// This module allows our presenters to be injected
@Binds
abstract fun providesPresenter(presenter: PopularMoviesPresenter): PopularMoviesContract.Presenter
}