Skip to content

Instantly share code, notes, and snippets.

@pask23
pask23 / MainActivity.kt
Created March 12, 2020 12:17 — forked from sankarcheppali/MainActivity.kt
Connecting WiFi programmatically
package example.siva.com.hellokotlin
import android.content.BroadcastReceiver
import android.content.Context
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.toast
import android.net.wifi.WifiConfiguration
@pask23
pask23 / docker-compose.yaml
Created April 4, 2019 16:58 — forked from indiejoseph/docker-compose.yaml
Docker compose for Home Assistant
version: "3"
services:
homeassistant:
container_name: homeassistant
image: homeassistant/home-assistant:latest
restart: unless-stopped
volumes:
- ./homeassistant/config:/config
- /etc/localtime:/etc/localtime:ro
ports:
@pask23
pask23 / PhonecallReceiver.java
Created December 5, 2018 20:48 — forked from ftvs/PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@pask23
pask23 / node-and-npm-in-30-seconds.sh
Created December 3, 2018 13:45 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@pask23
pask23 / basic-card.json
Created November 16, 2018 12:56 — forked from manniru/basic-card.json
Actions on Google Conversation API v2 - Sample Responses
{
"items": [
{
"simpleResponse": {
"textToSpeech":"This is the first simple response for a basic card"
}
},
{
"basicCard": {
"title":"Title: this is a title",
@pask23
pask23 / gist:d00358585f294053c5827ad3c8ec1b2f
Created August 31, 2018 16:09 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
  • Functional Programming is a model of programming that transform and compose stream of immutable sequences by applying map, filter and reduce. Events are immutable because you can't change history.
  • Reactive Programming is a model of programming focuses on data flow and change propagation.
  • ReactiveX is an API that focuses on asynchronous composition and manipulation of observable streams of data or events by using a combination of the Observer pattern, Iterator pattern, and features of Functional Programming.
  • RxJava is the open-source implementation of ReactiveX in Java.
  • RxJava is a Java VM implementation of ReactiveX (Reactive Extensions): a library for composing asynchronous and event-based programs by using observable sequences.
  • RxAndroid is a lightweight extension to RxJava that providers a Scheduler for Android’s Main Thread, as well as the ability to create a Scheduler that runs on any given Android Handler class.
  • The two main classes are Observable and Subscriber.
  • `O
@pask23
pask23 / BaseView.java
Created April 5, 2017 22:00 — forked from mandybess/BaseView.java
RxJava + MVP Signup Form Validation
public interface BaseView {
}
@pask23
pask23 / RxJava.md
Created April 5, 2017 15:40 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@pask23
pask23 / FloatingActionMenuBehavior.java
Created March 21, 2017 10:16 — forked from mmazzarolo/FloatingActionMenuBehavior.java
Floating Action Menu Behavior for Clans.FloatingActionButton
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.util.AttributeSet;
import android.view.View;
import com.github.clans.fab.FloatingActionMenu;