Skip to content

Instantly share code, notes, and snippets.

View VoloshynDmytro's full-sized avatar

Voloshyn Dmytro VoloshynDmytro

View GitHub Profile
@VoloshynDmytro
VoloshynDmytro / configure_queues.sh
Created January 27, 2021 11:25 — forked from fforbeck/configure_queues.sh
RabbitMQ - Command Line Setup. Create queue, bindings, exchanges with rabbitmqadmin and rabbitmqctl
#!/usr/bin/env bash
URL="http://localhost:15672/cli/rabbitmqadmin"
VHOST="<>"
USER="<>"
PWD="<>"
QUEUE="<>"
FAILED_QUEUE="<>"
@VoloshynDmytro
VoloshynDmytro / understanding-http-status-codes.md
Created November 23, 2016 10:09 — forked from nepsilon/understanding-http-status-codes.md
Understanding HTTP’s status codes — First published in fullweb.io issue #75

Understanding HTTP’s status codes

Following our series on HTTP, here is a quick note on HTTP status code, sent with the HTTP response. They are organized in 5 categories:

1xx Informational, ex:

  • 100 Continue used when doing a multi-part file upload
  • 101 Switching Protocol used when switching from HTTP to WebSocket

2xx Success, ex:

let animal = {
animalType: 'animal',
describe () {
return `An ${this.animalType} with ${this.furColor} fur,
${this.legs} legs, and a ${this.tail} tail.`;
}
};
let mouseFactory = function mouseFactory () {
let animal = {
animalType: 'animal',
describe () {
return `An ${this.animalType}, with ${this.furColor} fur,
${this.legs} legs, and a ${this.tail} tail.`;
}
};
let mouse = Object.assign(Object.create(animal), {
@VoloshynDmytro
VoloshynDmytro / Angular range filter example for few properties in collection
Last active August 29, 2015 14:20
Angular range filter example for few properties in collection
app.filter 'range', ->
(items, filters) ->
filtered = items
angular.forEach filters, (filter) ->
return if filter.min == filter.max == null
min = parseInt(filter.min)
max = parseInt(filter.max)
property = filter.property
filtered = _.reject filtered, (item) ->
return !(item[property] >= min and item[property] <= max)
@VoloshynDmytro
VoloshynDmytro / gist:90dd30bfe3291a8019a6
Created April 2, 2015 09:44
underscore continue/break
datas = [1, 2, 3, 4, 5, 6, 7]
_.each datas, (data, num) ->
console.log data, num
if num == 2
console.log 'continue'
return
if num > 4
console.log 'break'
return {}
@VoloshynDmytro
VoloshynDmytro / gist:a52d87d7077244810d14
Created December 6, 2014 14:33
Dropbox background daemon
# 1. create file "dropbox" at /usr/bin
# 2. Add below code to this file:
#!/bin/bash
($HOME/.dropbox-dist/dropboxd &)&
@VoloshynDmytro
VoloshynDmytro / gist:ac2ebb17dd3b507f8c25
Created December 6, 2014 12:50
Devise custom failure
class CustomAuthFailure < Devise::FailureApp
def respond
self.status = 401
self.content_type = 'json'
self.response_body = {"errors" => ["Invalid login credentials"]}.to_json
end
end
# at initializers/devise.rb
# config.warden do |manager|
@VoloshynDmytro
VoloshynDmytro / gist:676c52f09d4e8cf8bd1f
Created December 6, 2014 12:47
Devise SessionController to render JSON
module Api
module V1
module CustomDevise
class SessionsController < Devise::SessionsController
prepend_before_filter :require_no_authentication, :only => [:create ]
include Devise::Controllers::Helpers
respond_to :json
def create
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')