IdeaMonk

thoughts, ideas, code and other things...

Friday, June 27, 2008

Community based spam filtering

I encounter a Captcha. (1). at every step I try to add something to the web, or I try to participate. But sometimes it becomes a headache to keep typing screwed up words to do small small things as adding comments to websites and blogs.
I have also seen questions like 2+2=? to avoid spammers, I think this one is easy to beat. And the most promising form of online spam filter that I have ever seen, is the one used on Ajaxian. Its really creative to have questions based on common knowledge of web developer community to filter spam. Everytime you try adding a comment, it welcomes you with -

Spam Question: What three letter acronym is what we use to style web pages?
Spam Question: What does the X in Ajax stand for?

This helps you in two ways! First, you easily show the door to people who are least concerned/related to your website. and Secondly, its not easy to beat as the common knowledge of the community is an increasing function of time :P

Labels: , , ,

Adding SyntaxHighlighter to your blogger blog

Have you noticed colourful, beautified codes written in syntax highlighted format on so many blogs around the world? Here's how to get this into your own blog too -

1. If you want it to be done fast checkout FaziBear: Blogger Syntax Highlighter. You can add it as a widget on your blog. Clean and easy!

2. Now if you really want to use the real SyntaxHighlighter and wish to have greater control, the developertips article is worth reading.

3. Now as you have tried both of these, you will encounter strange extra
s and blank lines between each line. Don't worry I have a stupid hack for that. Use my negligibly modified code instead of the one mentioned at developertips.


<link href='http://[YOUR OWN PAGE].googlepages.com/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>

<script src='http://[YOUR OWN PAGE].googlepages.com/shCore.js' type='text/javascript'/>
<script src='http://[YOUR OWN PAGE].googlepages.com/shBrushCpp.js' type='text/javascript'/>
<script src='http://[YOUR OWN PAGE].googlepages.com/shBrushCSharp.js' type='text/javascript'/>
<script src='http://[YOUR OWN PAGE].googlepages.com/shBrushCss.js' type='text/javascript'/>
<script src='http://[YOUR OWN PAGE].googlepages.com/shBrushJava.js' type='text/javascript'/>
<script src='http://[YOUR OWN PAGE].googlepages.com/shBrushJScript.js' type='text/javascript'/>
<script src='http://[YOUR OWN PAGE].googlepages.com/shBrushSql.js' type='text/javascript'/>
<script src='http://[YOUR OWN PAGE].googlepages.com/shBrushXml.js' type='text/javascript'/>
<script src='http://[YOUR OWN PAGE].googlepages.com/shBrushRuby.js' type='text/javascript'/>

<script class='javascript'>
//<![CDATA[
function FindTagsByName(container, name, Tag)
{
var elements = document.getElementsByTagName(Tag);
for (var i = 0; i < elements.length; i++)
{
if (elements[i].getAttribute("name") == name)
{
container.push(elements[i]);
}
}
}
var elements = [];
FindTagsByName(elements, "code", "pre");
FindTagsByName(elements, "code", "textarea");

for(var i=0; i < elements.length; i++) {
if(elements[i].nodeName.toUpperCase() == "TEXTAREA") {
var childNode = elements[i].childNodes[0];
var newNode = document.createTextNode(childNode.nodeValue.replace(/<br\s*\/?>/gi,''));
elements[i].replaceChild(newNode, childNode);

}
else if(elements[i].nodeName.toUpperCase() == "PRE") {
brs = elements[i].getElementsByTagName("br");
for(var j = 0, brLength = brs.length; j < brLength; j++) {
var newNode = document.createTextNode("");
elements[i].replaceChild(newNode, brs[0]);
}
}
}
//clipboard does not work well, no line breaks
// dp.SyntaxHighlighter.ClipboardSwf =
//"http://[YOUR OWN PAGE].googlepages.com/clipboard.swf";
dp.SyntaxHighlighter.HighlightAll("code");
//]]>

</script>

Labels: ,

instr is indexOf in javascript

Is there any equivalent of instr of VBscript in javascript, yes there is, its called indexOf
object.indexOf (string);

