I hereby claim:
- I am melekes on github.
- I am melekes (https://keybase.io/melekes) on keybase.
- I have a public key ASA1kz6kxvacyRSjua9gxErX7nt2n46FvBFB-OfWYp572go
To claim this, I am signing this object:
| // addOrMax performs safe addition: if result overflows, it returns MaxUint64 | |
| func addOrMax(accum, value uint64) uint64 { | |
| if (accum + value) < accum { | |
| return math.MaxUint64 | |
| } else { | |
| return accum + value | |
| } | |
| } | |
| // subOrZero performs safe subtraction: if result underflows, it returns 0 |
I hereby claim:
To claim this, I am signing this object:
Any other languages or suggestions? Comment below.
Clojure:
C++:
Elixir
https://www.youtube.com/watch?v=d0yGdNEWdn0
Принципы:
| Latency Comparison Numbers | |
| -------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns | |
| Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
| Read 4K randomly from SSD* 150,000 ns 0.15 ms |
| -spec do(any(), [fun((...) -> any())]) -> any(). | |
| do(Arg, []) -> | |
| Arg; | |
| do(Arg, [Fun | Funs]) -> | |
| case Fun(Arg) of | |
| {error, Data} -> | |
| Data; | |
| Data -> | |
| do(Data, Funs) |
| .PHONY: all compile deps clean distclean test docs xref dialyzer \ | |
| cleanplt | |
| REBAR = `which rebar || ./script/rebar` | |
| all: deps compile | |
| compile: deps | |
| @$(REBAR) compile |
| public class AvgTemperatureDriver extends Configured implements Tool { | |
| @Override | |
| public int run(String[] args) throws Exception { | |
| Job job = new Job(getConf(), "Avg temperature"); | |
| job.setJarByClass(getClass()); | |
| job.setNumReduceTasks(0); | |
| Scan scan = new Scan(); |
| NO_COLOR=\033[0m | |
| OK_COLOR=\033[32;01m | |
| ERROR_COLOR=\033[31;01m | |
| WARN_COLOR=\033[33;01m | |
| DEPS = $(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...) | |
| deps: | |
| @echo "$(OK_COLOR)==> Installing dependencies$(NO_COLOR)" | |
| @go get -d -v ./... | |
| @echo $(DEPS) | xargs -n1 go get -d |
| require 'factory_girl' | |
| FactoryGirl.define do | |
| factory :company do | |
| name "Twitter Corp." | |
| before(:create) do |company, evaluator| | |
| offices_attributes = [] | |
| 3.times do # 3 offices per company | |
| offices_attributes << attributes_for(:office) |