Skip to content

Instantly share code, notes, and snippets.

View preist's full-sized avatar
🏠
Working from home

Igor Putina preist

🏠
Working from home
View GitHub Profile
@preist
preist / redis_and_resque.mkd
Created April 20, 2017 11:20 — forked from Diasporism/redis_and_resque.mkd
How to configure Redis and Resque for your Rails app.

Redis and Resque

What this guide will cover: the code you will need in order to include Redis and Resque in your Rails app, and the process of creating a background job with Resque.

What this guide will not cover: installing Ruby, Rails, or Redis.

Note: As of this writing I am still using Ruby 1.9.3p374, Rails 3.2.13, Redis 2.6.11, and Resque 1.24.1. I use SQLite in development and Postgres in production.

Background jobs are frustrating if you've never dealt with them before. Over the past few weeks I've had to incorporate Redis and Resque into my projects in various ways and every bit of progress I made was very painful. There are many 'gotchas' when it comes to background workers, and documentation tends to be outdated or scattered at best.

@preist
preist / 00.howto_install_phantomjs.md
Created April 11, 2017 09:00 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

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
# Rails 5 Puma configuration example
# Stores things in the `/tmp` folder of your Rails app
workers 1
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
port ENV.fetch("PORT") { 3000 }
# Puma rake tasks for starting, stoping and restarting a server
# In Rails 5+ you can run it by calling `rails puma:start`
namespace :puma do
desc "Starts Puma server"
task start: :environment do
FileUtils.mkdir_p(["tmp/sockets", "tmp/pids"])
Process.exec("puma -d")
end
desc "Stops Puma server"
@preist
preist / monty.rb
Last active March 24, 2016 02:41
Monty Hall Problem
#! /usr/bin/env ruby
# Monty Hall Problem Test
# Number of doors
CHOICES = 3
def play(change)
choices = (1..CHOICES).to_a
prize = rand(1..CHOICES)
@preist
preist / stats.sh
Last active March 7, 2016 05:27
Lines of Code Written Today (Rails Version)
#!/usr/bin/env bash
# Lines of Code Written Today (Rails Version)
#
# Copy this script into your Rails project folder
# and run it to see the number of lines commited
# by you to Git since midnight today.
GUSER=$(git config user.name)
SINCE=$(date +%Y-%m-%d)