this will give you position of string in the object indexed from 0. examples -
var foo="ideamonk";
document.writeln (foo.indexOf("idea"));
document.writeln (foo.indexOf("monk"));
document.writeln (foo.indexOf("nothing"));

the output is likely to be -
0
4
-1

Labels:

Thursday, June 26, 2008

“Shoot the Runner” by Kasabian

“Shoot the Runner” by Kasabian. The coolest music video I’ve seen in a while.

Labels:

Wednesday, June 25, 2008

Evil Captcha

http://i32.tinypic.com/2upqp6s.jpg

Is this the height of spam, or height of trust, or height of programmer's wild imagination. Whatever it is... its crazy!

Labels: ,

Tuesday, June 24, 2008

In love with OSX looks

After putting this midnightblue template for my blog, I've been obsessed with the looks & feels of Mac OSX Leopard. Checkout my desktop -

And all that is for free. Here's how to get the feel on your desktop/notebook
  1. Get FlyakiteOSX, its is a cool freeware to transform your windows XP look to resemble the look of Mac OS X. I got version 3.5. It will basically alter the icons, looks etc.
  2. Install RocketDock. Its free and great. You can also use RKLauncher or RKDock but, RocketDock is much better.
  3. Now for the appearance of your windows, get a patched Uxtheme.dll from softpedia. I like this Multipatcher, worked for me! Try this of that doesn't workout.
    I've always used "msstyles" rather than third party apps for customising Windows XP, these are the same format as the standard XP themes - you just need to patch a dll file (uxtheme.dll) or Windows won't allow you to install third party msstyles.

    Google "patch uxtheme.dll" if you are interested, it's fairly straight forward. I personally use a Milk theme mod called Cream (http://www.deviantart.com/deviation/3857913/) however a google search like this (http://www.google.co.uk/search?q=msstyle+tiger+xp&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official) should give you something a bit more Tiger like.

    Hey thanks for the suggestions. This works great. I got a couple that I like, but I haven't seem the cream one that you mentioned the link doesn't work.

    Here's a good FAQ if others want to do this.

    http://www.neowin.net/forum/index.php?showtopic=339820

    Here's a couple of good sites for the visual styles.

    www.Deviantart.com
    Goto Browse::customization::skins::themes::windows utilities::visual styles::sections::msstyles
  4. Get Flurry Screensaver for windows.
  5. After you have started using msstyle themes, shift the taskbar on top of the screen and let RocketDock be at bottom.
  6. Get OSX themes for Yahoo messenger, Trillian, whichever you use.
  7. Add Widgets. Widgets are desktop toys to entertain and to inform. Think of them like things you'd put on a real desk: a picture frame, a newspaper to a dancing hula girl! But they're on your PC desktop, not your real desk. You'll get it once you see it. They could be a fun addition to your boring computer. Download free widgets from the Yahoo Widgets page.
  8. Get Safari for Windows Just Get the new Safari 3 Beta, for Windows here, or get Firefox here. You can skin Firefox to look like Safari. I am using Firefox 3 with OSX skin.
  9. Change your wallpaper to look like Mac OS X Tiger: here. Or you can get a high resolution wallpaper here which won't make your computer mimic a mac desktop but will add a sense of style and a unique touch.
  10. Install your Expose from docs.kr. With this program (screen shot shows the 'Windows Vista Flip' move) you can set your Windows to spread out at the stroke of a key! A free download! You can even have Ubuntu style cube!
  11. Keep tweaking and playing. Try customizing all of the applications you downloaded. Whatever suits you!

Labels: , ,

Friday, June 20, 2008

GTA IV or some 3d Artist's work

Nopes! don't mistake it for GTA IV, its an "The Streets of memories" by Marek Denko overlayed with HUD of the game. some more -

