Skip to content

Instantly share code, notes, and snippets.

@ranyeli
ranyeli / 0_reuse_code.js
Created September 2, 2017 15:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ranyeli
ranyeli / supplier.component.html
Created September 14, 2017 04:32
manage supplier inputs, controllers and forms by using directives
<form #supplier = "ngForm" class="container">
<label>Supplier name:</label> <input type="text" [(ngModel)]="supplier.name" name="name" id="name">
<label for="">Supplier phone:</label> <input type="text" [(ngModel)]="supplier.phone" name="phone" id="phone">
<button (click)="logSupplier(supplier)">Log supplier</button>
<button (click)="newSupplier(supplier.value)">Create supplier</button>
{{supplier.value | json}}
</form>
<br><br>
<form #item = "ngForm">
<label for="">Item desc:</label> <input type="text" [(ngModel)]="item.description" name="description" >
@ranyeli
ranyeli / pagination.component.ts
Last active October 10, 2017 00:45
basic pagination
import { Component, OnInit, Input, EventEmitter, Output, OnChanges, SimpleChanges } from '@angular/core';
import 'rxjs/add/operator/toPromise';
@Component({
selector: 'app-pagination',
templateUrl: './pagination.component.html',
styleUrls: ['./pagination.component.css']
})
export class PaginationComponent implements OnInit, OnChanges {
@ranyeli
ranyeli / springboot_to_jar_instructions
Created September 28, 2017 23:06
Create a standalone jar file using maven plugin
To use the Spring Boot Maven Plugin simply include the appropriate XML in the plugins section of your pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ... -->
<build>
<plugins>
<plugin>
@ranyeli
ranyeli / springboot_run_on_tomcat
Last active September 29, 2017 20:15
Creating a springboot war that can be run on tomcat
1. First your pom.xml must be similar to this with packaging as war and the repackage goal:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.project</groupId>
<artifactId>invoiceBackend</artifactId>
<version>0.0.1-SNAPSHOT</version>
@ranyeli
ranyeli / app.modulev2.ts
Last active October 2, 2017 20:06
Initialize a class object right away to use the values in all other classes that need them
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { HttpModule, Http } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { SupplierComponent } from './components/supplier/supplier.component';
import { ApiCallService } from './service/apicall.service';
@ranyeli
ranyeli / GeneralFilter.java
Last active October 6, 2017 16:14
Common filters or information that all api controllers must received, helps pass url param information to other objects
package com.project.dto;
import org.springframework.web.context.request.WebRequest;
public class GeneralFilter {
private Integer offset;
private Integer limit;
@ranyeli
ranyeli / index.php
Last active October 16, 2017 03:31
Sample php file mixing html and php code
<html>
<head>
<title><?php echo "it works!"; ?></title>
</head>
<body>
<?php
spl_autoload_register(function ($class_name) {
include $class_name . '.php';
});
@ranyeli
ranyeli / GenusController.php
Last active May 4, 2022 12:04
A basic symfony controller
<?php
/**
* Created by PhpStorm.
* User: rober
* Date: 11/11/2017
* Time: 7:56 PM
*/
namespace AppBundle\Controller;
<?php
/**
* Created by PhpStorm.
* User: rober
* Date: 11/11/2017
* Time: 7:56 PM
*/
namespace AppBundle\Controller;