Skip to content

Instantly share code, notes, and snippets.

View sasssass's full-sized avatar

Ali Shobeyri sasssass

View GitHub Profile
@sasssass
sasssass / MyCode.cpp
Created May 3, 2024 11:26
MyCode.cpp
// detecting class type
jclass anotherCalculatorType = env->FindClass("com/sass/jni_sample/AnotherCalculator");
// allocating object based on our class type
jobject anotherCalculator = env->AllocObject(anotherCalculatorType);
// our desire method in our Kotlin code that we want to use
// formular for the input and output is : (input types) output type ,
jmethodID powerOfTwoMethodID = env->GetMethodID(anotherCalculatorType, "powerOfTwo", "(I)I");
// the result will be 2 * 2
jint result = env->CallIntMethod(anotherCalculator, powerOfTwoMethodID, 2);
@sasssass
sasssass / AnotherCalculator.kt
Created May 3, 2024 11:25
AnotherCalculator.kt
class AnotherCalculator {
fun powerOfTwo(input: Int): Int = input * input
}
@sasssass
sasssass / build.gradle.kts
Created May 3, 2024 09:21
build.gradle.kts
android {
defaultConfig {
// ...
externalNativeBuild {
cmake {
cppFlags += ""
}
}
}
// ...
@sasssass
sasssass / chop.kt
Created February 13, 2024 14:58
chop.kt
/**
* You can edit, run, and share this code.
* play.kotlinlang.org
*/
fun main() {
val length = readLine()?.toIntOrNull() ?: 0
val input = mutableListOf<Int>()
repeat(length) {
@sasssass
sasssass / TreeChoping.kt
Created February 12, 2024 09:01
TreeChoping.kt
/**
* You can edit, run, and share this code.
* play.kotlinlang.org
*/
fun main() {
val length = readLine()?.toIntOrNull() ?: 0
val input = mutableListOf<Int>()
repeat(length) {
@sasssass
sasssass / response.json
Created January 19, 2024 13:37
response.json
[
{
"title": "Pulp Fiction",
"imageUrl": "https://upload.wikimedia.org/wikipedia/en/3/3b/Pulp_Fiction_%281994%29_poster.jpg",
"actresses": ["Uma Thurman", "Mia Wallace", "John Travolta"]
},
{
"title": "The Matrix",
"imageUrl": "https://upload.wikimedia.org/wikipedia/en/c/c1/The_Matrix_Poster.jpg",
"actresses": ["Keanu Reeves", "Carrie-Anne Moss", "Laurence Fishburne"]
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.21"
repositories {
google()
jcenter()
}
dependencies {
def gradle = '7.0.0-alpha04'
classpath "com.android.tools.build:gradle:$gradle"
@sasssass
sasssass / response.json
Last active November 8, 2023 13:30
response.json
{
"response": [
{
"id": 1,
"name": "Parking Spot 1",
"area": "SOLNA",
"description": "Description of Parking Spot 1",
"isActive": true,
"latitude": 55.8275,
"longitude": 14.5693
@sasssass
sasssass / response.json
Last active November 3, 2023 13:23
response.json
{
"response": [
{
"name" : "Solna",
"phoneNumber" : "084555300",
"address" : "Rättarvägen 3, 169 68 Solna"
},
{
"name" : "Kista",
"phoneNumber" : null,
@sasssass
sasssass / response.json
Created November 1, 2023 14:45
response.json
[
{
"username": "Ali,
"passwordHash": 46792755
},
{
"username": "Yauheni,
"passwordHash": 1450575459
},
{