Skip to content

Instantly share code, notes, and snippets.

View 1uokun's full-sized avatar
🤙
always-online, part-time job contract me

罗坤 1uokun

🤙
always-online, part-time job contract me
View GitHub Profile
@1uokun
1uokun / NavigationService.js
Created November 18, 2020 03:46
NavigationService.js
import { NavigationActions } from 'react-navigation';
let _navigator;
function setTopLevelNavigator(navigatorRef) {
_navigator = navigatorRef;
}
function navigate(routeName, params, key) {
_navigator.dispatch(
@1uokun
1uokun / RealPathUtil.java
Last active June 27, 2024 07:18 — forked from tatocaster/RealPathUtil.java
Real Path Utility class for Android, works for all API
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {
@1uokun
1uokun / 1.js
Created June 19, 2019 03:21
<script defer async>
console.log(a)
document.addEventListener('DOMContentLoaded', function(event) {
console.log("DOMContentLoaded in serve");
});
@1uokun
1uokun / JSX&AST.html
Created April 21, 2019 07:32
Implementing JSX with AST
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
// 调用svgCompile编译器
@1uokun
1uokun / State.html
Created April 21, 2019 06:56
状态模式初探
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="border:1px #000000 solid;padding:10px">
<p>一个台灯只有开和关</p>
<h1 id="text">关</h1>
@1uokun
1uokun / Inert-single-case.html
Last active March 23, 2019 15:23
惰性单例简单应用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="hello"></div>
<button onclick="open1()">open</button>
<button onclick="close1()">close</button>
@1uokun
1uokun / react-native-root-view.js
Last active June 21, 2024 07:16
react-native-root-view by AppRegistry.registerComponent
/**
* react-native-root-view
*
* @article https://www.jianshu.com/p/2c79684481b3
* @auth https://github.com/1uokun
* */
import React, { Component } from 'react';
import { StyleSheet, AppRegistry, View, ScrollView, DeviceEventEmitter } from 'react-native';
@1uokun
1uokun / createElement.js
Created September 25, 2018 08:10
React.createElement
const React = {
createElement: function (tag, attrs, children) {
var element = document.createElement(tag);
for (let name in attrs) {
if (name && attrs.hasOwnProperty(name)) {
let value = attrs[name];
if (value === true) {
element.setAttribute(name, name);
} else if (value !== false && value != null) {
@1uokun
1uokun / Component.js
Last active September 25, 2018 08:15
React simple Component
/**
* @param type | string | element
* @param node.props | object | attr/event
* @param node.children | array | loop top/textNode
* */
class Component {
constructor(){
document.getElementById('app').appendChild(this.createElement(this.render()))
}
createElement(node){