INSERT INTO locations(dhis_id, facility_name, location) SELECT DISTINCT dhis_id, facility_name, location FROM dhis_count WHERE dhis_id NOT IN(SELECT dhis_id FROM locations)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package your.app.util; | |
import android.annotation.SuppressLint; | |
import android.app.Activity; | |
import android.content.ContentResolver; | |
import android.content.Context; | |
import android.content.pm.PackageInfo; | |
import android.content.pm.PackageManager; | |
import android.content.pm.PackageManager.NameNotFoundException; | |
import android.content.res.Configuration; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Intent; | |
import android.net.Uri; | |
import android.os.Environment; | |
import android.provider.MediaStore; | |
import android.support.v4.app.Fragment; | |
import android.util.Log; | |
import java.io.File; | |
import java.io.IOException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.location.Location; | |
import android.location.LocationListener; | |
import android.location.LocationManager; | |
import android.os.Bundle; | |
import android.support.v4.app.Fragment; | |
import android.util.Log; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chown -R www-data:www-data /var/www | |
find /var/www/ -type d -exec chmod 755 {} \; | |
find /var/www/ -type f -exec chmod 644 {} \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE users( | |
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, | |
`username` varchar(255) NOT NULL, | |
`password` varchar(255) NOT NULL, | |
`firstname` varchar(255) NOT NULL, | |
`lastname` varchar(255) NOT NULL); |
SELECT location, COUNT(location) FROM locations GROUP BY location HAVING COUNT(location) > 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require('jsonwebtoken'); | |
exports.isAuthenticated = (req, res, next) => { | |
//Get the request headers and check if we have an authorization header with our token | |
if (req.headers && req.headers.authorization && req.headers.authorization.split(' ')[0] === 'JWT') { | |
//Check the token for validity | |
var token = req.headers.authorization.split(' ')[1]; | |
jwt.verify(token, 'our-jwt-secret-goes-here', (err, payload) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router(); | |
const authMiddleware = require('../middleware/auth-middleware'); | |
const userController = require('../controllers/user-controller'); | |
//Get a list of all the users | |
//We are using the authentication middleware to protect this route from unauthorised access | |
router.get('/', authMiddleware.isAuthenticated, userController.getUsers); |