Skip to content

Instantly share code, notes, and snippets.

View suhaotian's full-sized avatar
🎯
Focusing

su suhaotian

🎯
Focusing
View GitHub Profile
@nyhassan
nyhassan / Settings.tsx
Created January 8, 2024 22:57
Turnstile app screens header opacity interpolation
import { useHeaderHeight } from "@react-navigation/elements";
import { Stack } from "expo-router";
import { Platform, ScrollView, StyleSheet, View } from "react-native";
import Animated, {
interpolate,
useAnimatedScrollHandler,
useAnimatedStyle,
useSharedValue,
} from "react-native-reanimated";
import { useTheme } from "src/context/ThemeProvider";
// component state
class LedgerContainer extends React.Component {
state = {
debits: null,
credits: null,
creditsError: null,
debitsError: null
}
componentDidMount() {
@nikgraf
nikgraf / reactive-2016.md
Last active August 5, 2021 15:31
Proposal for lightning talk at Reactive Conf 2016

Rich text editing with DraftJS Plugins

Earlier this year Facebook open sourced its React based rich text editing framework Draft.js. At Facebook it powers status updates, comments & notes. Others used it to build editors matching Medium’s experience.

Together with a whole team of open source contributors I built a plugin architecture on top of Draft.js. In this talk I walk you through the existing plugins and show how you can build your own feature-rich text editor for the web with only a handful lines of code. 🤓

Draft JS Plugins Logo

@knowbody
knowbody / App.js
Last active September 11, 2023 09:31
Check internet connection in React Native app
// quick snippet to check the connection in your RN app
// dispatches an `setIsConnected` action every time the NetInfo changes (on/off network)
componentDidMount() {
const dispatchConnected = isConnected => this.props.dispatch(setIsConnected(isConnected));
NetInfo.isConnected.fetch().then().done(() => {
NetInfo.isConnected.addEventListener('change', dispatchConnected);
});
}
@gaearon
gaearon / connect.js
Last active April 19, 2025 04:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@luckyadam
luckyadam / adaptation
Last active April 19, 2017 10:19
移动端多屏适配
移动端适配方案总结
===
> 移动端开发总是存在很多的挑战,兼容性、性能、更高要求的用户体验,都是前端攻城狮需要一一攻破的壁垒。而大屏、高分辨率的手机的出现,又为攻城狮们立下了一个新的制高点,如何适配不同尺寸,不同分辨率的机器,如何在高清分辨率的屏幕上为用户呈现更精致的作品,是前端攻城狮新的挑战。
### 利用zoom适配
在进行拍拍小店的开发中我们发现页面在高清分辨率的手机如iPhone6 Plus上表现不尽如人意,有些元素还有文案在这些手机上显示得太小,视觉体验非常不好。咋办类?为了快速解决适配更高分辨率手机的问题,我们天马行空地想到,直接将页面按照一定比例缩放不就好啦,这样在更高分辨率的手机上将页面适当放大,不就能达到适配高清分辨率手机的目的。
@chantastic
chantastic / on-jsx.markdown
Last active November 10, 2024 13:39
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@kejun
kejun / gist:72112e5848f5e3921b0d
Created March 7, 2015 12:14
react + linear partition算法实现的图墙布局
var React = require('react');
var EventListener = require('react/lib/EventListener');
var partition = require('linear-partitioning');
var TileLayout = React.createClass({
getDefaultProps: function() {
return {
gutter: 0,
photos: []
}
@gaearon
gaearon / createAsyncPage.jsx
Last active April 25, 2023 09:06
Webpack's async code splitting with React Router
'use strict';
var React = require('react');
function createAsyncHandler(getHandlerAsync, displayName) {
var Handler = null;
return React.createClass({
displayName: displayName,
@fqrouter
fqrouter / readme.txt
Last active February 14, 2025 03:11
shadowsocks 公共代理的必要设置
good, 你已经有了一个自己的shadowsocks代理了,现在想要把这个代理公布出去给所有人分享。
但是没有两个小时,代理就没法使用了,为什么?因为你需要额外注意以下事项(以下步骤需要比较高的linux技能)
本文只关注于确保shadowsocks服务还“活着”,如果你希望让其跑得更快,请参考
https://github.com/clowwindy/shadowsocks/wiki/Optimizing-Shadowsocks
1、 shadowsocks的timeout设置
超时时间越长,连接被保持得也就越长,导致并发的tcp的连接数也就越多。对于公共代理,这个值应该调整得小一些。推荐60秒。
2、 检查操作系统的各种限制
对于openvz的vps,特别需要检查一下