Skip to content

Instantly share code, notes, and snippets.

- (void)executeApplicationScript:(NSString *)script sourceURL:(NSURL *)URL onComplete:(RCTJavaScriptCompleteBlock)onComplete {
NSDictionary *message = @{
@"method": @"executeApplicationScript",
@"url": RCTNullIfNil(URL.absoluteString),
@"inject": _injectedObjects,
};
[self sendMessage:message waitForReply:^(NSError *error, NSDictionary *reply) {
onComplete(error);
}];
}
{
"remoteModuleConfig": {
"RCTTiming": {
"methods": {
"deleteTimer": {
"type": "remote",
"methodID": 1
},
"createTimer": {
"type": "remote",
executeApplicationScript: function(message, sendReply) {
for (var key in message.inject) {
window[key] = JSON.parse(message.inject[key]);
}
loadScript(message.url, sendReply.bind(null, null));
}
function loadScript(src, callback) {
var script = document.createElement('script');
script.type = 'text/javascript';
function runServer(options, readyCallback) {
var app = connect()
.use(loadRawBody)
.use(openStackFrameInEditor)
.use(getDevToolsLauncher(options))
.use(statusPageMiddleware)
// Temporarily disable flow check until it's more stable
//.use(getFlowTypeCheckMiddleware(options))
.use(getAppMiddleware(options));
@sghiassy
sghiassy / .gitignore
Last active July 3, 2019 18:30
My default .gitignore file
# Gist at: https://gist.github.com/sghiassy/e14593a439a03028b98a
##### OSX
.DS_Store
##### Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
@sghiassy
sghiassy / provisioning.sh
Created October 17, 2015 09:32
A Bash shell script for provisioning a new Ubuntu 14.04 LTS VM built for React Native
#!/bin/bash
####################################
# Setup
####################################
tmpfile="/vagrant/.capacitor/runonce"
if [ -e ${tmpfile} ]; then
echo "Provisioning already completed. Remove ${tmpfile} to run it again."
@sghiassy
sghiassy / StringPermutation.js
Last active June 17, 2017 05:38
A string permutation example written in JavaScript (ES6)
// NOTE: This is written using ES6 - make sure your JavaScript compiler is ES6 compliant
class StringPermutation {
constructor(str) {
this.originalString = str.slice(); // deep copy string
}
printAllPermutationsWithDuplicates() {
this.permutate(
@sghiassy
sghiassy / StringPermutations.js
Last active March 19, 2018 04:56
A JavaScript (ES6) implementation of printing all Permutations of a String
// Print all permutations of a string in JavaScript (ES6)
// O(2^n) runtime
class StringSubsets {
constructor(str) {
this.str = str;
}
print() {
const map = new Map();
class Node {
constructor(value = "", parent = undefined) {
this.value = value;
this.parent = parent;
this.children = [];
if (this.parent != undefined) {
this.parent.children.push(this);
}
}
@sghiassy
sghiassy / dec2bin.js
Created July 1, 2017 03:53
JavaScript utility function to output full 32 bit representations of binary digits
function dec2bin(dec){
var str = (dec >>> 0).toString(2);
return (str.length < 32) ? Array(32 - str.length).fill(0).join('').concat(str) : str;
}