Skip to content

Instantly share code, notes, and snippets.

View FaiChou's full-sized avatar
:octocat:
Focusing

周辉 FaiChou

:octocat:
Focusing
View GitHub Profile
HTTP/1.1 200 Connection established
HTTP/2 200
date: Thu, 04 May 2023 08:23:18 GMT
content-type: text/event-stream
access-control-allow-origin: *
cache-control: no-cache, must-revalidate
openai-model: gpt-3.5-turbo-0301
openai-organization: user-lfzgwo6e1z7v3qr5xxxx
openai-processing-ms: 633
{
"messages" : [
{
"content" : "翻译 string",
"role" : "user"
},
{
"content" : "从1数到40",
"role" : "user"
},
import React from 'react';
var obj = null;
var listener = null;
function getObj() {
return obj;
}
function setListener(l) {
listener = l;
}
function Detail() {
const [x, addOneToX] = React.useReducer(x=>x+1,0);
const [, forceUpdate] = React.useReducer(x=>x+1,0);
console.log('render: ', x);
React.useEffect(() => {
console.log('effect: ', x);
return function() {
console.log('cleanup: ', x);
}
}, [x]);
initJpush() {
const navigation = this.refs.app_root_nav._navigation;
console.log("navigation", navigation);
// 新版本必需写回调函数
if (!isIos) {
JPushModule.notifyJSDidLoad((resultCode) => {
if (resultCode === 0) {
console.log(resultCode)
}
});
@FaiChou
FaiChou / react-native-flatlist-load-more.js
Created October 26, 2019 05:49
A demo for react-native FlatList with load more action
class Demo extends React.Component {
state = {
data: [],
refreshing: true,
last_id: 0,
}
onEndReachedCalledDuringMomentum = true
componentDidMount() {
this._refreshData();
}
@FaiChou
FaiChou / GoogleSearchFilter
Created May 10, 2019 00:52
A tampermonkey script to filter bad information searching on google
// ==UserScript==
// @name GoogleSearchFilter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description filter google search!
// @author FaiChou
// @match https://www.google.com/search*
// @grant none
// ==/UserScript==
@FaiChou
FaiChou / Address.js
Last active January 4, 2019 09:11
React address demo js file
import React from 'react';
import ReactDOM from 'react-dom';
import '../styles/swiper.css';
function coroutine(f) {
const o = f(); // instantiate the coroutine
o.next(); // execute until the first yield
return function(x) {
o.next(x);
};
@FaiChou
FaiChou / NotificationCenter.js
Last active April 3, 2018 15:02
A javascript notification for react-native
// FaiChou
// willMount add
// willUnmount remove
const __notices = []; // eslint-disable-line
const isDebug = true;
// register notification,name: notification name,selector: function for action to do,observer: type Object
export const addNotification = (name, selector, observer) => {
@FaiChou
FaiChou / webpack.config.js
Created July 26, 2017 07:54 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"