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::panic; | |
extern crate sentry; | |
extern crate log; | |
pub struct Logger; | |
impl log::Log for Logger { | |
fn enabled(&self, metadata: &log::Metadata) -> bool { | |
metadata.level() <= log::max_level() |
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
let domain = require('domain'); | |
let fallbackCrumbs = []; | |
function getCrumbs() { | |
if (domain.active) { | |
let rv = domain.active.crumbs = domain.active.crumbs || []; | |
return rv; | |
} | |
return fallbackCrumbs; |
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
#[macro_use] extern crate serde_derive; | |
extern crate serde_json; | |
use std::collections::HashMap; | |
#[derive(Debug, PartialEq, Serialize, Deserialize)] | |
#[serde(tag = "type")] | |
enum X { | |
Hash { x: HashMap<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
#[derive(Serialize, Deserialize, Debug)] | |
#[serde(repr = "map")] | |
pub struct Breadcrumb { | |
#[serde(flatten)] | |
data: BreadcrumbData, | |
#[serde(flatten)] | |
extra: HashMap<String, serde_json::Value>, | |
} | |
#[derive(Serialize, 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
[package] | |
name = "experiments" | |
version = "0.1.0" | |
authors = ["Armin Ronacher <armin.ronacher@active-4.com>"] | |
[workspace] | |
[dependencies] | |
serde = "1.0" | |
serde_json = "1.0" |
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
#![feature(prelude_import)] | |
#![no_std] | |
#[prelude_import] | |
use std::prelude::v1::*; | |
#[macro_use] | |
extern crate serde_derive; | |
extern crate serde_json; | |
#[macro_use] | |
extern crate std as std; | |
use std::collections::HashMap; |
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
impl Serialize for UpstreamDescriptor<'static> { | |
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | |
where | |
S: Serializer, | |
{ | |
serializer.serialize_str(&self.to_string()) | |
} | |
} | |
impl<'de> Deserialize<'de> for UpstreamDescriptor<'static> { |
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
def create_validator(): | |
default_class = jsonschema.Draft4Validator | |
validate_properties = default_class.VALIDATORS['properties'] | |
def handle_props(validator, properties, instance, schema): | |
for property, subschema in properties.items(): | |
if 'default' in subschema: | |
instance.setdefault(property, subschema['default']) | |
for key in list(instance.keys()): |
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 threading import Thread | |
fname = 'testslice' | |
expected = '\x00\x00\x00\x00a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00d' | |
slice = 4 | |
open(fname, 'w').close() | |
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
pub trait Addr { | |
fn from_u64(addr: u64) -> Self; | |
fn to_u64(&self) -> u64; | |
} | |
#[derive(Copy, Clone, Default, Debug)] | |
pub struct Addr32 { | |
val: u32, | |
} |