Skip to content

Instantly share code, notes, and snippets.

View legalimpurity's full-sized avatar

Rajat Khanna legalimpurity

View GitHub Profile
@legalimpurity
legalimpurity / lambda_function.py
Created January 19, 2022 16:38 — forked from matt2005/lambda_function.py
Alexa Smart Home Skill Adapter for Home Assistant
"""
Copyright 2019 Jason Hu <awaregit at gmail.com>
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
@legalimpurity
legalimpurity / AppleAppStoreServiceImplTest.java
Created January 6, 2021 10:47
RxJava Tech Session Sample Code for various operators and use cases.
public class AppleAppStoreServiceImplTest {
@Test
public void simpleRxJava() {
Observable<Integer> basicObs = Observable.create(new ObservableOnSubscribe<Integer>() {
@Override public void subscribe(@NonNull ObservableEmitter<Integer> emitter)
throws Throwable {
emitter.onNext(5);
emitter.onNext(8);
emitter.onNext(3);
@legalimpurity
legalimpurity / MainActivity.kt
Created July 16, 2018 16:53
add parameters to implementation of MyAsyncTask.
package com.legalimpurity.asynctaskwrittenfromscratch
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import java.lang.ref.WeakReference
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@legalimpurity
legalimpurity / MyAsyncTaskImpl.kt
Last active July 16, 2018 16:50
MyAsyncTaskImpl with url task implementation structure.
package com.legalimpurity.asynctaskwrittenfromscratch
import android.util.Log
import com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode.MyAsyncTask
import kotlinx.android.synthetic.main.activity_main.*
import java.io.BufferedInputStream
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.Reader
import java.lang.ref.WeakReference
@legalimpurity
legalimpurity / MyAsyncTaskImpl.
Created July 16, 2018 16:47
MyAsyncTaskImpl empty implementation structure to make complaint with new generic type MyAsyncTask.
package com.legalimpurity.asynctaskwrittenfromscratch
import android.util.Log
import com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode.MyAsyncTask
class MyAsyncTaskImpl : MyAsyncTask<String>()
{
val LOG_TAG = "MyAsyncTask_Logs"
override fun doInBackground(): String {
@legalimpurity
legalimpurity / MyAsyncTask.kt
Created July 16, 2018 15:59
MyAsyncTask, added generic to get the result we want.
package com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode
import com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode.executors.ExecutorProvider
import java.util.concurrent.Callable
import java.util.concurrent.Future
abstract class MyAsyncTask<ResultTypeWeWantOnPostExecute>{
// Functions to be implemented by the user.
abstract fun doInBackground() : ResultTypeWeWantOnPostExecute
@legalimpurity
legalimpurity / MyAsyncTask.kt
Created July 16, 2018 15:45
MyAsyncTask.kt changed to make it work in the correct order.
package com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode
import com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode.executors.ExecutorProvider
import java.util.concurrent.Callable
import java.util.concurrent.Future
abstract class MyAsyncTask(){
// Functions to be implemented by the user.
abstract fun doInBackground()
@legalimpurity
legalimpurity / MainActivity.kt
Created July 16, 2018 15:38
adding myasynctask listener running linking.
package com.legalimpurity.asynctaskwrittenfromscratch
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@legalimpurity
legalimpurity / MyAsyncTaskImpl.kt
Created July 16, 2018 15:36
MyAsyncTaskImpl empty implementation structure.
package com.legalimpurity.asynctaskwrittenfromscratch
import android.util.Log
import com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode.MyAsyncTask
class MyAsyncTaskImpl : MyAsyncTask()
{
val LOG_TAG = "MyAsyncTask_Logs"
override fun doInBackground() {
@legalimpurity
legalimpurity / MyAsyncTask.kt
Created July 16, 2018 15:34
MyAsyncTask.kt failed try.
package com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode
import com.legalimpurity.asynctaskwrittenfromscratch.MyAsyncTaskCode.executors.ExecutorProvider
abstract class MyAsyncTask(){
// Functions to be implemented by the user.
abstract fun doInBackground()
abstract fun onPreExecute()
abstract fun onPostExecute()