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
EXPLAIN SELECT "customers".*, | |
coalesce("customer_bookings"."appointments", 0) AS "appointments", | |
coalesce("customer_bookings"."no_shows", 0) AS "no_shows", | |
"customer_bookings"."last_appointment" AS "last_appointment", | |
coalesce("customer_sales"."total_sales", 0) AS "total_sales", | |
greatest("customer_payments_accumulators"."unpaid_amount", 0) AS "outstanding", | |
"locations"."name" AS "last_location" | |
FROM "customers" | |
LEFT OUTER JOIN | |
(SELECT COUNT(*) FILTER( |
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
do $$ | |
begin | |
for i in 1..10 loop | |
INSERT INTO public.providers (name, description, address, online_booking, cancellation_policy, cancellation_time, website, contact_numbers, currency_code, country_code, time_zone, created_at, updated_at, print_receipts, receipt_message, prices_include_tax, beginning_of_week, default_calendar_view, time_slot_minutes, sms_enabled, business_type_id, widget_allows_employee_selection, widget_max_advance_time_in_months, commission_before_discount, commission_after_tax, time_format, voucher_expiration_period, locale, payments_activated, marketplace_enabled, marketplace_info, checkout_version, sale_custom_header_1, sale_custom_header_2, sale_show_customer_info, new_appointment_modal, new_appointment_summary, advance_notice_time_in_seconds, appointment_color_source, custom_invoice_title, payments_coming_soon, payments_enabled, new_taxes, sale_show_customer_address, zendesk_enabled, payments_enabled_by_provider, hidden_from_marketplace, payments_required, payment_due, new_cal |
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
<div class="row"> | |
{{ $t("WIND") }}: | |
{{ | |
** This ternary operator looks weird here, logic should be probably moved to function ** | |
getWindDirection(weather.wind ? weather.wind.direction : 400) | |
}} | |
| {{ weather.wind ? weather.wind.speed : "n/a" }}m/s | |
</div> |
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
gem 'oj' | |
gem 'oj_mimic_json' | |
#this will make you happy | |
# faster json rendering using oj |
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
<textarea name="comment" id="comment" cols="30" row="30" style="height:60px; width:300px" placeholder="Enter your comment..."></textarea> |
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
In Ruby, &method passes you! | |
Most Rubyists would know what the following does. | |
[1, 2, 3].map(&:to_s) | |
It takes the array of numbers, calls to_s on each item, and returns an array of the return values. | |
But what if you want to do the opposite? Rather than calling a method on the object, what if you want to call a method with the object as a parameter? Simple! | |
["1", "2", "3"].map(&method(:Integer)) |
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 pause_capybara | |
$stderr.write " | |
Capybara paused! | |
App running at http://localhost:#{Capybara.current_session.server.port} | |
Press enter to continue..." | |
$stdin.gets | |
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
You are given an n x n 2D matrix that represents an image. Rotate the image by 90 degrees (clockwise). | |
Example | |
For | |
a = [[1, 2, 3], | |
[4, 5, 6], | |
[7, 8, 9]] | |
the output should be |
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
Capybara.server_port = 9887 | |
Capybara.app_host = "http://#{ENV['APP_HOST']}:#{Capybara.server_port}" | |
Capybara.always_include_port = true | |
Capybara.register_driver :chrome do |app| | |
Capybara::Selenium::Driver.new(app, browser: :chrome) | |
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
netstat -vanp tcp | grep 3000 |
NewerOlder