Category: programming

  • BigQuery Bulk Insert using Python

    To insert multiple rows at once using DML in BigQuery, you can do something like this: The above snippet inserts multiple rows into the table (table with columns: id and createdAt) in one go. You can also see that values types are being supplied (id:STRING and createdAt:TIMESTAMP). Binding the values this way (using parameters) will…

  • 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…

  • 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…

  • 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.

  • 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…

  • casperjs output to html

    Documenting what I had to do. Used XSLT from here: nosetest xslt Problems and Fixes: Firefox was inserting “transformiix” as the root element, this caused the DOCTYPE to be spit out. I fixed by adding: doctype-public=”-//W3C//DTD HTML 4.0//EN”/ to