Skip to content

Instantly share code, notes, and snippets.

View alejandrofloresm's full-sized avatar

Alejandro Flores alejandrofloresm

View GitHub Profile
@alejandrofloresm
alejandrofloresm / hello-world.py
Created April 16, 2016 18:16
Hello World for Google
# Code example for:
# Hello World - Machine Learning Recipes #1 - Google Developers
# https://www.youtube.com/watch?v=cKxRvEZd3Mw
from sklearn import tree
# Bumpy = 0, Smooth = 1
features = [[140, 1], [130, 1], [150, 0], [170, 0]]
# Apple = 0, Orange = 1
labels = [0, 0, 1, 1]
@alejandrofloresm
alejandrofloresm / get_this_location_path.php
Created August 18, 2016 19:05
Get the url path of the current file
<?php
function get_this_location_path() {
$parts = parse_url($_SERVER['PHP_SELF']);
if (!isset($parts['scheme'])) {
$parts['scheme'] = "http";
if (isset($_SERVER["HTTPS"]) &&
$_SERVER["HTTPS"] == "on")
{
$parts['scheme'] .= "s";
@alejandrofloresm
alejandrofloresm / NormSInv.php
Last active August 10, 2023 15:57
Implementation of the function NORMSINV of EXCEL in PHP
<?php
/**
* Returns the inverse of the standard normal cumulative distribution.
* The distribution has a mean of zero and a standard deviation of one.
* Resources:
* http://board.phpbuilder.com/showthread.php?10367349-PHP-NORMSINV
* http://www.source-code.biz/snippets/vbasic/9.htm
* @param integer $week number of week
* @return float sales
*/
@alejandrofloresm
alejandrofloresm / Some useful regex things for sublime text.md
Last active January 31, 2017 21:54
Some useful regex for sublime text

This is a collection of useful regex formulas that I have found on the internet, to be honest mainly on stackoverflow :) #Selection

Select everything inside brackets {}

\{[^}]*\}

Select everything between ""

(["'])(?:(?=(\\?))\2.)*?\1
@alejandrofloresm
alejandrofloresm / gist:ba1eb5750a2afa6c3ec4d13f037db9d2
Created May 29, 2017 04:47
Generate a Laravel Key but don't added it to your .env file, just print it on the terminal
php artisan key:generate --show
@alejandrofloresm
alejandrofloresm / GenerateUserAndDatabaseMYSQL.sql
Last active January 2, 2019 20:26
Generate and grant new permissions to a MySQL user to a new database
/**
* 1. Create the database
* Change:
* <database_name>: to your database name
*/
CREATE DATABASE <database_name>;
/**
* 2. Create the user
* Change:
@alejandrofloresm
alejandrofloresm / resources.txt
Created June 23, 2017 17:03
Laravel Resources
+----------------------------------------+----------------------+---------+----------------+
| Actions Handled By Resource Controller | | | |
+----------------------------------------+----------------------+---------+----------------+
| Verb | URI | Action | Route Name |
| GET | /photos | index | photos.index |
| GET | /photos/create | create | photos.create |
| POST | /photos | store | photos.store |
| GET | /photos/{photo} | show | photos.show |
| GET | /photos/{photo}/edit | edit | photos.edit |
| PUT/PATCH | /photos/{photo} | update | photos.update |
@alejandrofloresm
alejandrofloresm / commands-git.sh
Created July 16, 2017 17:40
Delete your local branches that are not on the remote.
# Shows the branches that should be deleted
# Resource: https://kparal.wordpress.com/2011/04/15/git-tip-of-the-day-pruning-stale-remote-tracking-branches/
git remote prune origin --dry-run
# Deletes the branches
git remote prune origin
# It can also be done with fetch
git fetch origin --prune
@alejandrofloresm
alejandrofloresm / delete-all-branches-except-master-local.sh
Created September 9, 2017 16:02
Delete all branches except master in local
# Taken from:
# https://coderwall.com/p/x3jmig/remove-all-your-local-git-branches-but-keep-master
$ git branch | grep -v "master" | xargs git branch -D
@alejandrofloresm
alejandrofloresm / error-jquery.html
Last active September 10, 2017 17:41
error-jquery.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Description">
<title>File</title>
<script>
// Este método va a dar error por que jQuery no se ha cargado
$('body').change(function() { });
</script>