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/python3 | |
import os | |
import sqlite3 | |
import time | |
filename = "two_tables.db" | |
# Delete the db file so we can recreate it from scratch. | |
if os.path.exists(filename): |
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] | |
name = "fetch_hn" | |
version = "0.1.0" | |
edition = "2018" | |
[dependencies] | |
serde = { version = "1.0.89", features = ["derive"] } | |
reqwest = "0.9.11" | |
crossbeam-utils = "0.6.5" |
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 serde::Deserialize; | |
use std::sync::{Arc, Mutex}; | |
const STORIES_URL: &str = "https://hacker-news.firebaseio.com/v0/topstories.json"; | |
const ITEM_URL_BASE: &str = "https://hacker-news.firebaseio.com/v0/item"; | |
#[derive(Deserialize)] | |
struct Story { | |
title: String, | |
} |
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
#![feature(test)] | |
extern crate test; | |
use std::ptr; | |
use test::Bencher; | |
pub fn reverse_slice_orig<T>(s: &mut [T]) { | |
let mut i: usize = 0; | |
let ln = s.len(); |
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::atomic::{AtomicBool, Ordering}; | |
use std::sync::mpsc::sync_channel; | |
use std::sync::{Arc, Barrier}; | |
static MY_ORDERING: Ordering = Ordering::Relaxed; | |
static A: AtomicBool = AtomicBool::new(false); | |
static B: AtomicBool = AtomicBool::new(false); | |
fn main() { |
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 nom::types::CompleteStr; | |
use nom::*; | |
use std::collections::HashMap; | |
#[derive(Clone, Debug)] | |
enum Value { | |
Num(f64), | |
String(String), | |
List(Vec<Value>), | |
Object(HashMap<String, Value>), |
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
0 1.003 | |
1 1.006 | |
2 1.002 | |
3 1.006 | |
4 1.008 | |
5 1.009 | |
6 1.008 | |
7 1.008 | |
8 1.006 | |
9 1.008 |
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
fn bump_smaller(x: &mut i32, y: &mut i32) { | |
if *x <= *y { | |
*x += 1; | |
} else { | |
*y += 1; | |
} | |
} | |
fn main() { | |
// example with variables |
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] | |
name = "scratch" | |
version = "0.1.0" | |
edition = "2018" | |
[dependencies] | |
rayon = "1.2.0" | |
blake2s_simd = "0.5.8" |
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] | |
name = "race" | |
version = "0.1.0" | |
authors = ["Jack O'Connor <oconnor663@gmail.com>"] | |
edition = "2018" | |
[dependencies] | |
os_pipe = "0.9.0" | |
[[bin]] |