Skip to content

Instantly share code, notes, and snippets.

View mikestratton's full-sized avatar

Mike Stratton mikestratton

View GitHub Profile
@mikestratton
mikestratton / drawing-tools.html
Created October 21, 2016 02:18 — forked from Hagith/drawing-tools.html
Google Maps v3 Drawing Tools
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>Drawing Tools</title>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false&libraries=drawing"></script>
<style type="text/css">
#map, html, body {
@mikestratton
mikestratton / lottery.php
Created January 12, 2016 08:52
Lottery algorithm based on Benford's Law that will make your rich!
<html>
<head>
<title>Lottery & Benfords Law</title>
</head>
<body style="margin:2% auto; text-align:center;">
<h1>Win the Lottery Using Benford's Law!</h1>
<p>This PHP page uses Benford's law to randomly generates numbers for the Powerball Lottery<br />
<a href="https://en.wikipedia.org/wiki/Benford%27s_law" target="_blank">Click here to learn more about Beford's Law<a/></p>
<h3>This generator increases your chances to win by approximately 30% !</h3>
<?php
@mikestratton
mikestratton / gist:4a95a8b88f78713397b7
Last active September 5, 2015 07:14
Two Wordpress Menu Views: (Public and Logged in Users view different menus.)
function my_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in() ) {
$args['menu'] = 'menu-private';
} else {
$args['menu'] = 'menu-public';
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
?>
@mikestratton
mikestratton / git_simple
Last active August 29, 2015 14:23
Simple Git Command Instructions
Simple instructions to clone, push and pull Git content:
server <<<--->>> local system
To clone repository from Github to local system:
1. Open Git Bash
2. git clone <URL of Repository>
To add file or subdirectory to local Git (Record changes to repository)
1. Open Git Bash
2. cd <directory>
@mikestratton
mikestratton / MyClass.java
Created May 19, 2015 05:26
Cheat Sheet for Java
//Single line comment
/* multiple
* line
* comment
*/
//import libraries
import java.util.Scanner;
import java.math.BigDecimal;
@mikestratton
mikestratton / users_tweets.php
Last active August 29, 2015 14:21
Queries twitter using specific keyword and posts most recent 100 tweets
<?php
// Queries twitter using specific keyword and posts most recent 100 tweets
error_reporting(E_ERROR);
$json = file_get_contents("http://mikestratton.net/temp/bigdatabox/src/raw_twitter_Lebron_James.php");
$t_query = json_decode($json,true);
$query = $t_query ['search_metadata']['query'];
echo "<h1>Users Tweeting About: ".$query." </h1>";
reset($t_query);
@mikestratton
mikestratton / array_most_frequent.php
Created May 10, 2015 04:52
Program that finds the most frequent element in an array. (Uses methods: array_count_values, arsort, array_keys)
<?php
//Program that finds the most frequent element in an array.
$data=Array();
echo "Enter numbers:";
for($i=0;$i<6;$i++)
{
$data[$i]=trim(fgets(STDIN));;
}
// Using methods: array_count_values, arsort, array_keys
@mikestratton
mikestratton / array_reverse.php
Created May 9, 2015 04:38
Method: array_reverse — Return an array with elements in reverse order
<?php
// using method array_reverse
echo "Enter 5 elements:";
for($i = 0 ; $i<5;$i++)
{
$arr[$i]=trim(fgets(STDIN));
}
echo "\nYour input: \n";
foreach ($arr as $value1){
@mikestratton
mikestratton / math_operators.php
Last active August 29, 2015 14:20
Math Operators: sum, difference, product, quotient, remainder, increment, decrement, greater then comparison
<?php
echo "Enter 1st number:";
$num1 = trim(fgets(STDIN));
echo "Enter 2nd number:";
$num2 = trim(fgets(STDIN));
$sum = $num1 + $num2; //sum
echo ("Sum: "."\n".$sum."\n \n");
$dif = $num1 - $num2; //difference
echo ("Difference: "."\n".$dif."\n \n");
@mikestratton
mikestratton / salary_estimation.php
Created May 5, 2015 05:09
Salary estimation based on experience. Take experience and age of a person as input. If the person is experienced and his age is equal to or more than 35 the salary of the person is 6000. Otherwise, if the person is experienced and his age is equal to or more than 28 but less than 35, then the salary should be 4800. For experienced person below …
<?php
echo "Enter the experience:";
$exp = trim(fgets(STDIN));
echo "Enter the age of the person:";
$age = trim(fgets(STDIN));
while ($exp == 0){
$salary = 2000;
echo $salary;
exit;