Skip to content

Instantly share code, notes, and snippets.

View boneyard93501's full-sized avatar

boneyard93501

View GitHub Profile
fn mean<'a, T>(data: impl ExactSizeIterator<Item = &'a T>) -> Result<f64, &'static str>
where
T: 'a + std::iter::Sum<&'a T> + Into<f64>,
{
let len = data.len() as f64;
if len < 1 {
return Err("Invalid divisor");
}
Ok((data.sum::<T>()).into() / len)
}

Keybase proof

I hereby claim:

  • I am boneyard93501 on github.
  • I am boneyard93501 (https://keybase.io/boneyard93501) on keybase.
  • I have a public key ASD4uwBCNxzbsY3tbwLBLbcnynptZy4PBAGWEMJ6evDsNwo

To claim this, I am signing this object:

@boneyard93501
boneyard93501 / gist:e205f3c8ad8adc913ab401bc4a588b31
Created January 11, 2019 07:15
eth signature-recovery equivaency
# note to self
import requests
from eth_account.messages import defunct_hash_message
from hexbytes import HexBytes
from pymongo import MongoClient
from web3 import Web3
def personal_sign(w3, tx_hash: HexBytes, acct_addr: str, password: str) -> str:
'''
@boneyard93501
boneyard93501 / s3_obj_fetcher.rs
Created April 20, 2018 02:19
rust rusoto S3 obj fetcher with StaticProvider
extern crate rusoto_core;
extern crate rusoto_credential;
extern crate rusoto_s3;
use rusoto_core::Region;
use rusoto_credential::StaticProvider;
use rusoto_core::reactor::RequestDispatcher;
use rusoto_s3::{S3, S3Client, ListObjectsV2Request};
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import sys
import time
import json
# import signal
import threading
from collections import deque
note to self: toggle ec2 instance by one of two instance types using boto3
!/usr/bin/env python3
# -*- coding: utf8 -*-
import os, sys
import datetime
import boto3
@boneyard93501
boneyard93501 / drop-privileges.py
Created May 25, 2013 18:04
python drop privileges
import os, pwd, grp
def dropPrivileges(n_uid=None, n_gid=None, new_mask=077, critical=True, target_dir='.'):
'''
drop privileges without forking
e.g.:
http://www.charleshooper.net/blog/dropping-privileges-in-python-for-tornado-apps/
http://antonym.org/2005/12/dropping-privileges-in-python.html