- fmi.ruby.bg/lectures – това са лекции от курс във ФМИ, в чието водене съм участвал. В сбит вид дават доста добър общ преглед над езика, като на места се влиза в доста и ценни детайли. Има разни административни слайдове, които са за пропускане, но отвъд това, са сбити и полезни лекции. Направени са да са съпроводени от лекционни обяснения, така че ако нещо не е ясно от слайдовете, трябва да се търси/пита допълнително. Повечето неща би трябвало да са достатъчно ясни, в зависимост от това колко опит има човек с програмиране и скриптови езици.
- Има и няколко примерни задачи тук: http://fmi.ruby.bg/tasks – понеже са минали тези задачи, има и решения. Добре е да се пробват паралелно с четенето на слайдовете. Някои от решенията имат бонус точки и може да се ползват като пример как е добре и типично да се пише Ruby.
- Без писане на код не става. Полезно е да се прекарва горе-долу поравно време както в четене на неща, така и в пробването
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
while true; do PGCONNECT_TIMEOUT=2 psql -U receiptbank -h monolith-postgresql --list >/dev/null && date +'Host: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done | |
while true; do PGCONNECT_TIMEOUT=2 psql -U receiptbank -h 0.0.0.0 --list >/dev/null && date +'IP: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done | |
while true; do PGCONNECT_TIMEOUT=2 psql -U receiptbank --list >/dev/null && date +'Sock: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done | |
while ! kubectl -n probes logs --timestamps -f `kubectl get pods -n probes -l app=monolith -l component=postgresql --show-kind=false --no-headers 2>/dev/null|cut -d' ' -f1`; do echo -n .; sleep 0.1; done | |
while ! kubectl-exec-in probes `kubectl get pods -n probes -l app=monolith -l component=postgresql --show-kind=false --no-headers 2>/dev/null|cut -d' ' -f1` /bin/bash -lc "while true; do PGCONNECT_TIMEOUT=2 psql -U postgres -h 0.0.0.0 --list >/dev/null && date +'IP: %Y-%m-%d %H:%M:%S.%6N' || echo -n .; sleep 0.05; done" 2>/dev/null; do echo -n .; slee |
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 emails = ['[email protected]', 'another.example.com']; | |
var index = 0; | |
function inviteNextPerson() { | |
if (index >= emails.length) return; | |
var email = emails[index]; | |
var input = $('input[name=invite]'); | |
var submit = $('button[type=submit].solid.info.fat'); |
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
require 'open3' | |
class Command | |
def run(command, stdout_callback, stderr_callback) | |
Open3.popen3(command) do |stdin_write_io, stdout_read_io, stderr_read_io, process_wait_thread| | |
# We don't care about STDIN | |
stdin_write_io.close | |
stdout_reader = read_without_blocking_from(stdout_read_io, stdout_callback) | |
stderr_reader = read_without_blocking_from(stderr_read_io, stderr_callback) |
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
update wp_options set option_value = 'a:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:62:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:2 |
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
require 'thread' | |
require 'bunny' | |
c = Bunny::Session.new(continuation_timeout: 1_000) | |
c.start | |
ch = c.create_channel | |
ch.confirm_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
require 'thread' | |
require 'bunny' | |
operations_log = [] | |
operations_log_mutex = Mutex.new | |
c = Bunny::Session.new | |
c.start | |
ch = c.create_channel |
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
#!/bin/bash | |
duration="$1" | |
if [ -z "$duration" ]; then | |
echo "Usage: $0 <duration> where duration is a number in seconds, or a number with an m or a h suffix." >&2 | |
echo "Examples:" >&2 | |
echo "$0 10" >&2 | |
echo "$0 15m" >&2 | |
exit 1 |
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
slct = ->(lst, &blk) { | |
lst == [] ? [] : ( | |
((r = blk.(lst[0])) ? [r] : []) + slct.(lst[1..-1], &blk) | |
) | |
} | |
n_cs = ->((x, z)) { | |
[ | |
[x - 1, z - 1], [x, z - 1], [x + 1, z - 1], | |
[x - 1, z ], [x + 1, z ], |