Skip to content

Instantly share code, notes, and snippets.

View jerivas's full-sized avatar

Ed Rivas jerivas

View GitHub Profile
@jerivas
jerivas / instalar_magic.sh
Last active August 29, 2015 14:05
Script de instalación para Magic VLSI (versión de desarrollo).
#!/bin/bash
# INSTALADOR DE MAGIC
# Instala los prerequisitos, descarga la versión de desarrollo,
# la compila y la instala para todos los usuarios.
# También descarga e incluye los archivos de tecnologías.
# Todo queda almacenado en la carpeta "magic" en la carpeta de usuario.
# USO
# 1. Descargar el script en una ubicación de fácil acceso (carpeta de usuario)
@jerivas
jerivas / .gitignore
Last active November 19, 2020 00:16
Seguimiento de objetos por color. El script detecta objetos en base a colores y selecciona el más grande (por área). Se calcula la distancia del centroide del objeto al centro de la imagen.
*.pyc
*.pyo
*.db
.DS_Store
.coverage
*.sublime-project
*.sublime-workspace
*~
@jerivas
jerivas / scatter_plot.ino
Last active August 29, 2015 14:07
Gráficos de dispersión con Arduino y Processing por puerto serie
// Incluir la librería de Encoder
// http://www.pjrc.com/teensy/td_libs_Encoder.html
#include <Encoder.h>
// Inicializar un encoder conectado a los pines 2 y 3
Encoder encoder(2, 3);
// Variables para almacenar valores de encoder y ADC
long enc_old = 0;
int adc_now = 0;
@jerivas
jerivas / instalar_alliance.sh
Last active August 29, 2015 14:07
Instalador de la última versión de Alliance en Ubuntu 14.04 (x86 y x64)
#!/bin/bash
# INSTALADOR DE ALLIANCE
# USO
# 1. Descargar el script en una ubicación de fácil acceso (carpeta de usuario)
# 2. Dar permiso de ejecución:
# $ chmod +x instalar_alliance.sh
# 3. Ejecutar
# $ ./instalar_alliance.sh
# 4. Otorgar la contraseña si es necesario para tareas de superusuario
@jerivas
jerivas / tiny.py
Last active June 16, 2018 04:10
TinyPNG API via Python. Optimizes .png and .jpg files in the current directory and outputs to "optimized/".
from __future__ import print_function
import os
import tinify
tinify.key = "" # Fill your developer key here
exts = ("jpg", "png", "jpeg")
basewidth = 1500
files = [f for f in os.listdir(".") if os.path.isfile(f) and f.endswith(exts)]
@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:

@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

// 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 / 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]);

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