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
extern crate num; | |
use num::{ToPrimitive, Float}; | |
fn add<T, R, U>(a: T, b: R) -> U | |
where | |
T: ToPrimitive, | |
R: ToPrimitive, | |
U: Float, | |
{ |
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
async fn get_response(location: &str) -> Result<String, reqwest::Error> { | |
let base_http = "https://api.openweathermap.org/data/2.5/weather?q=".to_string(); | |
let units = "metric"; | |
let addr = base_http + &location + "&appid=" + API_KEY + "&units=" + &units; | |
let json = reqwest::get(&addr) | |
.await? | |
.text() | |
.await?; | |
Ok(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
//In using the automate library which is an async library that talks to rust I had two | |
//different errors I needed to deal with. One was automate::Error and the other was | |
//Box<dyn std::error::Error> from a call to an API in a module I'd created. | |
//Automate: https://crates.io/crates/automate | |
//mycode.rs | |
async fn weather(ctx: &mut Context, data: &MessageCreateDispatch) -> Result<(), Error> { | |
... |
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 crate::models::images::{Image, ImageJson, ImageNew, ImageUpdate}; | |
use crate::Pool; | |
use actix_web::{web, Error, HttpResponse}; | |
use diesel::dsl::insert_into; | |
use std::path::Path; | |
use anyhow::{Result}; | |
use tokio::fs::File; | |
use tokio::io::{AsyncWriteExt}; | |
use diesel::prelude::*; |
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 crate::models::links::{Link, LinkJson, LinkNew, LinkUpdate}; | |
use crate::Pool; | |
use actix_web::{web, Error, HttpResponse}; | |
use diesel::dsl::insert_into; | |
use diesel::prelude::*; | |
use regex::Regex; | |
use reqwest::Url; | |
pub async fn add_link( |
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
add_action( 'login_head', 'wpse_121687_hide_login' ); | |
function wpse_121687_hide_login() { | |
$style = ''; | |
$style .= '<style type="text/css">'; | |
$style .= '.login form{ display: none }'; | |
$style .= '.login #nav a, .login #backtoblog a { display: none }'; | |
$style .= '</style>'; | |
echo $style; |
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 actix_web::{App, post, get, HttpServer, HttpResponse, Error, web, Responder}; | |
use actix_cors::Cors; | |
use backend::models::Albums; | |
use dotenv::dotenv; | |
use std::env; | |
use sqlx::sqlite::SqlitePool; | |
use serde_derive::Deserialize; | |
#[derive(Deserialize, Debug)] |
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
// Example in posts on Rust borrow system | |
#include <stdio.h> | |
typedef struct { | |
int age; | |
int is_oldest; | |
} Person; | |
int main() { | |
Person people[] = { |