Skip to content

Instantly share code, notes, and snippets.

View Salakar's full-sized avatar
🐈
Fluttering right meow

Mike Diarmid Salakar

🐈
Fluttering right meow
View GitHub Profile
platform :ios, '9.3'
target 'rentcssbeta' do
rn_path = '../node_modules/react-native'
pod 'react-native-maps', path: '../node_modules/react-native-maps'
pod 'RNFirebase', path: '../node_modules/react-native-firebase/ios'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/Crash'
@brennanMKE
brennanMKE / app.js
Created June 6, 2017 18:11
React Native JS Bundle Source Mapping for Debugging
var sourceMap = require('source-map');
var convert = require('convert-source-map');
var fs = require('fs');
var source = 'PATH_TO_APP/Myapp.app/main.jsbundle';
var content = fs.readFileSync(source, 'utf8');
var json = convert.fromComment(content).toJSON();
var smc = new sourceMap.SourceMapConsumer(json);
var position = smc.originalPositionFor({
@bmeck
bmeck / commands.js
Last active June 29, 2018 15:44
Show fs.readFile callback acting as if it was sync in another thread (naive impl)
module.exports = {
__proto__: null,
START: 0,
WORKER_READY: 2,
BUS_READY: 3,
BUS_DRAINED: 4,
BUS_END: 5,
WORKER_ERROR: 6,
};
@bmeck
bmeck / bus.js
Created June 23, 2018 13:51
it is a better API at least
// Example way to construct a Bus
//
// const ctrl = new SharedArrayBuffer(12);
// const size = new SharedArrayBuffer(4);
// let busSize = 4096;
// const data = new SharedArrayBuffer(busSize);
// const bufs = {ctrl,size,data,};
// const bus = new Bus(bufs);
'use strict';
@ndelangen
ndelangen / spawn-node-ipc.js
Created January 2, 2017 15:01
Spawn can be used to create a process from any command.
const spawn = require('child_process').spawn;
const command = 'node';
const parameters = [path.resolve('program.js')];
const child = spawn(command, parameters, {
stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ]
});
@ndelangen
ndelangen / cluster-example.js
Created January 2, 2017 15:55
The cluster module allows you to easily create child processes that all share server ports.
const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
@ndelangen
ndelangen / process1.js
Created January 2, 2017 15:06
If you have 2 independent NodeJS processes running and want them to communicate, this can be done reliably using a npm package: node-ipc
const ipc = require('node-ipc');
ipc.config.id = 'a-unique-process-name1';
ipc.config.retry = 1500;
ipc.config.silent = true;
ipc.serve(() => ipc.server.on('a-unique-message-name', message => {
console.log(message);
}));
ipc.server.start();
@KiaraGrouwstra
KiaraGrouwstra / proxy-async.js
Last active January 3, 2021 15:36
using ES6 Proxy to let Promises/Observables pretend like they're regular values
// using ES6 Proxy to let Promises/Observables pretend like they're regular values.
// get the mapping function used for async objects
let getMapper = (target) => target instanceof Promise ? 'then' :
target instanceof Observable ? 'switchMap' : null;
// ^ fails if the Observable is in a local namespace e.g. Rx.Observable
// bind a value to its object if it's a function
let bindFn = (val, obj) => typeof val == 'function' ? val.bind(obj) : val;
@johnboiles
johnboiles / enable-charles-proxy.sh
Last active January 28, 2021 07:48
Add this as a "Run Script" build phase in Xcode to enable Charles Proxy on iOS 9
#!/bin/sh
# enable-charles-proxy.sh
#
# Created by John Boiles on 9/21/15.
#
# This script sets :NSAppTransportSecurity:NSAllowsArbitraryLoads to true in the Info.plist file if building the Debug configuration.
# This enables debugging from https proxies such as Charles.
INFO_PLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
@DoguD
DoguD / config.yml
Last active February 11, 2021 22:31 — forked from alexttransisland/gist:e8ebb98f769d31d7d0a0111550eb4bd8
Run Android emulator on CircleCI 2.0 macOS
version: 2
reference:
## Constants
gradle_cache_path: &gradle_cache_path
gradle_cache-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
workspace: &workspace
~/src
## Configurations
android_config: &android_config
working_directory: *workspace