Skip to content

Instantly share code, notes, and snippets.

@denwwer
denwwer / gist:6184924
Last active February 19, 2016 01:42
log rotate for rails logs
PATH_TO_RAILS_APP/log/*.log {
daily
missingok
rotate 30
dateext
compress
delaycompress
notifempty
copytruncate
}
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end
@denwwer
denwwer / gist:6712284
Last active December 23, 2015 23:49
Create env for wordpress (php 5) on Ubuntu
sudo apt-get install apache2 php5 php5-mysql libapache2-mod-php5
# copy wordpress to /var/www
# OPTINAL: change apache user
# sudo gedit /etc/apache2/envvars
# change next:
# export APACHE_RUN_USER=your_user
# export APACHE_RUN_GROUP=your_gpoup
sudo gedit /etc/php5/apache2/php.ini
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end
#put in lib/tasks/fixtures.rake
namespace :db do
namespace :fixtures do
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database. Set RAILS_ENV to override.'
task :dump => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_migrations"]
ActiveRecord::Base.establish_connection(:development)
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
@denwwer
denwwer / gist:7991651
Last active December 31, 2015 13:18
example how restore session in Rails 3
## in controller
# skip verify_authenticity_token when data from another server
skip_before_filter :verify_authenticity_token, :only => [:restore]
def restore
restore_session_from(params[:session_id])
redirect_to '/'
end
## ApplicationController
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@denwwer
denwwer / dj_plugin.rb
Created June 22, 2014 17:18
send email if delayed_job job is failed via exception_notification
# Usage
# DJ config
require Rails.root.join('lib', 'dj_plugin.rb')
Delayed::Worker.plugins << Delayed::Plugins::EmailNotify
# lib/dj_plugin.rb
require 'exception_notification'
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@denwwer
denwwer / 00.howto_install_phantomjs.md
Created September 20, 2016 20:37 — 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