Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Seizing time.

ncardez normancarcamo

😎
Seizing time.
View GitHub Profile
@normancarcamo
normancarcamo / Issue.md
Created Jul 10, 2021 — forked from Ashton-W/Issue.md
GitHub Markdown toggle code block
View Issue.md
Click to toggle contents of `code` ``` CODE! ```
Click to toggle contents of other `code` ```
@normancarcamo
normancarcamo / example_tab_bar_view.dart
Last active Jan 26, 2021
Example of how to compose a TabBar + TabBarView + NestedScrollView + CustomScrollView + SliverAppBar.
View example_tab_bar_view.dart
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 Jan 21, 2021
Redux example for dart & flutter with testing
View internet_manager_test.dart
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 Jun 11, 2019
Ejemplo de PM2 config file en js.
View ecosystem.config.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 Nov 24, 2018
Fix issues with: "Error: listen EADDRINUSE" and nodemon
View EADDRINUSE.md

nodemon.json

{
  "execMap": {
    "js": "babel-node"
  },
  "env": {
    "NODE_ENV": "development"
  },
  "ext": ".js,.jsx",
@normancarcamo
normancarcamo / promise_all.js
Last active Jul 13, 2018
Get errors and results from a parallel asynchronous call
View promise_all.js
// 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 Dec 31, 2017
Custom error builder in javascript
View BuildError.js
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 Oct 6, 2017
React Server Rendering with Universal Request
View .js
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() {