Skip to content

Instantly share code, notes, and snippets.

View Josscii's full-sized avatar
💭
??

Josscii Josscii

💭
??
View GitHub Profile
@Josscii
Josscii / weixin.md
Last active December 22, 2023 21:16
wechat_spider 原理扫盲帖

wechat_spider 原理扫盲帖

这篇文章旨在为刚接触 wechat_spider 的人提供一个快速了解这个项目基本原理的途径。

思路

首先我们随便进入一个微信公众号详情页。

@Josscii
Josscii / drawing.md
Last active August 4, 2022 14:26
iOS 绘图那些事

iOS 绘图那些事

在 iOS 中,我们通过 Core Graphics (也叫 Quarz 2D) 来绘图,而在 Core Grapihcs 之上的 UIKit 又封装了如 UIBeizerPath 等高级 api,这里就来简单的谈谈基础和技巧。

draw(_:)

对于 UIView 来说,我们可以重写 draw(_:) 方法来进行绘图,官方文档中对它的描述是:

Specifically, UIKit creates and configures a graphics context for drawing and adjusts the transform of that context so that its origin matches the origin of your view’s bounds rectangle.
@Josscii
Josscii / parseflomo.js
Created April 30, 2022 07:55
parse flomo html to md file
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const fs = require("fs");
const files = [
"202012.html",
"202111.html",
"202112.html",
"202201.html",
"202202.html",
@Josscii
Josscii / GlobalSpinnerContextProvider.tsx
Created April 18, 2022 05:35
how to use context with children to avoid rerender
import GlobalSpinner from '@/components/GlobalSpinner'
import { contextFactory } from './helpers/contextFactory'
import { useToggleState } from '@/hooks/useToggleState'
type GlobalSpinnerContextProviderProps = {
children: React.ReactNode
}
const GlobalSpinnerContextProvider = (
props: GlobalSpinnerContextProviderProps
@Josscii
Josscii / contextFactory.ts
Last active April 18, 2022 05:27
react typescript context helper
import { createContext, useContext } from 'react'
export const contextFactory = <A extends unknown | null>() => {
const context = createContext<A | undefined>(undefined)
const useCtx = () => {
const ctx = useContext(context)
if (ctx === undefined) {
throw new Error('useContext must be used inside of a Provider with a value.')
}
return ctx
@Josscii
Josscii / SkeletonLoader.tsx
Created February 12, 2022 08:05
try to create skeleton with styled component
import { FunctionComponent } from "react";
import styled, { keyframes, css } from "styled-components";
const SkeletonLoader: FunctionComponent<{
isLoading?: boolean;
}> = (props) => {
return (
<Content isLoading={props.isLoading}>
{props.isLoading && <Loader />}
{props.children}
@Josscii
Josscii / oc-runtime.md
Last active December 20, 2021 15:01
oc 运行时学习记录
@Josscii
Josscii / dart.md
Last active September 9, 2021 23:21
dart cheat sheet

string interpolation

var a = 3;
print("$a 123");
print("${a+1} 123");

final const

@Josscii
Josscii / iOS Navigation.md
Last active August 28, 2021 17:49
iOS Navigation Related Cheat Sheet

iOS Navigation Related Cheat Sheet

NavigationItem

每个 vc 都有自己的 navigationItem。

// 隐藏 push 的下一个 vc 的 back title。
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
@Josscii
Josscii / InnerShadow.swift
Last active July 30, 2021 10:20
create inner shadow - forget original source
// use after view has been layout
extension UIView
{
// different inner shadow styles
public enum innerShadowSide
{
case all, left, right, top, bottom, topAndLeft, topAndRight, bottomAndLeft, bottomAndRight, exceptLeft, exceptRight, exceptTop, exceptBottom
}