Skip to content

Instantly share code, notes, and snippets.

View andijakl's full-sized avatar

Andreas Jakl andijakl

View GitHub Profile
@andijakl
andijakl / document-db-sql-query.js
Created October 11, 2018 08:30
Create a new item in a Document DB through an SQL query (warning: unsafe!)
const queryResponse = await container.items.query(
"SELECT * FROM c WHERE c.id='" + newItemId + "'").toArray();
console.log(queryResponse.result[0].name);
@andijakl
andijakl / sql-injection-example.js
Last active December 31, 2019 22:05
Example of an SQL injection attack for the Cosmos DB
// Called through:
// http://127.0.0.1:3000/db?username=%27%20OR%20%271%27=%271
// Query username from URL parameter
const username = req.query.username;
// Create SQL query
const sqlQuery = "SELECT * FROM c WHERE c.name='" + username + "'";
// -> SQL Query is: SELECT * FROM c WHERE c.name='' OR '1'='1'
@andijakl
andijakl / cosmos-db-delete-readall.js
Created October 11, 2018 09:23
Delete an item and retrieve all items from an Azure Cosmos DB
// Delete item
const deleteResponse = await container.item(newItemId).delete();
console.log(deleteResponse.item.id);
// Read all items from the container
const docResponse = await container.items.readAll().toArray();
res.send(docResponse);
@andijakl
andijakl / strings.xml
Created November 15, 2018 15:54
Changing the Sumerian app name for Android
<resources>
<string name="app_name">Digital Healthcare Explained</string>
</resources>
@andijakl
andijakl / SpeechWelcome.ssml
Created November 19, 2018 15:07
Welcome speech with SSML markup
<speak><mark name="gesture:wave"/>Welcome to Digital Healthcare Explained. <mark name="gesture:self"/>I will answer <mark name="gesture:you"/>your questions for several exciting healthcare topics!</speak>
@andijakl
andijakl / SpeechBreak.ssml
Created November 19, 2018 15:08
SSML Break markup for Amazon Sumerian
<break time="500ms">
@andijakl
andijakl / build.gradle
Created January 24, 2019 18:53
Dependencies for using Retrofit, Moshi and Kotlin Coroutines
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation "com.squareup.retrofit2:converter-moshi:2.5.0"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2"
// Moshi
implementation "com.squareup.moshi:moshi:1.8.0"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.8.0"
// Kotlin Coroutines
@andijakl
andijakl / db.json
Last active January 28, 2019 10:16
Sample database file for JSON-server
{
"parts": [
{
"id": 100411,
"itemName": "LED Green 568 nm, 5mm"
},
{
"id": 101119,
"itemName": "Aluminium Capacitor 4.7μF"
},
@andijakl
andijakl / PartData.kt
Created January 24, 2019 19:57
Data class with Moshi annotations
package com.andresjakl.partslist
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class PartData ( var id: Long, var itemName: String)
@andijakl
andijakl / PartsApiClient.kt
Created January 24, 2019 21:07
Interface for a REST web service using Kotlin Coroutines for Retrofit
package com.andresjakl.partslist
import kotlinx.coroutines.Deferred
import retrofit2.Response
import retrofit2.http.*
interface PartsApiClient {
@GET("parts") fun getPartsAsync(): Deferred<Response<List<PartData>>>
@POST("parts") fun addPartAsync(@Body newPart : PartData): Deferred<Response<Void>>
@DELETE("parts/{id}") fun deletePartAsync(@Path("id") id: Long) : Deferred<Response<Void>>