Blog
Google-Like Compression
2011 Apr 30 08:15 PM MDT | PHP4 Programming18 Web13 [2011]8 | Estimated 1-min read
I have a PHP object buffer callback that allows you to compress your PHP like Google:
<?php
function op_handler($buffer, $mode) { // overpowered handler xD
// tabs
$buffers = explode("</script>", $buffer);
foreach($buffers as &$buffer) {
$tabsearch = array(
'/[\t]+/' => '', // strip tabs
'/\s+/' => ' ', // multi-spaces
);
$jssearch = array(
'/\s+<!--/' => '<!--', // comment start
'/-->\s+/' => '-->', // comment end
);
$buffer = explode("<script", $buffer, 2);
$buffer[0] = preg_replace(array_keys($tabsearch), array_values($tabsearch), $buffer[0]);
$buffer[1] = preg_replace(array_keys($jssearch), array_values($jssearch), $buffer[1]);
$buffer = implode("<script", $buffer);
}
$buffer = implode("</script>", $buffers);
// gzip!
return ob_gzhandler($buffer, $mode);
}
ob_start("op_handler");
// ...output the page here...
It does tries to compress it by stripping tabs and compacting spaces without affecting the *<script>* tags. Then it gzips it using Apache's mod\_deflate.
Domain Seizures
2011 Mar 28 12:27 PM MDT | DNS1 Domains2 Programming18 Web13 [2011]8 | Estimated 1-min read
I have noticed that seized domains all have one thing in common; their nameservers are:
ns1.seizedservers.com (74.81.170.109)
ns2.seizedservers.com (74.81.170.108)
and result in an A record to [74.81.170.110](http://74.81.170.110).
Just for fun, I have set up a record pointing to their seizure server on one of my subdomains.
NOTE: Neither my sub-domain nor my domain has been seized.
seizure.victorz.ca → A: 74.81.170.110
If I want the entire subdomain allocated (seizure AND *.seizure), I could use NS records instead.
Dotted Notes (Music)
2011 Feb 27 03:37 PM MST | Math7 [2011]8 | Estimated 1-min read
This is a formula (equation) to calculate the length of a note:
\[\frac{2^{d+1}-1}{2^d}o\]or simply
\[(2-2^{-d})o\]Alternatively (2^(d+1)-1)o/2^d
or (2-2^(-d))o
where
- *n* is the new note value
- *d* is the number of dots
- *o* is the base (original) duration
Google App Engine's Memcache with Quercus
2011 Feb 19 05:17 PM MST | Java1 PHP4 Programming18 Web13 [2011]8 | Estimated 1-min read
Google App Engine supports Java and Python, thus supporting PHP via Quercus on Java. We can use their fast-access Memcache with code similar to the following:
<?php
import com.google.appengine.api.memcache.MemcacheService;
import com.google.appengine.api.memcache.MemcacheServiceFactory;
$service = MemcacheServiceFactory::getMemcacheService();
$service->put("key", "this is the value");
echo $service->get("key"); // outputs, "this is the value"
As you can see, the **import** keyword is nonstandard PHP but works on Quercus.
LOL Equation
2011 Feb 8 04:43 PM MST | Math7 [2011]8 | Estimated 1-min read
Try to solve this equation:
\[2a - a = a^2 - a^2 + a-2\] Read more…Salmon Run
2010 Oct 11 11:51 AM MDT | Uncategorized2 [2010]4 | Estimated 1-min read
I went to the Salmon Run on Saturday in the morning. Adams River was full of bright red salmon. Most of the salmon were smart enough to swim along the side of the river because the center is the most turbulent, making the sides require the least energy to move.
I wonder,
Why would the salmon want to swim out of the ocean into the rivers?
I stayed at a hotel in Salmon Arm that night after watching the salmon, which was the only time I had internet access for the two days. I got back at 10 PM yesterday.
New (and last) AssaultCube video
2010 Oct 8 05:37 PM MDT | C++3 Gaming7 Windows5 [2010]4 | Estimated 1-min read
I have made a new—and likely my last—AssaultCube video at youtu.be/RLfnl9fU7h4 and youtu.be/W1ej0-yjas8.
This is the very likely to be my last AssaultCube video. This video shows the changes I have made in my Vulcan Mod revision 3. I have made some changes such as crash fixes, which is solved in rev3b.
If they try to claim copyright, I will do the same and counter-claim. They can only claim copyright on this video since the other ones won the dispute. If they take this video down, it will go back up in two weeks and never down again! They might be smart enough to realize that it is pointless for them to do that unless they want two weeks without the **new** video only, they are wasting their and my time if they do it.
EDIT: AssaultCube sucks; I do not play it anymore and do not care about nor plan on blogging about it anymore.
Stride Mega Mystery Gum (Flavor)
2010 Sep 11 03:08 PM MDT | Uncategorized2 [2010]4 | Estimated 1-min read
The Stride "Mega Mystery" gum tastes like
*Watermelon, strawberry, lemon, mango and pineapple.*
“Come get sum”, noobs. In other words, “Find me noobs!!!”. Send your threats to Homeland Security or Canadian Security Intelligence Service. LOL