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
// Please find the full, tested version in | |
// https://github.com/influxdata/influxdb_iox/blob/fe155e15fb2ad166aee66b0458e63c24a8128dd4/query/src/exec/task.rs#L101-L118 | |
pub struct DedicatedExecutor { | |
state: Arc<Mutex<State>>, | |
} | |
/// Runs futures (and any `tasks` that are `tokio::task::spawned` by | |
/// them) on a separate Tokio Executor | |
struct State { |
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
# -*- coding: utf-8 -*- | |
""" Deletes all tweets below a certain retweet threshold. | |
""" | |
import tweepy | |
from datetime import datetime | |
# Constants | |
CONSUMER_KEY = '' |
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::StreamExt; | |
use std::error::Error; | |
use tokio; | |
use tokio::macros::support::Pin; | |
use tokio::prelude::*; | |
use tokio::time::{Duration, Instant}; | |
pub fn main() -> Result<(), Box<dyn std::error::Error>> { | |
let mut multi_threaded_runtime = tokio::runtime::Builder::new() | |
.threaded_scheduler() |
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 plug -params 1 %{ | |
%sh{ | |
# Check out the repo to ~/build if it does not exist | |
if [[ ! -d $HOME/build/$1 ]]; then | |
(cd $HOME/build; git clone https://github.com/$1) | |
fi | |
# Source all .kak files in it | |
for file in $(echo $HOME/build/$(basename $1)/*.kak); do | |
echo source "$file" | |
done |
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
%matplotlib inline | |
buckets = [-87.0, -15, 0, 30, 120] | |
rdd_histogram_data = ml_bucketized_features\ | |
.select("ArrDelay")\ | |
.rdd\ | |
.flatMap(lambda x: x)\ | |
.histogram(buckets) | |
create_hist(rdd_histogram_data) |
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
#!/usr/bin/env python3 | |
# Based on a great article from Eli Bendersky: | |
# | |
# http://eli.thegreenplace.net/2009/08/29/co-routines-as-an-alternative-to-state-machines/ | |
# | |
# I just "ported" to Python3 (still using plain old yield) and added the proper type annotations, | |
# since Python 3.5 can now support them (and mypy can check them): | |
# | |
# $ mypy --disallow-untyped-defs protocol_via_coroutines.py |
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
{-# LANGUAGE TemplateHaskell #-} | |
module Data.Integer.FibonacciStack where | |
import Control.Monad.State | |
import Control.Lens | |
naiveFib :: Int -> Integer | |
naiveFib 0 = 0 | |
naiveFib 1 = 1 | |
naiveFib n = naiveFib (n-1) + naiveFib (n-2) |
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
module Data.Vector.FindMax where | |
import Data.Vector (Vector, (!), (!?)) | |
import qualified Data.Vector as V | |
import Data.Maybe (fromMaybe) | |
findMax :: Vector Int -> Maybe Int | |
findMax v | |
| V.null v = Nothing | |
| pivotValue > leftValue && pivotValue > rightValue = Just pivotValue |
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
module Data.Integer.EveryOther where | |
genericEveryOther :: Monoid a => [a] -> [a] | |
genericEveryOther [] = [] | |
genericEveryOther xs = zipWith mappend (scanl mappend mempty (init xs)) (scanr mappend mempty (tail xs)) | |
everyOther :: [Int] -> [Int] | |
everyOther [] = [] | |
everyOther xs = zipWith (*) (scanl (*) 1 (init xs)) (scanr (*) 1 (tail xs)) |
NewerOlder