Skip to content

Instantly share code, notes, and snippets.

View ivanovv's full-sized avatar
🏠
Working from home

Victor Ivanov ivanovv

🏠
Working from home
  • Russia, Moscow
View GitHub Profile
@ivanovv
ivanovv / phoenix.ex
Created May 12, 2021 22:06
socket_connected events
defmodule WebinarGeek.PromEx.Plugins.Phoenix do
@moduledoc false
use PromEx.Plugin
require Logger
alias Phoenix.Socket
alias Plug.Conn
@ivanovv
ivanovv / presence_monitor.ex
Created October 14, 2019 01:34
Server side Phoenix Presence monitor
defmodule PresenceMonitor do
use GenServer
alias App.ViewerPresence
## Client API
def monitor(server_name, topic, subscription_id) do
GenServer.call(server_name, {:monitor, topic, subscription_id})
end
defmodule Benchmark do
def measure(func) do
func
|> :timer.tc
|> elem(0)
|> Kernel./(1_000_000)
end
end
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
Prefix Verb URI Pattern Controller#Action
galleries GET /galleries(.:format) galleries#index
POST /galleries(.:format) galleries#create
new_gallery GET /galleries/new(.:format) galleries#new
edit_gallery GET /galleries/:id/edit(.:format) galleries#edit
gallery GET /galleries/:id(.:format) galleries#show
PATCH /galleries/:id(.:format) galleries#update
PUT /galleries/:id(.:format) galleries#update
DELETE /galleries/:id(.:format) galleries#destroy
premium_p
@ivanovv
ivanovv / routes.txt
Created March 13, 2015 08:31
challenges
join_challenge POST /challenges/:id/join(.:format) challenges#join
leaderboard_challenge GET /challenges/:id/leaderboard(.:format) challenges#leaderboard
leave_challenge DELETE /challenges/:id/leave(.:format) challenges#leave
challenges GET /challenges(.:format) challenges#index
POST /challenges(.:format) challenges#create
new_challenge GET /challenges/new(.:format) challenges#new
edit_challenge GET /challenges/:id/edit(.:format) challenges#edit
challenge GET /challenges/:id(.:format) challenges#show
PATCH /challenges/:id(.:format) challenges#update
2015-02-18T21:55:42.214Z 12439 TID--9yr4ng WARN: /home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/connection/ruby.rb:52:in `select'
/home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/connection/ruby.rb:52:in `rescue in _read_from_socket'
/home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/connection/ruby.rb:48:in `_read_from_socket'
/home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/connection/ruby.rb:41:in `gets'
/home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/connection/ruby.rb:273:in `read'
/home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/client.rb:245:in `block in read'
/home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/client.rb:233:in `io'
/home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/client.rb:244:in `read'
/home/deploy/apps/platform/shared/bundle/ruby/2.1.0/gems/redis-3.
Limit (cost=331597.28..331597.35 rows=29 width=187) (actual time=57145.891..57145.904 rows=30 loops=1)
-> Sort (cost=331597.28..331597.35 rows=29 width=187) (actual time=57145.889..57145.892 rows=30 loops=1)
Sort Key: customers.recurring_since
Sort Method: top-N heapsort Memory: 32kB
-> WindowAgg (cost=304409.86..331596.57 rows=29 width=187) (actual time=57143.748..57145.554 rows=400 loops=1)
-> Nested Loop Left Join (cost=304409.86..331588.74 rows=29 width=187) (actual time=2271.147..57140.744 rows=400 loops=1)
-> Nested Loop Left Join (cost=304409.57..331528.53 rows=29 width=158) (actual time=2271.105..57130.491 rows=400 loops=1
)
Join Filter: (customers.id = summary_mrr.customer_id)
Rows Removed by Join Filter: 107800444
relation | size
----------------------------------------------------------------+---------
statistics.mrrs | 22 GB
statistics.index_mrrs_on_account_id_and_has_new_and_date_id | 3415 MB
statistics.index_mrrs_on_account_id_and_date_id | 2432 MB
statistics.mrrs_pkey | 2432 MB
statistics.index_mrrs_date_id_customer_subscription_id | 2432 MB
pg_toast.pg_toast_16692 | 1075 MB
public.customer_mrr_readings | 368 MB
public.activities | 172 MB
I, [2015-01-20T17:15:22.270570 #11684] INFO -- Recurly: ===> GET https://api.recurly.com/v2/plans/platinum2/add_ons/add_store
I, [2015-01-20T17:15:22.545842 #11684] INFO -- Recurly: ===> GET https://api.recurly.com/v2/accounts/a9eec0d6-46a0-4494-8037-a80cd876ecf2
I, [2015-01-20T17:15:22.693809 #11684] INFO -- Recurly: ===> GET https://api.recurly.com/v2/accounts/c98b2cf5-9ec2-49ba-ba98-ed464ac28858
I, [2015-01-20T17:15:22.926471 #11684] INFO -- Recurly: ===> GET https://api.recurly.com/v2/plans/platinum2/add_ons/add_store
I, [2015-01-20T17:15:23.388682 #11684] INFO -- Recurly: ===> GET https://api.recurly.com/v2/accounts/c98b2cf5-9ec2-49ba-ba98-ed464ac28858/subscriptions?per_page=200
I, [2015-01-20T17:15:23.706596 #11684] INFO -- Recurly: ===> GET https://api.recurly.com/v2/plans/platinum2/add_ons/add_store
I, [2015-01-20T17:15:24.292496 #11684] INFO -- Recurly: ===> GET https://api.recurly.com/v2/accounts/a9eec0d6-46a0-4494-8037-a80cd876ecf2/subscriptions?per_page=200
I, [2015-01-20T17:15:25.192220 #1