This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int _HashingSourceInfo(in_addr_t sourceIp, uint32_t sourceId) | |
{ | |
// [0] Cantor pairing function | |
unsigned long long key = (sourceIp + sourceId) * (sourceIp + sourceId + 1) / 2 + sourceId; | |
// Ref: http://elliottback.com/wp/hashmap-implementation-in-c/ | |
// [1] Robert Jenkins 32 bit Mix Function | |
key += (key << 12); | |
key ^= (key >> 22); | |
key += (key << 4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var overrideFuncs = ["log", "error", "info", "warn", "trace"]; | |
for (var i = 0, n = overrideFuncs.length; i < n; ++i) { | |
(function(fName) { | |
var fn = console[fName]; | |
console[fName] = function() { | |
var time = new Date().toISOString(); | |
var newArgs = Array.prototype.slice.call(arguments); | |
newArgs.unshift(time + " [" + fName.toUpperCase() + "] -"); | |
fn.apply(this, newArgs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RNSampleModule extends ReactContextBaseJavaModule { | |
public static final String TAG = "RNSampleModule"; | |
private GitHubService mGitHubService; | |
public class Release { | |
public String tagName; | |
public String htmlUrl; | |
} | |
public interface GitHubService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocationManager extends ReactContextBaseJavaModule { | |
public static final String TAG = "LocationManager"; | |
private static final int LOCATION_TIMEOUT_IN_SECONDS = 10; | |
private static final int LOCATION_UPDATE_INTERVAL = 1000; | |
public LocationManager(ReactApplicationContext reactContext) { | |
super(reactContext); | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSomething() { | |
let cachePromiseFn = () => { | |
return cacheStorage.getItem(CACHE_KEY) | |
.then(value => { | |
return value && JSON.parse(value); | |
}); | |
}; | |
let requestPromiseFn = () => { | |
return fetch('https://localhost/foo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let immutableDataList = Immutable.List.of( | |
Immutable.Map({id: 123, name: 'foo'}), | |
Immutable.Map({id: 456, name: 'bar'}), | |
); | |
let dataSource = new ListView.DataSource({ | |
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | |
getRowData: (dataBlob, sectionID, rowID) => { return dataBlob[sectionID].get(rowID); } | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto HelloCxxModule::getMethods() -> std::vector<Method> { | |
return { | |
Method("foo", [](folly::dynamic args, Callback cb) { cb({"foo"}); }), | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto HelloCxxModule::getConstants() -> std::map<std::string, folly::dynamic> { | |
return { | |
{"one", 1}, {"two", 2}, {"animal", "fox"}, | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" HelloCxxModule* createHelloCxxModule() { | |
return new HelloCxxModule(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto HelloCxxModule::getMethods() -> std::vector<Method> { | |
return { | |
Method("bar", | |
[this]() { | |
if (auto reactInstance = getInstance().lock()) { | |
reactInstance->callJSFunction( | |
"RCTDeviceEventEmitter", "emit", | |
folly::dynamic::array( | |
"appStateDidChange", | |
folly::dynamic::object("app_state", "active"))); |
OlderNewer