Skip to content

Instantly share code, notes, and snippets.

@evaldasg
evaldasg / dmginstall.sh
Created August 17, 2016 17:08 — forked from afgomez/dmginstall.sh
Download and install a .dmg
#!/bin/bash
# Downloads and install a .dmg from a URL
#
# Usage
# $ dmginstall [url]
#
# For example, for installing alfred.app
# $ dmginstall http://cachefly.alfredapp.com/alfred_1.3.1_261.dmg
#
@evaldasg
evaldasg / gist:9699e696ee732640844fd21d68b9d57b
Created August 5, 2016 05:50 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@evaldasg
evaldasg / pg_locations.sh
Created July 27, 2016 05:46
get file locations for postgresql
select name,setting,category,source from pg_settings where category IN( 'Reporting and Logging / Where to Log', 'File Locations' ) order by category,name;
@evaldasg
evaldasg / .railsrc
Created July 20, 2016 05:05 — forked from janlelis/.railsrc
13 Rails-specific hints for your rails 3 console.
# .railsrc for Rails 3, encoding: utf-8
# see http://rbjl.net/49-railsrc-rails-console-snippets
if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else
# # #
def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end
# # #
# loggers

IO Open Mode

Ruby allows the following open modes:

"r"  Read-only, starts at beginning of file  (default mode).

"r+" Read-write, starts at beginning of file.

"w"  Write-only, truncates existing file
@evaldasg
evaldasg / 256_colors.rb
Last active July 9, 2016 12:18
Print out to the console terminal's 256 width colors.
#!/usr/bin/env ruby
# This prints to the console 256 colors for foreground & background
%w(38 48).each do |fgbg| # Foreground/Background
(0..256).each do |color|
print "\e[#{fgbg};5;#{color}m" + " #{color}".ljust(8, ' ') + "\e[0m"
print "\n" if (color + 1) % 10 == 0
end
print "\n\n"
end
from: https://www.johnhawthorn.com/2012/09/vi-escape-delays/
Eliminating delays on ESC in vim and zsh
While having a vim discussion on twitter with @_jaredn, I remembered that having a delay in entering normal mode after pressing ESC (switching to normal mode) really frustrates me. This delay exists because many keys (arrows keys, ALT) rely on it as an escape character. Here’s the setup I’ve used for a while for near instantaneous switch into normal mode.
vim
A simple solution for vim is to :set esckeys. However, this will break any sequences using escape in insert mode.
@evaldasg
evaldasg / Gemfile
Created July 1, 2016 15:50 — forked from petems/Gemfile
An example http download with Progress Bar output in the command line with Ruby and the native `net/http` library...
source "https://rubygems.org"
gem "progressbar"
@evaldasg
evaldasg / .profile
Created June 16, 2016 07:42 — forked from sindresorhus/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@evaldasg
evaldasg / readme.md
Created June 14, 2016 14:27 — forked from maxivak/readme.md
Send email to multiple recipients in Rails with ActionMailer

Send email to multiple recipients

Send multiple emails to different recipients.

Mailer class

# app/mailers/notify_mailer.rb

class NotifyMailer < ApplicationMailer