Skip to content

Instantly share code, notes, and snippets.

View RandomArray's full-sized avatar

Mike Johanning RandomArray

View GitHub Profile
Replace with your own usename and email:
------------------------------------------------
git config --global user.name "Username"
git config --global user.email "[email protected]"
These next two commands tell Git to use your Windows credentials to store your origin password.
------------------------------------------------
git config --global credential.helper wincred
git config --global credential.helper store
@RandomArray
RandomArray / RandomArray.php
Last active August 29, 2015 14:27
A Random Array of Random
<?php
// A Random Array of Random
FUNCTION R(){$N=0;FOR($I=1;$I<=64;$I++){$N.=rand(0,1);}
RETURN $N;}FOR($I=1;$I<=RAND(0,16);$I++){$A[R()]=R();}
print_r($A);
// http://sandbox.onlinephpfunctions.com/code/271c6c02aa703dca78ae00d8a00da4aae7181baa
?>
@RandomArray
RandomArray / install_iorpi.sh
Last active February 12, 2018 15:56
A BASH script for easy installation of io.js on a Raspberry Pi
#!/bin/bash
# ---------------------------------------------------------------------------------------
# install_iorpi.sh - A BASH shell script for Easy installation of io.js on a Rasberry Pi
# ---------------------------------------------------------------------------------------
PROGNAME=${0##*/}
VERSION="0.1.1"
clean_up() { # Perform pre-exit housekeeping
return
# Remove desktop.ini & thumbs.db from all sub-directories.
del /s /q /f /a "z:\your_dir\desktop.ini"
del /s /q /f /a "z:\your_dir\thumbs.db"
@RandomArray
RandomArray / array-to-sql.php
Created October 4, 2015 20:25
PHP Array to MySQL PDO Statement (Not a function/Saved From Project)
<?php
/*
/* Takes an array of checklist elements from a form and converts it all to a PDO SQL Insert Statemet.
* This was saved from a project where the following code was no longer being used.
* It won't do anything without proper input. I put this here as a reference on how to build PDO SQL statements from PHP Arrays.
*/
if (isset($_REQUEST['vehicleChecklistForm']) && !empty($_REQUEST['vehicleChecklistForm'])) { //Checks if action value exists
<?php
// Sample PHP function that Returns True if the Current Time is between the Start and End hours..
$ban_start = 19; // Clients not allow to login starting this hour
$ban_end = 7; // Clients allowed to log back in starting this hour
$currentHour = date('H');
@RandomArray
RandomArray / getMissingNameElements.js
Last active February 1, 2016 00:37
Finds missing Name element pairs for input ID elements starting with a defined prefix. Just a shortcut to find missing pairs for when working with a large form.
var ids=[], names=[], notfound=[];
$("input[id^='myPrefix_'], textarea[id^='myPrefix_'], select[id^='myPrefix_']").each(function(){
ids.push(this.id);
// console.log(this.id);
});
$("input[name^='myPrefix_'], textarea[name^='myPrefix_'], select[name^='myPrefix_']").each(function(){
names.push(this.name);
// console.log(this.name);
@RandomArray
RandomArray / random_delay_next_run.php
Last active February 15, 2016 00:33
Delays the next execution of the script by storing the next execution time in file and checking against it before continuing.
<?php
// Random time delay before next execution.
// Stores the next time in a file.
// Time is read from this file and compared against current time.
// If time has passed, perform another random delay between 1-59 seconds before execution.
$timeFile = 'nexttime.txt';
// $timeFile = dirname(__FILE__).'/nexttime.txt'; // Use this line for when running from CRON.
$minDelayMins = 1;
$maxDelayMins = 5;
@RandomArray
RandomArray / import_csv_to_mysql_pdo.php
Last active June 22, 2021 23:23
Imports a CSV file into a MySQL database line-by-line. Displays output timer, a count, and ok/fail status. This was created to import a 200mb CSV file with over 200,000 rows. After many failed attempts to import (Out of Memory errors), I wrote this script.
<?php
ini_set('max_execution_time', 0);
header( 'Content-type: text/html; charset=utf-8' ); // Stream output
echo '<div id="o"></div>
<script> function u(m){var e = document.getElementById("o");e.innerHTML=m;} </script>';
$startTime = time();
define('DB_HOST','localhost');
define('DB_NAME','mytestdb');
define('DB_USER','username');
@RandomArray
RandomArray / person_height.php
Created July 20, 2016 06:36
Generates HTML Select box for person's height in inches.
<?php
function personHeightOptions(){
$itotal = 95; $r = '';
for($foot=7;$foot>=3;$foot--){
for($inches=11;$inches>=0;$inches--){
if($inches==0){
$r .= "<option value='$itotal'> $foot' 0\" </option>";
}else{
$r .= "<option value='$itotal'> $foot' $inches\" </option>";