Skip to content

Instantly share code, notes, and snippets.

View Ploppz's full-sized avatar

Erlend Langseth Ploppz

  • Trondheim, Norway
View GitHub Profile
/// This is one of two sources of DB migrations.
/// The other one is pure SQL files found in the `migrations/` folder.
/// This module contains migrations made with Rust code.
use diesel::connection::BoxableConnection;
use diesel::migration::{Result as MResult, *};
use diesel::pg::Pg;
use diesel_migrations::EmbeddedMigrations;
use std::fmt::*;
mod scan_scope;
use std::task::{Context, Poll};
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
use actix_web::{
body::{Body, ResponseBody},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
error::{Error, Result},
};
use serde_json::json;
@Ploppz
Ploppz / all-objects.rs
Created April 10, 2019 20:51
Object implementations derived in the pdf libray
impl ::pdf::object::Object for Catalog {
fn serialize<W: ::std::io::Write>(&self, out: &mut W) -> ::std::io::Result<()> {
writeln!(out, "<<")?;
write!(out, "{} ", "Pages")?;
self.pages.serialize(out)?;
writeln!(out, "")?;
write!(out, "{} ", "Names")?;
self.names.serialize(out)?;
writeln!(out, "")?;
write!(out, "{} ", "StructTreeRoot")?;
#[macro_use] extern crate unixbar;
extern crate systemstat;
use unixbar::*;
use systemstat::{System, Platform, ByteSize};
#[macro_use] extern crate unixbar;
extern crate systemstat;
use unixbar::*;
use systemstat::{System, Platform, ByteSize};
const BGS: &'static [&'static str] = &["#111111", "#1F4B17", "#111111", "#497933"];
const BGS_c: &'static [&'static str] = &["#111111", "#"];
// Colors for center
const FG_WINGS: &'static str = "#ffaacc";
use std::sync::mpsc::Sender;
use std::time::Duration;
use std::thread;
use std::sync::{Arc, RwLock};
use super::base::Widget;
use format::data::Format;
use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
pub struct BatteryState {
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [dependencies]
//! unixbar = "0"
//! systemstat = "0"
//! ```
#[macro_use] extern crate unixbar;
extern crate systemstat;
use unixbar::*;
println!("DEBUG PARAMS {:?}", params.as_ref().unwrap());
println!("DEBUG DATA(len: {}): {:?}", out.len(), &out);
assert!(out.len() % (columns+1) == 0);
// Then unfilter (PNG)
let input = out;
let mut out = Vec::<u8>::new();
out.resize(input.len() / (columns+1) * columns, 0); // One less byte per row
if predictor > 10 {