Thursday, April 2, 2015

Friday, July 12, 2013

The Best Decepticon

When did the Decepticon, Soundwave, become Soundblaster?
The one who has smaller cassette tape bots in his chest.
Is Creative Technologies creating Decepticons now?

Wednesday, June 19, 2013

Faraday Shield For Multiple EZ-Link Cards

What is a Faraday Shield?
https://en.wikipedia.org/wiki/Faraday_cage

Contactless Smart Cards
Singapore, being the high-tech place it is, produces lots of cards.
Membership cards, credit cards, door access cards, contactless public transport fare (ez-link) cards.
Some of the more innovative companies produce multi-purpose cards!
The result is a Frankenstein member/credit/ez-link card.

This was great at first, I survived a long time carrying a bare minimum of 2 cards to deal with life. Suddenly, I was given an extra membership club that had a lot of benefits that I wanted to carry around too.

The Problem
However, it was also an ez-link card. The problem with that is that if you hold up your wallet to an ez-link  card reader on the bus or train station, it would throw an error as it detects multiple cards. With a loud series of beeps and flashing red lights. In a bunker somewhere, a monotone voice says, "The terrorists win"

Also, I didn't want to physically separate my cards, nor flip my wallet open like an FBI agent every other day (I had outgrown that phase).

Credits For The Solution
I first saw the design concept of a wallet-based Faraday shield at a Singapore Hack and Tell.

The hacker envisioned a time when evil hackers would go around touching butt pockets to scan for credit card information. So he sort of implemented it as a public/private facing wallet, depending on how he kept his wallet in his pants.

He had gone through several iterations, using aluminium foil, etc, before concluding that a soda can was the most ideal, in terms of weight, thickness and effectiveness.

The Implementation

  1. Buy a can of soda
  2. Drink soda
  3. Clean can
  4. Cut off the top and bottom of the can
  5. Cut a straight line across the height so that you have a sheet, instead of a tube
  6. Cut card sized pieces from the sheet
    1. Bonus points if you got it to look good



Testing
I had initially made 2 shields, to cover both sides of the new ez-link card:

| SHIELD | NEW CARD | SHIELD | OLD CARD | <- div="" scanner="">

The scanner picked up my old card. Perfect.
Boarding another bus, I flipped it around:

| OLD CARD | SHIELD | NEW CARD | SHIELD | <- div="" scanner="">

The scanner didn't pick anything up at all. It seems one shield is sufficient

| NEW CARD | SHIELD | OLD CARD | <- div="" scanner="">

Scanner picks up old card only. Done

Links
Here's a link to the results, in less than 140 characters:

Other links:

Thursday, May 30, 2013

EVA-01

A friend sent me an Evangelion related link and I went off on a wild Google chase.

Almost couldn't concentrate on my work as I was imagining wearing this:


while riding this:

Source(s):
http://internetflexin.tumblr.com/
http://cyrem.org/freewill/evangelion-superbike-to-compete-in-july/

Monday, May 20, 2013

This Is My Lorem Ipsum

A New Hope


It is a period of civil war.
Rebel spaceships, striking
from a hidden base, have won
their first victory against
the evil Galactic Empire.

During the battle, Rebel
spies managed to steal secret
plans to the Empire's
ultimate weapon, the DEATH
STAR, an armored space
station with enough power
to destroy an entire planet.

Pursued by the Empire's
sinister agents, Princess
Leia races home aboard her
starship, custodian of the
stolen plans that can save her
people and restore
freedom to the galaxy...

The Empire Strikes Back


It is a dark time for the
Rebellion. Although the Death
Star has been destroyed,
Imperial troops have driven the
Rebel forces from their hidden
base and pursued them across
the galaxy.

Evading the dreaded Imperial
Starfleet, a group of freedom
fighters led by Luke Skywalker
has established a new secret
base on the remote ice world
of Hoth.

The evil lord Darth Vader,
obsessed with finding young
Skywalker, has dispatched
thousands of remote probes into
the far reaches of space...

Return Of The Jedi


Luke Skywalker has returned to
his home planet of Tatooine in
an attempt to rescue his
friend Han Solo from the
clutches of the vile gangster
Jabba the Hutt.

