Skip to content

Instantly share code, notes, and snippets.

📖
Hunting high and low

Sergey Potapov greyblake

📖
Hunting high and low
Block or report user

Report or block greyblake

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View http-poll.spec.ts
import { throwError, of, interval, Observable } from 'rxjs';
import { take, filter, map, concatMap, catchError } from 'rxjs/operators';
import { httpPoll, isNotReady } from './http-poll';
function buildError(code) {
return {
error: {
errors: [{ code }]
}
@greyblake
greyblake / .travis.yml
Created Sep 15, 2018
Minimal rust setup for travis ci
View .travis.yml
language: rust
rust:
- stable
install:
- rustup component add rustfmt-preview
- rustup component add clippy-preview
script:
- cargo fmt -- --check
- touch ./src/main.rs && cargo clippy -- -D warnings
- cargo test
View binary_data_comparison_direct_vs_md5.rb
require "securerandom"
require "digest/md5"
require "benchmark"
data1 = SecureRandom.random_bytes(5 * 1024 * 1024)
data2 = data1.dup
N = 500
Benchmark.bm do |x|
View log_exec.rs
use std::time::Duration;
use std::time::Instant;
// Executes `func` and logs warning or error message if it takes longer than specified.
pub fn log_exec<F, T>(label: &str, warn_millis: u64, error_millis: u64, func: F) -> T where F: FnOnce() -> T {
let warn_duration = Duration::from_millis(warn_millis);
let error_duration = Duration::from_millis(error_millis);
let start = Instant::now();
let output = func();
View list_enum.rs
macro_rules! list_enum {
( $type:ident, { $($el:ident),* } ) => {
#[derive(Debug,Clone,Copy)]
enum $type{
$($el),*
}
impl $type {
pub fn list() -> &'static[$type] {
const LIST : &'static[$type] = &[$($type::$el),*];
View hyper011_api_client_example.rs
extern crate hyper;
extern crate tokio_core;
extern crate hyper_tls;
extern crate futures;
extern crate serde_json;
extern crate serde;
#[macro_use]
extern crate serde_derive;
use hyper::header;
View mutex_trait.rs
trait A {
fn a(&self);
}
trait B {
fn b(&self);
}
trait C {
fn c(&self);
View interior_mutability_example.rs
use std::cell::Cell;
#[derive(Debug)]
struct Ab {
a: i32,
b: i32,
cache: Cell<Option<i32>>
}
impl Ab {
View conway_v1.rs
extern crate rand;
use rand::Rng;
const WIDTH : usize = 80;
const HEIGH : usize = 40;
const SIZE : usize = WIDTH * HEIGH;
type MatrixLine = [bool; WIDTH];
View drop_trait.rs
#[derive(Debug)]
struct Point {
x : f64,
}
trait Math : {
fn sub(&self, &Self) -> Self;
fn add(&self, &Self) -> Self;
}
You can’t perform that action at this time.