Skip to content

Instantly share code, notes, and snippets.

@Luoyayu
Luoyayu / mixin-example.dart
Last active March 6, 2022 10:24
Tour of Dart: A simple Mixin example about printer
/// Tour of Dart
/// A simple Mixin example about printer.
class Paper {
String sizeName = 'Paper';
// bool printable = false;
// Paper(this.sizeName, this.printable);
/// Here we don't care whether Paper can be printed,
@Luoyayu
Luoyayu / PKGBUILD
Last active September 12, 2020 07:03 — forked from EHfive/PKGBUILD
给VLC打补丁, 使flac网络文件/流的Content-Type始终为"audio/flac", 以"修复"网易云音乐获取的flac网络文件Content-Type为"audio/mpeg"而导致VLC不能正确识别文件而播放失败的问题
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Giovanni Scafora <[email protected]>
# Contributor: Sarah Hay <[email protected]>
# Contributor: Martin Sandsmark <[email protected]>
pkgname=vlc
_vlcver=3.0.6
# optional fixup version including hyphen
_vlcfixupver=
pkgver=${_vlcver}${_vlcfixupver//-/.r}
@Luoyayu
Luoyayu / gist:3c5f099dd1a453f049fced1df7bc7964
Created December 12, 2019 18:48
extract Xcode.xip to a customed volume
By default, when extracts the Xcode.zip,
macos will create tmp file in `/private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T/com.apple.AUHelperService`.
Sometimes, the /private has no ehough space to hold 19GB Xcode.app.
Thus we can create a soft link named `com.apple.AUHelperService` in the tmp dir.
Steps:
1. BACKUP `com.apple.AUHelperService` in `/private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T/` to `com.apple.AUHelperService_BACKUP`
2. mkdir named `com.apple.AUHelperService` wherever you have enough space,
3. ln -s /your/absolute/path/com.apple.AUHelperService /private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T
4. double click the Xcode.xip
@Luoyayu
Luoyayu / init.vim
Last active January 11, 2022 11:31
coc init.vim
" Plugin Manager
call plug#begin(expand('~/.vim/plugged'))
" 主题
Plug 'arcticicestudio/nord-vim'
Plug 'tpope/vim-sensible'
Plug 'liuchengxu/space-vim-theme'
" 格式工具
Plug 'Yggdroot/indentLine' " 缩进显示
Plug 'scrooloose/nerdcommenter' " 注释工具
@Luoyayu
Luoyayu / bear_autosave.scpt
Last active May 12, 2021 16:17
Bear writer: autosave to icloud
tell application "System Events"
-- 前提/premiss:
-- 1. 在iCloud云盘下新建Bear文件夹/Create a new folder "Bear" under the iCloud
-- 脚本做的事:/What the script does:
-- 1. 自动化点击/Automated click
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
// 根据先序遍历判断是否是完全二叉树,输入-1表示null
struct TreeNode {
int ch;
struct TreeNode *left;
struct TreeNode *right;
};
@Luoyayu
Luoyayu / toposort.cpp
Last active January 23, 2018 14:13
toposort
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
std::vector<int> g[maxn], ans;
bool vis[maxn];
int indeg[maxn];
int n,m;
void toposort()
{
queue<int> q;
@Luoyayu
Luoyayu / AVL.cpp
Created January 3, 2018 08:42
AVL
#include <bits/stdc++.h>
using namespace std;
#define pass //
struct node
{
node *lc, *rc;
int key, color,height;
node(){}
node(int key):key(key){}
}*root;
@Luoyayu
Luoyayu / HDU 1710.cpp
Created January 2, 2018 12:48
給出二叉樹的先序排列和中序排序建樹
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000+7;
/* 二叉树的三种遍历方式:preorder, inorder, postorder
* 左子树T1, 右子树T2, 根 r
* 题意:给出preorder和inorder,求postorder
* 思想:先根据先序遍历和中序遍历建二叉树树,然后求后序遍历即可, 注意若只给出前序和后序则是无法建树的
* 9
1 2 4 7 3 5 8 9 6
4 7 2 1 8 5 9 3 6
@Luoyayu
Luoyayu / BST.cpp
Last active January 2, 2018 12:46
二叉树
// 1. 二叉树第i层最多2^{i-1}个节点
// 2. 深度为k的二叉树最多右2^k-1个节点
// 3. 对于二叉树,设节点数为n, 有n0 + n1 + n2 = n; (*1)
// n = B + 1; // B 为分支数目
// n = n1 + 2*n2 + 1; (*2)
// 结合(*1)、(*2) 有 n0 = n2 + 1; (*3)
// 如用二叉链表表示,空指针数为n+1, 由(*3)、(*1)易得2*n0 + n1 = n + 1;
// 4. 具有n个节点的完全二叉树的深度为floor(log_2n)+1
#include <bits/stdc++.h>