Using Facebook PHP SDK v4 – Part 1

I always have ideas on how to do things in a different way. Facebook today is like an aggregator with loads of information that can be mined/used to generate revenue/business for various simple ideas. Facebook is an excellent portal which not only provides avenues for advertising/social fall through, but also provides for instant access to millions of possible clients. If one is interested or trying to launch business, I think Facebook is a very essential part of bringing in direct customers and being a part of the social community advert networks. Google is one such other social portal which can be used for similar purposes.

Basic idea is to allow people to register/login to your website using the credentials supplied by FB/Google, get relevant data from the different portals, correlate and make the data usable (blah blah big data, SEO and data mining stuff here), and expedite the process of knowing, acknowledging, building and scaling your business. Any idea big or small today has a need to get accepted among social groups.

I am pretty sure we are all aware of this. So was I but my laziness got the better of me and would not allow me to start taking step in that direction. And after months of deliberation, I finally have decided to venture into this field. I will not tell you what my idea is until it is partially implemented but in short, I have decided to use the social power to my advantage Smile. I started up by using my FB account and signing in as a developer (https://developers.facebook.com/).

Once logged in, click on Apps and create your new app. Now goto settings on the left hand side, add platform, select desktop and give the URL of the website you are going to use for setting up your business idea. Save changes and head over to github FB PHP SDK v4 (https://github.com/facebook/facebook-php-sdk-v4) and download the master branch. One thing to note is that you will need a webhost running PHP 5.4 for this FB SDK to work. And before you ask me why I can’t use the older one. Well, the new v4 is much better organized, totally object oriented, uses nice features of 5.4 and removes all the cluttering from 5.3.

There are quite a few hosting providers giving 5.4. For the time being, I am using www.2freehosting.com which gives me a nice subdomain free of charge. Also runs 5.4 and a host of other things. Anyways, register for something, upload the FB SDK to your account and you are ready to go. In the next part, I will show write a basic PHP page which will use the FB PHP SDK v4 to ask for certain permissions from FB and show how we can harness the power of FB. Google thing will hopefully follow later on.

All the best for your idea to fly and garner success!

Win-REPO–A custom repo tool on Windows!

I have created a tool in my free time for duplicating repo functionality on windows without using the cygwin. Cygwin basically emulates Linux ABIs on windows and is prone to errors. My tool is using native windows binaries so no ABI translation is needed.

The tool is available for download at: https://github.com/wolverine2k/win-repo/tree/master/releases. The instructions for configuration are available at: https://github.com/wolverine2k/win-repo

The tool is a WIP but still the repo init and syncs are working great. Please do spread the information as needed.

If you are open to contribution, do drop me an email!

README available on https://github.com/wolverine2k/win-repo

Install Microsoft XNA 4.0 refresh without VS2010 for VS2013

Microsoft XNA 4.0 refresh is a very good framework for doing various things including game development, simulation, etc. Of course as with all good things, Microsoft is not going to support it anymore. And one more reason in not investing in MSFT technology. But that is besides the point that one cannot simply install XNA 4.0 without a VS 2010 installation. I had VS 2013 on my machine and wanted XNA for some simulation stuff I have been developing. And I don’t want to overload my machine with multiple versions of Visual Studio.

XNA installer will not allow you to go ahead without VS 2010 or Windows Phone Developer tools. So what do we do? We install it manually. But below is a script that can be used to semi-automate the installation. Of course I got a lot of help from http://blogs.msdn.com/b/astebner/archive/2009/06/12/9740290.aspx. The script was taken from http://78bytes.com/blog/2013/08/visual-studio-2012-xna-4-0-refresh/ and I changed a couple of lines so that it can work flawlessly on VS 2013.

Below is the script for x64. If you are running a 32 bit machine, go to 78bytes, download the batch file and update the x86 script accordingly. Put the below code in a text file, make the extension .bat and run it with Administrator privileges. Make sure that you have downloaded the XNA setup and placed it in the same directory as the batch file. Happy Game Programming!

%~dp0XNAGS40_Setup.exe /extract:%~dp0XNA
%~dp0XNA\redists.msi /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\XLiveRedist.msi" /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Redist\XNA FX Redist\xnafx40_redist.msi" /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\xnaliveproxy.msi" /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\xnags_platform_tools.msi" /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\xnags_shared.msi" /passive
msiexec /a "%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\xnags_visualstudio.msi" /qb TARGETDIR="%~dp0XNA\VS Tools"
xcopy "%~dp0XNA\VS Tools\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\XNA Game Studio 4.0" "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\XNA Game Studio 4.0" /e
%~dp0XNA\arpentry.msi /passive
%~dp0FindAndReplace.exe "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\XNA Game Studio 4.0\extension.vsixmanifest" "10.0" "12.0"
"%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" /setup
rmdir %~dp0XNA /s /q

PS: I wish all of you a very Happy New Year 2014.

Install old VSIX on VS2013

There are a load of extensions for VS2010 and VS2012 which should just work on VS2013. BUT, yes there is always a but, Microsoft does not want our life so easy. Each and every extension developer has to repack and republish his extensions every time a new VS version is released. Anyways, I was looking into a very exciting VS Extension known as Axiom3D. It is a rendering engine which is fully object oriented 3D graphics engine using C# and the .NET platform.

One can read more about that on the Axiom3D.net site. But basically, they have a nice Visual Studio Extension which unfortunately only works in VS 2012. Now if you want to install this on VS 2013, you cannot do it. So the easiest way to install it is to do it manually. Below is the procedure I used to install the VSIX manually.

Download the VSIX to your computer. Use 7-zip to unzip the VSIX file and take the templates folder and put it in <MSVC Install Folder>\Common7\IDE\ItemTemplates\CSharp\1033\AxiomSDK. This will put the templates in the proper folder. The next thing to do is to have nuget packages that comes the VSIX package. Take the packages and put them in a folder <MSVC Install Folder>\Common7\Packages\Axiom folder.

Now open VS 2013, open the Package Manager Settings, Click on package sources and add the axiom package folder path. That’s pretty much it. Now you can close VS 2013 and restart it. Make a new project and use the new templates.

Axiom3D is a nice rendering engine and is very much better then using direct OpenGL wrappers like OpenTK with a lot of useful documentation. Hope it helps and somebody working Axiom3D will create a new Visual Studio Extension VSIX file for VS 2013.

Screen toggle script using xrandr

Many of my friends using Linux have serious problems with switching screens, screen resolutions, connecting to projectors, etc. and all of them end up wasting humongous amount of time doing stuff like that. And after banging their heads for 30 minutes they curse Linux and all and put up a request for another meeting! Anyways, below is the code to get screen toggling and switching screens easily done. Of course one needs to modify to suite their own use-cases but I guess the script itself will suffice most people.

Also be sure to use the open source drivers for your graphic card and not the proprietary ones. Probably it does not work with proprietary drivers but if it does, do give me a heads up in the comments.
# Created by Naresh Mehta (c) 2012 - www.naresh.se
#!/bin/sh
## echo $1 " is a parameter -- Naresh"
case $1 in
    -dd|--dockdual)
	xrandr --output LVDS --off
	xrandr --output VGA-0 --mode 1680x1050 --primary
	xrandr --output DVI-0 --mode 1680x1050 --right-of VGA-0
	;;
    -d|--dock)
