Map [1]
| Operation | Time Complexity |
|---|---|
| Access | O(log n) |
| Search | O(log n) |
| Insertion | O(n) for <= 32 elements, O(log n) for > 32 elements [2] |
| Deletion | O(n) for <= 32 elements, O(log n) for > 32 elements |
| defmodule Mix.Tasks.ConvertToVerifiedRoutes do | |
| @moduledoc """ | |
| Replaces routes with verified routes. | |
| Forked from | |
| https://gist.github.com/andreaseriksson/e454b9244a734310d4ab74d8595f98cd | |
| This requires all routes to consistently be aliased with | |
| alias MyAppWeb.Router.Helpers, as: Routes | |
| Run with |
| defmodule MyApp.Repo.Migrations.AddPostgresTriggerAndFunctionForAllTables do | |
| use Ecto.Migration | |
| def up do | |
| # Create a function that broadcasts row changes | |
| execute " | |
| CREATE OR REPLACE FUNCTION broadcast_changes() | |
| RETURNS trigger AS $$ | |
| DECLARE | |
| current_row RECORD; |
This lets you load application JavaScript asynchronously from <head>. Compatible with Turbolink v2, v5.0, v5.1, jquery-turbolinks, and no Turbolinks. Compatible with all browsers and IE9+ (only IE10+ will actually benefit from this though).
How to use this:
Add the HTML snippet just before the closing </body> tag.
Add the on_page_load.js script to the beginning of your application.js, and use window.App.onPageLoad(...) instead of document.addEventListener('DOMContentLoaded', ...) and jQuery(($) -> ...) everywhere.
Include your JavaScript like so:
<head>| #!/bin/bash | |
| name=$RANDOM | |
| url='http://localhost:9093/api/v1/alerts' | |
| echo "firing up alert $name" | |
| # change url o | |
| curl -XPOST $url -d "[{ | |
| \"status\": \"firing\", |
| ### | |
| ### | |
| ### UPDATE: For Win 11, I recommend using this tool in place of this script: | |
| ### https://christitus.com/windows-tool/ | |
| ### https://github.com/ChrisTitusTech/winutil | |
| ### https://www.youtube.com/watch?v=6UQZ5oQg8XA | |
| ### iwr -useb https://christitus.com/win | iex | |
| ### | |
| ### OR take a look at | |
| ### https://github.com/HotCakeX/Harden-Windows-Security |
| # Elixir has pipes `|>`. Let's try to implement those in Ruby. | |
| # | |
| # I want to write this: | |
| # | |
| # email.body | RemoveSignature | HighlightMentions | :html_safe | |
| # | |
| # instead of: | |
| # | |
| # HighlightMentions.call(RemoveSignature.call(email.body)).html_safe | |
| # |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |