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 __future__ import unicode_literals | |
from bs4 import BeautifulSoup | |
from urllib import urlretrieve | |
import re | |
import json | |
import mechanize | |
class Browser(mechanize.Browser): | |
''' Browser |
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 numpy as np | |
import pandas as pd | |
from PIL import Image | |
from keras import backend as K | |
from keras.preprocessing.image import load_img, img_to_array | |
from keras.applications import VGG16 | |
from keras.applications.vgg16 import preprocess_input | |
from keras.layers import Input | |
from scipy.optimize import fmin_l_bfgs_b | |
import time |
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 io import BytesIO | |
from flask import Flask, make_response, render_template | |
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas | |
from BA_argo_playground.plot_image import create_plot | |
app = Flask(__name__, template_folder="/home/sebsch/Dokumente/Uni-Workdir/Bachelorarbeit/BA_argo_playground/templates") | |
@app.route("/simple.png") | |
def simple(): |
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 ureq; | |
use serde::{Deserialize, Serialize}; | |
use std::cmp::Ordering; | |
use std::error::Error; | |
#[derive(Serialize, Deserialize)] | |
struct Data { | |
title: String, | |
author: String, | |
subreddit: String, |
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 serde::{Deserialize, Serialize}; | |
pub trait SerdeDeserializeObject { | |
fn new<'de>(data: &'de str) -> Self | |
where | |
Self: Deserialize<'de>, | |
{ | |
let serialized_data: Self = serde_json::from_str(&data).unwrap(); | |
serialized_data | |
} |
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::thread; | |
use std::time::Duration; | |
use std::collections::HashMap; | |
struct Cacher<T> where T: Fn(u32) -> u32{ | |
calculation: T, | |
values: HashMap<u32, u32> | |
} | |
impl<T> Cacher<T> where T: Fn(u32) -> u32 { |
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 ureq; | |
use std::collections::HashMap; | |
use std::time::{Instant, Duration}; | |
pub struct Cacher { | |
call: Box<dyn Fn(&str) -> String>, | |
data: HashMap<String, (String, Instant)>, | |
cache_time: Duration, | |
} |
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::thread; | |
use std::sync::mpsc; | |
fn main() { | |
let (tx, rx) = mpsc::channel(); | |
let h1 = thread::spawn(move || { | |
let val = String::from("hi"); | |
tx.send(val).unwrap(); | |
}); |
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 regex::Regex; | |
fn main() { | |
let datetime = r"[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9],[0-9][0-9][0-9]"; | |
let host = r"([^\s]+)"; | |
let service = r"([^\s]+)"; | |
let message = r"(.*)"; | |
let re = Regex::new(&format!("(?P<datetime>({d})) (?P<hostname>({h}))] (?P<service>({s})) (?P<message>({m}))", | |
d = datetime, h = host, s = service, m = message)).unwrap(); |
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 regex::{Regex, Captures}; | |
use strfmt::strfmt; | |
use std::collections::HashMap; | |
fn main() { | |
#[derive(Debug)] | |
struct LogSchema{ | |
datetime: String, |
OlderNewer