Little does Luke know that the
GALACTIC EMPIRE has secretly
begun construction on a new
armored space station even
more powerful than the first
dreaded Death Star.

When completed, this ultimate
weapon will spell certain doom
for the small band of rebels
struggling to restore freedom
to the galaxy...


Thursday, April 11, 2013

Stop the Spam: Suzhou Beef Products

Just received this through WhatsApp and did a quick Google.

Best legible result is here:

Basically, it's an article that was written on 24 Oct 2012, dismissing the message as a false rumour.

If you read the message itself, it's an awesome doomsday message of anthrax-infected mad cows, which is as serious as avian flu and as infectious as SARS. All the main keywords are there.

Tuesday, February 19, 2013

Stuttering / Lagging Nexus 7 [SOLVED]

I had an issue with a badly stuttering Nexus 7.

Everything that was supposed to be "Butter" was now stuttering, lagging or downright unresponsive.

Features affected:
Screen rotate
Turning screen on / off
Volume control
Keyboard pop up
Unresponsive Application
Unresponsive OS (even the screen wouldn't switch off with the hardware button)

I Googled around, read up the Currents fix and applied it, but it still didn't work.

Android 4.2.2 rolled out, but I haven't got it yet and didn't have the patience to wait.

Growing up with MS Windows, I had a strange suspicion it had something to do with a page file or a swap file. And so I continued Googling about Android page files or swap files or minimum space issues but came up empty.

So, on a hunch, I started to delete things.

Initially, I had left 1GB of free space, just because.
And I had recently downloaded some more files, that reduced it to around 800MBs free.

Not good.

After deleting a couple of large-ish CBRs and an episode of Battlestar Galactica, I now had slightly more than 2GBs free.

And my 16GB Nexus 7 is back to its snappy self.

Conclusion: A 16GB Nexus 7 requires 2GBs of free space to run smoothly.

Sunday, February 17, 2013

Made L5 Today

I made it to L5 today.

Found a portal with only 1 resonator, half drained, in town while I was out with the family for dinner.

Perhaps the attacker had left the area, having run out of XM.

With only about 1000AP remaining to level up, I didn't do anything too fancy. Stepping into the periphery of the portal, I deployed 7 resonators and recharged the lone 8th reso which had survived.

Level up.

Satisfied, I left to rejoin my family. Thinking back, I think I forgot to hack it for resources!

Tuesday, December 18, 2012

Cleaned Up Picasa Web Albums

Today, I "cleaned" up my Picasa Web Albums of what I thought were badly named albums.
They were also showing up on my Android devices with a Picasa logo.

Obviously, I didn't heed the warning popups.
The pics on this blog are broken now, as well as some of my Google+ posts.

Dear Google,
I need a better image management tool.

Regards,

Thursday, November 8, 2012

Violation of PRIMARY KEY constraint


The gist of the conversation below is regarding a Microsoft SQL Server error, "Violation of PRIMARY KEY constraint" that happens after a move from 1 environment to another.

The application was working previously, but no longer after the move.

What could possibly go wrong?

Sensitive information have been removed, but the entirety of the conversation is here, typos and all.

[10:10:44] Gymson Viente: im encountering this.. if you have any thoughts on this
[10:10:45] Gymson Viente: Violation of PRIMARY KEY constraint 'PK_TestValues'. Cannot insert duplicate key in object 'dbo.TestValues'. The duplicate key value is (devil).
The statement has been terminated.
[10:11:11] Muhammad Yussuf: in [database name]...?
[10:11:17] Gymson Viente: yup.. hehe
[10:11:28] Muhammad Yussuf: huh, that has never happened before
[10:11:36] Muhammad Yussuf: did they move DBs or something?
[10:11:38] Gymson Viente: heheh.. its not happening in QA also
[10:11:41] Gymson Viente: prod i mean
[10:11:51] Gymson Viente: yes.. its a new server.. everything is new
[10:11:54] Gymson Viente: [a QA URL]
[10:12:08] Gymson Viente: we have moved to [hosting provider A].. from [hosting provider B]
[10:12:23] Gymson Viente: its ok suf.. im investigating it now.. see if i can find something
[10:12:29] Muhammad Yussuf: sounds like... someone forgot to set the table's last id when they moved the data
[10:12:38] Gymson Viente: hmmm..last id?
[10:12:53] Muhammad Yussuf: yeah, i forgot what it's called... the correct term
[10:13:07] Gymson Viente: its in QATest db
[10:13:25] Gymson Viente: whats the logic on this?. so that i can find it on myself
[10:13:28] Gymson Viente: ill try
[10:13:35] Muhammad Yussuf: ms sql right?
[10:13:40] Gymson Viente: yes
[10:14:11] Muhammad Yussuf: its like this, when a new table is created, internally, MSSQL saves the last primary key == 1 and increments it when a new row is created
[10:14:32] Muhammad Yussuf: but when you import data, you switch it off, so you can import your primary key too
[10:14:49] Gymson Viente: ah.. didnt know that part
[10:15:07] Gymson Viente: so whats the best solution for this?
[10:15:17] Muhammad Yussuf: after import, you're supposed to set that internal number to the last number inserted and switch on the feature again
[10:16:13] Gymson Viente: actuallly.. i had some problems also.. adding input parameters.. but i did a workaround..
[10:16:22] Gymson Viente: at the parameters side i did this
[10:16:30] Gymson Viente: SET IDENTITY_INSERT parameters ON

INSERT INTO Parameters(id, methodid, Name) VALUES(2356,134,'startDateTime')
INSERT INTO Parameters(id, methodid, Name) VALUES(2357,134,'endDateTime')
[10:16:32] Gymson Viente: and it work
[10:16:39] Gymson Viente: before.. it never allowed me to insert
[10:17:20] Muhammad Yussuf: yeah, so basically, your primary keys of that table is screwed up
[10:17:27] Gymson Viente: tsktsktsk
[10:17:36] Gymson Viente: any way to fix this suf?
[10:17:56] Muhammad Yussuf: it's mostly a DBA issue... you should forward to [our DBA]?
[10:18:22] Gymson Viente: i am trying to talk to her on this.. if she has any ideas... heheh
[10:18:29] Gymson Viente: ok.. ill work with her on this
[10:18:31] Gymson Viente: thank you suf!
[10:19:02] Muhammad Yussuf: but you understand the basic issue now? (if you need to explain to [our DBA])
[10:19:39] Gymson Viente: yeah.. when it was imported, the primary key was never turned off.. right?
[10:20:04] Gymson Viente: so that messes up everything.. is that it?
[10:21:17] Muhammad Yussuf: http://williamsportwebdeveloper.com/cgi/wp/?p=153
[10:21:24] Muhammad Yussuf: http://blog.sqlauthority.com/2010/04/04/sql-server-enable-identity-insert-import-expert-wizard/
[10:21:48] Gymson Viente: ok let me read it through
[10:22:23] Muhammad Yussuf: "This results in many errors when the web application attempts to insert new records without providing a value for the identity field because it is suppose to auto-increment"
[10:22:53] Gymson Viente: oh.. is that it?.. so the main solution for this.. is just to turn on the auto increment..
[10:23:31] Gymson Viente: but what if.. she never imported it.. she just backup and restore the DB.. that shouldnt happen right?
[10:23:38] Muhammad Yussuf: you can check, but i got a felling that it's already on... but it thinks the next number is 2, which already exists because of the import
[10:23:48] Gymson Viente: oh
[10:24:45] Muhammad Yussuf: so, the table needs to be set that the next number is 2001 or something (the number of the last pri key) so that the next row will be 2002
[10:24:45] Gymson Viente: ya ive seen its already auto increment
[10:26:23] Muhammad Yussuf: i think when you create an alter table script, it shows the next number under constraints
[10:27:07] Gymson Viente: alter to is not enable
[10:27:10] Gymson Viente: enabled
[10:29:55] Muhammad Yussuf: found it!
[10:29:56] Muhammad Yussuf: http://msdn.microsoft.com/en-us/library/aa933196(v=sql.80).aspx
[10:30:30] Muhammad Yussuf: basically alter table with a new seed. seed is the starting point. last row id. increment is 1
[10:31:36] Muhammad Yussuf: but.. if it's more than 1 or a few tables... delegate it to the DBAs...
[10:31:59] Gymson Viente: let me try to read on it
[10:32:23] Gymson Viente: which one is altering it suf?
[10:36:54] Gymson Viente: so i tried running this
[10:36:54] Gymson Viente: DBCC CHECKIDENT ('TestCases', NORESEED)
[10:37:02] Gymson Viente: it returns this
[10:37:03] Gymson Viente: Checking identity information: current identity value '12', current column value '1716'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

[10:37:14] Muhammad Yussuf: yeap
[10:37:30] Muhammad Yussuf: that confirms my suspicion
[10:37:46] Gymson Viente: so its expects.. 1716
[10:37:50] Gymson Viente: or +1
[10:37:58] Gymson Viente: the last number i see on the table is 1690
[10:38:26] Muhammad Yussuf: set your seed to 1717, to be safe
[10:38:42] Gymson Viente: a! no.. the last id i see is 1716
[10:39:03] Gymson Viente: so when entering a new entry, it should be ok righjt?
[10:39:53] Muhammad Yussuf: if you don't so the ALTER ...IDENTITY... SEED=1717,  MS SQL will try to insert a new row as prikey = 13...
[10:40:00] Muhammad Yussuf: *do
[10:40:38] Muhammad Yussuf: which may cause a pri key constraint error, as prikey row 13 may already exist due to import
[10:41:02] Gymson Viente: so i need to alter the table having identity 1777.. is it?
[10:41:18] Muhammad Yussuf: correct
[10:41:31] Muhammad Yussuf: 1717
[10:43:53] Gymson Viente: you have a script to do that?.. i couldnt find it here.. the ones i see in google are all reseeding
[10:44:50] Gymson Viente: this script
[10:44:51] Gymson Viente: DBCC CHECKIDENT
(
   TestCases,RESEED, 1717
)
[10:45:37] Gymson Viente: this is correct right?
[10:46:28] Muhammad Yussuf: not sure... :P copy a temp table to try it out... 1716 rows ain't a lot ;)
[10:46:33] Gymson Viente: hehehe
[10:46:36] Gymson Viente: ok
[10:48:09] Muhammad Yussuf: http://www.dbforums.com/microsoft-sql-server/664830-script-reset-identity-seed-identity-increment-values.html
[10:48:14] Muhammad Yussuf: http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/04d69ee6-d4f5-4f8f-a115-d89f7bcbc032/
[10:48:19] Muhammad Yussuf: http://dbaspot.com/ms-sqlserver/141929-script-alter-identity-identity-seed-identity-increment.html
[10:48:29] Muhammad Yussuf: some links i found on the topic
[10:49:01] Gymson Viente: ya this should work DBCC CHECKIDENT (tablename, RESEED, 0)
[10:49:12] Muhammad Yussuf: 0?
[10:58:09] Gymson Viente: but i think i let [our DBA] decide on this... dont want to break anything on the DB's end
[10:58:10] Gymson Viente: heheh
[10:58:50] Muhammad Yussuf: yeap, just present her the facts we found... she should know the fix and all affected tables
[10:58:58] Gymson Viente: ok... thanks suf

Tuesday, October 2, 2012

Trek 1.2 (2012) + Blackburn EX-1 Rack

Got myself a Blackburn Design EX-1 rear rack for my Trek 1.2 (2012)

Missed cycling to work with my stuff in a pannier instead of a sweaty backpack on my back.






Here's where I put it all together:
https://plus.google.com/u/0/117656446991353867555/posts/7QRMXHh13S5

Relevant Links:
http://www.trekbikes.com/us/en/bikes/road/sport/1_series/1_2/

http://www.blackburndesign.com/racks/ex-1-rack.html#.UWAtnJNTDh4

Friday, April 27, 2012

In The Clouds

Quite a bumper crop of free cloud storage this month (week?)

Dropbox offers up to 3GBs of free storage, if you tell your friends
Google Drive, the long rumoured service, finally goes live with 5GBs
SkyDrive finally got their act together and released 25GBs days before Google

My music is in Google Play,
My mobile photos are backup up regularly via Dropbox and Windows Live Mesh

What shall I keep in the massive 25GB SkyDrive that is accessible anywhere online?
(This would have been so useful back when I was in school)


Wednesday, November 23, 2011

Some Things Should Be Made Obvious #DNN


Q: What do the check boxes public role and auto assign under security roles mean and how does one use them?

A: Public role means that users can choose to "join" those roles by selecting the checkboxes for those roles at the bottom of their user profile page. Auto Assign assigns new registered users to that particular role automatically.

Snippet from: http://forums.asp.net/t/314593.aspx/1

Thursday, September 22, 2011

Package Recieved

From Chain Reaction Cycles! Yeay!

Respro Nitesight Mask (L) (which has the same specs as the City Mask)

http://www.respro.com/protection-faqs/#q2
"1. The City filter uses Dynamic Activated Charcoal Cloth (DACC) a 95% pure charcoal weave, originally developed by the U.K. Ministry of Defence for use in the protection against chemical and bacteria warfare situations. We use DACC to effectively filter out Primary pollutants associated with vehicle exhaust emissions. The DACC is laminated with medical grade non woven polypropylene material which filters particulates from the air and helps prevent them from entering the respiratory system.

The City filter offers protection against: - Hydrocarbons. e.g. Benzene; Pyrene;1,3 Butadiene. - Acid gases. e.g. Nitrogen dioxide; Sulphur dioxide. - Photo-chemical pollutants. e.g. Low level Ozone - Particulates. e.g. Black smoke; Pollen; Lead oxide. For a more comprehensive list of all the chemicals that have tested with DACC, please go to the Industrial section of the website."

According to the NEA, haze consists of:
http://app2.nea.gov.sg/psi_faq.aspx
sulphur dioxide,
nitrogen dioxide,
ozone,
carbon monoxide
particulate matter called PM10 (particulate matter of 10 microns or smaller in size)


Wednesday, August 10, 2011

Saturday, July 23, 2011

Library Book Sale

Today, I judged books by their covers.

They were categorized in broad categories in piles and with 2 kids in tow, I had not much time to browse.

The word "bicycle" on the cover? Grab.

Terry Pratchett? No brainer. Grab.

Jim Butcher / Dresden? Grab.

Grabbed John Saul for the wife.

Grabbed a book with a nice, red cover. No idea what's in it.

...and a couple more I'm sure I won't get around to reading.

But hey, $2 a book!


Friday, July 22, 2011

Going Home!

Sure is nice to go home while the sun is still shining - on a Friday too!


Monday, May 30, 2011

PortQry - The Ping For Ports

Need to find out if your port is correctly configured? Try portqry from Microsoft. It's command line and straightforward to use.


How to use:

Sunday, May 22, 2011

Wednesday, March 16, 2011

Building a Build Machine

So, these past couple of weeks, I've been tasked with building a build machine.

What's a build machine?
A build machine should automagically build your code project into something that is usable. Actually, the complete flow should be:
  1. Get Latest Codes
  2. Build Codes
  3. Deploy
  4. Test
  5. Logging
  6. Reporting
Since the keyword here is automated, that means a Scheduled Task is involved, to be executed every night so that developers can come in the next day to see how their project has performed overnight and maybe fix bugs that their new code may have introduced.
Developers go home.
Repeat.

For this post, I will concentrate on automating the first 2 tasks:
  1. Getting the latest codes; and
  2. Building codes
== THE BUILD ENVIRONMENT ==
Lucky for me, I have a dedicated machine and multiple VMs to play with, so here's the specs of my Build Machine, for a Microsoft .NET Framework 3.5 C# Web Projects:
  1. A clean install of Windows Server 2008 Standard Full x64
  2. Set it up with a Role of a Web Server with default IIS7 settings.
  3. Get the latest copy (in my case, version 3) of Microsoft's Web Platform Installer from http://www.microsoft.com/web/downloads/platform.aspx
  4. Use it to install .NET Framework 3.5 SP1


Since automating everything will probably involve several different products (eg: SVN, Microsoft Build, Deployment, FTP, etc), executing a single batch file (.bat) seems to be the best bet.

== STEP 1: GET LATEST CODES ==
Getting the latest codes is the easiest of all the above-mentioned steps, if you're using SVN.

Get the SVN command-line client from CollabNet: http://www.open.collab.net/downloads/subversion/

The command to get the latest codes is, for example:
svn checkout https://PathOfRepository C:\ProjectPath --username MyUsername --password MyPassword

There are tons of SVN commands and options.
It's well documented and has lots of real-world examples online.
Go Google it for more details.

== STEP 2: BUILD CODES ==
If you've installed .NET Framework 3.5 SP1 correctly and successfully, check out this path in Explorer:
C:\Windows\Microsoft.NET\Framework\v3.5\

You should have a nice MSBuild.exe sitting there.
No need for a copy of Visual Studio to build your project.

To build, use the following line:
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe C:\ProjectPath\MyProject.csproj

Again, MSBuild.exe can either build the Project or the Solution, so this also works:
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe C:\ProjectPath\MySolution.sln

It depends on how your Project or Solution is set up.
You will probably need to tweak your Solution or Project file, by setting up Dependencies or References in Visual Studio (the GUI really helps, instead of tweaking the csproj or sln file by hand) before MSBuild.exe performs the way you want it.

== BUILD TIPS ==
The /target or /t flag
Since I am automating a build for an end-product, I set my /target flag like so:
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /t:Rebuild C:\ProjectPath\MyProject.csproj

I use Rebuild so that MSBuild.exe always deletes old binaries and dependencies before rebuilding them.
This may take up some extra CPU cycles, but ensures that you are always building and referencing the latest codes.

The /property or /p flag
Again, since I am automating a build for an end-product, I add on my /property flag like so:
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /t:Rebuild /p:Configuration=Release C:\ProjectPath\MyProject.csproj

This ensures that the build is in a "Release" configuration, rather than a "Debug" build or some unknown, default build configuration.
Also, since this is a clean install of Windows, adding this Configuration=Release might throw an error, with an error message that looks something like a path not found.
(I forgot what was the exact error was).

Look for the missing path in your Development environment and copy it into the build machine. This should solve it.

MSBuild.exe has a ton of options, and is probably documented by developers (read: not user-friendly!) and not many real-world examples online.

Good luck using this tool!

Sunday, November 21, 2010

PHP on IIS7 on Windows 7 Home Premium

As a follow-up on my previous post, here's how to set up PHP 5.3.3 VC9 (MSI) on your newly enabled IIS7 on Windows 7 Home Premium

(The reason I'm emphasizing on Windows 7 Home Premium is because the Windows 7 Ultimate machine I have at work doesn't seem to have these kinds of problems)

Now if you run setup normally, you'd run into some weird error after selecting IIS FastCGI
Cancel PHP's setup and go back to

Start -> Control Panel -> Programs -> Turn Windows features on or off

Expand Internet Information Services -> World Wide Web Services -> Application Development Features and check CGI
Click OK and reboot your machine

Run PHP's setup again and select IIS FastCGI again. The install should go through normally now.

Enjoy!

Enable IIS7 on Windows 7 Home Premium

So I got this new PC and wanted to do some WAMP (Windows, Apache, MySQL, PHP) work on it. After 10+ years of Win XP, here I am with a Windows 7 Home Premium.

Installed Apache 2.2.17 and PHP 5.3.3 VC6 but couldn't get the 2 to talk to each other. (Apache insisted it couldn't find the PHP module)

