Skip to content

Instantly share code, notes, and snippets.

View gitllermopalafox's full-sized avatar
🏠
127.0.0.1

Guillermo Palafox gitllermopalafox

🏠
127.0.0.1
View GitHub Profile

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@gitllermopalafox
gitllermopalafox / calculate-2x1-promotions.php
Created August 30, 2021 03:51
Calculate price for 2x1 promotions with PHP
$price = 100;
$products = 9;
echo $price * $products/2 + ($products&1 ? $price/2 : 0); // 500
[19-02-16 02:41:37.001] NativeScript Sidekick version: 1.16.0-v.2019.2.7.3
[19-02-16 02:41:38.162] Checking for updates...
[19-02-16 02:41:38.403] No updates available.
[19-02-16 02:41:40.029] Dependencies versions: NodeJS: 11.6.0, npm: 6.5.0, NativeScript CLI: 5.2.0.
[19-02-16 02:41:42.137] (CLI) Using NativeScript CLI located in /usr/local/lib/node_modules/nativescript
[19-02-16 02:41:46.117] (CLI) Searching for devices...
[19-02-16 02:41:48.445] Loaded CLI extension nativescript-cloud, version 1.16.0.
[19-02-16 02:41:48.450] Loaded CLI extension nativescript-starter-kits, version 0.3.5.
[19-02-16 02:41:58.593] The user Guillermo Palafox logged in.
[19-02-16 02:42:02.147] App with path: /Volumes/HD2/Proyectos/CurrentDev/app-golf/Devs/app-golf was opened.
<template>
<div>
<input ref="input" type="text" v-model="localValue" />
<slot :localValue="localValue" :formattedDate="formattedDate">
{{ formattedDate }}
</slot>
<!-- parent can now use 'render prop through scoped slot' -->
<!--
<DatePickerComponent slot-scope="{localValue, formattedDate}" :value="value" @input="handleChildInput" @clear="clearChildInput">
{{ formattedDate }}
const Alexa = require('ask-sdk');
const LaunchRequestHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'LaunchRequest'
},
handle(handlerInput) {
@gitllermopalafox
gitllermopalafox / download_egghead_videos.sh
Created November 23, 2018 06:18 — forked from mnsami/download_egghead_videos.sh
this script is to download egghead videos using youtube-dl
#!/bin/bash
usage() { echo "usage: --coursename [--coursename \"build-a-react-app-with-redux\"] --type [--type \"courses|lessons\"]" 1>&2; exit 1; }
OPTS=$(getopt -o c:t: --long coursename:,type: -n 'download_egghead_videos.sh' -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$OPTS"
@gitllermopalafox
gitllermopalafox / grab_vimeo_thumbnail.php
Created October 24, 2018 18:47 — forked from bacoords/grab_vimeo_thumbnail.php
Grab a thumbnail of a private (but embeddable) Vimeo video
<?php
/**
* Grab the url of a publicly embeddable video hosted on vimeo
* @param str $video_url The "embed" url of a video
* @return str The url of the thumbnail, or false if there's an error
*/
function grab_vimeo_thumbnail($vimeo_url){
if( !$vimeo_url ) return false;
$data = json_decode( file_get_contents( 'http://vimeo.com/api/oembed.json?url=' . $vimeo_url ) );
@gitllermopalafox
gitllermopalafox / parse-jwt.js
Created October 11, 2018 21:00 — forked from Klerith/parse-jwt.js
Parse - JWT - Obtener Payload y fecha de creación y expiración
function parseJwt (token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace('-', '+').replace('_', '/');
return JSON.parse(window.atob(base64));
};
@gitllermopalafox
gitllermopalafox / db-connect-test.php
Created June 13, 2018 22:35 — forked from M165437/db-connect-test.php
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$link = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@gitllermopalafox
gitllermopalafox / Function.HTML-Build-Attributes.php
Created September 24, 2017 20:30 — forked from mcaskill/Function.HTML-Build-Attributes.php
PHP / WordPress : Generate a string of HTML attributes
<?php
if (!function_exists('html_build_attributes')) {
/**
* Generate a string of HTML attributes
*
* @param array $attr Associative array of attribute names and values.
* @param callable|null $callback Callback function to escape values for HTML attributes.
* Defaults to `htmlspecialchars()`.
* @return string Returns a string of HTML attributes.