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
using System; | |
namespace hello | |
{ | |
// A typed primitive it narrows the type of primitive | |
class TypedPrim<T> | |
{ | |
public T Value { get; set; } | |
public static implicit operator T(TypedPrim<T> v) => v.Value; | |
public static explicit operator TypedPrim<T>(T v) => new TypedPrim<T>() { Value = v }; |
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 typing import * | |
import re | |
Result = Tuple[str, Any] | |
Parser = Callable[[str], Result] | |
class ParseError(Exception): | |
pass |
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 get(obj, attr, default=None): | |
""" | |
Fetch an attribute deeply nested on an object or dict, return `default` if not found | |
>>> class Foo: pass | |
>>> f = Foo() | |
>>> f.a = Foo() | |
>>> f.a.b = Foo() | |
>>> f.a.b.c = True |
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
# test with `nc -kl 3000` | |
# write to nc terminal to send data | |
import socket | |
import sys | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
print("Socket successfully created") | |
except socket.error as err: | |
print("socket creation failed with error %s" %(err)) |
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::time::{Duration, Instant}; | |
struct Limiter { | |
instant: Option<Instant>, | |
duration: Duration, | |
} | |
impl Limiter { | |
pub fn new(secs: u64) -> Limiter { | |
Limiter { |
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
#![allow(unused_variables)] | |
use futures::future::LocalBoxFuture; | |
use futures::prelude::*; | |
use std::path::Path; | |
use tokio::fs::*; | |
fn walkdir<'a, C>(path: &'a Path, cb: &'a mut C) -> LocalBoxFuture<'a, ()> | |
where | |
C: Fn(&DirEntry), | |
{ |
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
1: ~/.config/nvim/init.vim | |
2: ~/.local/share/nvim/site/autoload/plug.vim | |
3: /usr/local/Cellar/neovim/0.4.3/share/nvim/runtime/filetype.vim | |
4: ~/.vim/plugged/vim-fugitive/ftdetect/fugitive.vim | |
5: ~/.vim/plugged/vim-javascript/ftdetect/flow.vim | |
6: ~/.vim/plugged/vim-javascript/ftdetect/javascript.vim | |
7: ~/.vim/plugged/typescript-vim/ftdetect/typescript.vim | |
8: ~/.vim/plugged/ultisnips/ftdetect/snippets.vim |
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 futures::future::Future; | |
struct MyStruct { | |
msg: String, | |
} | |
impl MyStruct { | |
fn new(msg: String) -> Self { MyStruct{ msg } } | |
} |
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
#![allow(unused_imports)] | |
use super::config::Machine; | |
use super::email; | |
use futures::future::join_all; | |
use log; | |
use std::io; | |
use std::process::{Command, ExitStatus}; | |
use tokio::task::spawn_blocking; | |
fn run_cmd(cmd: &'static str, args: Vec<&str>) -> io::Result<ExitStatus> { |
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 unittest import TestCase, main | |
from unittest.mock import patch | |
# import monkeypatch | |
from logging import getLogger | |
log = getLogger('foo') |