Skip to content

Instantly share code, notes, and snippets.

@xjbeta
xjbeta / decode.swift
Last active June 18, 2019 04:10
swift4 codable decode different type in an array.
let str = """
{"jsonrpc": "2.0","result": [{"code": 1,"message": "error"},[{"gid": "123"}],{"code": 1,"message": "error2"},[{"gid": "124"}]]}
"""
let data = str.data(using: .utf8)!
struct JSONRPC: Decodable {
enum DecodingError : Swift.Error, LocalizedError {
case decodeMismatch(type: Any)
}
@xjbeta
xjbeta / .zpreztorc
Created July 22, 2018 13:31
.zpreztorc
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
@xjbeta
xjbeta / av39444.xml
Created November 4, 2018 04:56
av39444.xml
<?xml version="1.0" encoding="UTF-8"?><i><chatserver>chat.bilibili.com</chatserver><chatid>66926</chatid><mission>0</mission><maxlimit>1000</maxlimit><state>0</state><real_name>0</real_name><source>k-v</source>
<d p="11.05900,1,25,15138834,1514716259,0,a3e2d0e3,4145395986">赤い</d
><d p="297.81000,1,25,16711680,1514716699,0,ab30d12c,4145417811">赤い赤い赤い赤い赤い赤い赤い 赤い赤い赤い赤い</d>
<d p="43.19800,1,18,16777215,1514717541,0,8dd7a79f,4145467029">赤</d>
<d p="87.77900,1,25,15138834,1514718209,0,5786bb47,4145495702">二小姐求舔足</d>
<d p="32.33500,1,25,15138834,1514722845,0,507cc80b,4145738957">赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い</d>
<d p="32.33500,1,25,15138834,1514722905,0,507cc80b,4145741925">赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い</d>
<d p="12.61600,1,25,15138834,1514723211,0,507cc80b,4145758728">赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い</d>
<d p="12.61600,1,25,15138834,1514723233,0,507cc80b,4145758963">赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い</d>
<d p="12.61600,1,25,15138834,1514723118,0,507cc80b,4145759195">赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い赤い</d>
@xjbeta
xjbeta / iinaTest.swift
Last active March 3, 2019 03:55
IINA 'iina://' example.
import Cocoa
var urlQueryValueAllowed: CharacterSet = {
let generalDelimitersToEncode = ":#[]@?/" // does not include "?" or "/" due to RFC 3986 - Section 3.4
let subDelimitersToEncode = "!$&'()*+,;="
var allowed = CharacterSet.urlQueryAllowed
allowed.remove(charactersIn: generalDelimitersToEncode + subDelimitersToEncode)
return allowed
@xjbeta
xjbeta / format.swift
Last active March 3, 2019 03:54
Swift format xxx-xxx-xxx -> xxxXxxXxx
import Cocoa
func format(t: [String]) -> [String] {
var tt: [String] = []
t.forEach {
let a = $0.components(separatedBy: "-")
let b = a.map {
a.index(of: $0) != 0 ? $0.capitalized : $0
}.joined(separator: "")
@xjbeta
xjbeta / OhMyBiliLive.js
Last active June 18, 2019 03:50
花Q PiliPili
// ==UserScript==
// @name OhMyBiliLive
// @version 0.1
// @description 花Q PiliPili
// @author xjbeta
// @match https://live.bilibili.com/*
// @grant GM_addStyle
// ==/UserScript==
GM_addStyle('div.room-info-ctnr>.room-info-upper-row a.info-section, div.room-info-ctnr>.room-info-upper-row .upper-right-ctnr div.pointer, div.room-info-ctnr>.room-info-down-row div.icon-label {display: none;}');
@xjbeta
xjbeta / base64.swift
Created March 3, 2019 04:03
Swift base64
import Cocoa
let emailEncode = "test@gmail.com".data(using: .utf8)?.base64EncodedString() ?? ""
let 📧 = String(data: Data(base64Encoded: "dGVzdEBnbWFpbC5jb20=")!, encoding: .utf8)
@xjbeta
xjbeta / URLSecurityScope.swift
Created July 17, 2019 01:11
App SandBox Security-Scoped
//
// URLSecurityScope.swift
// Aria2D
//
// Created by xjbeta on 2017/1/24.
// Copyright © 2017年 xjbeta. All rights reserved.
//
import Foundation
[00007ffeefbfdcb0] main generic error: cannot load plug-in /Applications/VLC.app/Contents/Frameworks/plugins/libmacosx_plugin.dylib: dlopen(/Applications/VLC.app/Contents/Frameworks/plugins/libmacosx_plugin.dylib, 1): Library not loaded: @executable_path/../Frameworks/Sparkle.framework/Versions/A/Sparkle
Referenced from: /Applications/VLC.app/Contents/Frameworks/plugins/libmacosx_plugin.dylib
Reason: image not found
VLC LOG: VLC media player - 4.0.0-dev Otto Chriek
VLC LOG: Copyright © 1996-2020 the VideoLAN team
VLC LOG: revision 4.0.0-dev-11117-g1597704fc1
VLC LOG: configured with /Users/jenkins/workspace/vlc-nightly/vlc-nightly-macOS-contrib/extras/package/macosx/../../../configure '--prefix=/' '--enable-macosx' '--enable-merge-ffmpeg' '--enable-osx-notifications' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-shout' '--enable-ncurses' '--enable-twolame' '--enable-libass' '--enable-macosx-avfoundation' '--disable-skins2' '--disable-xcb' '--disable-caca' '--disable-pu
2020-02-20 10:03:53.142558+0800 livblc test[68253:1220711] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000252fe0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2020-02-20 10:03:53.182658+0800 livblc test[68253:1220711] HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
2020-02-20 10:03:53.183108+0800 livblc test[68253:1220711] HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
[00000001011092e0] main interface error: no suitable interface module
[0000000101757a30] main libvlc error: interface "macosx_dialog_provider,none" initialization failed
VLC LOG: VLC media player - 4.0.0-dev Otto Chriek
VLC LOG: Copyright © 1996-2018 the VideoLAN team
VLC LOG: revision 4.0.0-dev-5424-g494e0319af
VLC LOG: configured with /Users/jenkins/workspace/vlc-nightly/vlc-nightly-macOS-contrib/extras/package/macosx/../../../configure '--prefix=/Users/jenkins/workspace/vlc-nightly/vlc-nightly-macOS-contrib/build/vlc_install_dir'