Skip to content

Instantly share code, notes, and snippets.

import { AirtopClient } from "@airtop/sdk";
import puppeteer from "puppeteer-core";
const apiKey = "YOUR_AIRTOP_API_KEY";
const client = new AirtopClient({ apiKey });
// Step 1: Create a session
const session = await client.sessions.create();
// Step 2: Connect to the browser
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url)
// Check if the path starts with /blog
if (url.pathname.startsWith('/blog')) {
const subPath = url.pathname.replace('/blog', '')
const githubUrl = new URL(`SOURCE_URL${subPath}`)
#include <Bounce2.h>
#define BUTTON_PIN PB4
#define led1Pin PB0
#define led2Pin PB1
#define led3Pin PB2
#define led4Pin PB3
#define switchPin PB4
#define delayInterval 100
Bounce debouncer = Bounce(); // Instantiate a Bounce object
#include <avr/sleep.h>
#include <avr/interrupt.h>
#include <Heart.h>
/*
Android Beating Heart V2- Sketch
Marcos Placona 2019
*/
const int switchPin = 3;
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
- val myData = DataSource()
- tvMagicNumber.text = myData.getMagicNumber().toString()
+ val model = ViewModelProviders.of(this).get(DataSource::class.java)
+ tvMagicNumber.text = model.getMagicNumber().toString()
}
package uk.co.placona.jetpackdemo1
- class DataSource {
+ import android.arch.lifecycle.ViewModel
+
+ class DataSource: ViewModel() {
private val tag = MainActivity::class.java.simpleName
private lateinit var myRandomNumber:Number
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ def lifecycle_version = "1.1.1"
+ implementation "android.arch.lifecycle:extensions:$lifecycle_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
private fun createMagicNumber(){
myRandomNumber = (1..42).shuffled().first()
}
exports.handler = function (context, event, callback) {
/***** configuration *****/
const phoneNumber = 'YOUR_PHONE_NUMBER';
const timeout = event.Timeout || 12;
const secureRecordingLinks = false;
const voiceOpts = {
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message to="YOUR_PHONE_NUMBER">
{{From}}: {{Body}}
</Message>
</Response>