Setting up Wireless Hotspot on Ubuntu 14.04 (With Video demo)

ap-hotspot is an open source program that allows users to create hotspot on their Ubuntu Machines

ap-hotspot has a dependency called hostapd. hostapd is used to create wireless networks

However the new version of hostapd in Ubuntu 14.04 default repo is buggy.

Hence we will first remove it and then install a previous version which is stable.

Once installed we will place a hold on it so that it doesn’t automatically upgrade itself

To uninstall hostapd:

sudo apt-get remove hostapd

To install non buggy version of hostapd:

32-bit:

cd /tmp
wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wpa/hostapd_1.0-3ubuntu2.1_i386.deb
sudo dpkg -i hostapd*.deb
sudo apt-mark hold hostapd

64-bit:

cd /tmp
wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wpa/hostapd_1.0-3ubuntu2.1_amd64.deb
sudo dpkg -i hostapd*.deb
sudo apt-mark hold hostapd

The last line “sudo apt-mark hold hostapd” will place a hold so that hostapd program doesn’t upgrade itself.

Now we need to install ap-hotspot, for that save this file on your desktop:
https://launchpad.net/~nilarimogard/+archive/ubuntu/webupd8/+files/ap-hotspot_0.3.1-1%7Ewebupd8%7E0_all.deb

Once done, run the file by just double clicking on it and let it install itself using Ubuntu Software Center (You can also install it via terminal if you are familiar of how to do so).

Once installed, run:

sudo ap-hotspot configure

-> Select correct WAN port on which you have working internet connection (in my case ppp0)
-> Select correct wireless LAN port on which you want to setup the hotspot (in my case wlan0)
-> Enter desired hotspot name and password

that’s it..

to start it, run:

sudo ap-hotspot start

and to stop the hotspot, run:

sudo ap-hotspot stop

Video Demo below:

Posted in Stuff for fun | Tagged , , , , , | 7 Comments

My CV – Created using HTML / CSS

So, as part of my continuous learning ventures, I learn HTML and CSS recently on Codecademy.com and as the final element of this learning track was to build my own Resume using the CSS knowledge that I acquired through this track. Although this wasn’t a hard requirement to complete the track (get a green tick confirming that the track is now finished) I thought I would take it seriously and went on creating my CV through HTML and styling it using basic CSS knowledge.

Thanks a ton to Codecademy that I was able to finish my first real task in CSS in less than 3 hours and I now have pasted my CSS and HTML code at codepen.io and you can access my CV here…

Deep Sukhwani - HTML/CSS CV

Its an amazing fun to code and it really gives the feeling of immense satisfaction once you achieve what you stress yourself and work hard for. Go check out my CV and let me know your comments / feedback.

Posted in Code Academy, CSS / HTML | Tagged , , , , , , , , , , , , , , , , | 5 Comments

Yet another one.. Blackjack game built using JavaScript, Love you Codecademy

I had no idea what blackjack is (I knew it was some kind of card game), but now, thanks to the step by step from ground zero instructions given by Codecademy, I have a functional Blackjack architecture that works just as intended.

I am still not well verse with Blackjack, but I now know the basics of it and can talk about it with people rather than being purely unknown to it.
And guess what, What better way to learn about Blackjack then building it ourselves using a programming language!

Here’s the code that I wrote through Codecademy’s instructions (that was like pseudo code for me as I was completely unknown to Blackjack game)

// Our deal function will return a random card
var deal = function() {
  card = Math.floor(Math.random()*52+1);
  return card;
};

// Deal out our first hand
var card1 = deal();
var card2 = deal();

// This function takes a card as a parameter and returns the value
// of that card
var getValue = function(card) {
  // if its a face card, number should be set to 10        
    if (card % 13 === 1)
        {
            return 11;
        }
  // What if it's an ace?
    else if (card % 13 === 0 || card % 13 === 11 || card % 13 === 12)
        {
            return 10;
        }
  // Otherwise, we just want its number value
    else
        {
            return card % 13;
        }
};
        
