Skip to content

Instantly share code, notes, and snippets.

View normancarcamo's full-sized avatar
😎
Seizing time.

ncardez normancarcamo

😎
Seizing time.
View GitHub Profile
@normancarcamo
normancarcamo / Issue.md
Created July 10, 2021 05:36 — forked from Ashton-W/Issue.md
GitHub Markdown toggle code block
Click to toggle contents of `code` ``` CODE! ```
Click to toggle contents of other `code` ```
@normancarcamo
normancarcamo / example_tab_bar_view.dart
Last active January 26, 2021 23:14
Example of how to compose a TabBar + TabBarView + NestedScrollView + CustomScrollView + SliverAppBar.
import 'dart:math' as math;
import 'package:flutter/material.dart';
void main() => runApp(Main());
class Main extends StatefulWidget {
@override
State<StatefulWidget> createState() => _MainState();
}
@normancarcamo
normancarcamo / internet_manager_test.dart
Last active January 21, 2021 10:02
Redux example for dart & flutter with testing
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meta/meta.dart';
import 'package:redux/redux.dart';
/// STATE:
@immutable
class AppState extends Equatable {
@normancarcamo
normancarcamo / ecosystem.config.js
Created June 11, 2019 22:32
Ejemplo de PM2 config file en js.
const pkg = require('package.json');
module.exports = {
apps : [{
name : pkg.name,
script : 'dist/index.js',
output : 'logs/out/logs.log',
error : 'logs/err/logs.log',
log : 'logs/all/logs.log',
instances : 0,
@normancarcamo
normancarcamo / EADDRINUSE.md
Last active November 24, 2018 04:46
Fix issues with: "Error: listen EADDRINUSE" and nodemon

nodemon.json

{
  "execMap": {
    "js": "babel-node"
  },
  "env": {
    "NODE_ENV": "development"
  },
 "ext": ".js,.jsx",
@normancarcamo
normancarcamo / promise_all.js
Last active July 13, 2018 22:55
Get errors and results from a parallel asynchronous call
// Wrapper to get results & errors in parallel:
// Here we could override the original Promise.all method but due to this is just merely a test, we'll just leave it aside.
function promiseAll(array, combine) {
return Promise.all(array.map(p => p.catch(e => e)))
.then(values => {
if (combine) {
return values;
}
let errors = values.reduce((target, value) => {
@normancarcamo
normancarcamo / BuildError.js
Last active December 31, 2017 10:24
Custom error builder in javascript
export function BuildError(object) {
// Throw an error if the 'object' param doesn't pass the follow rules:
// 1. If the object param is not an object
// 2. If the object param doesn't include a property 'message'
// 3. If the object param includes the property 'message' but is not of string type
// 4. If the object param includes the property 'message' but it is empty
if (!object.hasOwnProperty('message') || typeof object.message !== 'string') {
throw new Error('Error when trying to build a new error');
}
@normancarcamo
normancarcamo / .js
Created October 6, 2017 10:52
React Server Rendering with Universal Request
import React from 'react'
import { Router } from 'express'
import routes from 'shared/routes'
import { readFileSync } from 'fs'
import { resolve } from 'path'
import cheerio from 'cheerio'
import { StaticRouter } from 'react-router'
import { renderToString, renderToStaticMarkup } from 'react-dom/server'
function getTemplate() {