Become a Patron!

User Age off by a year [Now with 100% more sig banner code]

Saddletramp1200

Diamond Contributor
Member For 4 Years
Well My Friends, most of the Morons that heard cars are sleeping now. I am going to see if I can murder some bugs with my old Harley. Midnight bugs taste best!
 
  • Like
Reactions: jae

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Unless something is wrong with my server, it didn't like the $.prettydate->format() method and wanted a function. ;)

PHP:
date_format($prettydate, 'F j, Y')

(I reversed day and month)
 
  • Like
Reactions: jae

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Well My Friends, most of the Morons that heard cars are sleeping now. I am going to see if I can murder some bugs with my old Harley. Midnight bugs taste best!
Good eatin'!
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
I've never been all that good at learning new languages. I failed miserably at Spanish and Basic. I don't know why I think PHP and MySQL will be any different. :(
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
...and here's my code (based on @jeremy's (not really based on, but outright stolen)).

PHP:
<?php
/*
********************************************************************************************
* x jeremy jarratt coded this terribly didn't he - http://jeremyjarratt.com/ - @transmothra
* PRAISE DOBBS! HAIL ERIS! ALL HAIL DISCORDIA!
* This work is licensed under the
* Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
********************************************************************************************
*/

// EDIT THESE NEXT FEW LINES
// set your timezone or suffer the consequences
date_default_timezone_set('America/Chicago');

// set your quit date
$quitdate = "2014-04-29 22:00:00"; // change this to your quit date

// how much is a pack of smokes worth where you live?
$cigprice = 7.20; // omit the dollar sign

// how many packs per day did you smoke?
$packsperday = 1.5; // decimals ok

// how much do you spend on vaping per month?
$vapecostmonthly = 30; // omit the dollar sign

// how many mL per day?
$ml = 6; // omit units

// what nicotine strength in mg/mL?
$mg = 3; // omit units

$juice = 'DIY';

// set your font by filename - UPLOAD YOUR FONT FILE TO THE SAME DIRECTORY
$font = './fonts/tt0142m_.ttf';
$fontb = './fonts/tt0144m_.ttf';

// HEY LET'S CALCULATE A BUNCH OF CRAP (in general, leave this alone)
$prettydate = date_create_from_format("Y-m-j H:i:s", $quitdate); // no, not a girl/boy. just a nicer-looking date format.
$now = time(); // this is really NOW, for comparison to your quit date
$your_date = strtotime($quitdate);
$datediff = $now - $your_date; // compare your quit date to right now (output in seconds)
$datetime1 = new DateTime($quitdate);
$datetime2 = new DateTime();
$interval = date_diff($datetime1, $datetime2); // just another time comparison
$howlong = $interval->format('%y years, %m months, %d days, %h hours, %i minutes, %s seconds');
$vapedays = floor($datediff/(60*60*24)); // convert time since quitting to days (rounded down to eliminate any remainder)
$vapedayspre = $datediff/(60*60*24);
$vapecostdaily = $vapecostmonthly/30; // divide monthly cost by 30 for a daily cost
$vapecost_ttl = $vapecostdaily*$vapedays; // multiply daily vape cost by total days since quitting
$vapesaved = $vapedays*$cigprice*$packsperday; // days x cost x ppd, minus vaping costs
$cigsavoided = floor($packsperday*20*$vapedayspre); // ppd x 20 smokes per pack x total days since quitting
$packs = $cigsavoided/20; // total number of packs avoided since quitting

// format numbers: decimal places, decimal separator, thousands separator
$vapesaved = number_format($vapesaved, 2, '.', ',');
$cigsavoided = number_format($cigsavoided, 0, '.', ',');
$packs = number_format($packs, 0, '.', ',');
$vapedays = number_format($vapedays, 0, '.', ',');

// messages (save some typing and avoid formatting errors)
$cigline = $cigsavoided.' analogs avoided in the '.$vapedays.' days since '.date_format($prettydate, 'F j, Y').' ('.$packs.' packs).';
$moneyline = '$'.$vapesaved.' saved, of which $'.$vapecost_ttl.' was shamelessly vaped.';
$ml = $ml.'mL/day';
$mg = $mg.'mg/mL';

/*
// put in a bunch of quotes or whatever you want; space is limited!; rotated on a random basis
$randomquote = array(
'The SubGenius must have SLACK! (B.Dobbs)',
'Hail Eris! All Hail Discordia!',
'How can I be free in the shadow of a chapel? (anon)',
'Act like a dumbshit and they\'ll treat you like an equal (B.Dobbs)',
'Nature abhors a moron. (HL Mencken)',
'Puritanism: The haunting fear that someone, somewhere, may be happy. (HL Mencken)',
'The highest understanding we can achieve: laughter & human compassion. (Feynman)',
);
$quotation = $randomquote[rand(0, sizeof($randomquote) - 1)];
*/