I figured it was some bizarre permission issue that I didn't want to lose sleep over. (If you can't find something on Google within 15 minutes, it's a lost cause.)

So, I turned around and decided to try a WIMP instead. Windows, IIS, MySQL, PHP

Enough backstory. Here's how to enable IIS7 on Windows 7 Home Premium:

Start -> Control Panel -> Programs -> Turn Windows features on or off
Check the Internet Information Services once.
It'll default to a filled checkbox with the default options. It was good enough for me (for development work, not a live machine)
Click around to see what else you may need
Click OK

Windows may say it needs to restart. Go ahead.

Open up your web browser and type in http://localhost/ and the big ol' IIS7 image appears. The default root is in C:\inetpub\wwwroot\

Steps beyond this (eg: configuration, etc) is beyond the scope of this blog post.

Enjoy!

Monday, November 8, 2010

Compare MS SQL Databases

Found a tool today to help me deploy codes just that little bit faster by comparing 2 MS SQL databases.

Here's the link:

It's Freeware!

I don't think it will ALTER your databases for you. It just compares the DB structure. Doesn't compare data either, I think.

You have to resolve the differences manually and that's the way I like it.

Wednesday, November 3, 2010

MS SQL Fast SELECT a Random Row

Found this bit of code for MS SQL to quickly SELECT a random row from a table of millions of records.

