I hereby claim:
- I am hindenbug on github.
- I am hindenbug (https://keybase.io/hindenbug) on keybase.
- I have a public key ASAmvn6HfeoDODUEYwUwJlF5j6-ziUsB61XOoVIqYjk-Cgo
To claim this, I am signing this object:
| def solution(a) | |
| # write your code in Ruby 1.9.3 | |
| countr = [0] * (a.max) | |
| a.each do |v| | |
| countr[v-1] += 1 | |
| end | |
| if countr.include?(0) || countr.max > 1 | |
| 0 |
| %s/\r//g |
I hereby claim:
To claim this, I am signing this object:
| require "json" | |
| require "rspec" | |
| require "byebug" | |
| class Reconciler | |
| attr_accessor :invoices, :credit_lines, :max_finance_credit, :total_debtors_invoices, :customer_credits | |
| def financed_amount | |
| @total_debtors_invoices = @invoices.map {|x| x[:amount] }.reduce(:+) |
| # Here's my code with a few minor improvements | |
| class IpLookupService | |
| def self.lookup_country(ip_address) | |
| result = self.lookup(ip_address) | |
| # expecting result is a object/instance returned by @g.lookup method | |
| raise GeoIpDB::Error unless result && result.found? | |
| (result.country && result.country.iso_code) ? result.country.iso_code.downcase : raise GeoIpDB::Error | |
| rescue GeoIpDB::Error | |
| "en" |
| /sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}' | |
| hostname -I | awk '{print $3}' |
| - name: Delete multiple files | |
| file: | |
| path: "{{ item }}" | |
| state: absent | |
| with_items: | |
| - file1.txt | |
| - file2.txt | |
| - file3.txt |
| :%s/.*<patter>.*/"&"/ |
In modern binary protocols like Apache Kafka, Compact Arrays are used to save bandwidth. Instead of using a fixed 4-byte integer to store the length of a list, Kafka uses a Varint (Variable-length Integer) and an offset of 1.
In standard programming, an array is like a row of identical lockers. Even if you only put a tiny pebble in a locker, the locker stays the same huge size. This wastes space.
A Compact Array is "shrink-wrapped" data. It uses two main tricks to save space:
Varints: The length of the array isn't a fixed 4-byte block; it's a "stretchy" number that only uses the bytes it needs.