This file contains hidden or 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
language | agpl-3.0 | apache-2.0 | artistic-2.0 | bsd-2-clause | bsd-3-clause | cc0-1.0 | epl-1.0 | gpl-2.0 | gpl-3.0 | isc | lgpl-2.1 | lgpl-3.0 | mit | mpl-2.0 | unlicensed | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Ruby | 4513 | 42208 | 266 | 5463 | 13744 | 1682 | 533 | 20153 | 14975 | 797 | 1155 | 1617 | 269015 | 1878 | 2247 | |
Rust | 162 | 3188 | 21 | 328 | 714 | 83 | 8 | 665 | 1317 | 126 | 105 | 137 | 8108 | 492 | 297 | |
C | 3060 | 30281 | 468 | 8949 | 23247 | 996 | 802 | 71930 | 51125 | 1637 | 9981 | 6433 | 84365 | 1574 | 3057 | |
Python | 14102 | 79036 | 588 | 14517 | 46448 | 3891 | 1113 | 75928 | 82760 | 2503 | 5983 | 7923 | 209152 | 3630 | 6285 | |
PHP | 6205 | 29648 | 283 | 3141 | 23837 | 924 | 243 | 70814 | 36439 | 562 | 2209 | 4256 | 163556 | 1069 | 2306 | |
C++ | 3161 | 28707 | 387 | 7450 | 21009 | 909 | 584 | 64061 | 51985 | 877 | 8104 | 7311 | 83737 | 1599 | 3044 | |
Java | 4060 | 149147 | 550 | 3809 | 12911 | 1303 | 5360 | 32128 | 46739 | 609 | 4164 | 7993 | 98623 | 1753 | 3998 | |
Kotlin | 60 | 2722 | 12 | 51 | 139 | 21 | 14 | 141 | 597 | 26 | 13 | 60 | 2143 | 84 | 49 | |
Elixir | 76 | 740 | 18 | 126 | 363 | 13 | 9 | 496 | 328 | 93 | 34 | 70 | 4328 | 82 | 89 |
This file contains hidden or 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
def justify(text, width) | |
return if text.nil? || width.nil? || width.negative? | |
words = text.split(' ') | |
rows = group_words_into_rows(words, width) | |
rows = pad_rows(rows, width) | |
rows.map(&:join).join("\n") | |
end | |
def group_words_into_rows(words, width) |
This file contains hidden or 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
# return the array containing the tree levels, from root to last level. | |
def tree_by_levels(node) | |
return [] unless node | |
unpacked_tree = {} | |
breadth_first_search(node, unpacked_tree) | |
unpacked_tree.values.flatten | |
end | |
def breadth_first_search(node, hash = {}, depth = 0) | |
return unless node |
This file contains hidden or 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
-- Replace with your SQL query | |
SELECT | |
to_date(a.date::text, 'YYYY-MM-DD') AS date, | |
a.count AS count, | |
to_char( | |
(count::float / lag(count) over (order by date) - 1) * 100, | |
'FM999999999.0%' | |
) AS percent_growth | |
FROM ( | |
SELECT |
This file contains hidden or 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
-- Replace with your SQL Query | |
SELECT | |
a1.first_name || ' ' || a1.last_name AS first_actor, | |
a2.first_name || ' ' || a2.last_name AS second_actor, | |
film.title AS title | |
FROM film | |
JOIN film_actor AS fa1 ON fa1.film_id = film.film_id | |
JOIN film_actor AS fa2 ON fa2.film_id = film.film_id | |
AND fa1.actor_id <> fa2.actor_id | |
JOIN actor AS a1 ON fa1.actor_id = a1.actor_id |
This file contains hidden or 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
var evtSource = new EventSource('/stream'); | |
evtSource.onmessage = function(e) { | |
console.log('DATA', e.data); | |
} |
This file contains hidden or 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
# frozen_string_literal: true | |
# BasicService implements `self.call(*args)` so that you can | |
# use `ErrorObjectsBuilder.call(errors)` instead of | |
# `ErrorObjectsBuilder.new(errors).call` | |
class ErrorObjectsBuilder < BasicService | |
Error = Struct.new(:key, :index, :messages, :suberrors) | |
def initialize(errors, camelize_keys = true) | |
@errors = errors |
This file contains hidden or 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
# Wrapper around a HTTP library | |
class ApiClient; ... end | |
# Knows how to decode JSON responses from the API | |
class JSONApiClient < ApiClient; ... end | |
# Knows how to decode XML responses from the API | |
class XMLApiClient < ApiClient; ... end | |
# Exposes an API's endpoints as methods on an object |
This file contains hidden or 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 MyAppApiClient | |
attr_reader :json_client | |
attr_reader :xml_client | |
def initialize(api_token) | |
@json_client = ApiClient.new(API_KEY, JSON.method(:parse).to_proc) | |
@xml_client = ApiClient.new(API_KEY, XML.method(:parse).to_proc) | |
end | |
def current_account |
This file contains hidden or 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
array = [1,2,3,4,5] | |
array.map # => #<Enumerator: ...> | |
array.map { |i| i * 2 } # => [2, 4, 6, 8, 10] |