Skip to content

Instantly share code, notes, and snippets.

View Fullstop000's full-sized avatar
🎯
Focusing

Fullstop000 Fullstop000

🎯
Focusing
  • Hangzhou Zhejiang
View GitHub Profile
package tt;
import (
"strings"
"testing"
"unsafe"
)
func BenchmarkUnsafePointerVSExplicitlyConvert(b *testing.B) {
s := strings.Repeat("a", 1000)
bytes := []byte(s)
package main
import (
"fmt"
"sync"
"testing"
cmap "github.com/orcaman/concurrent-map"
)
#![feature(test)]
extern crate test;
fn main() {
println!("Hello, world!");
}
#[cfg(test)]
mod tests {
use test::Bencher;
@Fullstop000
Fullstop000 / main.go
Last active November 21, 2019 09:07
Something about pointer and value in go
package main
import (
"fmt"
)
type Test struct {
A int
}
             +----------+
             |          |
             |    C     |
             |          |
             +----^-+---+
                  | |
                  | |
 MsgAppend(e[4,5])| | MsgAppendResp
 | |
package common
import (
"fmt"
"reflect"
)
// `flatten` recursively retrieves every leaf node in a struct in depth-first fashion
// and aggregate the results into given string slice with format: "path.to.leaf = value"
// in the order of definition. Root name is ignored in the path. This helper function is
@Fullstop000
Fullstop000 / dlist.rs
Created May 27, 2019 10:54
double-linked list using Rust
use std::cell::RefCell;
use std::rc::{Rc, Weak};
pub type NodePtr<T> = Rc<RefCell<Node<T>>>;
#[derive(Debug)]
pub struct Node<T> {
pub data: T,
pub prev: Option<Weak<RefCell<Node<T>>>>,
pub next: Option<Rc<RefCell<Node<T>>>>,
}
#[macro_export]
macro_rules! invarint {
($condition:expr, $($arg:tt)*) => {
if !$condition {
panic!($($arg)*);
}
};
}
use mio::{Handler, EventLoop};
use std::{thread, time};
fn main() {
let mut event_loop = EventLoop::<MyHandler>::new().unwrap();
let sender = event_loop.channel();
let sender2 = sender.clone();
thread::spawn(move || {
loop {
thread::sleep(time::Duration::from_secs(1));
@Fullstop000
Fullstop000 / unix_permission.md
Last active April 23, 2018 06:08
What unix permission code means
+-----+---+--------------------------+
| rwx | 7 | Read, write and execute  |
| rw- | 6 | Read, write              |
| r-x | 5 | Read, and execute        |
| r-- | 4 | Read,                    |
| -wx | 3 | Write and execute        |
| -w- | 2 | Write                    |
| --x | 1 | Execute                  |
| --- | 0 | no permissions |