Skip to content

Instantly share code, notes, and snippets.

@bogdanRada
bogdanRada / gist:b19c381679da8fe299c3329a0ebe8001
Created June 7, 2018 11:48 — forked from sebsto/gist:6441df09e97c4cbbd22b8ba313b8d642
Amazon Linux 2 first boot on Virtual Box
# Download the VDI from https://cdn.amazonlinux.com/os-images/latest/
# Doc is at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html
# Be sure you have config/meta-data and config/user-data ready as per the below
# change ec2-user's password to your password
$ cat config/meta-data
local-hostname: amazonlinux.onprem
# eth0 is the default network interface enabled in the image. You can configure
@bogdanRada
bogdanRada / Gemfile
Created May 24, 2018 08:22 — forked from nathancolgate/Gemfile
How I built a rails interface on top of the amazing IceCube ruby gem. Video of final product: http://youtu.be/F6t-USuWPag
# Add these two gems
gem 'ice_cube', '0.9.3'
gem 'squeel', '1.0.16'
@bogdanRada
bogdanRada / gist:8a2928a9a34dcff887f1a5a2331c4afc
Created May 23, 2018 06:55 — forked from webdev1001/gist:e848abef8064c55c2f6443a282f75651
Array values in the parameter to `Gem.paths=` are deprecated.
Array values in the parameter to `Gem.paths=` are deprecated.
Please use a String or nil.
An Array (...) was passed in from bin/rails:3:in `load'
Solution
========
https://github.com/rubygems/rubygems/issues/1551
If you came to this issue by googling the error specified in the description of this issue, you should know that it has already been fixed in spring-1.6.4 and all you need to do is to update to latest spring and regenerate binstubs, like this:
@bogdanRada
bogdanRada / merge-object.js
Created May 22, 2018 14:02 — forked from wycliffepeart/merge-object.js
Javascript Object.assign Alternative . The mergeObject() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object.
function mergeObject(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (source.hasOwnProperty(key)) {
target[key] = source[key];
}
}
}
return target;
@bogdanRada
bogdanRada / README.md
Created May 10, 2018 11:19 — 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

@bogdanRada
bogdanRada / install.sh
Created May 8, 2018 12:37 — forked from jtilly/install.sh
Install qcachegrind on Ubuntu
#!/bin/bash
sudo apt-get install qt5-default
wget http://kcachegrind.sourceforge.net/kcachegrind-0.7.4.tar.gz
tar xvf kcachegrind-0.7.4.tar.gz
cd kcachegrind-0.7.4
qmake && make
sudo install -m 755 qcachegrind/qcachegrind /usr/local/bin
sudo install -m 644 qcachegrind/qcachegrind.desktop \
/usr/local/share/applications/
@bogdanRada
bogdanRada / install.sh
Created March 7, 2018 13:02 — forked from ziadoz/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
@bogdanRada
bogdanRada / example_table.html
Created February 20, 2018 18:43 — forked from chrisbloom7/example_table.html
A cucumber/capybara step to test the order of data in a table, either with or without headers
<html>
<body>
<section class="left">
<article id="customers">
<h2>New Customers</h2>
<table class="data">
<thead>
<tr>
<th>ID</th>
<th>First Name</th>
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
@bogdanRada
bogdanRada / gist:6742e2405c2fb231a1fdcd2ee3fdb798
Created February 15, 2018 18:14 — forked from wakiki/gist:3312792
Rails 3 merging scope with OR
# By Steve Leung
# [email protected]
class ActiveRecord::Relation
# temporarily hack for allowing combining scopes with OR
# doesn't add the join tables so need to use .includes manually
# ie. Jobship.includes(:job).or(Jobship.accepted, Jobship.declined).count
def or(*scopes)
clauses = *scopes.map do |relation|