SELECT TOP 1 *
FROM table_name
WHERE Primary_Key_ID = (SELECT CEILING(MAX(Primary_Key_ID) * RAND())
FROM table_name)

This is faster than the usual ORDER BY NEWID() as this method creates a temporary table (or view) with an additional column of NewIDs

The downside is that, if you have gaps in your Primary Key, you should take care of the statement returning blank rows in your code.

Friday, October 8, 2010

Dell Zino HD Windows Experience Index

Processor: 5.2
RAM: 5.9
Graphics: 3.6
Gaming Graphics: 5.2
Primary Hard Disk: 5.9

Wednesday, October 6, 2010

Posting to a Facebook Page

Just spent 6 hours with the new Facebook Graph API to figure out how to post to a Facebook Page.

Firstly, you need to register an app to get the App ID and Secret Key
(the basic app registration process is dead simple now. 2 textboxes, a drop down list and a submit button!)

This is for the portion that says "This is my status update - 6 minutes ago via Your App Name"

On the developer's end, you need to do 2 things:

1 - Provide a link for the user to click to log in to Facebook / authorize your app with the relevant permissions
a) Facebook Authorization Docs: http://developers.facebook.com/docs/authentication/
b) Extended Permissions: http://developers.facebook.com/docs/authentication/permissions/

