Skip to content

Instantly share code, notes, and snippets.

View reime005's full-sized avatar
ℹ️

Marius Reimer reime005

ℹ️
View GitHub Profile
@reime005
reime005 / iOS.yml
Created November 24, 2019 15:15
React Native Github Actions iOS E2E Detox
name: iOS
on: [push, pull_request]
jobs:
node-stuff:
runs-on: macos-latest
steps:
- name: Checkout project
@reime005
reime005 / android.yml
Created November 24, 2019 15:15
React Native Github Actions Android E2E Detox
name: Android
on: [push, pull_request]
jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout project
@reime005
reime005 / js-call-apply-complex.js
Last active August 31, 2019 10:30
A more complex call and apply example in JavaScript
const Example = {
name: "Hans",
age: 42,
print: function() {
console.log(`Name: "${this.name}", age: "${this.age}".`);
},
printSomething: function(extra) {
console.log(`Extra: ${extra}.`);
}
};
@reime005
reime005 / js-call-apply-simple.js
Last active August 31, 2019 10:09
Very simply call and apply example JavaScript
function add(a, b) {
console.log(a + b);
console.log(this);
}
add(1, 2);
// ⇒ 3
// ⇒ Object [global] { global: [Circular], clearInterval ... }
add.apply({ example: "test" }, [1, 2]);
@reime005
reime005 / simple-redux.js
Created August 24, 2019 13:48
Simple redux-like example that shows the basic Redux concept.
const actionTypes = {
ACTION_TYPE_TEST: 'ACTION_TYPE_TEST'
}
class Store {
constructor(initialState = { testValue: 0 }) {
this.state = initialState;
this.subscribers = [];
}
@reime005
reime005 / build.gradle
Created August 11, 2019 13:48
Android NDK build.gradle configuration
...
android {
...
defaultConfig {
...
externalNativeBuild {
cmake {
cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all"
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
}
@reime005
reime005 / CMakeLists.txt
Created August 11, 2019 13:46
Android NDK C++ CMakeLists file
cmake_minimum_required(VERSION 3.4.1)
set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 11)
add_library(cpp-code
SHARED
../cpp-code/src/src/example.cpp
cpp-adapter.cpp
)
@reime005
reime005 / jni.cpp
Created August 11, 2019 13:45
React Native C++ JNI Adapter
#include <jni.h>
#include "example.h"
extern "C"
JNIEXPORT jlong JNICALL
Java_com_mariusreimer_rncppcode_RNCPPCodeModule_multiply(JNIEnv *env, jclass type, jlong a, jlong b) {
return example::multiply(a, b);
}
@reime005
reime005 / jni.java
Created August 11, 2019 13:41
React Native Android JNI
package com.mariusreimer.rncppcode;
...
class RNCPPCodeModule {
static {
try {
System.loadLibrary("cpp-code");
Log.d(TAG, "-------- libcpp-code: loaded");
} catch (Exception e){
Log.d(TAG, "-------- libcpp-code: loaded");
@reime005
reime005 / rnobjc++.mm
Created August 11, 2019 12:19
React Native Objective C++ example
RCT_EXPORT_METHOD(
multiply:(nonnull NSNumber*)a
withB:(nonnull NSNumber*)b
withResolver:(RCTPromiseResolveBlock)resolve
withReject:(RCTPromiseRejectBlock)reject
)
{
long result = example::multiply([a longValue], [b longValue]);
resolve(@{