Last one - After many unsuccessful tries to quit smoking it looks like this time it will be successfully done. I’m really curious what will I find as a alternative. As far as I know myself I think it will be kind of coke or liquirizia roots. I didn’t like the ash part of my render so I cutted it away. If you are still interested to see it then check my demoreel with camera projected picture of real ash. That one is much better. This piece took me about 2 hours of work. Rendered in Final render stage-1.
Crowd 8 - It was a boring night and I didn’t know what to do so I typed the word “inspiration” into Google and I found this page: bsimple.com. I immediately fell in love with the work of photographer Misha Gordin. I used one of the impressive photographs and I made a re-make it in 3D. Hope you like it. Original photograph by Misha Gordin. Thank you! Done in 3dsmax with Final render.
Blood series - It all started when I cut my finger by accident. I started to bleed on the paper and notes from university. I started to play with blood trying to create some nice textures. Crazy i know. And blood series were born - then it was just a quick modeling of clothes based on real references and quick light setup. Rendered in Final render stage-1. Overpainted with my blood and lot of dirt textures in Photoshop.
Waiting for spring - It took me one week of work. I tried to achieve photorealistic look. I downloaded blueprints from http://www.suurland.com/ . I took many pictures of real Fiat500L to have best references as possible. Snow beneath the car is modeled and after displaced with semi-procedural displacement map. There is all 3d except the houses in background. Rendered in Final render.
Behind the portrait of Dorian Grey - I tried to achieve a good portrait look with deep feeling. It should be the dark side of Dorian Grey. Rendered in Final r

Labels: , ,

Wednesday, June 18, 2008

Scoring High in Word Games on facebook!



Ever played TextTwirl or WordShuffle on facebook or elsewhere ?

Don't you ever! for they are very addictive as my uber player buddy from Wisconsin warns me. But what can I do, I have my own problems, I'm jobless, there's nothing to do, And I like winning the smart way.
So, what do I do! I think of C++ and a Dictionary... and poof! my weapon is ready in my mind! And soon I come up with my own little tool called WordWar.
Heres the code:

#include <iostream>
using namespace std;

int main(int argc, char *argv[]){
string word,check,cword;
int len,match,count,checksum=0,l;

if (argc>=3){
word = argv[1];
len = word.length();
for (int i=0;i<len;i++)
checksum+=word[i];

freopen (argv[2],"r+",stdin);
if (argc==4){
while (cin >> check){
check[0]=tolower(check[0]);
if (check.length()<=len &amp;&amp; check.length()>=3){
match = 1; count=0;
cword=word;
for (int i=0;i<check.length();i++){
if (cword.find(check[i]) == string::npos){
match=0;
break;
} else {
cword[cword.find(check[i])]='_';
}
}
if (match == 1)
cout << check << endl;
}
}
} else {
while (cin >> check){
if (check.length()==len){
match = 1; count=0;
for (int i=0;i<len;i++){
if (word.find(check[i]) == string::npos){
match=0;
break;
} else {
count+=check[i];
}
}
if (match == 1 &amp;&amp; count==checksum)
cout << check << endl;
}
}
}
} else {
cout << "WordWar v0.1\t\t\t(c) Abhishek Mishra\n"
<<" \t\t\t ideamonk@gmail.com\n\n"
<<"Usage : "<<argv[0]<<"> <dictionary_file>\n\n";
}
return 0;
}

For this you also need a dictionary. Download dictionary here. This is a very basic dictionary, I recommend you to get better one or try adding 's' etc to this ones results. Compile WordWar in DevCPP/MinGW32 on windows or GCC on linux. Have 1.txt (your dictionary) in the same path. and run it like this ->

enjoy scoring high!
With PHP I can also make a neat live web interface to cheat. :)
happy hacking.
http://ideamonk.googlepages.com/ddl.gif

Labels: , ,

Tuesday, June 17, 2008

Peter Griffin and Homer Simpson: how alike they are?

peter-griffin.pnghomer-simpson.png

If you’ve watched Family Guy or the Simpsons for any length of time, you’ll notice some pretty glaring similarities. Let’s list a few:

  • They’re both, uh, “big-boned.”
  • They both have long-suffering wives who for some reason put up with all their stuff.
  • Each man has three kids.
  • Both men have issues with their fathers.
  • They’ve both had a ton of very odd jobs.
  • Both are heavy drinkers.
  • Both count watching TV as their favorite thing to do.
  • Both have small attention spans and think of other things when their wives are talking to them.
  • Homer and Peter both had strokes; Peter from eating thirty hamburgers at once, Homer from eating a giant feast including a turkey.

