A Pen by Brian J. Cardiff on CodePen.
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
def ej(a, b) | |
size = [a.size, b.size].min | |
a[0...size].zip(b[0...size]) | |
.map { |e| e.max } | |
.map(&.+(4)) | |
.select(&.>=(10)) | |
.sum | |
end | |
ej [1,5,3,4], [5,3,6] |
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
data = [{"Brian", 42}, {"Alan", 30}, {"Brian", 32}] | |
# unstable | |
data.sort_by &.[0] # => [{"Brian", 42}, {"Alan", 30}, {"Brian", 32}] | |
# stable | |
data.map_with_index { |d,i| {d,i} }.sort_by { |di| {di[0][0], di[1]} }.map { |di| di[0] } # => [{"Alan", 30}, {"Brian", 42}, {"Brian", 32}] |
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
require "benchmark" | |
def string_contains_word(source, word) | |
return false unless source | |
start = source.index(word) | |
return false unless start | |
return false if start > 0 && source[start-1].alphanumeric? | |
return false if start + word.size < source.size && source[start + word.size].alphanumeric? | |
true | |
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
puts "sfs" | |
class Crystal::Playground::Agent | |
def sendp(t) | |
send(t) | |
end | |
end | |
# $p.try &.sendp("bug") | |
10.times do |i| | |
puts i |
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
puts "sfs" | |
10.times do |i| | |
puts i | |
{ "Lon\nrem", i, i + 1 } | |
sleep 1 | |
end | |
sleep 2 |
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
clearscreen | |
rt 30 | |
repeat 3 [ | |
rt 30 | |
fd 172 | |
bk 172 | |
lt 30 | |
fd 200 | |
rt 120 |
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
# sample of a macro that flood the method calls with `#try` | |
# as a POC it does not support methods with arguments | |
macro mtry(expr) | |
{% if expr.is_a?(Call) %} | |
mtry({{expr.receiver}}).try(&.{{expr.name}}) | |
{% else %} | |
{{expr}} | |
{% end %} | |
end |
INTRODUCTION TO PROGRAMMING FOR THE VISUAL ARTS WITH P5.JS
Assignment 1: Port an Image to Code
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
{"tables":[{"name":"Trackers","guid":"bb1c463d-b35f-4fb0-a18b-78fab5f25963","kind":"local","fields":[{"name":"Phone","guid":"abf4aca1-502c-43f6-acad-0f88c33340fc","valid_values":""}],"protocol":["query","update","insert"]}],"message_triggers":[{"name":"track","enabled":true,"message":{"from":"+1-(234)-567-8912","pieces":[{"kind":"text","text":"track","guid":"815fa0f2-cfd7-4863-94d8-92fdb1430cdd"}],"pattern":"(?i-mx:\\A\\s*track\\s*\\Z)"},"kind":"message_trigger","actions":[{"kind":"create_entity","table":"bb1c463d-b35f-4fb0-a18b-78fab5f25963","field":"abf4aca1-502c-43f6-acad-0f88c33340fc","pill":{"kind":"placeholder","guid":"phone_number"}},{"kind":"send_message","message":[{"kind":"text","guid":"you are been tracked"}],"recipient":{"kind":"placeholder","guid":"phone_number"}}]},{"name":"all","enabled":true,"message":{"from":"+1-(234)-567-8912","pieces":[{"kind":"text","text":"all","guid":"0e2be89a-85dc-4eaf-b988-38f88ff0c9aa"},{"kind":"placeholder","text":"lorem ipsum","guid":"f02701b4-d99f-446b-aa90-39291f7 |