Dear eBay, it’s 2014

<tldr> both eBay and PayPal should implement MANDATORY 2-step auth to protect both their buyers and sellers.</tldr>

I’ve never been a big fan of PayPal. The first ever decent money I made online was frozen by them and I never managed to recover the funds. It is the single worst payment system when it comes to sell digital goods. No matter what happens they always favor the buyer.

It is kind of OK when you sell software or ebooks:

  • When someone asks for an (un-rightful) refund for your software it sucks, but you don’t actually lose money. Also you can cancel the software’s license, if you have proper licensing
  • There are plenty of alternatives to process payments
  • You don’t have to rely on eBay’s buying power, you can just sell on your site or other marketplaces

But it sucks balls when it comes to sell products which you can’t recover after the transaction.

A couple of week ago I came up with a pretty profitable way to make money on eBay. I started selling voucher codes from cex.io. CEX is a cloud mining platform where you can buy hasing power to mine Bitcoin. You can only buy the hashing power with Bitcoin itself and Bitcoin is still fairly hard to aquire. So I was like what the hell, let’s buy a lot for cheap and try selling it on eBay for more. It is not against CEX’s nor eBay’s policy to sell such item.

And it worked. I had days where I made over £500 profit with very little effort. Nice passive income.

Then the kaka hit the fan. A bunch of “Unauthorized transaction” claims started coming in and PayPal always refunded the money to the buyers. Of course I had no way to recover my vouchers. Money down the drain.

Even at the beginning I was trying to be careful. Compared the buyer’s eBay details with their PayPal details and sent the codes to the PayPal email address. So a potential scammer should have access to all 3 accounts (eBay, PayPal, email). But its apparently wasn’t enough. It is kind of annoying that PayPal actually favors the buyer who is stupid enough to get 3 of their accounts hacked against the seller who did everything (almost) in his power to protect against scam, but that is a different story.

Since then I improved my verification method. I still do my email verification but I added 2 new ways of verification which my customers can choose from:

  1. Ask my customer for their Facebook account, if it’s match the name and the city of the PayPal details and it is relatively active I send the voucher as a Facebook message.
  2. While browsing the (surprisingly good) eBay knowledge base, I found an interesting link. This forms allows sellers to ask for the customers contact details. And guess what? eBay requires phone number on sign up. And that phone number is really hard to change. A 4 digit pin sent to the phone number and all is verified. Easy.

Well, it is not that simple. Turns out lots of people uses landline numbers for eBay so I have to call them up and ask them if they made the transaction or not. Since about 3 out of 5 times it is a hacked account this phone call takes ages. About an hour ago I had a 15 minutes conversation with a technologically impaired women explaining to her why she should use different passwords for all her accounts, and why should she change her password right now. Sigh.

So dear eBay (and PayPal): You are a billion dollar company dealing with millions and millions of transactions. Why? Why the hell aren’t you implementing a mandatory 2 step auth system? Would it so bad if both your sellers and buyers were happy and make transactions without any doubt that the person they are dealing with is legit? Would it be so bad to re-train the people in your payment review team to do something actually useful instead of clicking the “refund” button mindlessly?

</rant>

Be Sociable, Share!

I guess I’m into crypto currencies now

I was mad at myself for a long while for not getting into Bitcoin when the price was as low as $10 / btc not too long ago. I guess the main reason why I never invested is because I never fully understood the technology. To be fair I still don’t understand it 100%.

Then came the rise of “altcoins”, the alternative crypto currencies. I got especially excited about DogeCoin. What sets this currency apart from the 100s of other ones?

  1. It started as a joke, “meme” currency and I fucking loves memes
  2. It is dubbed as a “tipping” currency which encourages the flow of the money. The doge community actually donated over $30.000 for the Jamaican bobsled team so they can attend to the winter olympics
  3. Mining is relatively easy even with CPU

With all new crypto currencies there are new marketplaces where you can buy / sell coins. One thing I realized the price of coin is varies wildly depending on how much risk does the seller have to take for a given transaction.

For example: on eBay the price of doge is about £1 / 1000 coins because eBay uses Paypal and Paypal transactions are reversible, while Doge transactions aren’t.

On dogeforsale.com the price currently around £0.6 / 1000 if you buy via UK bank account. The seller still takes a little risk but not nearly as much with Paypal.

