Skip to content

Instantly share code, notes, and snippets.

View AndresSepar's full-sized avatar
🤖
Coding mode!

Andres Separ AndresSepar

🤖
Coding mode!
View GitHub Profile
@AndresSepar
AndresSepar / Enum.js
Last active February 11, 2022 04:43
Javascript (ES6) Enum
export class Enum {
isObject (o) {
return (!!o) && (o.constructor === Object);
}
isArray (a) {
return (!!a) && (a.constructor === Array);
}
flipObject (o) {
return Object.entries(o).reduce((obj, [key, value]) => ({ ...obj, [value]: key }), {})
}
@AndresSepar
AndresSepar / gist:6a72c6ec5a13f14c189a205094ec5450
Created April 10, 2020 21:59 — forked from zachstronaut/gist:1184900
Stretch HTML5 canvas to fill window, preserving aspect ratio
/**
* fullscreenify()
* Stretch canvas to size of window.
*
* Zachary Johnson
* http://www.zachstronaut.com/
*
* See also: https://gist.github.com/1178522
*/
@AndresSepar
AndresSepar / nginx.conf
Created June 18, 2019 21:35 — forked from jrom/nginx.conf
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@AndresSepar
AndresSepar / desktop-icons.sh
Created May 18, 2019 03:39 — forked from falnatsheh/desktop-icons.sh
Simple script to hide or show the desktop icons in Mac OSX.
#!/bin/bash
# Show or Hide desktop icons.
# Usage: desktop-icons [show | hide]
set -e
if [ -z $1 ]; then
echo Error: Please enter show or hide.
exit
@AndresSepar
AndresSepar / javascript aspect ratio calculation (with GCD)
Created March 3, 2019 13:28 — forked from phobeo/javascript aspect ratio calculation (with GCD)
javascript aspect ratio calculation algorithm (take the GCD and divide both elements of resolution)
/* euclidean GCD (feel free to use any other) */
function gcd(a,b) {if(b>a) {temp = a; a = b; b = temp} while(b!=0) {m=a%b; a=b; b=m;} return a;}
/* ratio is to get the gcd and divide each component by the gcd, then return a string with the typical colon-separated value */
function ratio(x,y) {c=gcd(x,y); return ""+(x/c)+":"+(y/c)}
/* eg:
> ratio(320,240)
"4:3"
> ratio(360,240)
@AndresSepar
AndresSepar / MongoDB_macOS_Sierra.md
Created November 3, 2018 14:06 — forked from nrollr/MongoDB_macOS_Sierra.md
Install MongoDB on Sierra using Homebrew

Install MongoDB on macOS Sierra

This procedure explains how to install MongoDB using Homebrew on macOS Sierra 10.12.
Official MongoDB install documentation: here

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@AndresSepar
AndresSepar / ObjectListener.php
Created October 13, 2018 12:40 — forked from soyuka/ObjectListener.php
Streaming big json files the good way with php with https://soyuka.me/streaming-big-json-files-the-good-way/
<?php
namespace Fry;
use JsonStreamingParser\Listener;
/**
* This implementation allows to process an object at a specific level
* when it has been fully parsed
*/
class ObjectListener implements Listener
{
<div id="enigma"></div>
@AndresSepar
AndresSepar / blur.css
Created May 17, 2018 05:11 — forked from vishaltelangre/blur.css
cross browser blur filter using css
.blur {
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-ms-filter: blur(3px);
-o-filter: blur(3px);
/* FF doesn't support blur filter, but SVG */
filter: url("data:image/svg+xml;utf8,<svg height='0' xmlns='http://www.w3.org/2000/svg'><filter id='svgBlur' x='-5%' y='-5%' width='110%' height='110%'><feGaussianBlur in='SourceGraphic' stdDeviation='5'/></filter></svg>#svgBlur");
filter: progid: DXImageTransform.Microsoft.Blur(PixelRadius = '3');
filter: blur(3px);
}
@AndresSepar
AndresSepar / app.js
Created May 5, 2018 17:59 — forked from DarrylD/app.js
express.js, simple dynamic route loading
//all of your express config stuff
var express = require('express')
, app = express()
//load api routes (app of the files from /api)
require('./api').boot(app)
//rest of your expressjs stuff