-
Row to Column in MySQL
Say you have two tables like these: And you have these values: id name 1 Kesavan 2 Madhavan user_id attribute_name attribute_value 1 GENDER M 1 PREMIUM_USER N 1 SUBSCRIBED_TO_NEWSLETTER Y 2 GENDER M 2 PREMIUM_USER Y To get a result like this: id name GENDER PREMIUM_USER SUBSCRIBED_TO_NEWSLETTER 1 Kesavan M N Y 2 Madhavan M…
-
PHP openssl_encrypt tip
Recently I had to encrypt some data in PHP and send it to a Java App, the Java app was unable to decrypt the message. I experimented with (data) padding, changing ciphers and changing the options for openssl_encrypt, but, none of those worked. It was a requirement at the Java end for the Key to…
-
AWS SSM Parameter Store IAM Policy for restricting by Path and Tag
I wanted to restrict access to some parameters based on the path and tag. Say, I have a key:/production/Param1=Value1with a tag:Application1=One I was expecting a policy like this: { “Version”: “2012-10-17”, “Statement”: [ { “Sid”: “VisualEditor0”, “Effect”: “Allow”, “Action”: [ “ssm:GetParameterHistory”, “ssm:ListTagsForResource”, “ssm:GetParametersByPath”, “ssm:GetParameters”, “ssm:GetParameter” ], “Resource”: “arn:aws:ssm:::parameter/production/*”, “Condition”: { “StringEquals”: { “ssm:resourceTag/Application1”: “One” }…
-
AWS Codecommit – PR and Commits with large files
AWS Codecommit console UI fails to display a diff when viewing PRs or Commits with large files (in my case a 7125 line XML file was part of the PR that failed to render the diff). AWS support confirmed that this is a limitation as of now and failed to provide further details (on what…
-
MySQL substring start is one based
To my surprise, MySQL SUBSTRING functions start position is one based. A start position of ‘0’ will return an empty string. If you would like to get the first 100 characters of a column named ‘my_column’ you will need to use SUBSTRING(‘my_column’, 1, 100). Using SUBSTRING(‘my_column’, 0, 100). will return an empty string. Postgres and…
-
Using Generators to flatten a JSON doc in PHP
To flatten a JSON like this: to: I used the following code:
-
Add extra validation rules to Laravel ForgotPassword
I wanted to add a captcha to the Forgot Password form, so I ended up doing this to the default ForgotPasswordController: Only relevant bits are shown there.
-
ES6 support on iOS9
Recently while building a Cordova based app, few users complained that they were seeing blank pages or cryptic error messages. Someone mentioned they were on iOS9. Over the weekend, as I ran the app on a simulator, I noticed an error in Safari. And, that’s when I realized ES6 features and syntax is not fully…
-
Jenkins parallel pipeline
I was very excited to know about the ‘parallel’ feature in Jenkins Pipeline, but, there are many gotchas while making use of the pipeline feature (many of which are documented here: Jenkins Pipeline Example). After trying and reading a few different solutions, following worked for me (notice in screenshot that the browser jobs run in…
-
React Native: Application is not registered
– This is either due to a require() error during initialisation or failure to call AppRegistry.registerComponent. I had been struggling with this for some time and the answer was right there… I had to make sure I called AppRegistry.registerComponent with the right params/appname – I had renamed my app and forgot to update the class…