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
# run test for each commit in a commit chain. Stop at the commit that fails the test. | |
# It allows editing the commit, then git commit --amend , then git rebase --continue , | |
# the --continue will re-run the tests before it moves to the next commit. | |
# The progress of the rebase can be monitored in the file .git/rebase-merge/done | |
git rebase -i <rebase-target> --reschedule-failed-exec --exec "tox -e py27 && tox -e fast8" | |
# run test in parallel | |
git rebase -i <rebase-target> --reschedule-failed-exec --exec " echo 'functional py27 fast8' | tr ' ' '\n' | parallel --lb 'set -o pipefail && rtox -e {} | tee /tmp/{}.log'" | |
git rebase -i <rebase-target> --reschedule-failed-exec --exec "ptox functional py27 fast8" |
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
# --- prompt --- | |
# based on https://gist.github.com/mkottman/1936195 | |
RESET="\[\033[0m\]" | |
RED="\[\033[0;31m\]" | |
GREEN="\[\033[01;32m\]" | |
DARK_GREEN="\[\033[38;5;70m\]" | |
BLUE="\[\033[01;34m\]" | |
YELLOW="\[\033[0;33m\]" | |
WHITE="\[\033[0;37m\]" |
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 collections | |
import re | |
with open('sherlock.txt') as f: | |
words = re.findall(r'\w+', f.read().lower()) | |
counter = collections.Counter(words) | |
for w, c in counter.most_common(20): | |
print(w, c) |
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::collections::HashMap; | |
use std::fs::File; | |
use std::io::Read; | |
fn main() { | |
let mut counter = HashMap::new(); | |
let mut f = File::open("sherlock.txt") | |
.expect("cannot open file"); |
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
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
#include <regex> | |
#include <string> | |
#include <unordered_map> | |
#include <vector> | |
using namespace std; | |
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
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <unordered_map> | |
#include <algorithm> | |
#include <vector> | |
#include <ctype.h> | |
using namespace std; | |
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 collections | |
counter = collections.Counter() | |
word = "" | |
with open('sherlock.txt') as f: | |
while True: | |
c = f.read(1) | |
if not c: | |
break | |
if c.isalnum(): |
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
//! # Counting word frequncy in text | |
use std::collections::HashMap; | |
use std::fs::File; | |
use std::io::Read; | |
fn get_word_freq<R: Read>(input: &mut R) -> HashMap<String, u32> { | |
let mut text = String::new(); | |
// TODO: avoid reading the whole input into memory here | |
// TODO: would be nicer to return a Result<HashMap..., Err> instead of | |
// panic on non utf-8 input |
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
//! # A generic threaded pipeline | |
use std::fmt::Display; | |
use std::sync::mpsc; | |
use std::thread; | |
use std::time::Duration; | |
use log::{error, info}; | |
use log_panics; |
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 dataclasses | |
@dataclasses.dataclass | |
class Animal: | |
name: str | |
likeable: bool = True | |
class Cat(Animal): | |
color: str |
OlderNewer