// DON'T EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
$image = './images/signature_bar.png'; // create a banner image with this name; 468 pixels wide by 60 pixels tall
$im = imagecreatefrompng($image);

// set colors (RGB)
$main_color = imagecolorallocate($im, 51, 102, 153);
$black = imagecolorallocate($im, 0, 0, 0);
$orange = imagecolorallocate($im, 255, 140, 0);
$blue = imagecolorallocate($im, 100, 100, 255);
$red = imagecolorallocate($im, 212, 48, 52);
$green = imagecolorallocate($im, 0, 160, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 216, 216, 216);
$yellow = imagecolorallocate($im, 255, 216, 64);

// the spacing
$line1vert = 16;
$line2vert = 32;
$line3vert = 48;

// number of pixels for the left margin
$left_margin = 5;
$far_margin = 430;

// THE MAGIC: set font size, font angle, horizontal position, vertical position, color, fontface, text
// Add the text - drop shadow
imagettftext($im, 10, 0, $left_margin-2, $line1vert+2, $black, $fontb, $howlong);
imagettftext($im, 8, 0, $left_margin-2, $line2vert+2, $black, $font, $cigline);
imagettftext($im, 8, 0, $left_margin-2, $line3vert+2, $black, $font, $moneyline);
imagettftext($im, 6, 0, $far_margin-2, $line1vert+2, $black, $font, $ml);
imagettftext($im, 6, 0, $far_margin-2, $line2vert+2, $black, $font, $mg);
imagettftext($im, 6, 0, $far_margin-2, $line3vert+2, $black, $font, $juice);
//imagettftext($im, 8, 0, $left_margin-1, 65, $black, $fontb, $quotation);

// Add the text
imagettftext($im, 10, 0, $left_margin, $line1vert, $red, $fontb, $howlong);
imagettftext($im, 8, 0, $left_margin, $line2vert, $white, $font, $cigline);
imagettftext($im, 8, 0, $left_margin, $line3vert, $white, $font, $moneyline);
imagettftext($im, 6, 0, $far_margin, $line1vert, $white, $font, $ml);
imagettftext($im, 6, 0, $far_margin, $line2vert, $white, $font, $mg);
imagettftext($im, 6, 0, $far_margin, $line3vert, $white, $font, $juice);
//imagettftext($im, 8, 0, $left_margin, 64, $yellow, $fontb, $quotation);

// LEAVE THESE ALONE DAMN YOU
header('Content-Disposition: filename=signature_bar.png');
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);

?>
 

jae

Silver Contributor
Member For 4 Years
Unless something is wrong with my server, it didn't like the $.prettydate->format() method and wanted a function. ;)

PHP:
date_format($prettydate, 'F j, Y')

(I reversed day and month)
Interesting. Worked on mine. Guessing it's a version thing or some ini setting.
 

jae

Silver Contributor
Member For 4 Years
I've never been all that good at learning new languages. I failed miserably at Spanish and Basic. I don't know why I think PHP and MySQL will be any different. :(
IMHO your code is better than mine. Just sayin'. I'm not all that great (i never got the hang of functions, methods, or classes), but you clearly understand this stuff better than me.
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Interesting. Worked on mine. Guessing it's a version thing or some ini setting.

I have noooooo idea. ;)

See? I know very little. :D
 
  • Like
Reactions: jae

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
IMHO your code is better than mine. Just sayin'. I'm not all that great (i never got the hang of functions, methods, or classes), but you clearly understand this stuff better than me.

Not trying to out-ignorance you or anything, but I keep needing to go back and forth through the books I'm reading just to remember what was mentioned a chapter before. Some of it is STARTING to stick, but before a month ago, I didn't know what a class nor a method were.
 
  • Like
Reactions: jae

Saddletramp1200

Diamond Contributor
Member For 4 Years
...and here's my code (based on @jeremy's (not really based on, but outright stolen)).

PHP:
<?php
/*
********************************************************************************************
* x jeremy jarratt coded this terribly didn't he - http://jeremyjarratt.com/ - @transmothra
* PRAISE DOBBS! HAIL ERIS! ALL HAIL DISCORDIA!
* This work is licensed under the
* Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
********************************************************************************************
*/

// EDIT THESE NEXT FEW LINES
// set your timezone or suffer the consequences
date_default_timezone_set('America/Chicago');

// set your quit date
$quitdate = "2014-04-29 22:00:00"; // change this to your quit date

// how much is a pack of smokes worth where you live?
$cigprice = 7.20; // omit the dollar sign

// how many packs per day did you smoke?
$packsperday = 1.5; // decimals ok

