Skip to content

Instantly share code, notes, and snippets.

Avatar

Le Dinh Cuong cuongld2

View GitHub Profile
@cuongld2
cuongld2 / search.rs
Created Sep 22, 2020
Calling public struct
View search.rs
use search::SearchElement;
#[path="../src/models/search.rs"]
pub mod search;
use std;
#[tokio::test]
async fn call_api() -> Result<(), Box<dyn std::error::Error>> {
let res = reqwest::Client::builder()
.danger_accept_invalid_certs(true)
.build()
@cuongld2
cuongld2 / search.rs
Created Sep 22, 2020
Define public struct
View search.rs
#[derive(Deserialize, Debug)]
pub struct SearchElement{
pub auth_resource_path: String,
pub field: String,
pub id: String,
pub project_id: String,
#[serde(rename = "type")]
pub typepp: String,
pub value: String,
}
@cuongld2
cuongld2 / main.rs
Created Sep 22, 2020
Parse json from API to data structures in Rust
View main.rs
extern crate reqwest;
extern crate tokio;
extern crate serde_json;
extern crate serde;
use serde::{Serialize, Deserialize};
#[derive(Deserialize, Debug)]
struct SearchElement{
auth_resource_path: String,
@cuongld2
cuongld2 / struct.rs
Last active Sep 22, 2020
Define struct type
View struct.rs
#[derive(Deserialize, Debug)]
struct SearchElement{
auth_resource_path: String,
field: String,
id: String,
project_id: String,
#[serde(rename = "type")]
typep: String,
value: String,
}
@cuongld2
cuongld2 / danger_invalid_certs.rs
Created Sep 22, 2020
HTTP request ssl certificate
View danger_invalid_certs.rs
extern crate reqwest;
extern crate tokio;
extern crate serde_json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let res = reqwest::Client::builder()
.danger_accept_invalid_certs(true)
.build()
.unwrap()
@cuongld2
cuongld2 / http.rs
Created Sep 22, 2020
simple http request
View http.rs
use serde::Deserialize;
use reqwest::Error;
#[derive(Deserialize, Debug)]
struct User {
login: String,
id: u32,
}
#[tokio::main]
@cuongld2
cuongld2 / Dockerfile
Created Sep 21, 2020
For cypress test example
View Dockerfile
FROM cypress/included:3.4.0
LABEL maintainer="Le Dinh Cuong <ledinhcuong99@gmail.com>"
WORKDIR /app
COPY cypress.json .
COPY package.json .
COPY package-lock.json .
RUN mkdir cypress
COPY cypress ./cypress
View consistent.rs
fn main() {
let condition = true;
let number = if condition {
8
} else {
10
};
println!("The value of number is: {}", number);
}
View consistent.rs
fn main() {
let condition = true;
let number = if condition {
5
} else {
"six"
};
println!("The value of number is: {}", number);
}
@cuongld2
cuongld2 / expression.rs
Created Sep 17, 2020
Expression in Rust
View expression.rs
let y = {
let x = 3;
x + 1
};
You can’t perform that action at this time.