And finally there is the cheapest but most complicated way: Buy Doge with BTC. There is absolutely no risk there and you can get a 1000 coins for like £0.42. Naturally I went with this option, which raised an other issue: I have to acquire some BTC. I was using bitbargain.co.uk which is a peer to peer exchange and bought my first 0.5 BTC. Then using coinedup I exchanged them to Doges.

Now for selling i was considering dogeforsale, but got into a price war with some of the other sellers which made the price as low as it no longer worth my time to do it. So I moved on to eBay. As I mentioned selling crypto currencies via paypal is risky. The biggest risk you face is when someone is using a stolen paypal account for the purchase, then later the original owner issues a refund request. There are a few ways to protect yourself though:

  1. Only sell for eBay members with 50+ ratings (100% positive)
  2. Always ask the buyer to send his wallet address from the paypal email address to your email address (so you validate that they actually have access to the email account)

With this I made some good profit, but its still pocket money. I was started looking at profitable ways of mining BTC so I can achieve close to 100% profits. Some people says mining BTC is dead. Well turns out its not strictly true.

I found this cloud mining platform called cex.io which makes it possible to mine profitably with a relative small investment. You can purchase gigahash / sec mining power from them. When you purchase lets say 1 Gh/sec you actually own the hardware behind it (they actually deliver it to your door if you want it). If you don’t want to use the mining power anymore you can sell it back to the system.

The price of Gh/sec is fluctuating (oddly, as I see it correlates to the price of BTC which makes no sense, but whatever), at the moment its at 0.01176013 BTC / Gh. Luckily I found my old external hard drive which held my old BTC wallet with 2.3 BTC in it (talk about found money) and invested a portion of it for 100 Gh / sec. This mining power gave me about 0.02 BTC / day which equals about £7 profit daily. If I convert this to doge that will be around 17.000 doge coins and I can push that on eBay for £14-£17. If I get bored of it, or just want to cash out, I will sell back my Gh and exchange my BTC back to cash.

I’m doing this for about a month now. Lots of research, got scammed a couple of times but it kind of worth it. It is just fun to play broker with these virtual currencies. Yesterday for a little while I was a doge millionaire. Too bad you can’t get a physical, monopoly money-esque version of these coins.

Be Sociable, Share!

Booze, Drugs & Rock ‘n’ Roll

The company I’m working for, for almost 6 years (omg) now has a great tradition: Every year, around Christmas we take a trip to a random, previously undisclosed surprise location to celebrate the year behind us. This year the secret location was Rotterdam in the Netherlands. During the last day we had a treasure hunt where the company was split into 4 teams and each of these teams had to do challenges in random pubs, roaming around the city. Obviously a lot of drinking took place. At the end all 4 teams ended up in the same restaurant where a company dinner took place.

Most of us were completely wasted. I remember thinking: “Wow, these bunch of functional alcoholics built a multi-million pound company. And people actually invested money into it, what are the chances?”.

Thinking this further it made me realize that there wouldn’t be tech without booze. Just think about a tech meetup for programmers without the mandatory free beer! It would be something like the beginning of a 6th grade elementary school dance. People would stand around awkwardly interacting with no-one. We are geeks after all, we need some encouragement. Same valid with high profile tech conferences. I’m pretty sure most of the industry’s big investment deals been rooted around a couple of pints or some bubbly. Not to mention great ideas. If someone tells me the idea for stuff like Foursquare not started in a pub then I call bullshit. The original idea might have been like “Fuck, I’m wasted but still want a drink, would be nice to know where my buddies are” (just guessing). So thank you alcohol for all the good stuff (and fuck you for all the inevitable bad decisions, but that is a different story)

Speaking of Rotterdam: Drugs. I myself never been big fan of drugs. I’m not against them but had more bad experiences than good. That being said I’m smoking a joint like at least once every two months. Not for partying, just at home. I quite like how it is messing with my brain and it gives me great ideas / new perspective for existing ideas. These are not world changing ideas, but little fun ones.

