Skip to content

Instantly share code, notes, and snippets.

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

Wenceslao Negrete vampaynani

🏠
Working from home
View GitHub Profile
@vampaynani
vampaynani / assets.js
Created November 23, 2017 17:21
AWS S3 mock
import aws from 'aws-sdk';
// ========================================
// ! Sign
/*
* AWS connection to get the signed url
*/
// ========================================
const sign = (req, res) => {
const { AWS_KEY_ID, AWS_SECRET_ID, AWS_REGION, AWS_BUCKET, AWS_EXPIRY_TIME } = process.env;
@vampaynani
vampaynani / connect.js
Created March 9, 2018 19:51
How does Redux Connect works
function connect(mapStateToProps){
const state = {
currentGuess: 0,
response: '',
guesses: []
};
return function(component){
newProps = Object.assign(
{},
component.props,
@vampaynani
vampaynani / search.js
Created March 22, 2018 06:17
Pseudo code of how to do pagination
Docs: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/search
const pageLimit;
[.limit(pageLimit)]
book: 1,2,3,4,5,
limit: pageLimit,
total: Book.find().count()
/search?page=1
@vampaynani
vampaynani / prototype.js
Created April 2, 2018 06:52
Constructor, Instance, Composition
/*==============
* Constructor
===============*/
/* function Kitty:
* prototype: Function
* __proto__: Object
*/
function Kitty(){
this.legs = 4;
@vampaynani
vampaynani / static-properties-proto.js
Created April 2, 2018 06:57
How to share changes between instances with prototype(aka static properties)
function Robot(){
this.parts = [];
}
Robot.prototype.legs = 2;
Robot.prototype.changeLegs = function(num){
this.__proto__.legs = num;
}
robby = new Robot();
@vampaynani
vampaynani / script.md
Last active October 16, 2018 21:10
Webdev Elementary OS [steps to follow]

Update apt

sudo apt-get update

Install Wireless driver

sudo apt-get install git dkms
git clone https://github.com/smlinux/rtl8723de.git
sudo dkms add ./rtl8723de
@vampaynani
vampaynani / redux.js
Created May 9, 2018 16:36
How does redux store works behind the scenes
/*
* reducers/user.js
*/
const userInitialState = {
authToken: null,
userId: null
}
const userReducer = (state = userInitialState, action)=>{
return state;
}
@vampaynani
vampaynani / match.js
Created May 18, 2018 21:24
Matching parentheses in an expression recognizing three pairs of brackets: (), [], and {}
function match(str){
var temp = [];
for(var i = 0; i < str.length; i++){
var current = str[i];
var lastChild = temp[temp.length - 1];
console.log(current, lastChild);
if(current === '(' || current === '{' || current === '['){
temp.push(current);
}
if(temp.length > 0){
@vampaynani
vampaynani / index.js
Created October 17, 2018 15:10
Imports and exports with JS
/* ============================================
* index.js
* ============================================*/
import sumOperation from './operations'
/* ============================================
* operations.js
* ============================================*/
export default sum = (a,b) => a+b;
@vampaynani
vampaynani / questions
Last active February 4, 2019 17:41
Set of questions to pass the programming fundamentals phase
Qué es una variable?
Qué es una variable global?
Qué es una variable local?
Qué es una función?
A qué nos referimos con declarar una función?
A qué nos referimos con invocar una función?
Qué es un argumento?
Para qué sirve una declaración if?
En qué situaciones usamos un ciclo for?
En qué situaciones usamos un ciclo while?