Skip to content

Instantly share code, notes, and snippets.

View jerivas's full-sized avatar

Ed Rivas jerivas

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jerivas on github.
  • I am jerivas (https://keybase.io/jerivas) on keybase.
  • I have a public key ASDMvVofW-Y777vKRS2Z3MEBb12ey9Y0ivfuR51KAN1IsQo

To claim this, I am signing this object:

@jerivas
jerivas / wp-dev-workflow.md
Last active July 31, 2018 23:58
WordPress developer workflow

rsync_excludes.txt

.git
node_modules
wp-config.php

Getting started off a production site

On the server:

@jerivas
jerivas / basicas.md
Last active July 16, 2018 04:11
Herramientas básicas para desarrollo web

Herramientas básicas para desarrollo web

Una lista de recursos básicos para empezar en el mundo del desarrollo web.

Extensiones en el Explorador de Archivos

El Explorador de Archivos es el programa que te permite explorar los archivos que están almacenados en el disco duro de tu PC. Por defecto este programa esconde las extensiones de los archivos (el punto y las letras después del nombre del archivo). Por ejemplo, una foto puede tener el nombre "Mi foto", pero en realidad no estás viendo la extensión, que es "JPG". Así, si pudieras ver la extensión verías que el nombre real de la foto es "Mi foto.jpg". Distintos tipos de archivos tienen distintas extensiones, por ejemplo, los documentos de Word utilizan la extensión .docx, la música utiliza .mp3, los videos .mov, y así sucesivamente.

Sigue este tutorial para dejar de ocultar las extensiones en tu computadora Windows. Al final, tu explorador de archivos t

@jerivas
jerivas / create-borg-archive.sh
Last active February 4, 2019 16:30
Create a new borg archive on an rsync.net server. Make sure you `borg init` first! Based on: http://borgbackup.readthedocs.io/en/stable/quickstart.html#automating-backups
#!/bin/sh
if [ -z "$1" ] ; then
echo "Please provide a project name as argument"
exit 1
fi
project=$1
# Configure your remote repository here
@jerivas
jerivas / calculator.py
Last active April 26, 2017 18:11
Loan calculator
def mortgage_calculator(form_data):
"""
Takes a single object `form_data` and returns all calculations in a `results` object.
Notes:
- The `Decimal` class simply takes any number or string and casts it into a decimal
value for calculations. See https://docs.python.org/2/library/decimal.html
- When you see '%.2f' that's simply forcing a value to be displayed with two
decimal places, i.e. 15.4504 comes out as 15.45.
"""

Bringing websites back up after server migrations

Hello! I created a quick guide to fix websites after a migration. Depending on the application type, the steps will differ.

Webfaction Django app

A regular Django / Apache app created from the control panel. Generally the only thing required is to reinstall the database driver (for either MySQL or Postgres) in the virtualenv. The virtualenv is a folder in the application directory, usually named

@jerivas
jerivas / class-cycle.js
Last active September 20, 2016 22:31
Cycle through CSS classes (including no class at all)
var classes = ["style1", "style2"];
$("element").on("click", function(event) {
// Don't execute if the event is bubbling from a child node
if (event.target !== this) return;
var $el = $(this);
$.each(classes, function(i, klass) {
if ($el.hasClass(klass)) {
$el.removeClass(klass)
// Add the next class (if any)
if (i < classes.length - 1) $el.addClass(classes[i + 1]);
// http://n33.co/2013/03/23/browser-on-jquery-19x-for-legacy-ie-detection
jQuery.browser={};
(function() {
jQuery.browser.msie = false;
jQuery.browser.version = 0;
if(navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
jQuery.browser.msie = true;
jQuery.browser.version = RegExp.$1;
}
})();
@jerivas
jerivas / useful_commands.md
Last active October 19, 2017 04:25
Bunch of random useful commands I've encountered/put together

Useful commands

Bunch of random useful commands I've encountered/put together.

Use Liquid Prompt (useful bundle of shell customizations)

https://github.com/nojhan/liquidprompt

Find files by extension and convert newlines with dos2unix

find . -regex ".*\.\(html\|css\|js\|scss\)" | xargs dos2unix

Extract plain text from PSD

@jerivas
jerivas / Mezzanine deployment.md
Last active August 29, 2015 14:15
HOWTO: Deploy a Mezzanine site

[CASE 1] Deploying to a brand new server:

  1. Get your sever. Anything that grants you root access works. VPS's like those from Digital Ocean work great and are cheap.
  2. Fill the FABRIC dictionary in local_settings.py. For SSH_USER provide any username you want (not root), and the fabfile can create it for you.
  3. Run fab secure. You simply need to know the root password to your VPS. The new user will be created and you can SSH with that from now on (if needed).
  4. Run fab all. It will take a while, but after this your Mezzanine site will be live.

Notice that not even once you had to manually SSH into your VPS. Note: some server providers need you to login as root once to change the default password they give you. It should be the only time you are required to SSH into the sever.

[CASE 2] If you already have a server, and you already have created a non-root user with sudo privileges: