Skip to content

Instantly share code, notes, and snippets.

View ilmoralito's full-sized avatar

Mario Martinez ilmoralito

View GitHub Profile
@ilmoralito
ilmoralito / jornadas.js
Last active August 4, 2020 17:47
Jornadas
const startDate = "2020-08-03";
const matchDays = [1, 2];
const fields = ["Field 1", "Field 2"];
const teams = ["A", "B", "C", "D"];
const numberOfRematches = 3;
const getCombinations = (data) => {
let output = [];
for (let i = 0; i < teams.length - 1; i++) {
@xiaklizrum
xiaklizrum / reset.sh
Last active June 7, 2024 11:48
Reset jetbrains intellij idea 2020 30-day evaluation period
# linux
rm -rf ~/.config/JetBrains/IntelliJIdea*/eval/*.evaluation.key ~/.config/JetBrains/IntelliJIdea*/options/other.xml ~/.java/.userPrefs/jetbrains/idea
# mac os
rm ~/Library/Application\ Support/JetBrains/IntelliJIdea*/eval/*.evaluation.key ~/Library/Application\ Support/JetBrains/IntelliJIdea*/options/other.xml ~/Library/Preferences/jetbrains.idea.* ~/Library/Preferences/com.apple.java.util.prefs.plist
@topalex
topalex / mime.html
Last active September 22, 2022 09:43
How to check real mime type of image in javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mime type checker</title>
<script type="text/javascript" src="/jquery.min.js"></script>
<script>
$(function () {
var result = $('div#result');
if (window.FileReader && window.Blob) {
@micc83
micc83 / mysqldump.php
Created June 5, 2017 13:17
Simple PHP script to dump a MySql database
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$database = 'db';
$user = 'user';
$pass = 'pass';
$host = 'localhost';
@taniarascia
taniarascia / php-pdo-mysql-crud.md
Created May 4, 2017 15:40 — forked from odan/php-pdo-mysql-crud.md
Basic CRUD operations with PDO and MySQL

Basic CRUD operations with PDO

CRUD = Create, Read, Update, Delete

Open a database connection

$host = '127.0.0.1';
$dbname = 'test';
$username = 'root';
@zcaceres
zcaceres / Revealing-Module-Pattern.md
Last active June 18, 2024 00:44
Using the Revealing Module Pattern in Javascript

The Revealing Module Pattern in Javascript

Zach Caceres

Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.

The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.

Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.

Using Function Scope to Create Public and Private Methods

@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@wiledal
wiledal / template-literals-1-if-statements.js
Last active May 4, 2022 14:18
Template Literal Examples: if-statement
/*
Template literals if-statement example
Using a single-line conditional, we can create an if-statements within template literals.
*/
function makeHTML(title) {
return `
${title ? `
This element has a title, and it is "${title}"
` : `
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@mcaskill
mcaskill / Function.Array-Group-By.php
Last active January 3, 2024 10:15
PHP : Groups an array by a given key
<?php
if (!function_exists('array_group_by')) {
/**
* Groups an array by a given key.
*
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
*
* Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
* This variant allows $key to be closures.