Skip to content

Instantly share code, notes, and snippets.

View jnoortheen's full-sized avatar

Noorhteen Raja NJ jnoortheen

  • Software developer
  • Chennai, India
View GitHub Profile
@jnoortheen
jnoortheen / middleware.py
Created June 13, 2017 15:41
A simple Django 1.11+ middleware to record user activities to Database
from django.contrib.auth.decorators import login_required
from django.conf import settings
from re import compile
from django.http import HttpRequest, HttpResponse
from core.models import ActivityLog
from core.utils import get_ip_address
@jnoortheen
jnoortheen / autoconnect_wwan
Created January 8, 2017 13:54
Shell script to automatically connect network modems and keep on checking for connectivity
#!/bin/bash
while true
do
echo "checking connection"
if [ -n "$(nmcli -p d | grep cdma)" ]; then
echo "modem is connected"
if ! [ "$(ping -c 1 -W 30 google.com)" ]; then
nmcli nm wwan off
nmcli nm wwan on
# nmcli con up id "evdo"
@jnoortheen
jnoortheen / .py
Last active November 1, 2016 05:58
Flatten multi-dimensional array method
def flatten_array(array):
"""
flattens multi-dimensional array/list to one dimensional
Args:
array (list): multi-dimensional list
Returns:
list: resultant one-dimensional list
>>> flatten_array([1, 2, 3, 4, [7, 8, 9]])