Skip to content

Instantly share code, notes, and snippets.

View robertoandres24's full-sized avatar
🏠
Working from home

Roberto Obando robertoandres24

🏠
Working from home
View GitHub Profile
<label for="addressCountry">Country</label>
<select name="addressCountry">
<option></option>
<optgroup label="North America">
<option value="US">United States</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="CA">Canada</option>
<option value="MX">Mexico</option>
<option value="AI">Anguilla</option>
<option value="AG">Antigua and Barbuda</option>
@robertoandres24
robertoandres24 / alert.php
Created April 10, 2018 14:38
Components And Slots
<div class="alert">
{{ $slot }}
</div>
@robertoandres24
robertoandres24 / .gitconfig
Created April 25, 2018 14:54 — forked from therustmonk/.gitconfig
A Git alias to display the total number of insertions and deletions.
# Usage: git total [OPTION...]
#
# Options:
#
# In theory, the command accepts all command line options supported by
# the "git log" command. In reality, however, only few commit-limiting
# options are useful. This includes:
#
# --author=PATTERN, --committer=PATTERN
# Displays the number of lines changed by a certain author.
@robertoandres24
robertoandres24 / php-pdo-mysql-crud.md
Created June 13, 2018 15:42 — 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';
@robertoandres24
robertoandres24 / async-await.js
Created November 6, 2018 21:08 — forked from wesbos/async-await.js
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
});
}
@robertoandres24
robertoandres24 / customFnInModel.php
Last active January 24, 2019 19:32
Funciones Helpers
public function BannersActive()
{
return $this->hasMany('App\Ad')
->where('user_id', $this->id)
->where('status', 1)
->get();
}
var groupBy = function(xs, key) {
return xs.reduce(function(rv, x) {
(rv[x[key]] = rv[x[key]] || []).push(x);
return rv;
}, {});
};
console.log(groupBy(['one', 'two', 'three'], 'length'));
let sum = course.lessons
.map(l => l.contents)
.reduce((acc, val) => acc.concat(val), [])
.reduce((acc, val) => {
return acc + val.length
}, 0)
Brian Cray's original, for Wordpress:
<?php
$mycontent = $post->post_content; // wordpress users only
$word = str_word_count(strip_tags($mycontent));
$m = floor($word / 200);
$s = floor($word % 200 / (200 / 60));
$est = $m . ' minute' . ($m == 1 ? '' : 's') . ', ' . $s . ' second' . ($s == 1 ? '' : 's');
?>