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 Granite::ORM::Base | |
def self.where(**conditions) | |
params = [] of DB::Any | |
clause = String.build do |s| | |
s << "WHERE " | |
s << conditions.map do |k, v| | |
if v.nil? | |
"#{k} IS NULL" | |
else | |
params << v |
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
{ | |
"資安趨勢部落格在文章中指出「伺服器變挖礦機將是未來日漸嚴重的問題」,並以 JenkinsMiner 為例,含有漏洞的伺服器一旦被 JenkinsMiner 入侵且成功部屬挖礦程式,將會造成 ___________ 影響,請問 _________ 為?":"效能嚴重變慢", | |
"趨勢科技在〈典範轉移〉一文中提出,BEC 詐騙已開始放棄使用鍵盤側錄程式,而改用 ____________ 進行。":"網路釣魚 PDF 附件", | |
"請問下列何者不為剖析器?":"LSR", | |
"chroot 是在 UNIX 系統的一個操作,針對正在運作的軟體行程和它的子行程,改變它外顯的根目錄。chroot 程式可歸類為何種資安相關的應用?":"Sandbox", | |
"下列何者是 Ubuntu 的套件管理程式?":"APT", | |
"可以用哪個程式查詢從本地到另一個 IP Address 所經過的 router?":"traceroute", | |
"140.128.77.10/25 這個網段有多少可用的 IP?":"126", | |
"在二元樹走訪的方法中,我們常聽到 LVR、LRV、VLR 三種方法,請問 V 代表?":"Visiting,對當前的 node 進行print、assign或其他操作", | |
"Linux 裡有許多與系統相關的操作需要有 root 的權限,哪個指令可以幫助我們切換成 root?":"su", |
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
3 3 | |
0 1 2 | |
1 2 3 | |
0 2 4 | |
8 12 | |
0 1 3 | |
0 2 1 | |
1 2 1 | |
1 4 5 | |
1 5 4 |
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
10 | |
2 | |
2 3 | |
2 5 | |
3 | |
100 101 | |
10 102 | |
10 103 | |
2217 | |
561 25785 |
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 TestController < ApplicationController | |
before_action do | |
all do | |
puts count | |
end | |
end | |
def count | |
@count ||= 0 |
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 Array | |
def stable_sort | |
each_with_index.to_a.sort.map { |x| x[0] } | |
end | |
end |
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
# Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz | |
# Arch Linux x86_64 | |
# g++ (GCC) 6.2.1 20160830 | |
# Crystal 0.19.4 (2016-10-07) | |
======== random 2097152 ============= | |
with original quick sort 6.73 (± 2.34%) 1.16× slower | |
with intro sort 7.84 (± 1.49%) fastest | |
with std::sort in cpp 7.83 (± 1.74%) 1.00× slower | |
with qsort in c 4.98 (± 1.75%) 1.57× slower | |
======== seq 2097152 ============= |
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
# Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz | |
# Arch Linux x86_64 | |
# g++ (GCC) 6.2.1 20160830 | |
# Crystal 0.19.4 (2016-10-07) | |
======== random 2097152 ============= | |
(0.333) 2097152 elements with original quick sort | |
(0.247) 2097152 elements with intro sort | |
(0.245) 2097152 elements with std::sort in cpp | |
(0.444) 2097152 elements with qsort in c |
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
# Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz | |
# Arch Linux x86_64 | |
# g++ (GCC) 6.2.1 20160830 | |
# Crystal 0.19.4 (2016-10-07) | |
256 elements with original quick sort 702.73k (± 3.72%) 1.50× slower | |
256 elements with intro sort 1.05M (± 4.05%) fastest | |
256 elements with std::sort in cpp 845.94k (± 4.23%) 1.25× slower | |
256 elements with qsort in c 307.25k (± 5.24%) 3.43× slower | |
512 elements with original quick sort 320.05k (± 4.60%) 1.51× slower | |
512 elements with intro sort 483.13k (± 2.96%) fastest |
NewerOlder