##	xrandr --output DVI-0 --mode 1680x1050 --primary \
	xrandr --output LVDS --off
	xrandr --output VGA-0 --mode 1680x1050 --primary
##	xrandr --output DVI-0 --mode 1680x1050 --right-of VGA-0
##--right-of DVI-0
	;;
    -u|--undock|-l|--laptop)
	xrandr --output VGA-0 --off --output DVI-0 --off
	xrandr --output LVDS --mode 1280x800 --primary
	;;
    -p|--projector)
	xrandr --output LVDS --mode 1280x800 --primary
	xrandr --output VGA-0 --mode 1680x1050 --right-of LVDS
	;;
    -c|--clone)
	xrandr --output LVDS --mode 1280x800 --primary
	xrandr --output VGA-0 --mode 1280x800 --primary
	;;
    -h|--help|*)
	echo ""
	echo "Script Usage: toggle_dock.sh [OPTION]"
	echo ""
	echo " -d, --dock 	When the docking station is used"
	echo " -u, --undock	When the laptop is removed from the docking station"
	echo " -p, --projector	When connecting to a projector (VGA0)"
	echo " -c, --clone      When cloning laptop screen on projector"
	echo " -l, --laptop 	Getting back the dislpay on laptop LCD"
	echo " -h, --help	Show this help screen"
	echo ""
	;;
esac
Oh and put it in a bash script, make it executable and run it with the proper option. ENJOY