One of these ideas were responsible for a little media hack we did with my designer friends, which brought us almost 400.000 facebook fans in one night. About 9-10% of hungarian people are gypsies (roma). Now back then according to the law of Hungary you could name your child whatever you wanted, there was absolutely no regulation. For some reason the roma population started giving weird names to their kids, stuff like Nintendo Lakatos, Rambo Racz and my personal favorite Casette Olah. The government realized that this is not right and they made a law that every name must be approved. The news was full of it. I was fairly high when I saw this news piece and instantly though: we should capitalize on this. Asked my friend to design some funny background and quickly hacked together a facebook app. The user must like our page to get their “Gyspy name”. The app then generated the name on the background and shared it on the user’s wall with a link back to the app. I’m not proud of it (fuck yeah I’m), but it wasn’t against FB’s terms so why not. It went viral in minutes. The morning I woke up and we were up to 150k fans. It was all over the internet. Human rights people said its racist (70% of our users were gypsies so I don’t think they were offended), there were articles about privacy, it was even mentioned on national TV. All because of a joint.

Oh by the way, if you wonder about the quality of my code for this app I wrote while high. The best way to describe it is like this: My grandpa was a builder. As most builders he liked to lay bricks while drunk. One day he was particularly drunk while he was working on my mothers house. He managed to build a wall which was bent in three different ways (think about it how). My code was just like that: functioning, but nothing to be proud of, to say the least.

Now the title says “Booze, Drugs & Rock ‘n’ Roll” so lets talk about music and programming. (and yes, I know this post is about nothing)

For me music is one of the most important things in life. I listen to a bunch of different genres but my all time love is punk. I born in a country where all national holidays are celebrating a revolution so it is understandable that I listen to the music which celebrates the revolution against the “normal”. And by punk by the way I don’t just mean the genre. I mean any song that makes you think or makes you question things that everyone in your life accepts as a dogma. For example I consider Pink’s Mr. President as a fucking great punk track. I consider punk as a guide for out of the box thinking, much like I consider Bhagavad Gita not as a holy book of Krishna but a guide to live your life. (no I’m not a Krishna believer but found the book highly refreshing compared to any western holy books)

What does it have to do with programming? Well this will be highly generalized, I know a lot of people who are exception for this, but I think there are two kinds of coders (neither of the groups is better than the other, but they are different):

(again, this is just my humble opinion and there are more exception than rule)

There are the ones who listen to electronic music. They tend to be very accurate, efficient programmers, producing good code with the tools they been told to use (in school or [insert currently trending tech know-it-all place]). Everything by the book. They are the perfect people for a late stage start up or a big company.

On the other hand there are coders who listened to music their whole life with messages like “it’s ok to be hated”. We are the people who sit at planning meetings thinking stuff like “just fucking do it already”. We tend not to follow process. We would be happy to push an alpha release without QA even seeing the product. We tend to code way faster than the 1st group however most of the time our code is not as efficient / not as scalable. We are the perfect people for an early stage start up.

For example: Lets say there is a new API, pre-release, in a load testing phase. The API is way too slow.
- A group of coders from the 1st group discussing the problem. They decide to use a profiler so they have an argument on which profiler lib to use. They decide on the profiler and implement it. Lets say the implementation takes 2 hours. They find the buggy method and fix it
- A group of coders from the 2nd group get the task to solve the problem. They sit down around one of their computers. One coder adds print(time().”\n”); statements in the code before and after each method call they think could be problematic. They find the buggy method and fix it.
Which group is right? Both! It is just the way of thinking that is different.

Ok, this post was way too long to be about nothing. Sorry about that. To close this off. here is a video which perfectly sums what i think punk is (the band it self is not a big deal but this poem is spot on, especially the last verse)

“There’s a lesson to be learned, one that I will take home,
When I return to my normal reality zone,
Punk rock has the power to change the world,
It lies in every single punk rock boy and girl,
So don’t let anyone tell you you’re not worth the earth,
These streets are your streets, this turf is your turf,
Don’t let anyone tell you that you’ve got to give in,
Cos you can make a difference, you can change everything,
Just let your dreams be your pilot, your imagination your fuel,
Tear up the book and write your own damn rules,
Use all that heart, hope and soul that you’ve got,
And the love and the rage that you feel in your gut,
And realise that the other world that you’re always looking for,
Lies right here in front of us, just outside this door,
And it’s up to you to go out there and paint the canvas,
After all, you were put on the earth to do this,
So shine your light so bright that all can see,
Take pride in being whoever the fuck you want to be,
Throw your fist in the air in solidarity,
And shout “Viva la punk, just one life, anarchy”

