Skip to content

Instantly share code, notes, and snippets.

@funway
funway / RedirectWikiMobile2Desktop.js
Created October 2, 2022 08:36
a tempermonkey's js script that redirect wiki mobile page to desktop version.
// ==UserScript==
// @name Redirect Wiki Mobile to Desktop UI
// @name:zh-CN 移动端维基重定向到桌面端
// @namespace https://hawu.me
// @version 0.1
// @description Redirect wiki mobile version to desktop version. Auto redirect or Offer a hyperlink on the top of mobile version page.
// @description:zh-CN 将维基百科的移动端页面重定向到桌面端(两种方式:自动重定向 或 在移动端页首增加桌面端的跳转链接)
// @author funway
// @match https://zh.m.wikipedia.org/*
// @icon https://zh.wikipedia.org/favicon.ico
@funway
funway / TimerTest.swift
Created August 6, 2020 01:31
View with NSWindowDelegate, listens window events
import SwiftUI
struct TimerTest: View {
@State var date = Date()
@State var showSubView = false
var windowDelegate: MyWindowDelegate = MyWindowDelegate()
var body: some View {
ZStack{
if showSubView {
@funway
funway / TimerTest.swift
Created August 4, 2020 02:18
TimerPublisher conflict with NSWindow.willCloseNotification
import SwiftUI
struct TimerTest: View {
@State var showSubView = false
@State var date1 = Date()
@State var timer1 = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
weak var myWindow: NSWindow?
// In AppDelegate.swift, use "let contentView = TimerTest(myWindow: window)"
var body: some View {
@funway
funway / TimerTest.swift
Last active August 5, 2020 03:32
Test of TimerPublisher in SwiftUI
import SwiftUI
struct TimerTest: View {
@State var date = Date()
@State var showSubView = false
@State var timer: Timer?
@State var date1 = Date()
@State var timer1 = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
var body: some View {
@funway
funway / Laravel-Container.md
Last active April 20, 2020 04:49
Laravel's Dependency Injection Container in Depth 【中文翻译】

深入理解Laravel容器

Laravel 是一个具有很强控制反转(IoC)与依赖注入(DI)能力的容器。不幸的是它的官方文档没有更详细的介绍这些用法,所以我决定自己做点试验并写些更详细的文档。下面所有的都是基于Laravel 5.4.26,不同版本可能有异。

依赖注入

我不会在这里介绍DI/IoC的原理,如果对依赖注入与控制反转不是很熟悉,你可以阅读这篇文章 What is Dependency Injection?

访问容器