Skip to content

Instantly share code, notes, and snippets.

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

Rodrigo Espinoza rodrigoespinozadev

🏠
Working from home
View GitHub Profile
/* This is a small sampling of the various approaches to media queries. The
point is: they're all over the board. Part of the "issue" (if you can call
it that) may be due to the intended audience of each site/framework. Another
may be that it's really difficult to test for a lot of different devices.
Regardless, it would be really nice if there was standard baseline that
could be used as a starting point for maximum compatibility and coverage. */
/* ==========================================================================
Frameworks
========================================================================== */
@rodrigoespinozadev
rodrigoespinozadev / .eslintrc.json
Created April 13, 2018 06:24 — forked from egamma/.eslintrc.json
Visual Studio Code default .eslintrc.json
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
@rodrigoespinozadev
rodrigoespinozadev / Include-in-Sequelize.md
Created August 21, 2018 04:17 — forked from zcaceres/Include-in-Sequelize.md
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

@rodrigoespinozadev
rodrigoespinozadev / class.database.php
Created August 21, 2018 22:51 — forked from jameskropp/class.database.php
PHP OOP Database class using PDO and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
<?php
class DB {
private $connection;
private static $_instance;
@rodrigoespinozadev
rodrigoespinozadev / index.html
Created September 11, 2018 23:58 — forked from shiawuen/index.html
Sample to upload file by chunk
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>test upload by chunk</title>
</head>
<body>
<input type="file" id="f" />
<script src="script.js"></script>
@rodrigoespinozadev
rodrigoespinozadev / resize.js
Created September 19, 2018 04:33 — forked from vishalsrini/resize.js
A simple JavaScript to resize an image and create a blob out of it
window.resize = (function () {
'use strict';
function Resize() {}
Resize.prototype = {
init: function(outputQuality) {
this.outputQuality = (outputQuality === 'undefined' ? 0.8 : outputQuality);
},
@rodrigoespinozadev
rodrigoespinozadev / LICENCE SUBLIME TEXT
Created November 21, 2018 06:44
Sublime Text 3 Serial key build is 3176
## Sublime Text 3 Serial key build is 3176
> * Added these lines into /etc/hosts
127.0.0.1 www.sublimetext.com
127.0.0.1 license.sublimehq.com
> * Used the license key
----- BEGIN LICENSE -----
@rodrigoespinozadev
rodrigoespinozadev / gcloud-port-forward.md
Created December 5, 2018 22:54 — forked from jibs/gcloud-port-forward.md
port forwarding with a google cloud instance

Google cloud's ssh command lets you pass standard ssh flags. To, for example, forward local port 8088 to port 8088 on a vm instance, all you need to do is:

gcloud compute  ssh --ssh-flag="-L 8088:localhost:8088"  --zone "us-central1-b" "example_instance_name"

Now browsing to localhost:8088 works as it would with standard ssh.

@rodrigoespinozadev
rodrigoespinozadev / API.md
Created January 8, 2019 03:02 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@rodrigoespinozadev
rodrigoespinozadev / aws-lambda-unzipper.py
Created January 8, 2019 18:43 — forked from msharp/aws-lambda-unzipper.py
unzip archive from S3 on AWS Lambda
import os
import sys
import re
import boto3
import zipfile
def parse_s3_uri(url):
match = re.search('^s3://([^/]+)/(.+)', url)
if match:
return match.group(1), match.group(2)