Be Sociable, Share!

lePunk in MarketingLand – Week #1

I’ve launched my new product about 4 weeks ago. Sales been great, but my PPC bill is bit higher than I expected. Turns out I have competition. Well, this sucks balls, but I decided that instead of throwing money at the problem I do a little experiment.

I’ve read an article on Hacker News (i can’t find it anymore, sorry) about a guy who was doing one little growth hack a day to improve user experience and income / user. I decided to do a similar thing but with marketing. To be precise free / low cost marketing. Every night during the past week I spent an hour trying out different marketing “hacks” / methods to improve my search engine rankings, build my list and generally drive traffic and sales to my site. Here is what I did:

General on-site SEO:
When I launched my product I generally just wanted to get it out there without caring too much about SEO. My site content wasn’t keyword rich and i had the same title on every page. So I spent the first night with researching keywords and updating my site. I looked at the competition’s rankings and decided on some phrases where I think I can beat them. Updated my title, keywords and description tags. Not rocket science and I can’t tell if I did it right but will see on the long term.

Building backlinks:
SEO gurus say that Google don’t really care about backlinks anymore, unless they are coming from quality sites. I call bullshit on that one. On the 2nd night I found a guy onf Fiverr who were willing to send my link to 150 social bookmarking sites for $5. I gave him 10 different variations of titles and descriptions and asked him to spread the 150 bookmarks to 100 for inner pages and 50 for my main site. He delivered the work quickly and as of today I can see the improvements. My site is well indexed and GoogleBot is a regular visitor, which is nice if I want to try different on-page SEO strategies. Also I’m now on page 4 and 5 for my main keywords.

Video link juice
Before launching my site I made a pretty good promo video using Animoto. On Wednesday I found a nice Indian fella on Fiverr who was offering to upload my video to 50 different video hosts along with my descriptions and link back to my main site for a fiver. No brainer. He delivered the job promptly and provided me with a report with links to the videos. Then I hired the guy from Tuesday to social bookmark that 50 video links creating some link juice. As of today some of the videos are actually ranking on the 1st page of Google for my main keyword. Pretty good for 10 bucks

Script directories
On Thursday I submitted my site to Hotscripts and other similar script directories. According to my previous experience with selling scripts these directories are great for traffic, but not much of a help with SEO. Also it take ages for them to approve the links, but at least its done now.

Friday
On Friday I went out drinking. Fuck the system

List building
During the Saturday hangoverness I read some basic ebooks about how list building works. Basically you build your list buy giving away something for free in exchange for the user’s email address and name, and from that point you can send offers to that email address. Sounds straight forward. For the first step I fired up my pre-existing GetResponse account and did some further integration with my site. Now if someone orders my product, or uses the contact form he automatically has the option to opt-in to my list. Also I’m segmenting my list based on where the user in the process. My labels are “Interested”, “Registered” and “Ordered”.

Wrote an ebook
During the development of my script I set up a test site which I needed to promote to validate that the script itself will be profitable for my customers. In order to do that I developed a fairly unique promotion method for Pinterest. Today I decided to write down this method in a short, 7 pages long e-book, which I’m giving away for free. Don’t look at my squeeze page, it is ugly as hell but whatever. Will pretty it up whenever I have some time.

That is it for this week. I’m dedicated to do these kind of little improvements every day up until the point when I can just shut down my PPC campaigns and rely completely on organic traffic.

Be Sociable, Share!

Facebook Hacker Cup 2013: My solutions

Task 1: Beautiful strings

When John was a little kid he didn’t have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could… he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.

Given a string s, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.

The beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn’t care about whether letters are uppercase or lowercase, so that doesn’t affect the beauty of a letter. (Uppercase ‘F’ is exactly as beautiful as lowercase ‘f’, for example.)

You’re a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?

Input
The input file consists of a single integer m followed by m lines.

Output
Your output should consist of, for each test case, a line containing the string “Case #x: y” where x is the case number (with 1 being the first case in the input file, 2 being the second, etc.) and y is the maximum beauty for that test case.

Constraints
5 ≤ m ≤ 50
2 ≤ length of s ≤ 500

