Create WiFi Access Point On Ubuntu

Have you got a computer with a wired internet connection and a wireless LAN card available and you want to connect your wi-fi enabled devices to internet, then here is a solution to create a Wi-Fi Access point using your computer. Hence you can share your single internet connection with multiple devices, as well as have the flexibility of internet access on the go.

It is assumed that you are having the following available with you:
(a) A computer running Ubuntu operating system (we used 14.04 LTS for this setup).
(b) A wired internet connection.
(c) A wireless LAN card.

For the purpose of creating a hotspot or access point we will utilise ap-hotspot software.

First of all install ap-hotspot as follows.

(a) Open a new terminal from dash or use keyboard shortcut “ctrl+alt+t”.
(b) Issue the following commands in sequence:

sudo add-apt-repository ppa:nilarimogard/webupd8

sudo apt-get update

sudo apt-get install ap-hotspot

(c) After the installation is a success, issue following command to configure the hotspot or access point:

sudo apt-hotspot configure

It will detect your network connections and if all is correctly listed, it will ask you to enter an Access Point name (SSID) and access key (WI-Fi password).

(d) After above step we are ready to start our hotspot or access point. To start the hotspot issue the following command in the terminal:


sudo apt-hotspot start

(e) To stop the hotspot, issue the following command:


sudo apt-hotspot stop

Happy internet connection sharing with your wireless devices.

Change Facebook Open Graph Meta Tags For WordPress

The Facebook plugin for wordpress automatically inserts open graph meta tags into the web pages rendered by wordpress to make them a social entity. Since the plugin is general in nature, all tags are specified to be as the default ones.

But sometimes we get into a situation that we initially defined our webpage types which is different than the default ones (like what happened with us :-) ) and we dont see the social actions being published nicely or inaccurately to facebook. This may mean a loss of revenue or traffic to the site, as we are not able to harness the complete power of the social network. Also we may get errors when using the open graph debugger to check if the open graph tags are acceptable to facebook/ other social sites.

So the options are either we make changes in the facebook plugin files every time we update the same or the better one to make use of the fb_meta_tags filter provided by the plugin. Thats where we will be able to harness the full power of wordpress and once we have done this we need not do it over and over again, even after updating the facebook plugin.

The only thing you may have to do is to copy the following code at the end of your functions.php file or any of your plugin file. Please do make the small change for the APP_NAMESPACE:TYPE as indicated in the comments in the code.

/********change facebook open graph************
**************og:type meta tag**********************
* Add site-specific og:type meta tag for example og:type = preeti_blog:website
* in place of og:type = website (which is default)
*
* @param array $meta_tags an associative array of Open Graph protocol properties provided by facebook plugin
* @return array plugin default values with site-specific customized changes
* suggested by developers of http://preetisblog.com
*/
add_filter('fb_meta_tags', 'change_fb_meta_type');
function change_fb_meta_type($metatags) {
if (is_home()) //for changes on home page only, remove this 'if' for changing on all pages of your site
{
$metatags['http://ogp.me/ns#type'] = 'preeti_blog:website';
//here you replace preeti_blog:website with ur APP_NAMESPACE:TYPE
}

return $metatags;
}

Similarly you may also change other open graph meta tag values, as the argument $metatags is an associative array, which can be easily accesed by property values as index. As an example ‘type’ is shown in the code above. Also you may add additional tags to the array also.

Pls like/tweet/+1 us/ leave a comment to show your support for PreetisBlog

Happy publishing your wordpress site…..

Sampling from normal distribution

Many a times we need to generate random samples or rather random numbers, which essentially follow or approximate a normal distribution. Such random numbers find extensive applications in the fields of statistics, probability, gaming etc.

We present here  a very small function written in C/C++, which will generate pseudorandom numbers following a normal distribution having mean as zero(0) and given variance (bsq). As the code uses very basic statements, same can be easily tailored for use in other programming languages also.

//Sampling in a normal distribution with mean 0 and variance bsq
double normalSampling (double bsq)
{
double sum=0, tempB=0,b;
b=sqrt(bsq);
int i;
for (i=1; i<=12; i++)
{
srand(time(NULL)* i + rand());
tempB=(((double)rand())/RAND_MAX);
// generate a random double number between 0 and 1
tempB=2 * b * tempB;// to generate a random no between 0 and 2b
tempB=tempB-b;//to ensure random no generated falls between -b to b
sum+=tempB;    // add to the cumulative sum
}
sum=sum/2;
return sum;
}