Skip to content

Instantly share code, notes, and snippets.

View Eseperio's full-sized avatar

E.Alamo Eseperio

View GitHub Profile
class UniqueSelector {
static getElementSelector(element) {
if (element.id) {
return `#${element.id}`;
}
if (element.tagName === 'BODY') {
return 'body';
}
let selector = element.tagName.toLowerCase();
if (element.className) {
@Eseperio
Eseperio / readme.md
Last active April 1, 2022 10:47
Multiple PHP versions at same time on MacOS in 2022 and using Apache

Multiple PHP versions at same time on MacOS and Apache

This is how i achieved to get all PHP versions working at the same time.

I have as many php versions as i want all running at same time. Versions are attached to directories, so in my www directory i have a folder for each php version www/php71/, www/php72/ and so on. If i want to change a project to another version, i only have to move it to a different folder. In MacOs, moving a huge folder is less than 1 second, so this is the fastest way to change version without updating server configuration.

Installing PHP

Install all the php versions via brew command. Example command (replace version number for each one)

@Eseperio
Eseperio / readme.md
Last active August 26, 2021 08:52
AWS Transcribe JSON to Script with php

Snippet to convert AWS transcribe into a scripted text

Be careful: This script has been created to be used under a command controller in Yii2. 

You can easily port to any php by adapting last three lines

@Eseperio
Eseperio / _auto-color.scss
Last active May 5, 2021 17:56
Css color based on letter.
$alphabet: "1","2","3","4","5","6","7","8","A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z";
$colors: #69d2e7, #a7dbd8, #e0e4cc, #f38630, #fa6900, #fe4365, #fc9d9a, #f9cdad, #c8c8a9, #83af9b, #ecd078, #d95b43, #c02942, #542437, #53777a, #556270, #4ecdc4, #c7f464, #ff6b6b, #c44d58, #774f38, #e08e79, #f1d4af, #ece5ce, #c5e0dc, #e8ddcb, #cdb380, #036564, #033649, #031634, #490a3d, #bd1550, #e97f02, #f8ca00, #8a9b0f, #594f4f, #547980, #45ada8, #9de0ad, #e5fcc2, #00a0b0, #6a4a3c, #cc333f, #eb6841, #edc951, #e94e77, #d68189, #c6a49a, #c6e5d9, #f4ead5, #3fb8af, #7fc7af, #dad8a7, #ff9e9d, #ff3d7f, #d9ceb2, #948c75, #d5ded9, #7a6a53, #99b2b7, #ffffff, #cbe86b, #f2e9e1, #1c140d, #cbe86b, #efffcd, #dce9be, #555152, #2e2633, #99173c, #343838, #005f6b, #008c9e, #00b4cc, #00dffc, #413e4a, #73626e, #b38184, #f0b49e, #
@Eseperio
Eseperio / Logger.js
Last active May 5, 2021 11:27
Simple prefixed javascript logger
export class Logger {
static prefix = "[YourAppNameHere] ";
static log(...args) {
console.log(Logger.prefix, ...args);
}
static warn(...args) {
console.warn(Logger.prefix, ...args);
}
@Eseperio
Eseperio / all-file-extensions.json
Created July 16, 2019 09:50
List of all file extensions with description (listed on wikipedia) in JSON format.
{
"0": {
"descriptions": [
"Compressed harddisk data"
]
},
"1": {
"descriptions": [
"Fax",
"Roff/nroff/troff/groff source for manual page"
@Eseperio
Eseperio / extract-file-extensions-from-wikipedia.js
Last active July 16, 2019 09:34
A snippet to extract all file extension names from wikipedia pages.
/**
* This snippet is used to extract all file extension names from wikipedia pages.
*
* Usage: Copy this snippet and paste on Chrome console. Do it for each extensions page available.
* After that, get the json using `localStorage.getItem('extensions')`
* @see https://en.wikipedia.org/wiki/List_of_filename_extensions
* @type {string}
*/
var memorySlot='extensions';
@Eseperio
Eseperio / sample_migration.php
Last active April 2, 2019 16:28
This is an example of a migration to move translated messages from Yii php files to lajax yii2-translate
<?php
use lajax\translatemanager\models\LanguageSource;
use lajax\translatemanager\models\LanguageTranslate;
use yii\db\Migration;
/**
* Class m190402_151021_move_translations_to_db
*/
class m190402_151021_move_translations_to_db extends Migration

Markdown sample

This is a sample file created to fit my needs in development.

Sometimes

Sometimes you need some words with a different format, like italic or bold, like the first word.

Third header, and overline

Some people think a blockquote is enough to tell something important.

@Eseperio
Eseperio / bullying-php.md
Last active May 4, 2018 11:11
Stop bullying PHP

PHP is good, and let me tell you why.

  • PHP is easy to understand for a newbie. Thanks to that many people that have never been in programming can make real their ideas, and thanks to this you have a lot of services on internet.
  • PHP is getting better everyday and have one of the largest pools of users in the world.
  • Often i heard people talk about how many bugs have, but the reality is that you cannot use only the numbers of bugs as a reference. Other less buggy languages are not. They have not been tested enough to find all the hidden bugs, because the amount of applications that use them is lower.
  • PHP is open source and does not deppend on a corporate that one day can disappear (don´t believe me? Remember Lehman Brothers)

Using a common comparison: Compare a car with a jet. Jet can travel faster, further, but requires a lot of knowledge.