Posts

Showing posts with the label app

A sample Flask app that uses Keycloak for user registration and OIDC authentication

I've spent a couple of days exploring Keycloak, Istio, and EKS. The result is a sample Flask app that has these following features: User registration and authentication (OIDC) with Keycloak The app can be running on a local machine, in a Docker container, or inside a service mesh within a Kubernetes cluster and Istio. In that case, Istio and Keycloak were deployed on an EKS cluster following this tutorial [1]. The sample app repository is here [2]. Below are the detail instructions to run the sample app. Prerequisites Have a Keycloak instance up and running and you know the admin user credentials If you want to deploy the app on a Kubernetes cluster with Istio installed, make sure you have admin privileges to the cluster. You also need to install istioctl . Run the application normally 1. Clone the repo, install the requirements git clone https://github.com/dangtrinhnt/keycloak_flask cd keycloak_flask virtualenv ~/keycloak_flask source ~/keycloak_flask/bin/activa...

Generating Google Form from Google Spreadsheet using Google Apps Script

Google Form is such a great tool for us to create surveys with a great web interface. But, the thing is even with the cool drag-and-drop features, It's still a pain in the ass to generate forms from a mass amount of data (questions and choices). That's where Google Apps Scripts comes into its usefulness. Here is a case study from my real life experience: Earlier this week I had a chance to tinkering around the apps scripts to help my school create a survey with a set of data stored inside an excel file. The final goal is to create a form in which students give feedback to each of their teachers on each courses. So the excel data looks like this: Teachers sheet: this sheet contains 3 columns, each column is a list of all the teachers of each schools (elementary, middleschool and highschool) es,ms,hs teacher1,teacher2,teacher3 teacher6,teacher7,teacher8 ... Courses sheet: the courses sheets is storing name of the courses each teacher is teaching teacher1,teacher2,t...

Google Apps Script - Part 3 - Send email with form after submitting google form (advanced)

Image
So, you now know how to send people email after submitting a google form ? How about including in that email a form required that person to answer some questions? And the data that she submit will be inserted back into the response spreadsheet of the original form. Yeah, another form, sounds like inception huh :D Here is a hack: 1. In the email template, include the form: <h2>Please respond to the reflection question(s) posed to you in the Teacher Feedback form</h2> <form action="http://localhost:8081/myform" method="POST"> <input type="hidden" name="rownumber" value="{{rownumber}}"> <div> <textarea name="q" style="width:90%;height:100px;"></textarea> </div> <div> <button type="submit">Submit</button> </div> </form> The form will look something like this in the email: N...

Gunicorn error when running with Django1.7

If you running your django1.7 apps with Gunicorn, you will get this error: Traceback (most recent call last):   File "/home/.venv/ptc/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker     worker.init_process()   File "/home/.venv/ptc/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 114, in init_process     self.wsgi = self.app.wsgi()   File "/home/.venv/ptc/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 66, in wsgi     self.callable = self.load()   File "/home/.venv/ptc/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 105, in load     mod = util.import_module("gunicorn.app.django_wsgi")   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module     __import__(name)   File "/home/.venv/ptc/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 20, in <module>     from...

Docker - Trying to dockerize my Django app

I've spent sometime messing around the docker engine for couple days. I guess It's time to try dockerizing my Django app. Assuming I have already created a Ubuntu Trusty image  , open a container: Prerequisites: * The container (by default: eth0 - 172.17.0.2 ): python2.7, pip, virtualenv, mysql-client * The host machine (by default: docker0 - 172.17.42.1 ): mysql-server, grant permisson to the container host: MariaDB [(none)]> use appdb; MariaDB [appdb]> grant all privileges on appdb.* to 'myuser'@'172.17.0.2' identified by 'mypassword'; Inside the container: (mydjangoenv)root@93b3f27d3129:~# git clone https//my.git.repo/myproject (mydjangoenv)root@93b3f27d3129:~# cd myproject (mydjangoenv)root@93b3f27d3129:~# pip install -r requirements.txt (mydjangoenv)root@93b3f27d3129:~# ./manage run 0.0.0.0:8000 (remember to add the container's hostname ( 93b3f27d3129 ) to ALLOWED_HOSTS ) In the host machine:  Open the browser, ...

Android - Host your Linux images with DriveDroid

Yeah, It's true. You can host your Linux images (Ubuntu, Xubuntu, debian, fedora...) in your Android devices and boot from it. Now with DriveDroid , You don't need any dedicated USB drive or CDs/DVDs which are in a special format (FAT...) to be able to boot from. Everything you need to do are some super simple steps: 1. Install DriveDroid from the Google Play market:  https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid&hl=en 2. Download any Linux Image you want. I recently host the Xubuntu in my Android phone with DriveDroid ( http://xubuntu.org/ ). And then copy the image to /storage/sdcard0/Download/images . 3. On your Android phone, turn on DriveDroid, select the image to let your phone host the file over USB. 4. Restart your computer (make sure that you've set up to boot from USB as the first priority) 5. Enjoy Note: You can host many Linux images on your phone with DriveDroid .