Multiple includes on different depths in a LoopBack/Node.js query

javascript
Question: I'm trying to load an object on a node.js Loopback server and I want to load multiple related objects in the same query. These related objects are on different depths. This is the query:/api/Users/114?filter[include][institutes]=institute&filter[include]=departments&filter[include]=profiles Notice that [institutes]=institute have two levels and departments and profiles only one. This returns me an error: 500 Internal server error. Error: Relation "0" is not defined for User model. On node.js debug I noticed that the final JSON query generated seems to be wrong:{ include: { '0': 'departaments', '1': 'profiles', institutes: 'institute' } }, ... } Has anyone else faced this problem? Is it a loopback bug? If so, how can I turn around for a solution? Answer: Read more
Read More

How to read static files from jar useing Spring MVC? [duplicate]

Uncategorized
Question: This question already has an answer here:Spring MVC static resources in separate jar 1 answer How can I use spring mvc to read static files from jar, I used ; , but it didn't work. Answer: I solved it, it must use classpath, not classpath*, when using classpath, spring will make it as ClassPathResource not as ServletContextResource as usual. Read more
Read More

IONIC 2 PLATFORM. IONIC CANT GET GPS COORDINATES FROM IOS

Uncategorized
Question: i am creating a ionic application with ionic 2 for both android and ios, But i am developing this application in windows and i have checked all with an android device. for android everything is working fine but when i copied the files to MAC and tried to test it on ios emulator eveything worked fine except accessing geolocation plugin. it works well in the browser as well on android device. bellow is the code i used access the gps this.geolocation.getCurrentPosition().then((position) => { var pyrmont = { lat: position.coords.latitude, lng: position.coords.longitude }; this.map = new google.maps.Map(document.getElementById('map'), { center: pyrmont, zoom: 14 }); var image = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png'; var beachMarker = new google.maps.Marker({ position: { lat: position.coords.latitude, lng: position.coords.longitude }, map: this.map, icon: image }); this.infowindow = new google.maps.InfoWindow(); var service…
Read More

Sync identity columns between test and prod

Uncategorized
Question: We have a table that holds some enumeration values and application parameters values in our app database. These records use identity columns as their primary keys. We also have DEV, TEST and PROD databases. We need to sync the primary keys between TEST and PROD databases every time we release an update. What I want to ask is, what is the preferred method of syncing the identity columns? One option we thought of is to remove the identity property from the primary key column and manually create IDs which will all be same on DEV and PROD. What are your thoughts? Answer: You need to have a reason to add an Identity property to a PK. Apparently Identity automates the way PK is generated and allows you to forget…
Read More

Android, why IllegalBlockSizeException occur when i want to encrypt a string?

Uncategorized
Question: i am building an android apps that using fingerprint for the authentication, the source code of generating key and the cipher initialization for encryption in fingerprint authentication is like this (in FingerprintActivity). public final void generateKey() { try { keyStore = KeyStore.getInstance("AndroidKeyStore"); } catch (Exception e) { e.printStackTrace(); } KeyGenerator keyGenerator; try { keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore"); } catch (NoSuchAlgorithmException | NoSuchProviderException e) { throw new RuntimeException("Failed to get KeyGenerator instance", e); } try { keyStore.load(null); keyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT) .setBlockModes(KeyProperties.BLOCK_MODE_CBC) .setUserAuthenticationRequired(true) .setEncryptionPaddings( KeyProperties.ENCRYPTION_PADDING_PKCS7) .setKeySize(256) .build()); keyGenerator.generateKey(); } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException | CertificateException | IOException e) { throw new RuntimeException(e); } } @TargetApi(Build.VERSION_CODES.M) public boolean cipherInit() { try { cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {…
Read More