My solution for this problem was fairly straight forward. Not the fastest solution I guess, but it works: get the string, count the unique alpha characters in it and add up the “beauty”

<?php
 
$content = file_get_contents("input.txt");
$content = preg_replace("/\r\n/i","\n",$content);
$rows = explode("\n",$content);
$row_count = $rows[0];
 
if (!is_numeric($row_count)){
	print("invalid input\n");
	exit();
}
 
$handle = fopen("output.txt","w+");
 
for($case=1;$case<=$row_count;$case++){
	$row = $rows[$case];
	$row = strtolower(preg_replace("/[^a-zA-Z]/i","",$row));
 
	if (!strlen($row)){
		print("Case #$case: 0\n");
		fwrite($handle,"Case #$case: 0\n");
		continue;
	}
 
	$letters = array();
	for($j=0;$j<strlen($row);$j++){
		if (!isset($letters[$row[$j]])){
			$letters[$row[$j]] = 1;
		} else {
			$letters[$row[$j]]++;
		}
	}
 
	$total_beauty = 0;
	$current_beauty = 26;
	arsort($letters);
	foreach($letters as $letter => $count){
		$total_beauty+=$count*$current_beauty;
		$current_beauty--;
	}
 
	print("Case #$case: $total_beauty\n");
	fwrite($handle,"Case #$case: $total_beauty\n");
}

Task 2: Balanced Smileys

