Rivenge's Blog
My blog contains content that may be objectionable. Some of the posts in this blog may contain strong language or (because of my religious and personal views) may be offensive to some readers. In the future I may separate my programming posts from personal posts, but for now they are all contained in this blog. I should not have to even mention this, however some readers may be looking at my blog for programming help, therefore I am giving an advanced warning. All posts with material that may be offensive contain 'Objectionable material' at the end of the post title. If you see a post with "Objectionable material" in the title, and you are closed-minded or think that you may get queasy, don't fucking read it.
Friday, July 1, 2011
2012 Presidential Candidates Comparison
The original version can be found at Google Docs at the link below.
Google Docs - 2012 Presidential Candidates
Monday, March 7, 2011
Quotes of the day (Objectionable material)
"Did you ever notice how in the Bible, whenever God needed to punish someone, or make an example, or whenever God needed a killing, he sent an angel? Did you ever wonder what a creature like that must be like? A whole existence spent praising your God, but always with one wing dipped in blood. Would you ever really want to see an angel?"
"As you walk past me everyday, meaningless words, you take pride in.
Mockery is all i think of you.
Spineless.
Useless.
You have no meaning.
You have no understanding of how small you are.
Every perspective you look at falsely.
You have no understanding of who I am, where I am from.
Believe in only what you see as real.
Not knowing, that you are merely puppets."
Saturday, November 13, 2010
Ten signs you are a Christian (Objectionable material)
I found this as an image somewhere a while back, but I don't know the author. If you can site the original source, please post it as a comment.
- You vigorously deny the existence of thousands of gods claimed by other religions, but feel outraged when someone denies the existence of your god.
- You feel insulted when scientists say that people evolved from lesser life forms, but you have no problem with the Bible claim that we were created from dirt.
- You laugh at polytheists, but you have no problem believing in a Trinity god.
- Your face turns purple when you hear of the 'atrocities' attributed to Allah, but you don't even flinch when hearing about how god slaughtered all the babies of Egypt in'Exodus' and ordered the elimination of entire ethnic groups in 'Joshua' - including women, children and animals.
- You laugh at Hindu beliefs that deify humans, and Greek claims about gods sleeping with women, but you have no problem believing that the Holy Spirit impregnated Mary, who then gave birth to a man-god who got killed, came back to life, and then ascended into the sky.
- You are willing to spend your life looking for little loopholes in the scientifically established age of the Earth (4.55 billion years), but you find nothing wrong with believing dates recorded by pre-historic tribesmen sitting in their tents guessing that the Earth is a couple of generations old.
- You believe that the entire population of this planet with the exception of those who share your beliefs (though excluding those in all rival sects) will spend eternity in an infinite hell of suffering. Yet, you consider your religion the most 'tolerant' and 'loving'.
- While modern science, history, geology and physics have failed to convice you otherwise, some idiot rolling around on the floor 'speaking in tongues' may be all the evidence you need.
- You define 0.01% as a high success rate when it comes to answered prayers. You consider that to be evidence that prayer works. And you think that the remaining 99.99% failure was simply the will of god.
- You actually know a lot less than many Atheists and Agnostics do about the Bible, Christianity and church history - but still call yourself a 'Christian".
Wednesday, September 8, 2010
Florida church plans to burn the Koran (Objectionable material)
The Florida church Dove World Outreach Center is threatening to burn copies of the Muslim Koran (the proper spelling is Qur’an) on Saturday September 11th. With this story in all the headlines, I got into a short and quick debate with a Christian who supports the burning. As an atheist, this to me is just another example of Christians at their best. One of the arguments of this Christian were that Muslims burn the American flag “all the time”, which supposedly gives Americans the right to burn the Koran. The Christian bible says:
[27] "But I tell you who hear me: Love your enemies, do good to those who hate you, [28] bless those who curse you, pray for those who mistreat you. [29] If someone strikes you on one cheek, turn to him the other also.
- Luke 6:27-29
Does burning a flag or even the acts of terrorism that took place on 9/11 justify burning the Muslim holy book? Not one, but over 200 of them? This seems like revenge to me, not forgiving and loving your enemy.
The next argument in the debate was that the Koran teaches deceit, hatred and killing of Christians. I asked if they had ever actually read the Koran. I could not get an answer to that question, so I will assume the answer is no. How do you know what the Koran says if you have never read even a part of it? Because what you heard from someone, or some nutcase in the media or wherever you may have heard it, it must be true? The Koran does not teach, nor do “all Muslims believe” in hatred or killing. A handful of extremists may have these views, but that does not make all Muslims America-hating terrorists. Extremists can be found in any religion, be it Islam, Christianity or Atheism.
I tried the access the website for the church that is causing the mayhem, the Dove World Outreach Center, but the site is down. This quote I am taking from an article posted on the Fox News website, which claims the quote came from the church’s blog.
“We are using this act to warn about the teaching and ideology of Islam, which we do hate as it is hateful.”
So – they are warning who? Warning about the dangers of someone else's beliefs? Who gave Christians the right to “warn” anybody about someone else’s beliefs? Why do Christians feel the need to convert and push their beliefs along to someone else? What happened to “free will”? Is the next person not smart enough to think for themselves therefore they need the help of a Christian to tell them what to believe?
“We do not hate any people, however. We love, as God loves, all the people in the world and we want them to come to knowledge of the truth”.
So you are going against your own beliefs by taking revenge on your enemy in order to share your version of the truth? I don’t want to get into a religious debate because most Christians tend to be close-minded. I am simply saying that Christians should know the facts, stop the “all Muslims are evil” stereotyping and stop trying to force their views on others. If I decided to burn over 200 bibles, Christians would have a fit the same way the Muslims are. You are no better than the extremist committing terrorist acts. When will everyone grow up, believe what they want and leave others do the same? By provoking more terrorism, you are only putting American soldiers and possibly innocent civilians at risk.
Sources:The fox News article
Dove World Outreach Center website
Tuesday, August 10, 2010
Creating a line graph using dates with JpGraph
- It includes many different types of charts and graphs, from your basic line and pie charts to geolocation and stock charts.
- It is flexible and very customizable
- It is well documented, and there are plenty of examples (images along with the source code) included with the download.
JpGraph uses the PHP GD library to build the graphs into images. The images can be returned and presented directly in the browser, or saved to a cache file (or both).
For my uses, I needed a line graph using dates taken from a MySQL Timestamp. I also wanted to save the images to a cache file with a timeout, to prevent a new image from being generated if a recent version already exists.
I created a new PHP file and placed the code to create the graph into its own function. This way, I can add another graph function in the file later if need-be, and I can somewhat customize the graph through the function arguments while still keeping a consistent format and not re-writing code. To keep the example as simple as possible, I am not passing the title and legend text as arguments to the function. First I will show an example of how to create and save the graph, then I will show how I used it in my page.
Source Code:function newLineGraph($cachefilename, $ydata, $xdata) { require_once ('jpgraph-3.0.7/src/jpgraph.php'); require_once ('jpgraph-3.0.7/src/jpgraph_line.php'); require_once ('jpgraph-3.0.7/src/jpgraph_utils.inc.php'); require_once ('jpgraph-3.0.7/src/jpgraph_date.php'); // First we create the graph with a size of 600 x 500. $graph = new Graph(600, 500); // Check if the image already exists in the cache and is valid $valid = $graph -> cache -> IsValid($cachefilename); if ($valid) { // The cached file exists and has not expired, so we do not // need to create a new one return; } else { // The cache file does not exists or has expired, so we // create the graph as normal // Tell the graph that we want to cache this image // with a timeout of 60 $graph -> SetupCache($cachefilename, 60); //Set the scale to use DateScale $graph -> SetScale("datlin"); //Set the text for the graph Title $graph -> title -> Set('My Date Graph'); //Enable clipping to prevent the line from extending // outside of the plot area $graph -> SetClipping(true); // Set the date format to use for the date labels $graph -> xaxis -> scale -> SetDateFormat('M-d'); // Since we're taking in dates from MySQL, we need to // convert them to time $xDates = array (); for ($i = 0; $i < sizeof($xdata); $i++) { $time = strtotime($xdata[$i]); array_push($xDates, $time); } $dateUtils = new DateScaleUtils(); // We'll let getAutoTicks calculate all of the ticks between // our min and max dates. We also set the max number of // ticks to 5.' $autoTicks = $dateUtils -> getAutoTicks($xDates[0],
$xDates[sizeof($xDates) - 1], 10); // Se the tick positions to the ones returned by getAutoTicks $graph -> xaxis -> SetTickPositions($autoTicks[1]); // Now we create the actual plot line $lineplot = new LinePlot($ydata, $xDates); $lineplot -> SetLegend('My Plot Line'); // Add the plot line to the graph $graph -> Add($lineplot); // Get the filepath where the cache file will be saved // NOTE: You MUST specify an absolute filepath here, // for example '/myCacheFiles/filename' will not work $absolutePath = (CACHE_DIR . "" . $cachefilename); // And finally, set the filepath when we call the Stroke function $graph -> Stroke($absolutePath); } }
Now that we have the graph created and saved to the cache, we can present it on the page. We will place it just as any other image in HTML, using the <img> tag. You can use any filename you wish, whether it be static or dynamic. For my purpose I chose to use a dynamic generated filename, which includes the date and hour, as well as a unique ID. If you choose to generate a filename, be sure that it is unique enough so that if the image has not expired in the cache and the browser pulls it up, it does not present the wrong data. For this example I will use a simple static filename called myFile.png. The default image type in JpGraph is .png.
Important Note: The graph must be created before anything is written to the page. Create the graph, save the filename to a variable, then use the variable in your image tag.
Another Note: I found that when I use full Timestamps directly from MySQL, the graph works for the most part, however the leftmost label disappears on the x-axis, and the right label and plot point is pushed to the left slightly. It is not a big concern, but enough to prevent a professional looking graph. I didn't spend much time trying to figure this out, as simply selecting only the date from the timestamp in the MySQL query solved the issue. I have not tried using times in place of dates, so I'm not sure if the issue is present here or not.
Source Code:<?php $ydata = array ( 11, 12, 11, 10, 10.5); $xdata = array ('2010-07-01', '2010-07-02', '2010-07-03',
'2010-07-04', '2010-07-05'); $filename = 'myFile.png'; $graph = newLineGraph($filename, $ydata, $xdata); ?> <html> <title>My Graph Page</title> <body> <img src='<?php echo $filename; ?>'></img> </body> </html>
The result:
And there ya have it, folks - a simple line graph with dates using JpGraph. Here are a few links that helped me that you may want to look in to:
- JpGraph Official Site
- Developing Professional Quality Graphs with PHP
- JpGraph API (Not from the JpGraph site, but the offical API Doc on the site doesn't seem to work at the time of writing this.)
Sunday, August 8, 2010
Get Date from MySQL Timestamp in PHP
Sometimes you need to do something with a Timestamp taken from MySQL. Whether that is formatting the Timestamp for better user readability, or to do some sort of processing with it, this can be easily accomplished by converting the Timestamp to a Date. The format of a Timestamp in MySQL is:
We can convert to a Date simply by using PHP's strtotime function:'YYYY-MM-DD HH:MM:SS'
//Normally the Timestamp would come from MySQL, but //for the example I will define it here. $timestamp = '2010-08-08 15:25:18'; echo date('D M j G:i:s Y', strtotime($timestamp)); echo '<br>'; echo date('d-m-y', strtotime($timestamp));
This will output the following lines:
Sun Aug 8 15:25:18 2010
08-08-10
Read more about the date and strtotime functions.
Thursday, July 29, 2010
PHP Exponential Decay Calculator
I've searched the web for hours looking for any kind of PHP scripts that calculate exponential decay. I was surprised not to find any, so I've written one up quickly. It's not very advanced, but it gets the job done, and it does what I need it for. It includes a simple form to enter values, and displays the result once the form is submitted. I will supply the script here for anyone to take and use. If you modify or add to it, please supply me with the new code and I will update it here for others to use as well. The formula used is:
N(t) = N0e-kt
For more help on exponential decay, I found these links to be useful to me:
- http://www.youtube.com/watch?v=HTDop6eEsaA (YouTube video)
- http://www.wtamu.edu/academic/anns/mps/math/mathlab/col_algebra/col_alg_tut47_growth.htm
Source Code:
<!-- // Exponential Decay Calculator // Original Author: Mike Burch // Created: 29 July 2010 // Description: A simple form and script to calculate exponential decay. --> <h2>Exponential Decay Calculator</h2> Formula: <b><i>N(t) = N<sub>0</sub>e<sup>-kt</sup></i></b><br> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> <table> <tr><td><b><i>t</i></b> (Initial Time)</td> <td><input type="text" name="ti" value="<?php echo @$_POST['ti']; ?>"></td></tr> <tr><td><b><i>k</i></b> (Quantity)</td> <td><input type="text" name="k" value="<?php echo @$_POST['k']; ?>"></td></tr> <tr><td><b><i>t</i></b> (New Time)</td> <td><input type="text" name="t" value="<?php echo @$_POST['t']; ?>"></td></tr> <tr><td><b><i>N<sub>0</sub></i></b> (Initial Quantity)</td> <td><input type="text" name="N0" value="<?php echo @$_POST['N0']; ?>"></td></tr> <tr><td colspan="2" align="right"><input type=submit name="calc" value="Calculate"> </td></tr> </table> </form> <?php if (isset($_POST['calc'])) { $k = $_POST['k']; $ti = $_POST['ti']; $t = $_POST['t']; $N0 = $_POST['N0']; $k = log($k) / $ti; $k = -$k * $t; $N = pow(2.718281828, -$k) * $N0; echo "Result: <b>$N</b>"; } ?> <p>How to use: If after <i><b>t</b></i> (initial time) there is <i><b>k</b></i> quantity left, how<br> much will be left after <i><b>t</b></i> (new time), with an initial quantity of <b><i>N<sub>0</sub></i></b>?</p>