Skip to content

Instantly share code, notes, and snippets.

@moneeb777
moneeb777 / tpm2.sh
Last active May 10, 2018 08:54
tpm2-tools setup
#!/bin/bash
set -e # Exit on error
## stable release links
tss="https://github.com/tpm2-software/tpm2-tss/archive/2.0.0_rc0.tar.gz"
abrmd="https://github.com/tpm2-software/tpm2-abrmd/archive/1.3.1.tar.gz"
tools="https://github.com/tpm2-software/tpm2-tools/archive/3.0.4.tar.gz"
sudo apt-get -qq -y install autoconf-archive libcmocka0 libcmocka-dev build-essential git pkg-config gcc g++ m4 libtool automake liburiparser-dev autoconf libgcrypt11-dev #> /dev/null
@moneeb777
moneeb777 / AndroidLocation-map.html
Created May 12, 2016 13:56
plot the coordinates received from AndroidLocation application on a google map object
<html>
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<style type="text/css">
#map {
height: 100%;
width: 100%;
}
@moneeb777
moneeb777 / AndroidLocation-phpListener.php
Last active May 12, 2016 13:44
to get POST data from AndroidLocation application
<?php
// overwrite current location to myCurrentLocation.json
$myfile = fopen("resources/myCurrentLocation.json", "w");
$time = $_POST["time"];
$lat = $_POST["lat"];
$lng = $_POST["lng"];
$arr = array('time' => $time, 'lat' => $lat, 'lng' => $lng);
fwrite($myfile, json_encode($arr));
fwrite($myfile, "\n");
fclose($myfile);
try {
// Create a new HttpClient
OkHttpClient client = new OkHttpClient();
// Define request being sent to the server
RequestBody postData = new FormBody.Builder()
.add("lat", "Test")
.add("lng", "Test")
.build();
@moneeb777
moneeb777 / AndroidLocation-activity_main.xml
Last active May 10, 2016 08:11
actitvity_main.xml file to display longitude and latitude coordinates captured by GPS receiver for android phone
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android.androidlocation.MainActivity">
@moneeb777
moneeb777 / androidAsynchronous.java
Created April 29, 2016 03:16
Android - Asynchronous task
public class FeedTask extends AsyncTask<Void, Void, String> {
double lat;
double lng;
public FeedTask(double lat, double lng) {
this.lat = lat;
this.lng = lng;
}
@Override
@moneeb777
moneeb777 / androidFileHandling.java
Last active April 29, 2016 03:15
Android I/O- write file to storage
// find the root of the external storage
File root = android.os.Environment.getExternalStorageDirectory();
myRootFolder.append("\nExternal file system root: " + root);
//make a new directory
File dir = new File (root.getAbsolutePath() + "/testDownload");
dir.mkdirs();
File file = new File(dir, "testData.txt");
try {
FileOutputStream f = new FileOutputStream(file);