This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
def main(): | |
random.seed(time.time()) | |
names = open("names.txt").read().split("\n") | |
items = ["iPad mini6 64G"] * 5 + ["iPad 9th 256G"] * 15 + ["apple watch 9 45mm al"]*3 | |
random.shuffle(names) | |
for (name, item) in zip(names, items): | |
print(f"{name} {item}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct A { | |
uint64_t f1; | |
}; | |
struct B { | |
uint64_t f1; | |
uint64_t f2; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct BufferInterval<T, S, I> | |
where | |
T: Stream<Item = I>, | |
S: Store<Item = I>, | |
I: Clone, | |
{ | |
interval: Interval, | |
rx: T, | |
store: S, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lanaya apiv2 | |
## POST /api/v2/clusters | |
### json参数 | |
| 参数名 | 参数类型 | 是否必须 | 备注 | | |
|--------------------|----------|----------|------------------------------------------------------| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(iterator_step_by)] | |
use std::time::SystemTime; | |
// 10! = 3_628_800 | |
const TIMES: usize = 3_628_800 * 100; | |
fn lock_concurrency(worker: usize) { | |
use std::sync::{Mutex, Arc}; | |
use std::thread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(test)] | |
extern crate test; | |
#[bench] | |
fn test_lock(b: &mut test::Bencher) { | |
use std::sync::Mutex; | |
let locker = Mutex::new(1u32); | |
b.iter(|| { | |
for _ in 0..1000 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::time::SystemTime; | |
fn main() { | |
let letters: String = (b'a'..b'z' + 1).map(|c| c as char).collect(); | |
let repeated = letters.repeat(1000_0000); | |
let now = SystemTime::now(); | |
let mut rslt: Vec<_> = (0..26).map(|_| 0).collect(); | |
for ch in repeated.chars() { | |
let pos = ch as usize - 'a' as usize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gevent.monkey | |
gevent.monkey.patch_all() | |
import time | |
from multiprocessing import Process | |
import gevent | |
import redis | |
from lanaya.invoker.bind import unwrap_bind | |
c = redis.StrictRedis() | |
def greenlet_func(): | |
time.sleep(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
class Parent(namedtuple("Parent",'name')): | |
def show(self): | |
print(self.name) | |
class Child(namedtuple("FirstChild", "sex"), Parent): | |
def show_sex(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{ops, fmt}; | |
#[derive(PartialEq, Debug)] | |
pub struct Matrix<T> { | |
data: Vec<T>, | |
row: usize, | |
col: usize, | |
} | |
impl<T: Copy> Matrix<T> { |
NewerOlder