Skip to content

Instantly share code, notes, and snippets.

View Pamblam's full-sized avatar
🕶️
Coding

Rob Parham Pamblam

🕶️
Coding
  • Our Town America
  • Tampa Bay, Florida
View GitHub Profile
@Pamblam
Pamblam / Versionator.java
Last active April 2, 2018 17:55
Check for updates in the play store and prompt user to update if an update is available.
package com.geneticcoder.Versionator;
// Check here for updates: https://gist.github.com/Pamblam/53cb2b1c90dea09d4872084956d17b5c
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
/**
* A disposable alert modal that uses Bootstrap
* https://jsfiddle.net/s9ojmwwt/2/
*/
function BSAlert(text){
var mid = "modal"+Math.floor(Math.random() * 10000000000000001);
var html = '<div class="modal fade" id="'+mid+'" tabindex="-1"'+
'role="dialog" aria-labelledby="myModalLabel" aria-hidden='+
'"true"><div class="modal-dialog"><div class="modal-conten'+
@Pamblam
Pamblam / rateBeggar.java
Created September 12, 2016 16:46
A class to ask user to rate appp if they have not done so.
package com.package.name;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.util.Log;
@Pamblam
Pamblam / API_TEMPLATE.php
Created April 5, 2017 17:09
Simple starting point for PHP webservices
<?php
session_start();
// Create the return array
$return = array(
"response" => "Success",
"success" => true,
"data" => array()
);
/**
* Format a date using PHP date shorthand
* @param {Date} date - A Javascript Date object
* @param {String} format - The format of the outputted date
* @returns {String} - The formatted date
*/
function formatDate(date, format) {
if (isNaN(date.getTime())) return "Invalid Date";
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
<?php
/*
* Makes an HTTP request via GET or POST, and can download a file
* @returns - Returns the response of the request
* @param $url - The URL to request, including any GET parameters
* @param $params - An array of POST values to send
* @param $filename - If provided, the response will be saved to the
* specified filename
*/
<?php
/**
* Given a string of PHP code, this will provide a list of classes, their
* constructors and the line number they're on. Used for programmatically
* updating older code using PHP4 style constructors to PHP7
*/
class classParser{
private $code;
private $tokens = array();
@Pamblam
Pamblam / Oracle To Mysql Geometry Conversion.php
Last active April 20, 2023 06:22
Convert Oracle Spatial to MySQL Spatial
<?php
/**
* Convert an Oracle SYS.SDO_GEOMETRY definition (perhaps extracted from an insert
* statement) to a MySQL Geometry column. This function only handles Polygons and
* Multipolygons.
*
* Example:
* $definition = "MDSYS.SDO_GEOMETRY(2003,4326,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),MDSYS.SDO_ORDINATE_ARRAY(-75.01703,41.79308,-75.02978,41.7941,-75.02735,41.772,-75.02716,41.77193,-75.02697,41.77187,-75.01354,41.79051,-75.01337,41.79061,-75.0132,41.79072,-75.00949,41.79234,-75.00946,41.79254,-75.00943,41.79274,-75.00518,41.7943,-74.9995,41.79178,-74.99365,41.79788,-74.99383,41.79798,-74.99876,41.80318,-74.9988,41.80337,-74.99883,41.80349,-75.00425,41.80479,-75.00431,41.80459,-75.01239,41.79415,-75.01245,41.79412,-75.01688,41.79345,-75.01696,41.79327,-75.01703,41.79308))";
* $sql = "INSERT INTO mytable (geom) VALUES (".OraclePolygonToMysql($definition).")";
@Pamblam
Pamblam / processMonitor
Created June 1, 2017 14:47
Monitor and kill a process when it has been idle for 10 minutes (in this case, Oracle) - Written on mac, not tested on linux
#!/bin/bash
# The name of the process to search for and kill
PROCESSNAME="oracle";
# Determine if this script is currently running
if [ -f omstatus ]; then
# The status file exists, wait a second and see if it changes
CURRENTSTATUS=$(cat omstatus); sleep 2;
@Pamblam
Pamblam / RequestCache.php
Created June 8, 2017 16:54
Dynamically cache requests and responses in a single mysql table
<?php
/**
* Dynamically cache requests and responses in a single mysql table
*/
class RequestCache{
// Configurable Options
// The mysql options (except for $mysql_table) may be left blank if a $pdo
// connection is passed to the constructor.