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
using UnityEngine; | |
public class Ball : MonoBehaviour | |
{ | |
[SerializeField][Range(1, 100)] private float _force = 5; | |
[SerializeField] private float _radius = 0.5f; | |
private Rigidbody _rigidbody; | |
public float Radius => _radius; | |
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
namespace ConsoleApp | |
{ | |
public class Item | |
{ | |
public string Name { get; } | |
public Item(string name) | |
{ | |
Name = name; | |
} |
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
using System; | |
namespace ConsoleApp | |
{ | |
internal class Program | |
{ | |
// Смотрю есть горячий спор по именованию констант. Майкрософт рекомендует | |
// использовать PascalCase, но в этом случае можно путать с методами и property. | |
// Коммьюнити, судя по интернетам, предпочитает использовать UPPER_CASE. Мне кстати | |
// такой подход тоже нравится. Сразу видно, что это константа. |
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
using System; | |
using System.Globalization; | |
namespace ConsoleApp | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Объявить и проинициализировать 10 переменных. Среди них обязательно должны быть int, float, string и char. |
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
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 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
module Publisher | |
def subscribe(subscribers) | |
@subscribers ||= [] # if @subscribers is nil, we initialize it as empty array, else we do nothing | |
@subscribers += subscribers | |
end | |
def broadcast(event, *payload) | |
@subscribers ||= [] # @subscribers is nil, we can't do each on it | |
@subscribers.each do |subscriber| | |
# If event is :item_added occured with payload item itself |
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
module ComponentHelper | |
def react_component(name, props: {}) | |
content_tag(:div, nil, id: name, data: { props: props.to_json, handler: "react" }) | |
end |
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
Проект "Подземелье драконов" | |
Задание 1 | |
Генератор подземелья | |
Напишите скрипт, который генерирует подхемелье с комнатами. | |
Подземелье – квадрат 10x10 (массив). | |
Комната – элемент массива. Каждая комната должна иметь хотя-бы одну дверь в другую комнату (сверху, справа, слева, снизу). Максимум четыре двери в комнате. Дверь не может выводить из подземелья. Поэтому комната в массиве с индексом [0][0] может иметь дверь только внизу и справа. |
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
Photosession.all.each do |p| | |
p.photos.each do |ph| | |
begin | |
p.process_photos_upload = true | |
ph.cache_stored_file! | |
ph.retrieve_from_cache!(ph.cache_name) | |
ph.recreate_versions!(:xl, :l, :m, :s, :xs) | |
p.save! | |
rescue => e | |
puts "ERROR: YourModel: #{e.to_s}" |
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
# lib/breadcrumbs/admin_breadcrumbs.rb | |
AdminBreadcrumbs = Crumbs.build do | |
framework :rails | |
namespace :admin | |
crumb 'welcome#index' do | |
link 'Дашборд' | |
end |
NewerOlder