Skip to content

Instantly share code, notes, and snippets.

View leonardocregis's full-sized avatar

Leonardo leonardocregis

  • Rio de Janeiro
View GitHub Profile
@leonardocregis
leonardocregis / java - restfull - authentication
Created October 22, 2019 17:12
a sample authentication for Restfull with a Bearer
DgaAuthenticationConfigs dgaAuthenticationConfigs = new DgaAuthenticationConfigs();
String user = "test";
String password = "senha";
StringReader stringReader = new StringReader("{ \"username\": \" " + user + "\", \"password\": \"" + password + "\" }");
WebTarget authenticationTarget = ClientWrapperUtil.getWebTarget("https:\\someurl");
Response authenticationResponse = authenticationTarget.path("service").request(MediaType.APPLICATION_JSON)
.post(Entity.json(stringReader));
String token = authenticationResponse.readEntity(String.class);
@leonardocregis
leonardocregis / get_gists.py
Created October 14, 2019 14:12 — forked from leoloobeek/get_gists.py
Download all gists for a specific user
# first: mkdir user && cd user && cp /path/to/get_gists.py .
# python3 get_gists.py user
import requests
import sys
from subprocess import call
user = sys.argv[1]
r = requests.get('https://api.github.com/users/{0}/gists'.format(user))
@leonardocregis
leonardocregis / java - hibernate
Created October 10, 2019 18:56
A mapping to be use for a Clob into the hbm
#mapping for clob int hbm
<property name="somename" type="string">
<column name="somename" sql-type="clob"/>
</property>
#similar to into the class.
@Lob
private String somename;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class ResponseTest {
@Test
#Atribute Directives
#only affect the element they are added, have () for events or [] for attributes
#Structure Directives
#has a leading *, a whole area of the DOM are affected
#its agood practice to impelment the interface OnInit, OnChanges and so on.
#ngOnChanges: several called, in start , and after some change,Called after a bound input property changes
ngOnChanges(changes: SimpleChanges){
console.log('ngOnChanges called!');
console.log(changes);
}
#ngOnInit: once the component is initialized, not displayed yet, afeter the constructor runs
#ngDoCheck: called during every change dection run, even if doesnt happen some change, just a click
#does that
#ngAfterContentInit: Called after content(ng-content) has been projected into view
#the angular 8 encapsulate the css to the module
# it uses a marker to make that
# meaning if you want to change this behavior you do in the component desired in the atribute encapsulation
#change to not use any of the encapsulation, meaning that the css will affect globally
...
@Component{
...
encapsulation: ViewEncapsulation.none
...
}
#component comunication
#input to the componeent
#needs to add the @Input from import { Input } from '@angular/core';
#sample
...
@Input() element: {type: string, name: string, content: string};
...
#this allows a comunication like below, because if not , the element should be availiable outside the component
<app-server-element
*ngFor="let element of serverElements"
#augury , chrome tool to help to debug angular 8 soluctions(may be earlier also)
#using bootstrap
#install it
npm i --save bootstrap
#change into the angular.json the entry to point to bootstrap
...
"my-first-app": {
...
"architect": {
"build": {
...