Skip to content

Instantly share code, notes, and snippets.

View liweinan's full-sized avatar
🎯

Wei Nan Li liweinan

🎯
View GitHub Profile
#include<iostream>
using namespace std;
struct node {
int data;
node *next;
};
int main() {
@liweinan
liweinan / index.html
Created November 26, 2020 18:09
Vue 3 Wrapper Component Example
<div id="el"></div>
<!-- using string template here to work around HTML <option> placement restriction -->
<script type="text/x-template" id="demo-template">
<div>
<p>Selected: {{ selected }}</p>
<select2 :options="options" v-model="selected">
<option disabled value="0">Select one</option>
</select2>
</div>
@liweinan
liweinan / macro.rs
Created August 24, 2020 06:49
macro.rs
macro_rules! A {
(1+ $input:expr) => {
$input + 1
};
(2+ $input:expr) => {
$input + 2
};
}
fn main() {
@liweinan
liweinan / .vimrc
Created August 22, 2020 06:10
.vimrc
set nocompatible " be iMproved, required
filetype off " required
syntax on
let g:python3_host_prog = '/Users/weli/.pyenv/versions/3.8.5/bin/python'
let g:python_host_prog = '/Users/weli/.pyenv/versions/2.7.18/bin/python'
nmap <C-n> :NERDTreeToggle<CR>
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
@liweinan
liweinan / JS Snippets
Last active August 19, 2020 13:09
JS Snippets
JS Snippets
@liweinan
liweinan / play_with_struct.rs
Created August 17, 2020 19:51
Rust Code Snippets
struct Foo {
x: i32,
s: String,
opt: Option<i32>,
}
struct Bar(i32, i32);
fn play_with_struct() -> Foo {
let d = Foo {
@liweinan
liweinan / callback.rs
Created August 17, 2020 06:26
Rust Callback
type Callback = fn();
struct Processor {
callback: Callback,
}
impl Processor {
fn process_event(&self) {
(self.callback)();
}
@liweinan
liweinan / fedora_bcc.md
Created August 8, 2020 15:48
fedora bcc

Fedora BCC Example

@liweinan
liweinan / 2638.md
Created July 16, 2020 13:34
RESTEASY2638 Root Cause

The root cause is because JSONB can't unmarshall an interface.

@liweinan
liweinan / LearnRust.rs
Created April 28, 2020 03:07
LearnRust
// 关于by value和by reference
fn main() {
let x = String::from("hi");
let y = &x;
println!("{}", y);
let z = {
let _z = String::from("42");
_z