Skip to content

Instantly share code, notes, and snippets.

View mytrile's full-sized avatar

Dimitar Kostov mytrile

View GitHub Profile

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@mytrile
mytrile / example
Last active August 29, 2015 14:25 — forked from koreno/README.md
'rebaser' improves on 'git rebase -i' by adding information per commit regarding which files it touched.
pick d0d13d0 1:removed some bullshit from __entrypoint.d _________9______
pick a44e878 2:Improvements to object.d and __entrypoint.d ________89______
pick 12c5b47 3:Add usage to build.d ___3____________
pick 318af43 4:Added .gitignore ______________e_
pick eb9ad0f 5:Attempting to add more array support _1_3_56_89abcd__
pick 8b8df05 6:Added some special support for ldc to object.d ________8_______
pick e630300 7:Removed imports from build ___3____________
pick 69ae673 8:c-main to d-main __2345_7_9______
pick c00b344 9:Implemented write an exit system calls _1_345678_______
pick 3901cca 10:Add wscript_build file 0__3____________
@mytrile
mytrile / gist:150c2d715c31d9562caf
Created September 23, 2015 08:00 — forked from afn/gist:c04ccfe71d648763b306
Restart phantomjs when it hangs
# Borrowed from https://github.com/y310/rspec-retry/blob/master/lib/rspec/retry.rb
CAPYBARA_TIMEOUT_RETRIES = 3
RSpec.configure do |config|
config.around(:each, type: :feature) do |ex|
example = RSpec.current_example
CAPYBARA_TIMEOUT_RETRIES.times do |i|
example.instance_variable_set('@exception', nil)
self.instance_variable_set('@__memoized', nil) # clear let variables
@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:

@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 / 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
#!/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 / Dockerfile
Created August 4, 2016 08:17 — forked from sergio1990/Dockerfile
Elixir in Docker
FROM elixir:1.2.3
MAINTAINER Sergey Gernyak <sergeg1990@gmail.com>
ENV MIX_ENV=prod
RUN apt-get update && apt-get install -y build-essential git-core
RUN mkdir -p /app
WORKDIR /app
@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 / 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 {