Skip to content

Instantly share code, notes, and snippets.

View mytrile's full-sized avatar

Dimitar Kostov mytrile

View GitHub Profile
@mytrile
mytrile / example.database.mysql.extra
Created October 16, 2018 11:32 — forked from karuna/example.database.mysql.extra
database.yml collection
pool: number indicating size of connection pool (default 5)
checkout_timeout: number of seconds to block and wait for a connection before giving up and raising a timeout error (default 5 seconds).
reaping_frequency: frequency in seconds to periodically run the Reaper, which attempts to find and close dead connections, which can occur if a programmer forgets to close a connection at the end of a thread or a thread dies unexpectedly. (Default nil, which means don't run the Reaper).
dead_connection_timeout: number of seconds from last checkout after which the Reaper will consider a connection reapable. (default 5 seconds).
encoding: (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection.
reconnect: Defaults to false (See MySQL documentation: dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html).
strict: Defaults to true. Enable STRICT_ALL_TABLES. (See MySQL documentation: dev.mysql.com/doc/refman/5.0/en
@mytrile
mytrile / richhickey.md
Created April 18, 2018 06:01 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

def currency_euro(item)
number_to_currency(item, :unit => "&euro;", :separator => ",", :delimiter => "", :format => "%n %u")
end
@mytrile
mytrile / TestVertxWeb.kt
Created November 19, 2016 20:36 — forked from itang/TestVertxWeb.kt
Test Vertx Web
package demo
import io.vertx.core.Vertx
import io.vertx.core.http.HttpServer
import io.vertx.core.http.HttpServerResponse
import io.vertx.ext.web.Route
import io.vertx.ext.web.Router
import io.vertx.ext.web.RoutingContext
fun Router.get(path: String, handler: (RoutingContext) -> Unit): Route {
@mytrile
mytrile / description.markdown
Created October 10, 2016 12:30 — forked from runemadsen/description.markdown
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

@mytrile
mytrile / Dockerfile
Created August 4, 2016 08:17 — forked from sergio1990/Dockerfile
Elixir in Docker
FROM elixir:1.2.3
MAINTAINER Sergey Gernyak <[email protected]>
ENV MIX_ENV=prod
RUN apt-get update && apt-get install -y build-essential git-core
RUN mkdir -p /app
WORKDIR /app
#!/bin/sh
#
if [ "X$SSH_AUTH_SOCK" = "X" ]; then
eval `ssh-agent -s`
ssh-add $HOME/.ssh/id_rsa
fi
HOST=
REDIS_SLAVE_PORT=6000
@mytrile
mytrile / rest_client.ex
Created January 24, 2016 19:55 — forked from miwee/rest_client.ex
Rest Client implementation based on HTTPoison
defmodule RestClient do
require Logger
alias Poison, as: JSON
@baseurl "http://someapi.com"
@username "username"
@password "password"
def get_by_path(path, id, params)
when is_binary(id) or is_integer(id) and is_list(params) do
@mytrile
mytrile / README.md
Created November 26, 2015 12:29 — forked from wvengen/README.md
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

@mytrile
mytrile / phantomjs_selectable_text.md
Created September 25, 2015 08:48 — forked from jordanandree/phantomjs_selectable_text.md
PhantomJS 1.9.8 - Selectable Text

There is a bug in PhantomJS on Mac OS X that doesn't render an HTML page as selectable text. It will be fixed in PhantomJS 2.0, so for now you'll have to apply a patch when installing with Homebrew.

First, update homebrew formulae:

$ brew update

If you already have PhantomJS installed, then remove it:

$ brew uninstall phantomjs Next, the PhantomJS formula needs to be edited to apply a patch that fixes native text rendering in Mac OS X: