Skip to content

Instantly share code, notes, and snippets.

View aldodelgado's full-sized avatar
💭
Bring a spring upon her cable

Aldo Delgado aldodelgado

💭
Bring a spring upon her cable
View GitHub Profile
@aldodelgado
aldodelgado / README
Created October 24, 2019 01:59 — forked from andreaslillebo/README
Rails - models organization - Keep code structure in models consistent
# Keep code struture in models consistent
# Inspired by http://rails-bestpractices.com/posts/75-keep-code-struture-in-models-consistent
# One example: (From top to bottom)
associations
scopes
class methods
validates
callbacks
instance methods
@aldodelgado
aldodelgado / update_hosts
Created May 28, 2019 01:27 — forked from kolpanic/update_hosts
Uses the MVPS hosts file to block unwanted parasites by redirecting them to `0.0.0.0`
#!/bin/bash
# Downloads the MVPS hosts file, and append it to the system hosts file
#
# If you want to make any manual persistent changes to the system hosts
# file, run this script first, then make sure that the change is backed up to
# /etc/hosts.orig.
if [ "$(whoami)" != "root" ]; then
echo "Sorry, this script must be run as root."
@aldodelgado
aldodelgado / mysql_db_backup.sh
Created February 11, 2019 04:56
Shell script to backup MySql database
#!/bin/bash
# Shell script to backup MySql database
# To backup Nysql databases file to /backup dir and later pick up by your
# script. You can skip few databases from backup too.
# For more info please see (Installation info):
# http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/01/mysql-backup-script.html
# Last updated: Aug - 2005
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 2.0 or above
# Copyright (C) 2004, 2005 nixCraft project
<?php
require('restclient.php');
class Edocgen {
private $api = '';
private $results = '';
private $response = '';
function __construct() {
@aldodelgado
aldodelgado / mysql.php
Created February 11, 2019 00:29
PHP script to connect to a MySQL database and query for results
<?php
# Database Connection
$link = mysqli_connect("SERVER", "DB_USER", "DB_PSSWORD", "DB_NAME");
# Checks to see if the database connection was made
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
@aldodelgado
aldodelgado / xss_whitelist.php
Created February 11, 2019 00:25
A basic whitelist to prevent XSS in PHP
<?php
function xss_whitelist($input, $limit = null, $offset = 0) {
// Force input to be a string0
$x = (string) $input;
// Allow alphanumeric characters, whitespace, and specific characters
$x = preg_replace("/[^a-zA-Z0-9 -:,.!?\/|]/", "",$x);
// Limit characters
@aldodelgado
aldodelgado / php_password_hasing.php
Created February 11, 2019 00:24
PHP Password Hasing with Blowfish algorithm
<?php
$username = '';
$password = '';
// A higher "cost" is more secure but consumes more processing power
$cost = 10;
// Create a random salt
$salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
@aldodelgado
aldodelgado / keybase.md
Created September 27, 2018 15:18
keybase.md

Keybase proof

I hereby claim:

  • I am aldodelgado on github.
  • I am aldodelgado (https://keybase.io/aldodelgado) on keybase.
  • I have a public key ASBOuV8_KRT-oAW4VGzX45pjJlaz3MoSF-WHuN-l7siQaQo

To claim this, I am signing this object:

@aldodelgado
aldodelgado / restclient.php
Created August 28, 2018 15:54
PHP REST Client
<?php
/**
* PHP REST Client
* https://github.com/tcdent/php-restclient
* (c) 2013-2017 Travis Dent <tcdent@gmail.com>
*/
class RestClientException extends Exception {}
@aldodelgado
aldodelgado / mortgage_affordability_zillow_api.md
Created August 2, 2018 18:09 — forked from ryandhaase/mortgage_affordability_zillow_api.md
Mortgage Affordability Calculator - Built in Ruby on Rails

Mortgage Affordability Calculator - Built in Ruby on Rails

Functionality
  1. Send a GET request containing the following user inputs to Zillow's Mortgage Affordability API. Inputs as follows:
  • Annual Income, Monthly Payment, Down, Monthly Debts, Rate, Schedule, Term, Debt to Income, Income Tax, Property Tax, Hazard, PMI, HOA, ZIP
  1. A successful response from the GET request will contain the following attributes/information:
    • Affordability Amount, Monthly Principle and Interest, Monthly Property Tax, Monthly Hazard Insurance, Monthly PMI, Monthly HOA Dues, Total Monthly Payment, Total Payments, Total Interest Payments, Total Principal, Total Taxes Fees and Insurance, Monthly Income, Monthly Debts, Monthly Income Tax, Monthly Remaining Budget
Build: