Skip to content

Instantly share code, notes, and snippets.

@petrov82
petrov82 / stardate.js
Created September 15, 2014 17:55
JS Stardate
// Stardate script © Phillip L. Sublett
// Phillip.L@Sublett.org
// http://TrekGuide.com
var now = new Date();
var then = new Date("July 15, 1987");
var stardate = now.getTime() - then.getTime();
stardate = stardate / (1000 * 60 * 60 * 24 * 0.036525);
stardate = Math.floor(stardate + 410000);
stardate = stardate / 10
@petrov82
petrov82 / dashboard.js
Created April 18, 2014 19:48
dashboard info
$(document).ready(function() {
var formExpenditure = $( '#formExpenditure' ).on( 'submit', function() {
//.....
//show some spinner etc to indicate operation in progress
//.....
@petrov82
petrov82 / gist:9486521
Created March 11, 2014 14:13
Window JS
<html>
<head>
<title>Delayed Autosave</title>
</head>
<body>
<h2>Type Your Thoughts</h2>
<textarea rows="10" cols="60" id="important"></textarea>
<div id="message"></div>
@petrov82
petrov82 / gist:9124212
Created February 20, 2014 22:03
undefined error in my prompt
<!DOCTYPE html>
<html>
<head>
<title>User Interaction for JS</title>
</head>
<body>
<p>
<script>
@petrov82
petrov82 / internal-functions
Created February 12, 2014 14:39
internal-functions with unseat error
<?php
$nothing = 0xFF;
$something = '';
$array = array(1,2,3);
//Before the first conditional, unset($nothing). What happens? PHP Notices
unset($nothing);
//Create a funciton that checks if a variable is set or empty, and display "$variable_name is SET|EMPTY"
function set_or_empty($checkvar) {
@petrov82
petrov82 / gist:8947434
Created February 12, 2014 00:29
serialize & unserialize an array
$array = array(1,2,3,4,5,6,7,8,9,0);
$serialized = serialize($array);
echo $serialized . PHP_EOL;
$deser = unserialize($serialized);
echo $deser . PHP_EOL;