// how much do you spend on vaping per month?
$vapecostmonthly = 30; // omit the dollar sign

// how many mL per day?
$ml = 6; // omit units

// what nicotine strength in mg/mL?
$mg = 3; // omit units

$juice = 'DIY';

// set your font by filename - UPLOAD YOUR FONT FILE TO THE SAME DIRECTORY
$font = './fonts/tt0142m_.ttf';
$fontb = './fonts/tt0144m_.ttf';

// HEY LET'S CALCULATE A BUNCH OF CRAP (in general, leave this alone)
$prettydate = date_create_from_format("Y-m-j H:i:s", $quitdate); // no, not a girl/boy. just a nicer-looking date format.
$now = time(); // this is really NOW, for comparison to your quit date
$your_date = strtotime($quitdate);
$datediff = $now - $your_date; // compare your quit date to right now (output in seconds)
$datetime1 = new DateTime($quitdate);
$datetime2 = new DateTime();
$interval = date_diff($datetime1, $datetime2); // just another time comparison
$howlong = $interval->format('%y years, %m months, %d days, %h hours, %i minutes, %s seconds');
$vapedays = floor($datediff/(60*60*24)); // convert time since quitting to days (rounded down to eliminate any remainder)
$vapedayspre = $datediff/(60*60*24);
$vapecostdaily = $vapecostmonthly/30; // divide monthly cost by 30 for a daily cost
$vapecost_ttl = $vapecostdaily*$vapedays; // multiply daily vape cost by total days since quitting
$vapesaved = $vapedays*$cigprice*$packsperday; // days x cost x ppd, minus vaping costs
$cigsavoided = floor($packsperday*20*$vapedayspre); // ppd x 20 smokes per pack x total days since quitting
$packs = $cigsavoided/20; // total number of packs avoided since quitting

// format numbers: decimal places, decimal separator, thousands separator
$vapesaved = number_format($vapesaved, 2, '.', ',');
$cigsavoided = number_format($cigsavoided, 0, '.', ',');
$packs = number_format($packs, 0, '.', ',');
$vapedays = number_format($vapedays, 0, '.', ',');

// messages (save some typing and avoid formatting errors)
$cigline = $cigsavoided.' analogs avoided in the '.$vapedays.' days since '.date_format($prettydate, 'F j, Y').' ('.$packs.' packs).';
$moneyline = '$'.$vapesaved.' saved, of which $'.$vapecost_ttl.' was shamelessly vaped.';
$ml = $ml.'mL/day';
$mg = $mg.'mg/mL';

/*
// put in a bunch of quotes or whatever you want; space is limited!; rotated on a random basis
$randomquote = array(
'The SubGenius must have SLACK! (B.Dobbs)',
'Hail Eris! All Hail Discordia!',
'How can I be free in the shadow of a chapel? (anon)',
'Act like a dumbshit and they\'ll treat you like an equal (B.Dobbs)',
'Nature abhors a moron. (HL Mencken)',
'Puritanism: The haunting fear that someone, somewhere, may be happy. (HL Mencken)',
'The highest understanding we can achieve: laughter & human compassion. (Feynman)',
);
$quotation = $randomquote[rand(0, sizeof($randomquote) - 1)];
*/

// DON'T EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
$image = './images/signature_bar.png'; // create a banner image with this name; 468 pixels wide by 60 pixels tall
$im = imagecreatefrompng($image);

// set colors (RGB)
$main_color = imagecolorallocate($im, 51, 102, 153);
$black = imagecolorallocate($im, 0, 0, 0);
$orange = imagecolorallocate($im, 255, 140, 0);
$blue = imagecolorallocate($im, 100, 100, 255);
$red = imagecolorallocate($im, 212, 48, 52);
$green = imagecolorallocate($im, 0, 160, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 216, 216, 216);
$yellow = imagecolorallocate($im, 255, 216, 64);

// the spacing
$line1vert = 16;
$line2vert = 32;
$line3vert = 48;

// number of pixels for the left margin
$left_margin = 5;
$far_margin = 430;

// THE MAGIC: set font size, font angle, horizontal position, vertical position, color, fontface, text
// Add the text - drop shadow
imagettftext($im, 10, 0, $left_margin-2, $line1vert+2, $black, $fontb, $howlong);
imagettftext($im, 8, 0, $left_margin-2, $line2vert+2, $black, $font, $cigline);
imagettftext($im, 8, 0, $left_margin-2, $line3vert+2, $black, $font, $moneyline);
imagettftext($im, 6, 0, $far_margin-2, $line1vert+2, $black, $font, $ml);
imagettftext($im, 6, 0, $far_margin-2, $line2vert+2, $black, $font, $mg);
imagettftext($im, 6, 0, $far_margin-2, $line3vert+2, $black, $font, $juice);
//imagettftext($im, 8, 0, $left_margin-1, 65, $black, $fontb, $quotation);