Your friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go :(

Sometimes he puts emoticons within parentheses, and you find it hard to tell if a parenthesis really is a parenthesis or part of an emoticon.

A message has balanced parentheses if it consists of one of the following:
- An empty string “”
- One or more of the following characters: ‘a’ to ‘z’, ‘ ‘ (a space) or ‘:’ (a colon)
- An open parenthesis ‘(‘, followed by a message with balanced parentheses, followed by a close parenthesis ‘)’.
- A message with balanced parentheses followed by another message with balanced parentheses.
- A smiley face “:)” or a frowny face “:(”

Write a program that determines if there is a way to interpret his message while leaving the parentheses balanced.
Input

The first line of the input contains a number T (1 ≤ T ≤ 50), the number of test cases.
The following T lines each contain a message of length s that you got from John.
Output

For each of the test cases numbered in order from 1 to T, output “Case #i: ” followed by a string stating whether or not it is possible that the message had balanced parentheses. If it is, the string should be “YES”, else it should be “NO” (all quotes for clarity only)
Constraints
1 ≤ length of s ≤ 100

I spent quite a lot of time, about 40 minutes on this one. I ended up with a recursive function which relies on a regular expression: “/(\(.*)(:\))?(:\()?(\))/U”. This regex will match the parts of the string which are in brackets even if the parts are containing a smiley. Then it is just a loop for counting the opening and closing parentheses.

<?php
 
$content = file_get_contents("input.txt");
$content = preg_replace("/\r\n/i","\n",$content);
$rows = explode("\n",$content);
$row_count = $rows[0];
 
if (!is_numeric($row_count)){
	print("invalid input\n");
	exit();
}
 
function replace_once($haystack, $needle, $replacement){
	$pos = strpos($haystack, $needle);
	if ($pos !== false){
		return substr_replace($haystack, $replacement, $pos, strlen($needle));
	} else {
		return $haystack;
	}
}
 
function is_balanced($string){
 
	preg_match_all("/(\(.*)(:\))?(:\()?(\))/U", $string, $matches);
 
	if (count($matches) && count($matches[0])){
		$remaining = $string;
		foreach($matches[0] as $key => $val){
			$balanced = true;
 
			$remaining = replace_once($remaining, $val, "");
 
			$val = substr($val, 1, strlen($val)-2);
			$balanced = is_balanced($val);
			if (!$balanced){
				return false;
			}
		}
 
		return is_balanced($remaining);
	} else {
 
		$string = str_replace(array(":)",":("),array("",""), $string);
		$open = 0;
		for($i=0;$i<strlen($string);$i++){
			if ($string[$i] == ")"){
				if ($open > 0){
					$open--;
				} else {
					return false;
				}
			}
 
			if ($string[$i] == "("){
				$open++;
			}
		}
 
		if ($open == 0){
			return true;
		} else {
			return false;
		}
	}
 
}
 
$handle = fopen("output.txt","w+");
 
for($case=1;$case<=$row_count;$case++){
	$row = $rows[$case];
 
	if (is_balanced($row)){
		print("Case #$case: YES\n");
		fwrite($handle,"Case #$case: YES\n");
	} else {
		print("Case #$case: NO\n");
		fwrite($handle,"Case #$case: NO\n");
	}
}
 
fclose($handle);

Task 3: Find the min

After sending smileys, John decided to play with arrays. Did you know that hackers enjoy playing with arrays? John has a zero-based index array, m, which contains n non-negative integers. However, only the first k values of the array are known to him, and he wants to figure out the rest.

John knows the following: for each index i, where k <= i < n, m[i] is the minimum non-negative integer which is *not* contained in the previous *k* values of m.

For example, if k = 3, n = 4 and the known values of m are [2, 3, 0], he can figure out that m[3] = 1.

John is very busy making the world more open and connected, as such, he doesn't have time to figure out the rest of the array. It is your task to help him.

Given the first k values of m, calculate the nth value of this array. (i.e. m[n - 1]).

Because the values of n and k can be very large, we use a pseudo-random number generator to calculate the first k values of m. Given positive integers a, b, c and r, the known values of m can be calculated as follows:
m[0] = a
m[i] = (b * m[i - 1] + c) % r, 0 < i < k

Input
The first line contains an integer T (T <= 20), the number of test cases.
This is followed by T test cases, consisting of 2 lines each.
The first line of each test case contains 2 space separated integers, n, k (1 <= k <= 10^5, k < n <= 10^9).
The second line of each test case contains 4 space separated integers a, b, c, r (0 <= a, b, c <= 10^9, 1 <= r <= 10^9).

Output
For each test case, output a single line containing the case number and the nth element of m.

Well, I failed this task. Not because my solution wasn’t working. It wasn’t fast enough in some cases. I considered seed (it is not my first time on the Hacker cup) and tested it with large arrays but I missed a case when my script fails. The key speed up was when I realized that the analyzed array slices are repeating. They are repeating after every Kth element, therefor:

if ($n > $k * 2){
	$n = $k + ($n % $k) -1;
}

It gave me a huge speed up, but apparently not enough. I tried to run my script with the test cases provided by Facebook’s system and it didn’t finish in the 6 minutes limit even on the high-compute Amazon EC2 instances. Epic fail. Well next time. Anyway, my solution for task #3:

<?php
 
set_time_limit(0);
ini_set("memory_limit","2048M");
 
$content = file_get_contents("input.txt");
$content = preg_replace("/\r\n/i","\n",$content);
$rows = explode("\n",$content);
$task_count = $rows[0];
 
if (!is_numeric($task_count)){
	print("invalid input\n");
	exit();
}
 
 
for($case=0; $case < $task_count; $case++){
 
	$m = array();
 
	$tmp = explode(" ",$rows[1+$case*2]);
 
	$n = $tmp[0]; // count($m);
	$k = $tmp[1]; // known length
 
	$tmp = explode(" ",$rows[2+$case*2]);
 
	$a = $tmp[0];
	$b = $tmp[1];
	$c = $tmp[2];
	$r = $tmp[3];
 
	$m[0] = $a;
 
	for ($i=1; $i < $k; $i++){
		$m[$i] = ($b * $m[$i-1] + $c) % $r;
	}
 
	// reduce n
	if ($n > $k * 2){
		$n = $k + ($n % $k) -1;
	}
 
	print($k."\t".$n."\n");
 
	for($i=$k; $i<$n; $i++){
 
		$current_slice = array_slice($m, $i-$k, $k);
 
		asort($current_slice);
		$min = -1;
		while(true){
 
			if (empty($current_slice)){
				$min = $min+1;
				break;
			}
 
			$test = array_shift($current_slice);
 
			if ($test > $min+1){
				$min = $min+1;
				break;
			} else {
				$min = $test;
			}
		}
 
		$m[$i] = $min;
	}
 
	print("Case #".($case+1).": ".$min."\n");
 
 
}
Be Sociable, Share!

We are the worst people so far

We have the most amazing technology… “and it is wasted on the sh*ttiest generation of piece of sh*t assholes of all time”

People are stupid, they really are. Especially users. Usually I don’t mind if someone asks me stupid questions, or react to something I do rudely or stupidly. What pisses me off is when someone is not making an effort to figure out the answer by himself before asking. Or making an opposing comment on something I post without reasoning.

I own a couple of quite large communities and the users sometimes scare me. One of the communities is a Facebook fan page with like 350k, mostly Hungarian fans. To be honest the page is not aimed to the most educated audience but sometimes their stupidity freaks me out. For example yesterday I posted a funny picture about a laughing Jesus with a caption “Yes, your girlfriend is saying my name while having sex” (i believe in loads of things Jesus and the Christian god is not one of them). I expected some Christian comments but not this. One of the guys commented:

God will punish you! If I would know who are you I would beat you to death with crowbar

WTF man? That is very Christian of you. This way we will truly get your point. Rock on.

My other community is a social network built around TV shows and movies. Members can watch them, comment them, like them, etc. About 800.000 people using it monthly and the feedback is mostly positive. Then sometimes I get “error reports” like this:

“You f*cking asshole. I can’t watch Twilight on my mobile. You better fix it”

How on earth I owe you something? The service is free of charge, you haven’t lost any money by not being able to watch (the lamest ever) movie. Of course if you ask me politely I will try to figure out a solution for you but not like this.

I think these people are not behaving like this in the “real world”. I think most people don’t understand that when you are communicating with someone online is exactly the same as talking to someone on the street. You don’t say “Nice tits” to a hot girl on the street at broad daylight, but some people do comment stuff like that on Facebook. You don’t go up on the stage after an amazing guitar solo to tell the guitarist “you are a wanker, Slash is way better”, but some (apparently most) people do it on Youtube.

Anyway, sometimes I wish browsers would implement an initial IQ or EQ test before letting anyone to surf the web, even if ad revenues would drop (stupid people tend to click more ads)

Be Sociable, Share!

Howto: Install OSX Lion under Windows 7 and VMware

So I decided to learn objective C, partly because it’s been a long time since I developed anything besides web apps and partly because I have a couple app ideas in my mind. Anyway, it turns out there is no option to code for the iPhone on Windows 7 (besides Visual Studio. Thanks, but no thanks) so I decided to install OSX Lion using VMware. I read a whole bunch of tutorials on how to do it and finally succeeded. Here is a simple step by step guide so you can try it yourself

What will you need?

  1. You need a bootable OSX Lion image. Not sure how to legally acquire it but here is a link for a torrent file
  2. VMWare Workstation. Now this is a paid software but a quick search on isohunt will help you out. I recommend getting the latest version (9.0) if you can
  3. VMWare hard drive files. You can download them from here (self-extracting exe)
  4. “Additional files”. Various tools

Ready? Let’s install!

  1. Install VMware workstation. Don’t run it just yet.
  2. From “Additional files” extract “macosx_guest_vmware_7.tar.gz” and run “windows.bat” as an Administrator. This will patch VMware workstation to enable you to run OSX
  3. Start the self-extracting “Mac OS X Lion VMware Files.exe” (point #3 in the “What will you need section”
  4. Start VMware workstation and click on “Open a Virtual Machine” and browse to the folder extracted in the previous step. Open “Mac OSX Lion/Mac OS X Lion.vmx”
  5. Click on “Edit virtual machine settings” and remove the CD / DVD drive
  6. Still in “Edit virtual machine settings” click “Add…” then “Hard Disk” then “Use an existing virtual disk and browse to the downloaded OSX Lion image (the big one)
  7. Click “Power on this virtual machine” to launch the virtual machine. If it asks you a random question (can’t remember what exactly was it) answer “I copied it”
  8. The installer should start in a couple of moments. Just follow the installation steps and you are ready to go

Couple of problems / tweaks

  1. The image by default will only work with 1024×768 resolution which can be really annoying. To solve this copy “darvin.iso” from your “Sysprobs Lion Files” to an usb drive and install it on your OSX system. After the install and the reboot you will be able to choose whatever resolution you want
  2. Sound doesn’t work. I’m still trying to figure out how to solve this
  3. I tried to install OSX on my work computer which has an AMD processor but it gave me errors. There are some tutorials around the web to solve that problem, but its time consuming so I just didn’t bother. Just google the exact error message and you will be able to solve it if you really want. The method described here works perfectly for my Intel i7 desktop and my Intel i5 laptop (I guess it should work on any Intel chipset systems)

Have fun

Be Sociable, Share!

How Bandwidth is Killing Productivity

Actually the title is bit misleading. The fact is it’s not the bandwidth’s fault but the fact that most of the modern ISP’s plans comes with almost unlimited data.

I’ve moved to a new flat in early December and I was trying to move my BT broadband package with me. Turned out that the building I moved into has some internal cabling issues so BT couldn’t connect me up. I had a couple of fights between me and my landlord, and me and BT but long story short I have no hope for getting broadband in this flat. So I decided to buy one of these mobile broadband dongles. I’m lucky enough to live in a HSPA+ area so the speed is pretty good, but the data transfer is limited and the top-ups are quite expensive. They charge me £25 / 7 Gb of data, which is enough for about 5-7 days of surfing (+ bloody windows downloading it’s annoying updates). First I was really annoyed by it but then I started to realize that it is probably a good thing.

I’m a full time coder at a startup in London but I also have my own projects / freelance jobs on the side so I used to spend about 2-3 nights a week working on those projects. Since I don’t have a proper broadband connection these coding sessions became more frequent (3-4 nights a week) and the output of them was way better. Here is why (I think):

  • No more streaming videos: I have to admit that I’m addicted to TV shows. I used to spend at least 3 hours a day watching my shows. Also there is Youtube where I was just aimlessly watching random videos which I don’t even care about. At the high cost of the mobile broadband data I can’t afford this luxury => more time for actual work.
  • Facebook: I never realized before that Facebook notifications are probably the most disrupting things in the world. I always had FB open in a tab and whenever a notification came up I had to check it. And while I was at it I checked all the recent activity. There goes 30 minutes down the toilet. Then again with these data prices I learned to check Facebook way less.
  • Music: Data cap means no more Spotify, back to the good old mp3s. No more Spotify means I don’t spend hours seeking for new music (which I listen to once then never again)
  • Email: Instead of having gmail constantly open in a window and answering each email right after receiving it, I started to check it periodically. It led to less real-time conversations which saves tons of time for me.

And this list could go on, but you get the idea. The other interesting thing I realized is that I’m more willing to work on boring stuff since the change. Before I usually did the proof-of-concept kind, exciting parts of the project during weekdays and left the tweaking and the fine tuning for the more relaxed weekends. Nowdays I’m more than willing to do a boring form validation or database cleanup type of code chunk during a Wednesday evening.

Anyways: I challenge you to try out having a limited amount of data transfer for a week (install a bandwidth cap software or tether your mobile) and I guarantee you that you will produce more and better lines of code.

Disclaimer: Writing this blog post wasn’t really productive. Now I will use 500 Mb of my data allowance to stream a movie

Be Sociable, Share!

PHP header(“location”); vulnerability

Every documentation and every code piece you can find about PHP’s header(“location: ….”); function recommends using die(); after the statement, but I never realized why until a couple of days ago. Most of the times I use die(); or exit(); after redirect statements, but for some reason I forgot to do so in one of my script. I learned the hard way why is it important: someone gained partial access to my site’s admin area. Turns out you can turn off redirects in your browser and in that case the rest of the script will execute without problems. Rookie mistake, I know, but I thought it’s worth sharing

Be Sociable, Share!

Some cool and little known PHP functions / features

  1. register_shutdown_function
    Recently I was building a PHP based load balancer for handling long running (video streams, sometimes up to 1 hour) processes. My biggest problem were if the user closed the page the load balancer had to react. This handy function is the best solution for the problem. Basically it calls the callback function when the script’s execution finishes or the user closes the browser window
  2. scandir
    If you are tired of using opendir, readdir and closedir, this function is for you
  3. glob
    Even better than scandir. It will only list the files matching the pattern passed in as an argument
  4. CURLOPT_PROGRESSFUNCTION
    This is a fairly new feature of the curl library. You can specify a callback function which will be executed every time a chunk of data comes back from the remote host. Usually I’m using it to create progress bars for long running curl processes
  5. escapeshellcmd
    I’m dealing with loads of user generated files in many different languages. As you may know the golden rule: “Users are idiots” so they put spaces, quotes and many many random characters in the file names. escapeshellcmd is a really handy function to escape a command before you call exec
Be Sociable, Share!