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 main | |
import ( | |
"crypto/rand" | |
"errors" | |
"fmt" | |
"io" | |
"net/http" | |
"strconv" | |
) |
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 ( | |
"bytes" | |
"fmt" | |
"log" | |
"net" | |
"os" | |
"golang.org/x/crypto/ssh" | |
) |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<rpc-reply xmlns:nxos="http://www.cisco.com/nxos:1.0" xmlns:if="http://www.cisco.com/nxos:1.0:if_manager" xmlns:nfcli="http://www.cisco.com/nxos:1.0:nfcli" xmlns:vlan_mgr_cli="http://www.cisco.com/nxos:1.0:vlan_mgr_cli" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:edb152bf-d81c-42e4-b368-2d67d278ab88"> | |
<data> | |
<lldp xmlns="http://openconfig.net/yang/lldp"> | |
<config> | |
<enabled>true</enabled> | |
<hello-timer>30</hello-timer> | |
</config> | |
<interfaces> | |
<interface> |
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::sync::Arc; | |
use std::fs::File; | |
use yang2::context::{Context, ContextFlags}; | |
use yang2::data::{ | |
Data, DataFormat, DataParserFlags, DataTree, | |
DataValidationFlags, | |
}; | |
static SEARCH_DIR: &str = "/path/to/openconfig/public/"; |
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 tokio; | |
fn main() { | |
// we want to use this after the async block | |
let hosts = ["hostA", "hostB"]; | |
let rt = tokio::runtime::Runtime::new().unwrap(); | |
let mut results = Vec::with_capacity(hosts.len()); | |
rt.block_on(async { |
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 returns import context, result, curry, pipeline, pointfree | |
def some(s): | |
def factory(deps): | |
print('in factory', deps) | |
return result.Success(42) | |
return context.RequiresContextResult(factory) | |
def plusone(arg): |
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
@future.future_safe | |
async def run_process(proc: asyncio.subprocess.Process) -> typing.Tuple[bytes, bytes]: | |
"""Run the async process and check the return code.""" | |
stdout, stderr = await proc.communicate() | |
if proc.returncode: | |
logger.error('process exited with returncode {0}'.format(proc.returncode)) | |
raise ValueError('process returned non-zero code') | |
return stdout, stderr | |
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
END { | |
for ( i = 1; i < 100; i++) { | |
arr[i] = i | |
} | |
for (p = 2;p < 49; p++) { | |
for (i = p*2; i < 100; i += p) { | |
delete arr[i] | |
} | |
} | |
for ( i = 1; i < 100; i++) { |
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 crypt | |
from hmac import compare_digest | |
cisco = "username REDACTED password 5 $5$SALT$SOME-HASH role network-admin" | |
def check_pw_hashes_are_eq(username_cmd: str, cleartext: str) -> bool: | |
parts = username_cmd.split(' ') | |
pw_hash = parts[4] | |
pw_parts = pw_hash.split('$') | |
meth, salt, pw = pw_parts[1:] |
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 itertools import groupby | |
import re | |
import typing as t | |
WEIGHTS: t.Dict[str, int] = {".": 10, "/": 20} | |
def split_interface_tuple(interface: str) -> t.Tuple[str, ...]: | |
"""Crappy parser-combinator hacky-hack""" | |
head = interface.rstrip(r"/\0123456789. ") |
NewerOlder