Skip to content

Instantly share code, notes, and snippets.

View gomezcabo's full-sized avatar

Juan Gómez gomezcabo

  • Tenerife, España
View GitHub Profile
@gomezcabo
gomezcabo / cloudSettings
Last active January 29, 2018 10:49
Visual Studio Code Sync Settings GIST
{"lastUpload":"2018-01-29T10:49:48.875Z","extensionVersion":"v2.8.7"}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>One file React.js</title>
</head>
<body>
<div id="root"></div>
@gomezcabo
gomezcabo / angryflip
Last active November 20, 2017 08:40
Flip commands ¯\_(ツ)_/¯
#!/usr/bin/perl
use utf8;
use Data::Dumper;
if ($#ARGV + 1 < 1) {
print "\nUsage: angryflip something_to_flip\n";
exit;
}
function my_git_prompt() {
tester=$(git rev-parse --git-dir 2> /dev/null) || return
INDEX=$(git status --porcelain 2> /dev/null)
STATUS=""
# is branch ahead?
if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
@gomezcabo
gomezcabo / slugify.js
Created March 14, 2019 10:31 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@gomezcabo
gomezcabo / storage-polyfill.js
Created March 28, 2019 09:38 — forked from ghinda/gist:6036998
local/session storage polyfill (@Rem's version + with support for opera mini)
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
function Snippet1() {
return 'Hola'
}
@gomezcabo
gomezcabo / create-fragment-function.js
Last active July 8, 2019 08:24
Why you should give Svelte a try
function create_fragment(ctx) {
var button, t1, p, t2, t3, t4, t5, t6_value = ctx.count1 + ctx.count2, t6, dispose;
return {
c: function create() {
button = element("button");
button.textContent = "Click";
t1 = space();
p = element("p");
t2 = text(ctx.count1);
import Sum from './Sum';
describe('Sum', () => {
it('should render', () => (
));
it('should have two inputs to add the numbers', () => (
));
it('should have a button to fire the sum action', () => (
));
it('should have text to show the result', () => (
));
@gomezcabo
gomezcabo / parser
Last active February 16, 2021 09:35
Simple query to SQL parser
// ================================
// Simple query to SQL parser
//
// Copy and paste to https://pegjs.org/online
//
// It parses expressions like:
//
// (flag == True) AND (name == 'Paco' OR (name LIKE '%garcia%') OR (age > 18 AND age <= 45))
//
// ================================