Skip to content

Instantly share code, notes, and snippets.

View International's full-sized avatar
🪲
Debugging

George Opritescu International

🪲
Debugging
View GitHub Profile
@International
International / rabbitmq.txt
Created February 28, 2018 13:05 — forked from sdieunidou/rabbitmq.txt
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
@International
International / Upgrading rails 5.0 to 5.1
Created February 15, 2018 21:43 — forked from kirankarki/Upgrading rails 5.0 to 5.1
Notes on upgrading rails 5.0 to 5.1
1. Change rails version in Gemfile
> gem 'rails', '~> 5.1', '>= 5.1.4'
2. Remove Gemfile.lock
> git rm Gemfile.lock
3. Run bundle install command
> bundle install --jobs=5
4. Run rails' app update to apply changes to app
require 'cucumber'
require 'selenium-webdriver'
# require 'cukehub' # optional, but recommended. See cukehub.com for more details
caps = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { binary: "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary",
args: [ "--headless" ]})
Before do
@browser = Selenium::WebDriver.for :chrome, desired_capabilities: caps
end
require 'cucumber'
require 'selenium-webdriver'
# require 'cukehub' # optional, but recommended. See cukehub.com for more details
caps = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { binary: "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary",
args: [ "--headless" ]})
Before do
@browser = Selenium::WebDriver.for :chrome, desired_capabilities: caps
end
@International
International / delayed_job.rb
Created May 20, 2017 21:00 — forked from thisduck/delayed_job.rb
delayed job profiling
# config/initializer/delayed_job.rb
module Delayed
module Plugins
class Flaming < Plugin
callbacks do |lifecycle|
lifecycle.around(:invoke_job) do |job, *args, &block|
HelperMethods.flaming(name: "DELAYEDJOB--#{job.name}") do
block.call(job, *args)
end
@International
International / channel_check.go
Created December 22, 2016 15:58 — forked from iamatypeofwalrus/channel_check.go
Check if a Go Channel is open or closed
// An intersting pattern for testing, but you can use the check anywhere
import "testing"
func TestCheckingChannel(t *testing.T) {
stop := make(chan bool)
// Testing some fucntion that SHOULD close the channel
func (stop chan bool) {
close(chan)
}(stop)
@International
International / gist:91497de9d32411af8455e436f601971c
Created December 6, 2016 19:16 — forked from joho/gist:3735740
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@International
International / understanding-http-transfer-encoding-chunked.md
Created November 15, 2016 21:58 — forked from nepsilon/understanding-http-transfer-encoding-chunked.md
Understanding HTTP’s Transfer-Encoding: chunked — First published in fullweb.io issue #74

Understanding HTTP’s Transfer-Encoding: chunked

Simply put, Transfer-Encoding: chunked, in a HTTP response header, tells us the body will be received in several chunks.

This is ideal in 2 scenarios:

  1. When the size of the body isn’t known in advance, like when generating output from a database.
  2. When the size of the body is too big to be fully loaded in RAM before being sent to the client.

In practice, the body has each of its chunks separated with X\r\n, where X is the size of the chunk in hexadecimal. For instance:

# Add mixin to /config/initializers/
module LogQuerySource
def debug(*args, &block)
return unless super
backtrace = Rails.backtrace_cleaner.clean caller
relevant_caller_line = backtrace.detect do |caller_line|
!caller_line.include?('/initializers/')
end
@International
International / loop.ex
Created September 4, 2016 17:50 — forked from nanne007/loop.ex
loop, while,break construct in elixir
defmodule Loop do
defmacro while(predicate, do: block) do
quote do
try do
for _ <- Stream.cycle([:ok]) do
if unquote(predicate) do
unquote(block)
else
throw :break
end