Skip to content

Instantly share code, notes, and snippets.

class CustomerList extends React.Component {
constructor(props){
super(props)
this.state = {
customers: []
}
}
@ygamretuta
ygamretuta / package.json
Created July 26, 2017 09:28
create-react-app package.json
"scripts": {
"start": "PORT=3001 react-scripts start",
"start:production": "npm run build && npm run start:prod",
"start:prod": "NODE_ENV=production node server",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
@ygamretuta
ygamretuta / ecosystem.config.js
Created July 26, 2017 09:25
PM2 create-react-app config
module.exports = {
/**
* Application configuration section
* http://pm2.keymetrics.io/docs/usage/application-declaration/
*/
apps : [
{
name : 'my_react_app',
script : 'npm',
args : 'run start:production',
@ygamretuta
ygamretuta / index.js
Last active June 29, 2017 07:21
Latest Most Up-to-Date Basic React Routing Example
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import {
BrowserRouter as Router,
Route
} from 'react-router-dom';
class Home extends Component {
render() {
@ygamretuta
ygamretuta / database.php
Last active April 27, 2017 03:04
config/database.php
// abbreviated
'default' => env('DB_CONNECTION', 'pgsql'),
'connections' => [
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
@ygamretuta
ygamretuta / e2e_tut.html
Last active March 23, 2017 00:58
e2e tutorial dom
<h1 id="myHeader">My Header</h1>
<ul id="myList">
<li>My Item #1</li>
<li>My Item #1</li>
<li>My Item #1</li>
</ul>
@ygamretuta
ygamretuta / e2e_1.js
Last active March 23, 2017 01:01
$ and $$ on Protractor
// my.e2e-spec.ts
import { $, $$ } from 'protractor';
describe('MyDOM', ()=> {
it('should have a header with my text', () => {
expect($('h1.myHeader').getText()).toBe('My Header');
});
it('should have 3 list items', () => {
expect($$('#myList li').count()).toEqual(3));
"scripts": {
"ng": "ng",
"heroku-prebuild": "npm install -g http-server",
"heroku-postbuild": "ng build --prod",
"start": "http-server dist/",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
@ygamretuta
ygamretuta / truncate-angular2.js
Last active March 7, 2017 10:33
custom pipe that truncates a long string to a certain number of chars; uses lodash
// pipes/truncate.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
import * as _ from 'lodash';
@Pipe({ name: 'truncate' })
export class TruncatePipe implements PipeTransform {
transform(value: string, chars?: number): string {
let length = chars ? chars : 100;
return _.truncate(value, {length: length });
}
import { Component, OnInit, ViewChild } from '@angular/core';
import { LazyLoadEvent, DataTable } from 'primeng/primeng';
import { Router, ActivatedRoute } from '@angular/router';
// component
declare var jQuery: any;
params = {page: 1, page_size: 10};
paginator = {total_records: 0, per_page: 10, total_pages: 0, current_page: 1};