Skip to content

Instantly share code, notes, and snippets.

<?php
require_once('settings.php');
require_once('google-login-api.php');
// Google passes a parameter 'code' in the Redirect Url
if(isset($_GET['code'])) {
try {
$gapi = new GoogleLoginApi();
// Get the access token
@arodu
arodu / textarea_autoresize.html
Created February 4, 2019 13:09
textarea autoresize vanillajs
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>textarea autoresize</title>
<style media="screen">
textarea {
min-height: 5em;
width: 100%;
function timeSince(timeStamp) {
var now = new Date(),
secondsPast = (now.getTime() - timeStamp.getTime()) / 1000;
if(secondsPast < 60){
return parseInt(secondsPast) + 's';
}
if(secondsPast < 3600){
return parseInt(secondsPast/60) + 'm';
}
if(secondsPast <= 86400){
@arodu
arodu / pre-commit
Created January 19, 2019 14:50
Evitar hacer commit en la rama master
#!/bin/bash
if [[ `git symbolic-ref HEAD` == "refs/heads/master" ]]
then
echo "You cannot commit in master!"
exit 1
fi
# .git/hooks/pre-commit
@arodu
arodu / es6_fetch_example.js
Created January 14, 2019 16:52 — forked from robvolk/es6_fetch_example.js
AJAX requests in ES6 using fetch()
// ES6 Fetch docs
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
fetch('https://some.url.com')
.then(response => {
if (response.ok) {
return Promise.resolve(response);
}
else {
return Promise.reject(new Error('Failed to load'));
@arodu
arodu / google_login.html
Created January 14, 2019 15:08 — forked from georgeOsdDev/google_login.html
google login by javascript
<!DOCTYPE html>
<html>
<head>
<title>Google login example</title>
<script src="https://apis.google.com/js/client:platform.js" async defer></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style media="screen">
h3 {
color:green;
}
@arodu
arodu / local-storage-with-json-parse-stringify.js
Created January 4, 2019 17:13 — forked from jbail/local-storage-with-json-parse-stringify.js
Local storage with JSON parse and stringify
var animal = {
name: 'Karl',
type: 'cat',
color: 'black',
age: 7
};
//convert JSON animal into a string
var dehydratedAnimal = JSON.stringify(animal);
@arodu
arodu / atom_trash.md
Last active September 21, 2018 15:23
No need for gvfs-trash to delete files in Atom (Electron)

I don’t want to install gvfs with all its friends just to be able to delete files from within Atom/Electron. However, the environment variable ELECTRON_TRASH can set another trash handler, e.g. trash-cli, which is dependency free.

So I append the variable to my .bashrc and live on as a happy man.

# pacman -S trash-cli --noconfirm > /dev/null
$ echo "export ELECTRON_TRASH=trash-cli" >> ~/.bashrc

Restart Atom and continue to enjoy life

@arodu
arodu / emojis.json
Created July 18, 2018 17:59 — forked from oliveratgithub/emojis.json
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family_mothers_two_girls", "shortname": "", "unicode": "", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family_mothers_children", "shortname": "", "unicode": "", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family_mothers_two_boys", "shortname": "", "unicode": "", "html": "&#128105;&zwj;&#128105;&zwj;&#128102;&zwj;&#128102;", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family_two_girls", "shortname": "", "unicode": "", "html": "&#128104;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👦", "name": "family_children", "shortname": "", "unicode": "", "html": "&#128104;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👦‍👦", "name": "family_two_boys", "shortname": "", "unicode": "", "html": "&#128104;&zw
@arodu
arodu / gist:4a14045003730bb70aa38716ace621ea
Created June 18, 2018 10:39
Eliminar paquetes huerfanos, Arch y derivados
pacman -Rsdn $(pacman -Qqdt)