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
https://github.com/sat2707/hlcupdocs/blob/master/TECHNICAL_TASK.md | |
iex(9)> :ets.info(:visits) | |
[read_concurrency: true, write_concurrency: false, compressed: false, | |
memory: 110008228, owner: #PID<0.3544.0>, heir: :none, name: :visits, | |
size: 10000740, node: :nonode@nohost, named_table: true, type: :ordered_set, | |
keypos: 1, protection: :public] | |
iex(11)> fun = :ets.fun2ms(fn {id, user, location, visited_at, mark} when user == 475422 -> id end) | |
[{{:"$1", :"$2", :"$3", :"$4", :"$5"}, [{:==, :"$2", 475422}], [:"$1"]}] |
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
# Move erts IO Polling to dedicated threads | |
# https://github.com/erlang/otp/pull/1552 |
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 main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
"time" | |
) |
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
CREATE TABLE accounts( | |
id serial PRIMARY KEY, | |
name VARCHAR(256) NOT NULL | |
); | |
CREATE TABLE entries( | |
id serial PRIMARY KEY, | |
description VARCHAR(1024) NOT NULL, | |
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0), | |
-- Every entry is a credit to one account... |
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
SELECT l.what, l.nr AS "bytes/ct" | |
, CASE WHEN is_size THEN pg_size_pretty(nr) END AS bytes_pretty | |
, CASE WHEN is_size THEN nr / x.ct END AS bytes_per_row | |
FROM ( | |
SELECT min(tableoid) AS tbl -- same as 'public.tbl'::regclass::oid | |
, count(*) AS ct | |
, sum(length(t::text)) AS txt_len -- length in characters | |
FROM public.write_a_table_name_instead t -- provide table name *once* | |
) x | |
, LATERAL ( |
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
# gem install benchmark-ips | |
require "benchmark/ips" | |
path = "lib/rubycritic/cli/options.rb" | |
Benchmark.ips do |x| | |
x.report("read + each_line") { File.read(path).each_line.count } | |
x.report("open + each_line") { File.open(path, "r").each_line.count } |
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
sleep 10 && echo -en "\007" |
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
$ for i in {1..12}; do date -v1d -v-1d -v-${i}m +%Y-%m-%d; done | |
2018-11-30 | |
2018-10-31 | |
2018-09-30 | |
2018-08-31 | |
2018-07-31 | |
2018-06-30 | |
2018-05-31 | |
2018-04-30 | |
2018-03-31 |
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
# 1. Clear retry set | |
Sidekiq::RetrySet.new.clear | |
# 2. Clear scheduled jobs | |
Sidekiq::ScheduledSet.new.clear | |
# 3. Clear 'Processed' and 'Failed' jobs |
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
$ irb -r ./select_server | |
>> client.puts "hi" | |
=> nil | |
>> client.puts "bye" | |
=> nil | |
>> client.close | |
=> nil | |
>> exit |
OlderNewer