Skip to content

Instantly share code, notes, and snippets.

require 'yaml'
require 'logger'
require 'active_record'
namespace :db do
def create_database config
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'}
create_db = lambda do |config|
ActiveRecord::Base.establish_connection config.merge('database' => nil)
# Install stuff
$ apt-get update
$ apt-get upgrade
# NGINX
$ apt-get install git htop vim nginx mysql-server mysql-client libmysqlclient-dev php5-fpm php5-curl phpmyadmin
# Apache 2
$ apt-get install git htop vim apache2 mysql-server mysql-client libmysqlclient-dev php5 php5-curl phpmyadmin
@Jpuelpan
Jpuelpan / replace.sql
Last active August 29, 2015 14:04
Wordpress domain change, database replace
-- Wordpress domain change, database replace
UPDATE wp_options SET option_value = replace(option_value, 'http://oldurl.com','http://newurl.com');
UPDATE wp_posts SET POST_CONTENT = replace(POST_CONTENT, 'http://oldurl.com','http://newurl.com');
UPDATE wp_posts SET guid = replace(guid, 'http://oldurl.com', 'http://newurl.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://oldurl.com', 'http://newurl.com');
@Jpuelpan
Jpuelpan / unicorn.rb
Last active September 3, 2015 18:50 — forked from rodw/pid-file-daemon.sh
Unicorn Basic configuration
APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__)))
worker_processes 1
working_directory APP_ROOT
timeout 30
listen APP_ROOT + "/tmp/appname.sock", backlog: 64
listen "127.0.0.1:8080", tcp_nopush: true
@Jpuelpan
Jpuelpan / hosts
Last active October 18, 2015 22:01
Configurations for NGINX
# Listen on port
server {
listen 80;
server_name my.domain.com;
location ~ ^/(assets)/ {
root /path/to/project/public;
# gzip_static on;
# expires max;
@Jpuelpan
Jpuelpan / token.rb
Last active August 29, 2015 14:02
Generate access token
class User < ActiveRecord::Base
def generate_token
self.access_token = loop do
random_token = SecureRandom.uuid
break random_token unless self.class.exists?(access_token: random_token)
end
end
end
@Jpuelpan
Jpuelpan / rvm.md
Last active August 29, 2015 13:56
RVM installation Multi User. Many users each one with his own gemsets, but only one shared Ruby

Multi-User RVM

From a user with sudo permissions

$ \curl -sSL https://get.rvm.io | sudo bash -s stable
$ source /etc/profile

Install Ruby

$ rvm requirements

@Jpuelpan
Jpuelpan / exporter.rb
Last active October 30, 2018 13:17
A very simple Ruby wrapper for PhantomJS.
# exporter.rb
# A very simple Ruby wrapper for PhantomJS
# for create PDF's or anything you can create with PhantomJS
require 'json'
class Exporter
class PhantomJSNotFound < StandardError; end
class << self
def default_options