This file contains hidden or 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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"os" | |
) | |
type UserList struct { |
This file contains hidden or 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
#![cfg_attr(not(feature = "std"), no_std)] | |
// a module for proof of existence | |
pub use pallet::*; | |
#[frame_support::pallet] | |
pub mod pallet { | |
use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; | |
use frame_system::pallet_prelude::*; | |
use sp_std::vec::Vec; |
This file contains hidden or 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::thread; | |
use std::net::{TcpListener, TcpStream, Shutdown}; | |
use std::io::{Read, Write}; | |
use std::str; | |
fn handle_client(mut stream:TcpStream) { | |
let mut data = [0 as u8; 50]; // 设置50个字节的数据缓冲区, 传输的数据被按50个字节切割 | |
while match stream.read(&mut data) { // match表达式返回true或者false 控制空循环 | |
Ok(size) => { // 当前的数据缓冲块的长度 | |
println!("size is {}", size); |
This file contains hidden or 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
enum TrafficTight { | |
Red, | |
Green, | |
Yellow, | |
} | |
impl TrafficTight { | |
fn time(&self) -> u8 { |
This file contains hidden or 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
app.get('/dog/age/:age', (req, res) => { | |
redis.lrange('dog:age:' + req.params.age) | |
.then((data) => Promise.all(data.map(redis.hgetall))) | |
.then((data) => res.send(data)); | |
console.timeEnd('request'); | |
}) | |
app.get('/dog/age/:age', (req, res) => { | |
redis.lrange('dog:age:'+req.params.age) | |
.then((data)=> { |
This file contains hidden or 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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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
# hit | |
## hello | |
![http://lorempixel.com/125/125/animals/9/cc] |