// Score the hand
function score() {
  return getValue(card1) + getValue(card2);
}

console.log("You have cards " + card1 + " and " + card2 +
        " for a score of " + score(card1, card2));

Expect me soon with more adventures on Codecademy.. Till then adios amigos!

Posted in Code Academy, JavaScript | Tagged , , , , , , , , , , , , , , , , | 2 Comments

Long time.. Missed you blog! Another Dice game (A real simple one) using JavaScript

Its been quite a long while since I last blogged about my learning experiences, but hey that DOES NOT mean I have stopped learning in fact I have managed to secure a job in the city of New Delhi as a Support Engineer for one of the fastest growing startups in India called Wingify Software Pvt. Ltd., check out My LinkedIn Profile for details on that.

So here comes another coding experience with Codecademy.com.

This primarily focuses on use of conditionals (if-else statements) for practice purpose of course.
This dice game has two dices, once the gamer (user) rolls the dices, depending on what the numbers they get on their dice, they get their scores.

// pick a random number between 1 and 6 for our roll of the die
var die1 = Math.floor(Math.random()*6 + 1);
var die2 = Math.floor(Math.random()*6 + 1);
var score;

// If either die roll is 1 then score should be 0 
if(die1 === 1 || die2 === 1)
    {
        score = 0;
    }
else
    {
        if (die1 === die2)
            {
                score = (die1 + die2) * 2;
            }
        else
        {
            score = die1 + die2;
        }
    }
console.log("You rolled a "+die1+" and a "+die2+" for a score of "+score);

Hopefully I will see you guys soon with more such fun and easy to create games!

Posted in Code Academy, JavaScript | Tagged , , , , , , , , , , , , , , , , , , | Leave a comment

Yet another Game created using JavaScript on Codecademy.com – Rock, Paper & Scissors

Here goes another adventure tale with codecademy.com

Just finished another game project as part of my JavaScript learning track.
This time it is Rock, Paper, Scissors game, built using only the very basic knowledge of conditional flows / JavaScript Syntax gained through Codecademy’s JavaScript learning track so far.

Check out my Codecademy profile to see how I am progressing on my Code Learning Ventures…

Here is how the source code looks for this game:

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
}

var compare = function (choice1, choice2)
{
	if (choice1 === choice2)
	{
		return "The result is a tie!";
	}
	else if (choice1 === "rock")
	{
		if(choice2 === "scissors")
		{
			return "rock wins";
		}
		else if (choice2 === "paper")
		{
			return "paper wins";
		}
	}
	else if (choice1 === "paper")
	{
		if (choice2 === "rock")
		{
			return "paper wins";
		}
		else if (choice2 === "scissors")
		{
			return "scissors win";
		}
	}
	else if (choice1 === "scissors")
	{
		if (choice2 === "rock")
		{
			return "rock wins";
		}
		else if (choice2 === "paper")
		{
			return "scissors win";
		}
	}
};

compare (userChoice, computerChoice);
Posted in Code Academy, JavaScript | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 4 Comments

What I learnt in JavaScript in 2 days — Finished building a “short game”!

I always had an impression that using Java / JS (JavaScript) as a language to write some piece of code and have it function properly is one of the toughest tasks out there as JavaScript is a very tough language and would take long long time to learn and a huge amount of effort….

BUT THIS IS SOOO Damn wrong:

I started learning JavaScript yesterday through Codecademy’s JavaScript track and here I am, after a few hours of work since yesterday, I am already up and running a super small game that has although nothing in it at the moment, but has completely changed my perception of JavaScript and removed the fear of having to overcome a huge challenge in order to learn JavaScript.

Here is my JavaScript code for the game that I just wrote this morning:

// Check if the user is ready to play!

