<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Sapience Society</title>
	<atom:link href="http://blog.lococobra.com/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.lococobra.com</link>
	<description>The advice of a technological ninjician</description>
	<lastBuildDate>Fri, 06 Aug 2010 21:35:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Help Me Out?</title>
		<link>http://blog.lococobra.com/help-me-out</link>
		<comments>http://blog.lococobra.com/help-me-out#comments</comments>
		<pubDate>Fri, 06 Aug 2010 21:35:07 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Dropbox]]></category>
		<category><![CDATA[Favor]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=382</guid>
		<description><![CDATA[This will take you about 3 minutes or so, and it would be really awesome if you&#8217;d do it for me. Go to http://10minutemail.com and copy the email address that it gives you (you&#8217;ll need this a couple times). Go here: https://www.dropbox.com/referrals/NTc5OTc1OQ Sign up using some random name, the email you just copied, and a [...]]]></description>
			<content:encoded><![CDATA[<p>This will take you about 3 minutes or so, and it would be really awesome if you&#8217;d do it for me.</p>
<ol>
<li>Go to http://10minutemail.com and copy the email address that it gives you (you&#8217;ll need this a couple times).</li>
<li>Go here: https://www.dropbox.com/referrals/NTc5OTc1OQ</li>
<li>Sign up using some random name, the email you just copied, and a password you can remember for 2 minutes.</li>
<li>Download their client thingy (should start automatically)</li>
<li>Install it and log in using the email and password from before.</li>
<li>Click skip</li>
<li>Uninstall Dropbox (<a href="https://www.dropbox.com/help/41">instructions here</a>)</li>
</ol>
<p>If you did that, thank you very much! Please don&#8217;t do it multiple times, it only helps me the first time.</p>
<p>As a side note, you might just check out this &#8220;Dropbox&#8221; thing and sign up for real. It&#8217;s kind of cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/help-me-out/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automagically Load Class Files in PHP</title>
		<link>http://blog.lococobra.com/automagically-load-class-files-in-php</link>
		<comments>http://blog.lococobra.com/automagically-load-class-files-in-php#comments</comments>
		<pubDate>Fri, 06 Aug 2010 05:59:16 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[PHP Magic]]></category>
		<category><![CDATA[Classes]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=366</guid>
		<description><![CDATA[If you have very much experience with writing medium/large PHP based projects, you&#8217;ve probably run into the following annoyance: You have a bunch of classes that you use ubiquitously, some which you wrote and some which others have written. Each file has a single class in it, but since the classes are from difference sources, [...]]]></description>
			<content:encoded><![CDATA[<p>If you have very much experience with writing medium/large PHP based projects, you&#8217;ve probably run into the following annoyance:</p>
<p>You have a bunch of classes that you use ubiquitously, some which you wrote and some which others have written. Each file has a single class in it, but since the classes are from difference sources, some of their files have non-consistent naming conventions. You have to include classes into the files which use them, so you might include all of the classes in a header file, but that will cause unnecessary overhead because even unneeded classes get included in ever file which uses the header at all. The other option is to individually include only the necessary classes into the files that use them, but what a pain in the ass!</p>
<p>Fortunately there is a third option, available in PHP 5.0+; it&#8217;s called <a title="Autoloading Classes" href="http://php.net/manual/en/language.oop5.autoload.php" target="_blank">Autoloading Classes</a>. Basically, as soon as an object of a class is created for which the source file has not yet been included a function called <em>__autoload</em> is called. Using that function, we can then include the appropriate class file just before the object is created. Thus avoiding including any additional classes via a header or having to type out extra includes. So how does this magical function work?<br />
<span id="more-366"></span><br />
Here&#8217;s a simple example from the PHP site:</p>
<pre class="brush: php; gutter: false;">function __autoload($class_name) {
    require_once $class_name . '.php';
}</pre>
<p>Not bad, but rather restrictive. All it does is attempts to include a file called whateverYourClassIsCalled.php. If that file doesn&#8217;t exist.. FATAL ERROR! Here is my version, which (at least to me) seems much more robust:</p>
<pre class="brush: php; gutter: false;">function __autoload($Name)
{
    $seperators = array('.', '-', '', '_');
    $namingConventions = array(
        'class[SEP]'.$Name,
        $Name.'[SEP]class',
        $Name,
    );
    $includePath = array(
        '/includes/',
        '/secondary/path/'
    );

    foreach ($includePath as $path)
        foreach ($seperators as $sep)
            foreach ($namingConventions as $convention)
                if (is_file($file = $_SERVER['DOCUMENT_ROOT'].$path.str_replace('[SEP]', $sep, $convention).'.php'))
                    include_once ($file);
}</pre>
<p>My function searches for any of the following files inside any pre-specified includes folder.<br />
<em>class.Example.php<br />
Example.class.php<br />
Example.php<br />
class-Example.php<br />
Example-class.php<br />
Example.php<br />
classExample.php<br />
Exampleclass.php<br />
Example.php<br />
class_Example.php<br />
Example_class.php<br />
Example.php</em></p>
<p>Efficiency may take a small hit (a ten-thousandth of a second on my machine for each additional path) if you specify multiple include folders, but I think the ease of never having to specify your class files is well worth it. Also, it&#8217;s worth noting that my function is completely case-insensitive, trust me on that one.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/automagically-load-class-files-in-php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stop Hating on Longboarders</title>
		<link>http://blog.lococobra.com/stop-hating-on-longboarders</link>
		<comments>http://blog.lococobra.com/stop-hating-on-longboarders#comments</comments>
		<pubDate>Thu, 22 Jul 2010 03:19:13 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[longboard]]></category>
		<category><![CDATA[police]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=345</guid>
		<description><![CDATA[My room mate (Steven) and I went out to longboard. First we went down to this construction area that said &#8220;Road closed to through traffic&#8221;, but had a very well built hill and turn well before there was any construction. We parked and went to slide on the turn. We took one run down and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.lococobra.com/wp-content/uploads/2010/07/NoLongboarding.png"><img class="alignleft size-full wp-image-346" title="NoLongboarding" src="http://blog.lococobra.com/wp-content/uploads/2010/07/NoLongboarding.png" alt="NoLongboarding Stop Hating on Longboarders" width="323" height="100" /></a>My room mate (Steven) and I went out to longboard. First we went down to this construction area that said &#8220;Road closed to through traffic&#8221;, but had a very well built hill and turn well before there was any construction. We parked and went to slide on the turn. We took one run down and then went back to evaluate how to better take the turn. That&#8217;s when a &#8220;Police&#8221; car drove up.</p>
<p>&#8220;You aren&#8217;t allowed to be here. In a couple of weeks this road will open up and be public property but until then it&#8217;s private.&#8221;</p>
<p>We apologized and explained that we didn&#8217;t know and turned to leave. The cop seemed plenty friendly. We left, and won&#8217;t go back there until it&#8217;s open. No problem! If everyone was as polite as this, we&#8217;d have no problems.</p>
<p>Then we headed over to the Ross Complex. We parked at a C-Tran parking lot, and about a minute after parking we were approached by a security car. The driver told my room-mate that we could only stay parked there until 7:30. We agreed and went to walk up the hill. After about twenty minutes of riding a different security car stopped us and an older man said &#8220;Pick em up and head out&#8221; (talking about the longboards we were already carrying. We said, &#8220;well we can still skate in the street right? It&#8217;s public property.&#8221; He replied, &#8220;yes I suppose.&#8221;</p>
<p>A while later the second security car drove up to me and said &#8220;That doesn&#8217;t look very safe with the cars, you better go do that somewhere else.&#8221; I shrugged and said &#8220;It&#8217;s fine, we&#8217;re being careful.&#8221;</p>
<p>Then after taking just one more he stopped both my room mate and I yet again and said &#8220;You guys can&#8217;t be here, you better leave before I call the cops.&#8221;</p>
<p>We had been very careful not to ride only on public property after his initial warning so we asked, &#8220;Why? We have every right to be here, but we were just about to leave anyways.&#8221; I started towards the car. He assumed we were walking to go ride some more, and he repeated &#8220;you have to leave.&#8221; This is where the conversation took a turn for the worse. Here&#8217;s everything he said as best I remember it..</p>
<p><strong>Me:</strong> Yeah, our car is over here.. we&#8217;re leaving.<br />
<strong>Steven:</strong> We have every right to be here.<br />
<strong>Security:</strong> No you don&#8217;t, if you don&#8217;t leave I&#8217;m calling the cops.<br />
<strong>Steven:</strong> We have the same rights as bikers.<br />
<strong>Security:</strong> No you don&#8217;t. Stick around and find out because I&#8217;m going to call the police.<br />
<strong>Steven:</strong> Go ahead and call them, we&#8217;re on public property. We have every right to be here.<br />
<strong>Security:</strong> Do you pay taxes?<br />
<strong>Steven:</strong> What?? Yeah I own a business, I pay both state business and income tax.<br />
<strong>Security:</strong> Well you&#8217;re not allowed to ride here, you&#8217;re being a nuisance.<br />
<strong>Steven:</strong> How are we being a nuisance?<br />
<strong>Security:</strong> What if a car hit you?<br />
<strong>Steven:</strong> It didn&#8217;t.<br />
<strong>Security:</strong> Well what if one did?<br />
<strong>Steven:</strong> Then it would be our fault but we were being very careful. Besides, since when is being a nuisance against the law?</p>
<p>At this point I was just done. I started to walk back to the car and told Steven to do the same.</p>
<p>It&#8217;s the comment about the taxes that made me decide to write this. He assumed that just because we were on longboards we were of no use to society. This is so far from the truth. I own my own business, which means I have to pay small business taxes and pay for the full 15% income tax. Anyone who is employed has half of their income tax paid by their employer, so I actually pay way more than most people! What gives him the right to stereotype me based on how I spend my free time?</p>
<p>And this wasn&#8217;t by any means an isolated incident. This kind of thing happens all the time. We&#8217;ve gotten chased out of public parks by cops, and constantly get nasty looks by people we pass. I know I&#8217;m not by any means the stereotypical skater, but that doesn&#8217;t give anyone the right to treat me as less than any other person.</p>
<p><strong>UPDATE:</strong><br />
I just got some information about what that security officer was and wasn&#8217;t allowed to do. Here will be my response next time this happens:</p>
<ol>
<li>Take the security person&#8217;s name</li>
<li>If I&#8217;m able to, begin either recording or taking video of the confrontation, and let them know they are being recorded. This is <a href="http://gizmodo.com/5592808/why-photography-bullying-is-illegal-and-you-dont-have-to-put-up-with-it">100% legal as long as you&#8217;re on public property</a></li>
<li>Let them know that their liability insurance doesn&#8217;t cover them on public property. I know this because I did some work for an insurance broker who specifically insures security guards.</li>
<li>If they continue harassment, let them know that they can be convicted of a misdemeanor because they are not within their jurisdiction and trying to act as a public officer.</li>
<li>If they still don&#8217;t quit, call the cops.</li>
</ol>
<p>Of course, all of this only applies if it&#8217;s a private security guard and he&#8217;s on  public property, so it doesn&#8217;t help if it&#8217;s the actual police. It&#8217;s still useful information though.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/stop-hating-on-longboarders/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AT&amp;T &#8211; Slower Than Dial-Up and More Disapointing Than Ever</title>
		<link>http://blog.lococobra.com/att-slower-than-dial-up-and-more-disapointing-than-ever</link>
		<comments>http://blog.lococobra.com/att-slower-than-dial-up-and-more-disapointing-than-ever#comments</comments>
		<pubDate>Sun, 11 Jul 2010 08:08:58 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[iPhone and You Can Too]]></category>
		<category><![CDATA[AT&T]]></category>
		<category><![CDATA[fail]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=342</guid>
		<description><![CDATA[So much fail in one screenshot. No shenanigans here, no death grip. Notice the five bars? For those who don&#8217;t know why this is bad: do you remember dial-up? Dial up was 56kbps. AT&#38;T is currently charging me $30 a month for an upload speed that is slower than what I was using 10 years [...]]]></description>
			<content:encoded><![CDATA[<p><a href="../wp-content/uploads/2010/07/p_960_640_F54916EB-5D45-498B-A026-1F5FC65AA5C3.jpeg"><img class="size-full alignleft" style="margin-right: 20px; margin-bottom: 20px;" src="../wp-content/uploads/2010/07/p_960_640_F54916EB-5D45-498B-A026-1F5FC65AA5C3.jpeg" alt=" AT&T   Slower Than Dial Up and More Disapointing Than Ever" width="342" height="512" title="AT&T   Slower Than Dial Up and More Disapointing Than Ever" /></a>So much fail in one screenshot. No shenanigans here, no death grip. Notice the five bars? For those who don&#8217;t know why this is bad: do you remember dial-up? Dial up was 56kbps. AT&amp;T is currently charging me $30 a month for an upload speed that is slower than what I was using 10 years ago.</p>
<p>Apparently I fall into the &#8220;less than 2%&#8221; of AT&amp;T&#8217;s customers who are affected by <a href="http://www.wired.com/epicenter/2010/07/att-blames-slow-3g-on-alcatel-lucent-bug/" target="_blank">this glitch</a>.</p>
<p>Should I still be paying $30 even though AT&amp;T is not providing me an adequate service?</p>
<p>It seems to me like any person affected by this should not be charged for data every day that this persists, at least.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/att-slower-than-dial-up-and-more-disapointing-than-ever/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple, AT&amp;T &#8230; I am disappointed in you.</title>
		<link>http://blog.lococobra.com/apple-att-i-am-disappointed-in-you</link>
		<comments>http://blog.lococobra.com/apple-att-i-am-disappointed-in-you#comments</comments>
		<pubDate>Thu, 24 Jun 2010 20:58:47 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[iPhone and You Can Too]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[AT&T]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=337</guid>
		<description><![CDATA[June 7th &#8211; iPhone 4 is announced June 15th &#8211; Pre-orders start, I try unsuccessfully to pre-order my new iPhone that morning, and then try again that night. Success! A page showing that I did in fact reserve my new phone, and some instructions on what information to bring, when, etc&#8230; June 24th &#8211; 5:00 [...]]]></description>
			<content:encoded><![CDATA[<p>June 7th &#8211; iPhone 4 is announced</p>
<p>June 15th &#8211; Pre-orders start, I try unsuccessfully to pre-order my new iPhone that morning, and then try again that night. Success! A page showing that I did in fact reserve my new phone, and some instructions on what information to bring, when, etc&#8230;</p>
<p>June 24th &#8211; 5:00 AM &#8211; Wake up after only several hours of sleep.</p>
<p>June 24th &#8211; 6:15 AM &#8211; Arrive at the Apple store at Pioneer Place, get into line.</p>
<p>June 24th &#8211; 6:20 AM &#8211; I&#8217;m very sick to my stomach, probably due to an overdose of allergy medication.</p>
<p>June 24th &#8211; 10:00 AM &#8211; My friend and I are told that our pre-orders didn&#8217;t go through, and that we should go home. Apparently our reservations were only valid if we received an email about them. When asked, an employee at the Apple store tells me that my best bet is to order the phone online, and that it will probably arrive in the later half of July.</p>
<p>There are so many things wrong with this.</p>
<ol>
<li>How was I supposed to know that I should have gotten an email? This seemingly crucial piece of information was never at any point given to me.</li>
<li>Why did I see that my pre-order went through successfully when it didn&#8217;t? This one is probably AT&amp;T&#8217;s fault and this time it&#8217;s inexcusable.  This is the FOURTH iPhone launch. Every time it gets bigger, and every time both AT&amp;T and Apple are woefully under-prepared.</li>
<li>Why didn&#8217;t the Apple store employees check the pre-orders as people showed up? It really goes to show you the way that Apple operates that they would wait for four hours before getting around to tell you that you&#8217;re screwed.</li>
</ol>
<p>The hidden subtext is:</p>
<p>Apple knows that they don&#8217;t even have to try to get people to buy their products. They have already sufficiently hyped the new iPhone, and at this point any delays will just cause customers to want the phone even more. What they&#8217;re not thinking about is: while this is true, most people (including myself) who had similar experiences will still buy the new phone if they were originally intending to.. all it&#8217;s doing is pissing people off! Apple doesn&#8217;t care! A year to prepare for this launch and they can&#8217;t even keep up with the (predictably obviously insane) demand. I feel like this is just bullshit marketing. I don&#8217;t like being pushed around!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/apple-att-i-am-disappointed-in-you/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate Javascript Bookmarklets Using A Simple PHP Function</title>
		<link>http://blog.lococobra.com/generate-javascript-bookmarklets-using-a-simple-php-function</link>
		<comments>http://blog.lococobra.com/generate-javascript-bookmarklets-using-a-simple-php-function#comments</comments>
		<pubDate>Wed, 09 Jun 2010 19:42:52 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[PHP Magic]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[Bookmarklet]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=327</guid>
		<description><![CDATA[I wrote a pretty simple PHP function for converting Javascript into a bookmarklet. As you&#8217;ll see, it&#8217;s nothing too crazy. I did come up with a kind of interesting way of shortening the source using base 64. I don&#8217;t know if I&#8217;m the first person to do this, but I came up with the idea [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a pretty simple PHP function for converting Javascript into a bookmarklet. As you&#8217;ll see, it&#8217;s nothing too crazy. I did come up with a kind of interesting way of shortening the source using base 64. I don&#8217;t know if I&#8217;m the first person to do this, but I came up with the idea on my own (no plagiarism!). Unfortunately, it&#8217;s not IE compatible.. so there&#8217;s a switch to turn that feature off (if you want). <span id="more-327"></span></p>
<p>Here&#8217;s the PHP function:</p>
<pre class="brush: php;">function Bookmarkletize($source, $ieCompatible = false){
	$source = preg_replace('~[\t\r\n]~', '', $source);
	$source1 = 'javascript:'.rawurlencode($source);
	if($ieCompatible) return $source1;
	$source2 = 'javascript:eval(atob(\''.base64_encode($source).'\'))';
	if(strlen($source1) &lt; strlen($source2))
		return $source1;
	else
		return $source2;
}</pre>
<p>As an example, you can try &#8220;Bookmarkletizing&#8221; the source for the form hijacker I previously posted about. Here&#8217;s what that would look like:</p>
<pre class="brush: php;">$source = &lt;&lt;&lt;source
var index=prompt('Form index?', '0');
if(confirm('The action url is:\\n'+document.forms[index].action.substr(0,100)+'\\n\\nDoes that look right?')){
	document.forms[index].action='https://lococobra.com/showreq.php';
	document.forms[index].submit();
}
source;

echo Bookmarkletize($source);</pre>
<p>(syntax might look funny, it&#8217;s just because the PHP highlighting wordpress plugin I&#8217;m using doesn&#8217;t support Heredoc string quoting)</p>
<p>Hope this is useful for someone!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/generate-javascript-bookmarklets-using-a-simple-php-function/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Form Request Hijacker Javascript Bookmarklet</title>
		<link>http://blog.lococobra.com/form-request-hijacker-javascript-bookmarklet</link>
		<comments>http://blog.lococobra.com/form-request-hijacker-javascript-bookmarklet#comments</comments>
		<pubDate>Sat, 05 Jun 2010 00:06:09 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[PHP Magic]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[hijack]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=322</guid>
		<description><![CDATA[The idea: Lets say you want to use some service hosted at another site, but there isn&#8217;t an API or anything.. just a user-accessible form. Well, in order to use that form, you&#8217;re going to have to use something like cURL to submit some POST variables or something to the form handler. Here&#8217;s the problem: [...]]]></description>
			<content:encoded><![CDATA[<p>The idea: Lets say you want to use some service hosted at another site, but there isn&#8217;t an API or anything.. just a user-accessible form. Well, in order to use that form, you&#8217;re going to have to use something like cURL to submit some POST variables or something to the form handler. </p>
<p>Here&#8217;s the problem: What information is actually getting submitted with the form?</p>
<p>The only way to form your curl request is if you know every single bit of data that&#8217;s getting sent to the form. You could do this with a tool like the &#8220;Web Developer&#8221; add-on for Firefox, but then if there&#8217;s some onsubmit javascript that affects the form in any way, you don&#8217;t get those changes.</p>
<p>My solution: Using javascript, hijack the form and have it submit to a custom URL which will then tell you any variables sent through the headers.<span id="more-322"></span></p>
<p>The original javascript:</p>
<pre>var index=prompt('Form index?', '0');
if(confirm('The action url is:\\n'+document.forms[index].action.substr(0,100)+'\\n\\nDoes that look right?')){
	document.forms[index].action='https://lococobra.com/showreq.php';
	document.forms[index].submit();
}</pre>
<p>As you (maybe) can see, the code targets the Xth form on the page you&#8217;re currently on, tells you where the form submits to (so you can submit to that url in cURL), and finally, submits the form to another script located at &#8216;http://trappar.net/showreq.php&#8217;.</p>
<p>Lets make that into a bookmarklet! (Take a look <a href="http://blog.lococobra.com/generate-javascript-bookmarklets-using-a-simple-php-function">at this</a> to see how I made it)</p>
<pre>javascript:eval(atob('dmFyIGluZGV4PXByb21wdCgnRm9ybSBpbmRleD8nLCAnMCcpO2lmKGNvbmZpcm0oJ1RoZSBhY3Rpb24gdXJsIGlzOlxuJytkb2N1bWVudC5mb3Jtc1tpbmRleF0uYWN0aW9uLnN1YnN0cigwLDEwMCkrJ1xuXG5Eb2VzIHRoYXQgbG9vayByaWdodD8nKSl7ZG9jdW1lbnQuZm9ybXNbaW5kZXhdLmFjdGlvbj0naHR0cHM6Ly9sb2NvY29icmEuY29tL3Nob3dyZXEucGhwJztkb2N1bWVudC5mb3Jtc1tpbmRleF0uc3VibWl0KCk7fQ=='))</pre>
<p>Here&#8217;s that in a link, if that helps: <a href="javascript:eval(atob('dmFyIGluZGV4PXByb21wdCgnRm9ybSBpbmRleD8nLCAnMCcpO2lmKGNvbmZpcm0oJ1RoZSBhY3Rpb24gdXJsIGlzOlxuJytkb2N1bWVudC5mb3Jtc1tpbmRleF0uYWN0aW9uLnN1YnN0cigwLDEwMCkrJ1xuXG5Eb2VzIHRoYXQgbG9vayByaWdodD8nKSl7ZG9jdW1lbnQuZm9ybXNbaW5kZXhdLmFjdGlvbj0naHR0cHM6Ly9sb2NvY29icmEuY29tL3Nob3dyZXEucGhwJztkb2N1bWVudC5mb3Jtc1tpbmRleF0uc3VibWl0KCk7fQ=='))">Bookmarklet</a></p>
<p>Now what does that new action URL do? It shows you all of the header variables that were sent through the form. Here&#8217;s the code for that page (PHP)</p>
<pre>&lt;?
$vars = array('$_GET', '$_POST', '$_REQUEST', '$_FILES');
foreach($vars as $var)
	eval('if(count('.$var.') &gt; 0) echo \'&lt;h3&gt;'.$var.'&lt;/h3&gt;&lt;pre&gt;\'.var_export('.$var.',true).\'&lt;/pre&gt;\';');
?&gt;</pre>
<p>Voila! With one click you can take over any form and find out exactly what it&#8217;s doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/form-request-hijacker-javascript-bookmarklet/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manually Mask Rounded iPhone Icons for Stacks/Categories</title>
		<link>http://blog.lococobra.com/manually-mask-iphone-icons-for-stackscategories</link>
		<comments>http://blog.lococobra.com/manually-mask-iphone-icons-for-stackscategories#comments</comments>
		<pubDate>Fri, 12 Feb 2010 06:11:34 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[iPhone and You Can Too]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[jailbreak]]></category>
		<category><![CDATA[mod]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=317</guid>
		<description><![CDATA[I&#8217;m writing this post because I was not able to find anything remotely close to solving this problem elsewhere. The goal (for me, but there are other uses): custom theme stacks icons so that dock reflections work properly. There are more reasons to do this though, such as making icons display correctly in categories. You [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this post because I was not able to find anything remotely close to solving this problem elsewhere.</p>
<p>The goal (for me, but there are other uses): custom theme stacks icons so that dock reflections work properly. There are more reasons to do this though, such as making icons display correctly in categories. You could also use this to fix jailbroken apps which don&#8217;t have nice iPhone style icons.</p>
<p><span id="more-317"></span></p>
<ol>
<li>Locate your app&#8217;s folder. If the target app is a stock/jailbroken one, you&#8217;re going to look in /private/var/stash/Applications/yourApp. If it&#8217;s an AppStore app, look in /private/var/mobile/Applications (you just have to look through the folders to find it).</li>
<li>Get the app&#8217;s icon. Inside the app&#8217;s folder you&#8217;ll find another folder called &#8220;appname&#8221;.app, inside this folder look for a file called &#8220;icon.png&#8221;. If you can&#8217;t find that, you can look at Info.plist which should give you the name of the icon file.</li>
<li>Copy the icon to your machine.</li>
<li>Try to look at it. If you can see the icon skip to step 7.</li>
<li>This is the mac-only solution. I don&#8217;t know what to do if you&#8217;re trying to do this on a windows machine. It looks like your icon is encoded with apple&#8217;s weird proprietary format. That won&#8217;t work, so you need to fix it. Go <a href="http://www.cyberhq.nl/2007/07/05/iphone-png-fixer-upper.html">here</a> and download the link in the 2nd response.</li>
<li>Open a terminal window and run ./fixpng &#8220;path/to/icon.png&#8221; &#8220;path/to/fixedicon.png&#8221; &#8211; hopefully you&#8217;ll now have a readable png image.</li>
<li>We&#8217;re going to need the mask images that the iPhone OS uses. These are located on the iPhone at /System/Library/Frameworks/UIKit.framework/Other.artwork. Copy the &#8220;Other.artwork&#8221; file to your machine.</li>
<li>To extract this file we&#8217;ll use another tool. Go download <a href="http://modmyi.com/forums/skinning-themes-discussion/665281-iphoneshop-3-0-import-export-artwork-files-3-0-a.html">iPhoneShop</a>. (you will need the latest version of the java runtime installed too)</li>
<li>Put the Other.artwork file into the same folder as iPhoneShop, and create a new directory called &#8220;pngs&#8221;</li>
<li>Use the following command to extract the Other.artwork file &#8211; &#8220;java -jar iPhoneShop-0.6.jar ARTWORK Other.artwork export pngs&#8221;</li>
<li>The three files you will want are &#8220;AppIconMask.png&#8221;, &#8220;AppIconOverlay.png&#8221;, and &#8220;AppIconShadow.png&#8221;.</li>
<li>Open your image editing program of choice, and open the app icon you grabbed. I used Photoshop CS4</li>
<li>Change the size of the icon to 59&#215;60 with the icon at the top center.</li>
<li>Add the AppIconShadow behind the app icon layer, and the AppIconOverlay on top of it</li>
<li>Add the AppIconMask as a layer mask to both the icon and the AppIconOverlay. In Photoshop this is done by clicking the layer mask and using Image/Apply Image&#8230;</li>
<li>Depending on the app, you may or may not need to use the AppIconOverlay, just check what looks right visually</li>
<li>Save the icon as a PNG with the alpha layer. In Photoshop you can do this by using &#8220;Save for Web &amp; Devices&#8230;&#8221; and then save as a PNG-24 with transparency enabled.</li>
<li>Now, either make a theme (I&#8217;m not going to describe how to do that) or overwrite the icon_b.png file in each stacks directory (located in /private/var/stash/Applications/Stack#.app with your new icon.</li>
</ol>
<p>Ta-da, success! I&#8217;m pretty much positive that almost no one will be able to follow this whole tutorial&#8230; but I&#8217;ll be happy to answer any questions you might have.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/manually-mask-iphone-icons-for-stackscategories/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Enter to Win One of Three Google Wave Invite Packs</title>
		<link>http://blog.lococobra.com/enter-to-win-one-of-three-google-wave-invite-packs</link>
		<comments>http://blog.lococobra.com/enter-to-win-one-of-three-google-wave-invite-packs#comments</comments>
		<pubDate>Thu, 12 Nov 2009 20:18:47 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[invite]]></category>
		<category><![CDATA[sweepstakes]]></category>
		<category><![CDATA[wave]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=294</guid>
		<description><![CDATA[Howdy folks. Time for some shameless self promotion! &#60;- Click Here to Enter! I just got a bunch more Google Wave invites and I&#8217;ve decided to give some away! Here&#8217;s how it works&#8230; Retweet this article (make sure you&#8217;re retweeting @jeff_way) before December 4th. Congratulations, you&#8217;ve been entered to win one of three Google Wave [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-left:20px;margin-bottom:20px;">Howdy folks. Time for some shameless self promotion!</p>
<p>&lt;- Click Here to Enter!</p>
<p><a href="http://blog.lococobra.com/wp-content/uploads/2009/11/googlewave1.jpg"><img class="alignleft size-full  wp-image-296" style="margin-right: 10px; margin-bottom: 10px; margin-top: 10px;" title="googlewave" src="http://blog.lococobra.com/wp-content/uploads/2009/11/googlewave1.jpg" alt="googlewave1 Enter to Win One of Three Google Wave Invite Packs" width="180" height="153" /></a></p>
<p>I just got a bunch more Google Wave invites and I&#8217;ve decided to give some away! Here&#8217;s how it works&#8230;</p>
<ol>
<li> Retweet this article (make sure you&#8217;re retweeting @jeff_way) before December 4th.</li>
</ol>
<p>Congratulations, you&#8217;ve been entered to win one of three Google Wave invite packs! Winners will be chosen on Nov 20, Nov 27, and Dec 4. Each winner will receive the following.</p>
<ul>
<li>One direct instant activation link to join Google Wave</li>
<li>Four Google Wave nominations for your friends (they take a bit longer)</li>
</ul>
<p>Enter now! I&#8217;ll be tweeting the three winners names as I draw them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/enter-to-win-one-of-three-google-wave-invite-packs/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Variable Variables and Reference Arrays in Use</title>
		<link>http://blog.lococobra.com/php-variable-variables-reference-arrays</link>
		<comments>http://blog.lococobra.com/php-variable-variables-reference-arrays#comments</comments>
		<pubDate>Wed, 23 Sep 2009 18:37:27 +0000</pubDate>
		<dc:creator>lococobra</dc:creator>
				<category><![CDATA[PHP Magic]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://blog.lococobra.com/?p=220</guid>
		<description><![CDATA[PHP Variable Variables and Reference Arrays in UseSomething I haven&#8217;t talked about a whole lot on here is that I&#8217;m actually a professional PHP developer. It&#8217;s my job, so usually I don&#8217;t mix work and online stuff. This is pretty cool though, so I want people to be able to find it if they&#8217;re trying [...]]]></description>
			<content:encoded><![CDATA[<a href='http://blog.lococobra.com/php-variable-variables-reference-arrays' class='retweet vert' startCount = '0' target = '_blank' >PHP Variable Variables and Reference Arrays in Use</a><p>Something I haven&#8217;t talked about a whole lot on here is that I&#8217;m actually a professional PHP developer. It&#8217;s my job, so usually I don&#8217;t mix work and online stuff. This is pretty cool though, so I want people to be able to find it if they&#8217;re trying to figure out how to do it. Be warned, if you&#8217;re not a PHP coder the following post will make ZERO sense to you <img src='http://blog.lococobra.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' title="PHP Variable Variables and Reference Arrays in Use" /> </p>
<p>Before I get into what a &#8220;reference array&#8221; is (I made that term up) let me guide you through the discovery and some practical uses of the theory around references. A while ago I was looking for a way to do something in code that didn&#8217;t seem very possible. I wanted to do this:</p>
<pre class="brush: php;">$var1 = 'Hello World';
echo $&quot;var1&quot;;</pre>
<p>Problem is, that doesn&#8217;t work.. instead I found that you can use variable variables (also known as dynamic variables)<br />
<span id="more-220"></span></p>
<h3>Variable Variables</h3>
<pre class="brush: php;">$var1 = 'Hello World';
$var2 = 'var1';
echo $$var2;
Output: Hello World</pre>
<p>So how does that code work? PHP parses the inside string and evaluates which outside string to call.</p>
<pre class="brush: php;">IF: $var1 = 'Hello World';
$var2 = 'var1';
THEN: $var1 == $$var2</pre>
<p>But what&#8217;s the practical use? Why on earth would we call a variable that way? When could there possibly be a situation where you don&#8217;t already know the name of the variables you&#8217;re accessing? I&#8217;ll tell you with an example, it&#8217;s one of my favorite pieces of code I&#8217;ve ever written. It&#8217;s short and elegant and would probably be used by 80% of developers if they knew about it.</p>
<pre class="brush: php;">
foreach($_REQUEST as $key=&gt;$elem)
	$$key = $elem;</pre>
<p>That code takes every $_GET, $_POST, and $_COOKIE variable and converts it like this:</p>
<pre class="brush: php;">IF: $_POST['foo'] = 'bar';
THEN: $foo = 'bar';</pre>
<p>Form processing just became so much easier! Plus if you want you can add trim and stripslashes to make form processing even easier&#8230;</p>
<pre class="brush: php;">foreach($_REQUEST as $key=&gt;$elem)
	$$key = trim(stripslashes($elem));</pre>
<p>This is all well and good, but there&#8217;s still a completely different way to do all this.</p>
<h3>Using References</h3>
<pre class="brush: php;">$var1 = 'Hello World';
$var2 = &amp;$var1;
echo $var2;
OUTPUT: Hello World</pre>
<p>In that code, $var2 is created as a reference to $var1, meaning the two can be used interchangeably. You can reassign the value of either $var1 or $var2 and both variables will reflect the change. What&#8217;s interesting is, references can not be used to do the code I wrote earlier! Anyways, one more example before we get to reference arrays.</p>
<pre class="brush: php;">$var1 = 'Hello';
$var2 = ', ';
$var3 = 'World';
$varArr = array(&amp;$var1, &amp;$var2, &amp;$var3);
$var1 = 'Goodbye';
$var2 = ' Cruel ';
foreach($varArr as $item)
	echo $item;
OUTPUT: Goodbye Cruel World</pre>
<p>What&#8217;s important here? You can use references to create an array which will always reflect the current information being stored in other variables. This can still be replicated by the double string approach though. Example:</p>
<pre class="brush: php;">$var1 = 'Hello';
$var2 = ', ';
$var3 = 'World';
$varArr = array('var1', 'var2', 'var3');
$var1 = 'Goodbye';
$var2 = ' Cruel ';
foreach($varArr as $item)
	echo $$item;
OUTPUT: Goodbye Cruel World</pre>
<p> So by now if you&#8217;re still even reading you&#8217;re probably thinking &#8220;Why even use this stuff? What&#8217;s the point? Especially what&#8217;s the point of reference arrays?&#8221;</p>
<h3>Using Reference Arrays</h3>
<p>Lets say have several arrays filled with similar content, and we need to do some processing to the data in those arrays. You could combine the arrays, but what if you need them to be separate? I&#8217;ll leave you with this rather simple example. If you have questions please post comments and I&#8217;ll answer them.</p>
<pre class="brush: php;">
$fruits = array(' appLE', 'pear3', 'banana--');
$vegetables = array('pea', 'broccoli   ');
$processArr = array(&amp;$fruits, &amp;$vegetables);

foreach($processArr as &amp;$array)
	foreach($array as &amp;$item)
	{
		$item = preg_replace('/[^a-z]/i', '', $item);
		$item = ucwords(strtolower($item));
	}

echo '&amp;lt;pre&gt;';
print_r($fruits);
print_r($vegetables);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.lococobra.com/php-variable-variables-reference-arrays/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
