Skip to content

Instantly share code, notes, and snippets.

Safely updating a Craft installation

1. Download correct version

2. Backup database

  • Craft usually backsup the database on update but I've found that if you have a large database, this can cause the update script to timeout.
  • Craft should be set to 'backupDbOnUpdate' => false
  • This means that you'll be responsible for updating previous to updating

NCurses Disk Usage (aka: ncdu)

Use it like ncdu -x -q if you're invoking it remotely (e.g. via ssh) and ncdu -x otherwise.

ncdu 1.10 ~ Use the arrow keys to navigate, press ? for help
--- / --------------------------------------------------------
    6.2GiB [##########] /home  
    1.9GiB [##        ] /var
 1.0GiB [# ] /usr
@cballenar
cballenar / better-server-permissions.md
Last active November 6, 2015 22:09
Avoid having to manually change the permissions after adding files as root or another user. These commands have to be ran as root. After running these commands the files and directories inside www will inherit the ownership and permission given.
# add user to www-data
gpasswd -a user www-data

# change ownership
chown -R user:www-data /var/www/

# find all files, set permissions to rw-r-----
find /var/www -type f -exec chmod 0640 {} \;
@cballenar
cballenar / _setting-up-mt-self-managed-vps.md
Last active August 29, 2015 14:26
Walkthrough for setting up MediaTemple's self managed server with VirtualMin and getting your websites running.

Setting up MediaTemple Self Managed VPS

I recently moved from MediaTemple's Legacy (dv) 4.0 VPS server to their new Self Managed DV server. You get to save up some money at the expense of all the software that comes pre installed on a server. All you get when you rent one of these badboys is an empty box with your choice of OS. Sounds exciting!? You bet your ass it does! It can also be a bitch if you're not as familiar with how things work in a web server. Getting this setup helped me understand servers unlike never before and having full control over everything that happens in your box does feel kinda nice.

Installing VirtualMin

The best free application I found for managing websites is Webmin + VirtualMin. Though I would like to mention Ajenti, which looks pretty badass and seems to be in active development.

I come from Plesk which was definitely a superior tool but so far I envy noth

@cballenar
cballenar / 00-starting-with-laravel.md
Last active February 18, 2016 22:10
Starting with Laravel

Starting with Laravel on Mac OSX

Installation

Install composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
@cballenar
cballenar / _setting-up-rpi-web-server.md
Last active February 18, 2016 22:09
RaspberryPi Web Server

Setting up a RaspberryPi Web Server with NginX

WARNING!

I started this guide as I was building my web server but it was never finished. Nonetheless there's some valuable info for anyone starting a web server from scratch.

Steps

  1. [download offline raspbian][0]
  2. follow instructions for [no screen install of raspbian][1]
  3. setup [static ip address][2], reserve in router, and update hosts file on remote computer
  4. follow [secure web server][7], [secure ssh best practices][3], setup [ssh-copy-id in mac][4]
@cballenar
cballenar / gist:b71de8117b7042b01e92
Created August 21, 2014 17:16
Craft & Twig bits
{# Convert hyphenated-string to camelCase #}
{{ string | regex ( '/-([a-z])/e', 'ucfirst("\\1")' ) }}
{# Convert camelCasedString to hyphenated-one #}
{{ string | regex( '/(^|[a-z])([A-Z])/e', 'strtolower( strlen("\\1") ? "\\1-\\2" : "\\2" )', (type.handle) ) }}
@cballenar
cballenar / README.md
Last active January 2, 2016 04:49
'alpha-me' is a SCSS mixin that calculates a fallback solid color based on a translucent color (rgba or hsla) and a background color (by default, white) and returns both colors (fallback and original) with their properties and attributes. This allows us to use this mixin for multiple properties, such as: borders, shadows, etc. View live example at

alpha-me()

A SCSS mixin to create RGB fallbacks for RGBa styles.

  • By: @cballenar
  • Last updated: January 4th, 2014

How to

This mixin takes up to 4 arguments (minimum of two)