confirm("Are you ready to play?");
var age = prompt("What's your age?");
if (age < 18)
{
	console.log("You are allowed to play but the system takes no responsibility!");
}
else
{
	console.log("Great, carry on playing! Wish you luck.");
}

console.log("Snow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him.");
console.log("");
console.log("Batman glares at you.");

var userAnswer = prompt("Are you feeling lucky, punk?");

if (userAnswer === "yes")
{
	console.log("Batman hits you very hard. It's Batman and you're you! Of course Batman wins!");
}
else
{
	console.log("You did not say yes to feeling lucky. Good choice! You are a winner in the game of not getting beaten up by Batman.");
}
var feedback = prompt("Please rate your game-play experience from 1 to 10");

if (feedback > 8)
{
	console.log("This is just the beginning of my game empire. Stay tuned for more!");
}
else
{
	console.log("I slaved away at this game and you gave me that score?! The nerve! Just you wait!");
}
Posted in JavaScript | Tagged , , , , , , , , , , , , , , , , , , , , , , , , | 1 Comment

My Second Python Program – BattleShip Game

programming

Started Programming less than two weeks ago through Codecademy.com,made my first Python program, A PygLatin Translator about a week ago and just yesterday completed a small simple game called BattleShip, Thanks to Codecademy.com

Here is the source code for the game that I completed yesterday as a part of my Python Learning Track on Codecademy.com.

The game is like the famous Minesweeper game in Windows, of course it is not that complicated, rather a simpler version of that game.

import random

board = []

#Adds 5 rows to list board[]
for x in range(0,5):
	board.append(["O"] * 5) #adds 5 'O's to each row in list board[]

def print_board(board):
	for row in board:		#for loop puts the rows in a grid format
		print " ".join(row) #deletes unnecessary formatting of the grid and makes it a clear list of 2 dimensional 'O's

print "Let's play Battleship!"
print_board(board)

def random_row(board):		#radomint function randomly creates a number where the battleship is stored.
  return random.randint(0,len(board)-1)

def random_col(board):
  return random.randint(0,len(board[0])-1) #board[0] represents first row, so board[0] - 1 represents the length of column in first row.

ship_row = random_row(board) #ship_row stores the row number where the battleship is located.
ship_col = random_col(board) #ship_col stores the col number where the battleship is located.

print 'The correct row is: %d' % ship_row
print 'The correct Column is: %d' % ship_col

#Everything from here on should go in your for loop, to ensure turns.
#Be sure to indent!
for turn in range(4): #gives 4 turns to the user to correct the right location of battleship
	guess_row = input("Guess Row:")
	guess_col = input("Guess Col:")

	if guess_row == ship_row and guess_col == ship_col:
		print "Congratulations! You sunk my battleship!\n"
		break	#End of the program if user correctly finds the location of battleship
	else:
		if (turn == 3): #if all turns have passed, game is over, end of program!
			print 'Game Over, you have used your all turns.\n'
			break
		elif (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
			print "Oops, that's not even in the ocean.\n"
		elif(board[guess_row][guess_col] == "X"):
			print "You guessed that one already.\n"
		else:
			print "You missed my battleship!\n"
  			board[guess_row][guess_col] = "X"
	print 'You have used %d turn(s)' % (turn + 1) #turn+1 because user must not get turn 0,1,2 and 3 instead the user must get turn 1,2,3 and 4.
	print_board(board)

print 'The correct row is: %d\n' % ship_row
print 'The correct Column is: %d\n' % ship_col

For many, this might not be a very interesting game, but trust me, from knowing nothing about Python less than 2 weeks ago, to creating a small game all by myself without anyone’s help, sitting in my bedroom, this is a miracle for me and has given me such an immense level of confidence.

I am full set on to go ahead and complete my Python Learning Track, currently I am on while and while / else Loops in Python.

Wish me luck guys, not to be able to code, but to stay seriously motivated for the rest of the learning experience just like I am now.

Aside | Posted on by | Tagged , , , , , , , , , , , , , , , , , | 3 Comments