I know there are a lot more similarities; can you think of any others?

Labels: , ,

Thursday, June 12, 2008

I am a lakhpati now! wow :|

got $69 today. That makes my total revenue since March '07 sum up to $2870 + $230(yet to come)
So, it takes me 450 days to become a lakh-pati from Adbrite. Making average $6.8 per day wasn't that hard. Thanks to my SEO skills everyday 10-15 people arrive at my $$ blog from google search alone. But now my CTR has been falling. Average revenue per day lags at $1.xx a day. So, I manage to make Rs. 1500 a month effortlessly. Thats Rs.50 a day. Hmm.. this means I don't have to ask for pocket-money anymore.
And what happened to $2870 that I got so far? Hmm..
initially 30k was wasted on broadband bills.
Some 7-8k used in flight to Bangalore.
3K for Samsung portable HDD.
30K for my Compaq Presario V6000.
Rest of the 30K saved me from being ashamed at my lavish expenditures in 1st and 2nd semester. hehe.
Its time to make some more moolah! Adbrite... here I come to plunder.




and yes! looks like my average daily is going to shoot up! $4.56 yesterday :-)

Labels:

Wednesday, June 11, 2008

Today is my lucky day!

if you are trying KAMIL problem with Ruby, go and read Variety in output...
# print is 'low level', puts
# puts adds a \n if needed
# p dumps a variable - so quotes it


so why not use 'p' instead of that puts
and we now jump to 43 bytes of code

10.times{q=1
gets.gsub(/[DTFL]/){q*=2}
p q}

I love ruby, I envy perl(best solution is of 6 bytes in perl)
people say its so because of weakness of the judge... who knows !

Bingo! SIZECON becomes 44 bytes now!
checkout change in s+=b>0?b:0

s=0;gets.to_i.times{b=gets.to_i;s+=b if b>0}
p s

Labels: , ,

KAMIL! jumping from 57 to 53 to 46!

Okay this is what made me happy about ruby -

10.times do
s=gets
p=1
s.gsub(/[DTFL]/){p*=2}
puts p
end

this made me happier :) to 53 bytes
i just remembered that Ruby is object oriented to the core!

10.times do
p=1
gets.gsub(/[DTFL]/){p*=2}
puts p
end

and some common syntax sense made it shrink to 48 bytes :))

10.times{p=1;gets.gsub(/[DTFL]/){p*=2}
puts p}

Still i know there is a shorter solution... that's the beauty of spoj.
The day ends in world rank of 1900 and 1.4 points. :)

Labels: , ,

Monday, June 09, 2008

KAMIL ... stuck at 57

Another challenge problem at SPOJ - KAMIL
interesting one, easy to figure out, but what the heck, write shortest code!
with C i could get 127 bytes code :(
Come Ruby into picture and poof! we got 57!

10.times do
s=gets
p=1
s.gsub(/[DTFL]/){p*=2}
puts p
end

looking forward for more compression... ;)

Labels: , ,

When Ruby comes to help!

Recently I have been trying to solve problems on the SPOJ online judge. Earlier I used to write in C then C++ and now in C++ andd Ruby. SIZECON is a challenge problem where you have to write the shortest code to summate positive integers give by users. The score is on how short you write.
This is where C/C++ won't help you out, you have to look foreward to how perl hackers write cryptic codes.
Heres my best solution in Ruby

s=0;gets.to_i.times{b=gets.to_i;s+=b>0?b:0}
puts s

This one gets 48. Anyone got better solutions in Ruby?
Perl hackers have written 6 byte codes... that still seems impossible :O in a way.
The best in perl I could get is
while(<>){$a+=$_>0?$_:0;}print $a;

thats 34 bytes, but sadly fails to compile on the judge :(
Anyone got better insights ?

Labels: , ,

Sunday, June 08, 2008

Poster Work @ College

in 2007 -





Labels: ,