// Add the text
imagettftext($im, 10, 0, $left_margin, $line1vert, $red, $fontb, $howlong);
imagettftext($im, 8, 0, $left_margin, $line2vert, $white, $font, $cigline);
imagettftext($im, 8, 0, $left_margin, $line3vert, $white, $font, $moneyline);
imagettftext($im, 6, 0, $far_margin, $line1vert, $white, $font, $ml);
imagettftext($im, 6, 0, $far_margin, $line2vert, $white, $font, $mg);
imagettftext($im, 6, 0, $far_margin, $line3vert, $white, $font, $juice);
//imagettftext($im, 8, 0, $left_margin, 64, $yellow, $fontb, $quotation);

// LEAVE THESE ALONE DAMN YOU
header('Content-Disposition: filename=signature_bar.png');
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);

?>
"You can't steal code", but you can replicate someone else's ideas to the point of a punch in the nose. Dr. Marvin Cooper/ USC
 

jae

Silver Contributor
Member For 4 Years
Most of it was cribbed from examples on php.net anyway.

Fat-fingered on my Nexus 4
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Oh! That's how I code! :D
 
  • Like
Reactions: jae

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
For some reason, while I'm reading my books about all these functions and operators, I can come up with all sorts of ideas on how to use them. Once it's time to come up with code to accomplish something specific, though, my mind goes blank, and I'm off to find code snippets.

I really appreciate you finding the snippets you have and assembling them into something that works, though! :)
 
  • Like
Reactions: jae

jae

Silver Contributor
Member For 4 Years
10 print"hello"
20 goto 10

that is about as far as I ever made it, and that may even be wrong.lol
Output:
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello
etc haha

Fat-fingered on my Nexus 4
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
@jeremy, would you mind if I "borrow" your code and perhaps turn it into a hosted solution for others to use?

I can't guarantee that I'll do that, but I wouldn't mind practicing and getting better with PHP and MySQL.

Only if you don't mind.
 
  • Like
Reactions: jae

jae

Silver Contributor
Member For 4 Years
@jeremy, would you mind if I "borrow" your code and perhaps turn it into a hosted solution for others to use?

I can't guarantee that I'll do that, but I wouldn't mind practicing and getting better with PHP and MySQL.

Only if you don't mind.
Absolutely, why not!
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
Took long enough...

Unfortunately, you need to sign up in order to use it, but I'll change that, eventually.

If anyone does decide to sign up, it will be in your Member Area down on the left side under "About Me" -> "Signature".

http://mod.bid

:)
 

Emilie

Silver Contributor
Member For 4 Years
Member For 3 Years
Member For 2 Years
Member For 1 Year
Member For 5 Years
For those of you who are NOT members:

54313113b9.png


http://mod.bid/sigimage.php

:)
 
Last edited:

UncleRJ

Will write reviews for Beer!
Staff member
Senior Moderator
VU Donator
Platinum Contributor
Member For 4 Years
ECF Refugee
Reviewer
Moderator
If I ever forget my age I can just figure out my age by counting the folds/rings in my........(fill in the blank if you dare:p)
 

MrScaryZ

VU Donator
Platinum Contributor
Member For 5 Years
First rule of JavaScript - nobody learns about JavaScript
Funny thing man when I worked for Sun Microsystems (Creators of Java) They said their biggest mistake was making the slowest bloated Interpreted language of all time.. It does not matter as much today as it did since computers are multi-core but in the early days we had java apps back in the 90's they would literally take 10 minutes to start up on a high end UNIX system hahaha
 

Hobby Kid

Brighton Boy
Gold Contributor
Member For 4 Years
Funny thing man when I worked for Sun Microsystems (Creators of Java) They said their biggest mistake was making the slowest bloated Interpreted language of all time.. It does not matter as much today as it did since computers are multi-core but in the early days we had java apps back in the 90's they would literally take 10 minutes to start up on a high end UNIX system hahaha
you worked for Sun.. cool!
i don't really remember thier litle applets being slow, but then it's going back a while now. we used them on our phones. i don't keep up with it anymore but java was seen as a highly regarded language. it went like this: first learn C > delphi or asp > Java > then you're employable. times have changed
 

MrScaryZ

VU Donator
Platinum Contributor
Member For 5 Years
you worked for Sun.. cool!
i don't really remember thier litle applets being slow, but then it's going back a while now. we used them on our phones. i don't keep up with it anymore but java was seen as a highly regarded language. it went like this: first learn C > delphi or asp > Java > then you're employable. times have changed
Yep worked for Sun for 3 years :) ask me who I have not worked for would be the best question hahaha .....
 

VU Sponsors

Top