Skip to content

Instantly share code, notes, and snippets.

View 0x30's full-sized avatar
👊
不会武功 天生神力

wenzheng 0x30

👊
不会武功 天生神力
View GitHub Profile
@0x30
0x30 / libPopup.tsx
Last active September 2, 2022 07:35
vue 动态创建 组件的辅助方法
/**
* 动态弹出视图方法
*
* ```ts
* const { show, close } = usePopup();
show(
<button
onClick={async () => {
@0x30
0x30 / check.swift
Created May 30, 2022 10:52
IOS Check Tcp Port Can use
func tcpPortIsCanUse(port: in_port_t) -> Bool {
let socketFileDescriptor = socket(AF_INET, SOCK_STREAM, 0)
if socketFileDescriptor == -1 {
return false
}
defer {
Darwin.shutdown(socketFileDescriptor, SHUT_RDWR)
close(socketFileDescriptor)
}
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
OpenInstall = function (e, n, t) {
function r(n) {
n = n || e.location.href;for (var t = n.indexOf("?"), r = -1 == t ? "" : n.substring(t + 1).replace(/\+/g, "%20"), i = r.split("&"), o = {}, a = 0; a < i.length; a++) {
var c = i[a].split("="),
u = decodeURIComponent(c[0] || ""),
l = decodeURIComponent(c[1] || "");u && l && (void 0 === o[u] ? o[u] = l : "object" == _typeof(o[u]) ? o[u].push(l) : o[u] = [o[u], l]);
@0x30
0x30 / useMountComponentAndAnimed.tsx
Created October 29, 2020 09:14
vue3 动态加载模块 并且设置进入和离开动画 可以统一管理这些弹出框
import {
Component,
createApp,
defineComponent,
onMounted,
PropType,
ref,
Transition
} from "vue";
@0x30
0x30 / ToggleDarkMode.js
Created December 24, 2019 10:29
JavaScript change dark mode
// Query for the toggle that is used to change between themes
const toggle = document.querySelector('#themeToggle');
// Listen for the toggle check/uncheck to toggle the dark class on the <body>
toggle.addEventListener('ionChange', (ev) => {
document.body.classList.toggle('dark', ev.detail.checked);
});
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
/**
use:
```js
import router from "<you router path>"
import KeepScroll from "<you code path>"
Vue.use(KeepScroll, { router })
```
@0x30
0x30 / String+Country.swift
Last active March 31, 2023 07:48
城市代码 获取 Emoij , 字符串 拼音 处理
//
// String+Country.swift
// Rate
//
// Created by 0x30 on 2017/11/20.
// Copyright © 2017年 s. All rights reserved.
//
import Foundation
@0x30
0x30 / String+Regex.swift
Created December 20, 2017 08:00
使用 STRegex 完成 jsonp 完成数据的解析, 将字符串完成 gb2312 编码解析
//
// String+Regex.swift
// Rate
//
// Created by 荆文征 on 2017/11/20.
// Copyright © 2017年 s. All rights reserved.
//
import Regex
import Foundation
@0x30
0x30 / UIScrollView+topBackColor.mm
Created November 13, 2017 05:36
UIScrollerView Top screen backColor
-(void)setTopBackgroundColor:(UIColor *)color{
CGRect frame = self.bounds;
frame.origin.y = -CGRectGetHeight(UIScreen.mainScreen.bounds);
frame.size = UIScreen.mainScreen.bounds.size;
UIView* grayView = [UIView.alloc initWithFrame:frame];
grayView.backgroundColor = color;
[self addSubview:grayView];
}
@0x30
0x30 / UIColor+Loan.m
Created November 13, 2017 05:35
UIColor init With hexString
+ (UIColor *)colorFromHexString:(NSString *)hexString {
unsigned rgbValue = 0;
NSScanner *scanner = [NSScanner scannerWithString:hexString];
[scanner setScanLocation:1]; // bypass '#' character
[scanner scanHexInt:&rgbValue];
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
}