@RequestParam with small boolean
@RequestParam(required = false, name = "e", defaultValue = "false") boolean everywhere, …@RequestParam(required = false, name = "e", defaultValue = "false") boolean everywhere, …
mini blog / notes
@RequestParam(required = false, name = "e", defaultValue = "false") boolean everywhere, …@RequestParam(required = false, name = "e", defaultValue = "false") boolean everywhere, …
(?s)<tag1>(.*?)</tag2>(?s)<tag1>(.*?)</tag2>
On example of diff2html result let sides = this.diffResult.nativeElement.querySelectorAll(’.d2h-file-side-diff’); sides.forEach((sideDiv,idx) => { sideDiv.addEventListener(’scroll’, (event) => { let scrollLeft = event.target.scrollLeft; sides[idx==0?1:0].scrollLeft = scrollLeft; }); });let sides = this.diffResult.nativeElement.querySelectorAll(‘.d2h-file-side-diff’); sides.forEach((sideDiv,idx) => { sideDiv.addEventListener(‘scroll’, (event) => { let scrollLeft = event.target.scrollLeft; sides[idx==0?1:0].scrollLeft = scrollLeft; }); });
package net.marioosh.ldapdemo; import java.util.Arrays; import java.util.Collection; import org.springframework.context.annotation.Configuration; import org.springframework.ldap.core.DirContextOperations; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator; @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest() .fullyAuthenticated() .and().formLogin(); } @Override public void configure(AuthenticationManagerBuilder auth) throws Exception { Read more about Active Directory/LDAP authentication with Spring Boot[…]
Buffer.from(’login:password’).toString(’base64’); // bG9naW46cGFzc3dvcmQ=Buffer.from(‘login:password’).toString(‘base64’); // bG9naW46cGFzc3dvcmQ=
public boolean isValid(String xmlFilePath) throws FileNotFoundException { FileInputStream in = new FileInputStream(xmlFilePath); try { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader staxXmlReader = factory.createXMLStreamReader(in); while(staxXmlReader.next() != XMLStreamConstants.END_DOCUMENT) {} return true; } catch (XMLStreamException e) { e.printStackTrace(); return false; } }public boolean isValid(String xmlFilePath) throws FileNotFoundException { FileInputStream in = new FileInputStream(xmlFilePath); try { XMLInputFactory factory = XMLInputFactory.newInstance(); Read more about XML – check is well formed[…]
<ng-template #toolbar> lorem ipsum… </ng-template> <!– put my template here –> <ng-container *ngTemplateOutlet="toolbar"></ng-container> <!– and here –> <ng-container *ngTemplateOutlet="toolbar"></ng-container> <!– and here, too 😉 –> <ng-container *ngTemplateOutlet="toolbar"></ng-container><ng-template #toolbar> lorem ipsum… </ng-template> <!– put my template here –> <ng-container *ngTemplateOutlet="toolbar"></ng-container> <!– and here –> <ng-container *ngTemplateOutlet="toolbar"></ng-container> <!– and here, too 😉 –> <ng-container Read more about *ngTemplateOutlet[…]
let months = [ {month: 1, data1: "test1", data2: "test2"}, {month: 2, data1: "test1", data2: "test2"}, {month: 3, data1: "test1", data2: "test2"} ]; let monthsAsMap = months.reduce((map, obj) => { map[obj.month] = obj; return map; }, {}); console.log(monthsAsMap); console.log(monthsAsMap[’2’]);let months = [ {month: 1, data1: "test1", data2: "test2"}, {month: 2, data1: "test1", data2: Read more about array to map with reduce()[…]
import java.io.ByteArrayOutputStream; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; /** * AES-128 */ public class EncryptionUtils { /** * initialisation vector */ private final static byte[] IV = "thai8bai9voo1haV".getBytes(); /** * algorithm/mode/padding */ private final static String TRANSFORMATION = "AES/CBC/PKCS5Padding"; /** * * @param text encrypted text * @param password need Read more about Simple AES-128 encryption in Java[…]
const iv = Buffer.from(’aeghei1Di8tieNg0’); exports.encrypt = function(text, password){ try { var cipher = crypto.createCipheriv(’aes-128-cbc’,password,iv); var crypted = cipher.update(text,’utf8′,’hex’); crypted += cipher.final(’hex’); return crypted; } catch (err) { console.error(’encrypt error’,err); return null; } }; exports.decrypt = function(text, password){ try { var decipher = crypto.createDecipheriv(’aes-128-cbc’,password,iv); var dec = decipher.update(text,’hex’,’utf8’); dec += decipher.final(’utf8’); return dec; } Read more about AES-128 in js/Node.js[…]