2 - Provide a page for Facebook to return to once the User has logged in / authorized your app
a) Facebook will return the access token (code) that the developer can use to manipulate user data

Extended Permissions
==================
Seems that the 2 minimum extended permissions you will need are publish_stream and manage_pages. This should come under the "scope" querystring when doing the Authentication link, as mentioned above.

Get the authenticated User's accounts details
Note that "Accounts" refers to the Pages that the User administers
"https://graph.facebook.com/me/accounts?access_token=" + strAccessToken

Account details will return Page ID, Name, and Page Token

Note that the Page Token is different from the User's Token in the sense that if you POST something to Facebook using the User's token, the User will be reflected as the one contributing the POST. Example, "Muhammad Yussuf posted an update".

When you use the Page Token, it will look like this instead: "[Page Name] posted an update"

Publishing to Facebook Reference:

Facebook User Setup
====================
The only requirement to this is that the User must be the Owner / Creator of the Page to impersonate it. That means, the average Facebook user does not have any data under the "accounts" API call.

Other Notes:
=====================
The Facebook Graph API returns JSON only. So it's a bit of a headache to integrate with C#. Google for JSON.NET at CodePlex

Sunday, February 7, 2010

Guess What? I Just Completed Warcraft 3

With all the amount of people playing DOTA these days, I picked up an old copy of Warcraft 3 and started playing.

I realized I never really finished the Night Elf campaign. And now I have.

After so many years.

And just in time too. The PC died again today. Sigh.

Friday, January 8, 2010

What We Did

It's funny 'cos it's true. - http://xkcd.com/674/

Sunday, January 3, 2010

Two Zero One Zero

The future is here... so where are the robots and flying cars?

Sunday, November 22, 2009

Attack Of The 7 Year Old PC

Success! My PC's up and running again after buying a generic power supply ($40) from CyberActive at Sengkang Compass Point.

It's been down for almost a year as I simply couldn't find the time to go and buy one.

I have totally forgotten what crappy specs it has.

Gotta get some new parts so I can install Windows 7 RC and enjoy Aero.

2 x 1GB DDR SDRAM 266MHz at $50 each
Currently, BIOS says I have 768MB RAM.

Largest 3.5" IDE HDD I can find:
500GB at $80

A new LAN card $20
I have no idea where my current LAN card or it's driver comes from. Windows 7 and Google can't find the drivers either

That's $200 to run an OS that WILL die in March 2010

Now I'm wondering if it's worth it