-
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…
-
darker background image
I was stunned to learn I could set the opacity of a background image like this: background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url(‘/path/to/image’); and darken the background image.
-
High System CPU usage
After upgrading a webserver running Apache to Debian Jessie (from Wheezy), I noticed that the system CPU usage was higher. Running an strace on one of the Apache processes was giving me very little info: strace -c -p 10112 Process 10112 attached – interrupt to quit ^CProcess 10112 detached % time seconds usecs/call calls errors…
-
HHVM notes
Impressive throughput improvements (>100%) with the app that I am working on. phpinfo() doesn’t output what you would expect. xhprof output_dir doesn’t get read from ini files, need to set that up in the constructor of XHProfRuns_Default. Set hhvm.server.thread_count to a high value (>=MaxRequestWorkers), otherwise a few slow MySQL queries could bring the server to…
-
HTTPS and GA referral exclusion
After converting a site to be served over TLS, we noticed the drop off rates increasing on some pages. This was because: user was being redirected to a payment page on another domain that was also served over TLS. As, now both sites were served over TLS, Google Analytics was picking up the referrer (HTTPS…