Skip to content

Instantly share code, notes, and snippets.

@littleV
littleV / Cache.m
Created September 28, 2018 18:34
Cache.m
#import "Cache.h"
#import <WebKit/Webkit.h>
static NSInteger expireCacheMilliSeconds = 300000; // expire content cached longer than 5 minutes
@interface CacheOperation : NSOperation <UIWebViewDelegate, WKNavigationDelegate>
{
BOOL executing;
BOOL finished;
}
@littleV
littleV / genesis.py
Created December 7, 2018 21:33
Genesis
import random
import sys
def random01():
return random.randint(0,1)
# if 1+1 !=2 is false, it's easy, everything is normal
# but if 1+1 != 2 is true, what value should it be?
def baseRuleWhenOneMeetOne():
# In binary
@littleV
littleV / App.js
Created March 22, 2019 19:43
A React Native tab based app example
import React from "react";
import { Button, View, Text } from "react-native";
import { createStackNavigator, createAppContainer } from "react-navigation";
class HomeScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
<Button
@littleV
littleV / App.js
Created March 22, 2019 20:46
A React Native WebView Example
import React from "react";
import { Button, View, Text, WebView } from "react-native";
import { createStackNavigator, createAppContainer } from "react-navigation";
class HomeScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
<Button
@littleV
littleV / package.json
Created March 22, 2019 21:40
Bare minimal package.json for React Native
{
"name": "FancyLibs",
"version": "0.0.0",
"private": true,
"dependencies": {
"react": "^16.6.3",
"react-native": "^0.57.8"
},
"devDependencies": {
"babel-loader": "7.1.4",
@littleV
littleV / index.js
Created March 22, 2019 21:43
An example of how to use BatchedBridge in js code
import BatchedBridge from "react-native/Libraries/BatchedBridge/BatchedBridge";
import AppRegistry from 'react-native';
export class CommonInterface {
helloworld(message) {
alert("Hello World\n" + message);
}
}
const exposed = new CommonInterface();
public class UnifiedSDK {
private static ReactInstanceManager manager;
public static void init(Activity activity) {
if (manager == null) {
manager = ReactInstanceManager.builder()
.setApplication(activity.getApplication())
.setCurrentActivity(activity)
.setBundleAssetName("unifiedsdk.bundle")
.setJSMainModulePath("index")
{
"name": "UnifiedSDK",
"version": "0.0.0",
"private": true,
"scripts": {
"build-android": "react-native bundle --platform android --dev false --entry-file js/index.js --bundle-output android/fancylib/src/main/assets/unifiedsdk.bundle --assets-dest android/fancylib/src/main/res"
},
"dependencies": {
"react": "^16.6.3",
"react-native": "^0.57.8"
{
"name": "UnifiedSDK",
"version": "0.0.0",
"private": true,
"scripts": {
"build-android": "react-native bundle --platform android --dev false --entry-file js/index.js --bundle-output android/fancylib/src/main/assets/unifiedsdk.bundle --assets-dest android/fancylib/src/main/res"
},
"dependencies": {
"react": "^16.6.3",
"react-native": "^0.57.8"
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'FancyLibiOS' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for FancyLibiOS
pod 'React', :path => '../../node_modules/react-native', :subspecs => [
'Core',