Skip to content

Instantly share code, notes, and snippets.

View mutaimwiti's full-sized avatar
🕵️‍♂️
JavaScripting

Mutai Mwiti mutaimwiti

🕵️‍♂️
JavaScripting
View GitHub Profile
@mutaimwiti
mutaimwiti / Loading CMS data.md
Last active March 5, 2019 10:26
Updates to load cms data
  • The dots(.) on the file names represent the directory hierarchy e.g. js.cms.[your_module].js represents js/cms/[your_module].js.
  • REPLACE the current js/utils.js file with the one on this gist. The changes on this file allow for synchronization of cms data loading for your module.
  • Follow the same naming convection for your module scripts. If your script belongs to a broad module create a subdirectory for the module e.g. js/cms/repository/documents.js
  • ENSURE you place the link to your script on the section to that is loaded by jquery. e.g. documents.js is imported inside documents.html of resources.
  • CREATE js/cms/utils.js and add the content on this gist. This will prevent multiple
@mutaimwiti
mutaimwiti / app.js
Created January 22, 2019 14:46 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@mutaimwiti
mutaimwiti / test_login.py
Last active September 19, 2018 13:02
Example Python test
from unittest import TestCase
from rest_framework import status
from rest_framework.test import APIClient
class BaseTestCase(TestCase):
def setUp(self):
self.client = APIClient()
def post_login(self, username='johndoe', password='P@$$word'):
@mutaimwiti
mutaimwiti / huawei_e303_api_device
Created August 26, 2016 08:03 — forked from manuel-rabade/huawei_e303_api_device
API del modem Huawei E303
$ curl http://192.168.1.1/api/device/information
<?xml version="1.0" encoding="UTF-8"?>
<response>
<DeviceName>E303</DeviceName>
<SerialNumber>K3XBYAxxxxxxxxxx</SerialNumber>
<Imei>xxxxxxxxxxxxxxx</Imei>
<Imsi>xxxxxxxxxxxxxxx</Imsi>
<Iccid>xxxxxxxxxxxxxxxxxxxx</Iccid>
<Msisdn></Msisdn>
<HardwareVersion>CH2E303SM</HardwareVersion>