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 python | |
# mypy: allow-untyped-defs | |
""" | |
This script is used for applying affinity settings for various hardware devices. | |
Script originally based on Intel's [set_irq_affinity.sh](https://gist.github.com/SaveTheRbtz/8875474). | |
Over the years it was updated with heuristics based on the shape of Dropbox infrastructure. | |
Currently, this script can manage IRQ affinities, RPS, XPS, and RXQS. For the description of |
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::process::{Command}; | |
fn main() { | |
let output = Command::new("curl").arg("-s").arg("http://ovh.net/files/100Mio.dat").output(); | |
println!("{:?}", output.unwrap().stdout.len()); | |
} | |
~/stuff ❯❯❯ time ./dwl | |
104857600 | |
./dwl 16.22s user 1.80s system 23% cpu 1:15.24 total |
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
/* automatically generated by rust-bindgen */ | |
pub type size_t = ::libc::c_ulong; | |
pub type __u_char = ::libc::c_uchar; | |
pub type __u_short = ::libc::c_ushort; | |
pub type __u_int = ::libc::c_uint; | |
pub type __u_long = ::libc::c_ulong; | |
pub type __int8_t = ::libc::c_char; | |
pub type __uint8_t = ::libc::c_uchar; | |
pub type __int16_t = ::libc::c_short; |
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
# Enumerator#lazy is very slow and should only be used when iterating over large/infinite collections | |
# where you know you are going to get your results quite early in the iteration. | |
# This benchmark is purposely made to advantage the lazy version, without much success. | |
require 'benchmark/ips' | |
class Enumerator::Lazy | |
def filter_map | |
Lazy.new(self) do |yielder, *values| |
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
# Obviously the second solution is faster or a large collection, but some said the first solution is more readable. | |
# Which would you use? | |
result = [] | |
collection.each do |c| | |
result << some_method(c) | |
end | |
result.reject!(&:nil?) |
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
class RangedHash | |
def initialize(hash={}) | |
@ranged_hash = hash | |
end | |
def []=(key, value) | |
@ranged_hash[key] = value | |
end | |
def [](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
(ns phrase | |
(:require [clojure.string :as str])) | |
(defn- strip-punctuation [phrase] | |
(str/replace phrase #"[^\w\s]" "") | |
) | |
(defn word-count [phrase] | |
(frequencies (str/split(str/lower-case (strip-punctuation phrase)) #"\s+")) | |
) |
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
require "benchmark/ips" | |
Benchmark.ips do |x| | |
x.report("double quote assignment:") {a = "yo man"} | |
x.report("double quote +:") {|i| a = "yo man" + i.to_s} | |
x.report("double quote <<:") {|i| a = "yo man" << i.to_s} | |
x.report("double quote interpolation:") {|i| a = "yo man #{i}"} | |
x.report("single quote assignment:") {a = 'yo man'} | |
x.report("single quote +:") {|i| a = 'yo man' + i.to_s} |
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
# Any difference between: | |
[:db_create, :db_drop, :db_list].each do |cmd| | |
#THIS: | |
define_method(cmd) do |*args| | |
NoBrainer.run { RethinkDB::RQL.send(cmd, *args) } | |
end | |
# OR THIS |
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
let(:date) do | |
Time.now | |
end | |
it "converts the elements properly" do | |
p date.zone | |
mongoized.first.should eq(date) | |
p date.zone | |
end |
NewerOlder