Skip to content

Instantly share code, notes, and snippets.

💪
never stop coding

Phlegx Systems OG phlegx

💪
never stop coding
Block or report user

Report or block phlegx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View app-controllers-concerns-authenticable.rb
module Authenticable
extend ActiveSupport::Concern
# Filter to use with before_action
def authenticate_user
jwt_token
rescue JWT::DecodeError => e
render json: { error: e.message }, status: :unauthorized
end
View HTTP.md
POST /oauth/token HTTP/1.1
Content-Type: application/json

{
  "grant_type": "password",
  "client_id": "CLIENT_ID",
  "owner_type": "OWNER_TYPE",
  "username": "OWNER_EMAIL",
  "password": "OWNER_PASSWORD"
View gist:db21c67b8dcaf6b55896df2f8a415e39
ag POSTGRES
sentry.conf.py
5:# SENTRY_POSTGRES_HOST
6:# SENTRY_POSTGRES_PORT
43:postgres = env('SENTRY_POSTGRES_HOST') or (env('POSTGRES_PORT_5432_TCP_ADDR') and 'postgres')
50: or env('POSTGRES_ENV_POSTGRES_USER')
55: or env('POSTGRES_ENV_POSTGRES_USER')
60: or env('POSTGRES_ENV_POSTGRES_PASSWORD')
65: env('SENTRY_POSTGRES_PORT')
View gist:b02fc9897d1f0e3a324e9468c008de53
We are experiencing problems connecting to the Graylog server running on http://172.18.0.3:9000/api/. Please verify that the server is healthy and working correctly.
You will be automatically redirected to the previous page once we can connect to the server.
View gist:de09ddd55091da486a021021823fc8e9
Chain PREROUTING (policy ACCEPT 328K packets, 22M bytes)
pkts bytes target prot opt in out source destination
61479 4282K DOCKER all -- * * 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT 33114 packets, 2374K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 8963 packets, 611K bytes)
pkts bytes target prot opt in out source destination
32 1944 DOCKER all -- * * 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL
View gist:e6e451e64b92cd1991d5
Dec 9 11:34:18 aio1_nova_conductor_container-70e5afee nova-conductor: 2015-12-09 11:34:17.183 1231 INFO oslo.messaging._drivers.impl_rabbit [req-c68520ca-1de5-41dc-a519-93ce8ec27fe1 e4bf261ec4284e0fa9ece0b2a81ef830 d8012f50a5e54e7a85e58ae74a94661d - - -] Connecting to AMQP server on 172.29.236.108:5671
Dec 9 11:34:18 aio1_nova_conductor_container-70e5afee nova-conductor: 2015-12-09 11:34:17.229 1231 INFO oslo.messaging._drivers.impl_rabbit [req-c68520ca-1de5-41dc-a519-93ce8ec27fe1 e4bf261ec4284e0fa9ece0b2a81ef830 d8012f50a5e54e7a85e58ae74a94661d - - -] Connected to AMQP server on 172.29.236.108:5671
@phlegx
phlegx / my_controller.rb
Last active Aug 29, 2015
Websocket-Rails Rescue
View my_controller.rb
MyController < WebsocketRails::BaseController
include ActionController::Rescue
rescue_from ActiveRecord::RecordNotFound, with: :not_found_error
def not_found_error(exception)
# do something here
end
end
@phlegx
phlegx / gist:4fe3bd7df1eab5d780d6
Last active Aug 29, 2015
Websocket-Rails duplicate messages
View gist:4fe3bd7df1eab5d780d6
[["client_connected",{"id":null,"channel":null,"user_id":null,"data":{"connection_id":"ac42958a66e6682a07d7","user_id":1},"success":null,"result":null,"token":null,"server_token":null}]]
["websocket_rails.subscribe",{"id":119155,"data":{"channel":"unit_channel"}}]
[["websocket_rails.channel_token",{"id":null,"channel":"unit_channel","user_id":null,"data":{"token":"a37d1c7d-73ef-4070-983c-384d9ac10fe4"},"success":null,"result":null,"token":null,"server_token":null}]]
[["websocket_rails.subscribe",{"id":119155,"channel":null,"user_id":null,"data":{"channel":"unit_channel","success":"Channel authorization successful."},"success":true,"result":null,"token":null,"server_token":null}]]
[["websocket_rails.channel_token",{"id":null,"channel":"unit_channel","user_id":null,"data":{"token":"57b0fc35-bb50-4acc-a547-79e4b87a8690"},"success":null,"result":null,"token":null,"server_token":null}]]
[["websocket_rails.subscribe",{"id":119155,"channel":null,"user_id":null,"data":null,"success":true,"result":null,"token":null,"s
@phlegx
phlegx / Rails 4 - how to give alias names to includes() and joins() in active record quering
Last active Jul 26, 2019
Rails 4 - how to give alias names to includes() and joins() in active record quering
View Rails 4 - how to give alias names to includes() and joins() in active record quering
See question on stack overflow: http://stackoverflow.com/questions/28595636/rails-4-how-to-give-alias-names-to-includes-and-joins-in-active-record-que
- Model Student and model Teacher are both STI models with super class model User
- Model Story is a STI model with super class model Task
- includes() and joins(), both fails
Rails alias naming convention (includes() and joins())
- One model as parameter
- is base model (includes(:users))
View array_validator.rb
# Syntax sugar
class ArrayValidator < EnumValidator
end
You can’t perform that action at this time.