Banner

Banner
Ramast
Linux Developer

Sunday, December 22, 2013

Websites that will educate you for free

I found this list of links posted by a redditor called Fletch71011 
The original post can be found here

Now here is the list:

No Excuse List - Includes sources for everything you can want. I included some more popular ones with brief write-ups below. Credit to /u/lix2333.

Reddit Resources - Reddit's List of the best online education sources

Khan Academy - Educational organization and a website created by Bangladeshi-American educator Salman Khan, a graduate of MIT and Harvard Business School. The website supplies a free online collection of micro lectures stored on YouTube teaching mathematics, history, healthcare and medicine, finance, physics, chemistry, biology, astronomy, economics, cosmology, organic chemistry, American civics, art history, macroeconomics, microeconomics, and computer science.

Ted Talks - Talks that address a wide range of topics ("ideas worth spreading") within the research and practice of science and culture, often through storytelling. Many famous academics have given talks, and they are usually short and easy to digest.

Coursera - Coursera partners with various universities and makes a few of their courses available online free for a large audience. Founded by computer science professors, so again a heavy CS emphasis.

Wolfram Alpha - Online service that answers factual queries directly by computing the answer from structured data, rather than providing a list of documents or web pages that might contain the answer as a search engine might. Unbelievable what this thing can compute; you can ask it near anything and find an answer.

Udacity - Outgrowth of free computer science classes offered in 2011 through Stanford University. Plans to offer more, but concentrated on computer science for now.

MIT OpenCourseWare - Initiative of the Massachusetts Institute of Technology to put all of the educational materials from its undergraduate- and graduate-level courses online, partly free and openly available to anyone, anywhere.

Open Yale Courses - Provides free and open access to a selection of introductory courses taught by distinguished teachers and scholars at Yale University.

Codecademy - Online interactive platform that offers free coding classes in programming languages like Python, JavaScript, and Ruby, as well as markup languages including HTML and CSS. Gives your points and "level ups" like a video game, which is why I enjoyed doing classes here. Not lecture-oriented either; usually just jump right into coding, which works best for those that have trouble paying attention.

Team Treehouse - Alternative to Codecademy which has video tutorials. EDIT: Been brought to my attention that Team Treehouse is not free, but I included it due to many comments. Nick Pettit, teaching team lead at Treehouse, created a 50% off discount code for redditors. Simply use 'REDDIT50'. Karma goes to Mr. Pettit if you enjoyed or used this.

Think Tutorial - Database of simple, easy to follow tutorials covering all aspects of popular computing. Includes lots of easier, basic tasks for your every day questions or new users.

Duolingo - For all of your language learning needs.

Memrise - Online learning tool that uses flashcards augmented with mnemonics—partly gathered through crowdsourcing—and the spacing effect to boost the speed and ease of learning. Several languages available to learn.

Livemocha - Commercial online language learning community boasting 12 million members which provides instructional materials in 38 languages and a platform for speakers to interact with and help each other learn new languages.

edX - Massive open online course platform founded by Massachusetts Institute of Technology and Harvard University to offer online university-level courses in a wide range of disciplines to a worldwide audience at no charge. Many other universities now take part in it, including Cal Berkeley. Differs from most of these by including "due dates" with assignments and grades.

Education portal - Free courses which allow you to pass exams to earn real college credit.

uReddit - Made by Redditors for other Redditors. Tons of different topics, varying from things like science and art to Starcraft strategy.

iTunes U - Podcasts from a variety of places including universities and colleges on various subjects.

Stack Exchange - Group of question and answer websites on topics in many different fields, each website covering a specific topic, where questions, answers, and users are subject to a reputation award process. Stack Overflow is used for programming, probably their most famous topic. Self-moderated with reputation similar to Reddit.

Wikipedia - Collaboratively edited, multilingual, free Internet encyclopedia. Much better source than most people give it credit for, and great for random learning whenever you need it. For those looking for more legit sources for papers and such, it is usually easy to jump to a Wikipedia page and grab some sources at the bottom.

Tuesday, October 29, 2013

How can you tell good from bad?


Mummy, when people die in the war... Where do they go?

Oh, what a question.
-It depends.

-On what?

Whether they fought on the side of the goodies or the baddies.
Your father, for example, fought for England on the side of the goodies.

How do you know who the goodies and the baddies are?

[Sighs] That's enough questions.
Eat your food.

This conversation from the movie "The others" which was between children and their Mother.

Now we all know how difficult it is to answer that question "How to know which side is good and which is bad?". If there is a definite answer for that question there we should be able to end all wars

So why is it so hard to tell good from bad?
I thought it isn't, and so being a very logical person I tried to come up with a set of rules which - ideally - if followed I could always tell which side is good and which is bad

Result: Complete failure!
First reason is obvious: You need to know all the facts including people's inner intentions among other things to judge.
But lets say for the sake of argument that I know everything can I tell which is right and which is wrong?

Turns out that its not possible
To know why let me give a simple example.
Lets say you live somewhere in north Egypt and you want to visit somewhere in south Egypt and so you started to head north.
Is that right direction or wrong direction?
A quick answer would be of course wrong. If you live in the north and want to go somewhere in the south then you should head south not north.

But that is not always true, maybe I am moving north to reach the airport.
Also in theory if I keep moving to the north I will eventually (after going around the earth) reach my destination in the south

On the other hand if I live in the north and want to have a walk with no specific destination in mind, any direction would right and no direction would be wrong

Conclusion: good or bad depends on your own personal goals
If your goal is to reach the southern place fast then you should head north to the airport. (the other solutions are bad/wrong)
If your goal is to reach cheap then go south.
If your goal is to reach after 20 years, then head north.
If you have no goal, right and wrong become irrelevant

Applications in real life
If your goal is to make a lot of money in short time, then robbing houses is "good" while having a full time job is "bad".
BUT If your goal is to make a lot of money in short time while living long enough to enjoy it then robbing houses is bad

That is none sense, Morals are universal and everyone knows good from bad!
True but that's only because humans share same universal goal
This goal is to survive and thrive

Killing is terrible crime everywhere because its against surviving
Stealing is less terrible because it reduces chance of survival for the robbed one rather than eliminate it all together
Helping others is good because it increases the chances of survival for the ones being helped

The rule for global morals
Its easy to make a rule now that we know the universal goal
The good is anything I do that increase chance of survival for others and/or their offspring
The heroic is anything I do that increase chance of survival for others and/or their offspring while greatly DECEASING mine [ ex: saving a drawning person ]
The bad is simply the opposite

Where does the conflict comes from then?
It comes from the question: Who are the "others" ?
For a serial killer, the others are only him
For a gang, the others are the gang members and their families so the rule above only applies to them.
For a normal civilian, the others are people living in their country, other countries don't matter much
........
And so on until you reach a vegan person who consider the others to be every living creature on the planet.

Is it still bad to do bad things if I am sure it will not affect my "survive and thrive" goal?
In principal yes but in practice I would say No, because eventually it will conflict with that goal.
Lets say you have a powerful position in a corrupted country and you can steal as much as you want without anyone dare to hurt you.

At first you will be greatly increasing your chance of survival while decreasing chance of survival for the rest of population (which is ok). but as your community become weaker and weaker another community/country will be tempted to invade it. That would endanger the whole community including yourself
[ of course the above example can happen over decades by you and your offspring, the result will eventually be the same ]

What if I am a super human would it still be bad to do bad things?
If you are a super human - that is you belong to a species superior to humans - and hurting humans would increase your chance of survival then its is considered a good thing to hurt them.
We do all sort of terrible things to other species that we consider lower than ours like
Monkies => Medical experiements
Dolphins => Enslave to have some entertainment
Whales => Kill them because they reduce our fishing stock
All of that is  generally accepted and considered an honest job.
So if you are much smarter, much stronger than normal humans and you decided to use some of them as pets or slaves or run some medical experiments on them that would be totally acceptable by your "super humans" community

Why do I have to commit to that survive and thrive goal rather than having a different goal of my own?
You don't have to and in fact a small percentage of people don't commit to that goal. for example people looking for risky adventures, people who don't want kids, monks to name few examples.
The reason those people will remain a small ineffective minority is because they generally don't get to transfer their genes to next generation.

If you are one of those who don't commit to the universal goal then right or wrong depends on your religion or your own personal goals if you have no religion.

If you neither have religion nor a personal goal then right or wrong become irrelevant to you

Wednesday, September 25, 2013

Running MK802 as linux server

The goal:

Installing linux distro on MK802 and it has to
  • Be very light weight
  • Support most USB devices that I might need (Webcam, bluetooth dongle, ...) plus internal wireless lan and video card
  • Support iptables
  • Be easy to install and maintain
  • Has right package repository

First I found this page that offer wide selection of linux distros
http://liliputing.com/2012/07/linux-distributions-that-can-run-on-an-mk802-mini-pc.html

Puppy Linux 

Is very lightweight and can work from memory
That means it won't need to constantly writing on the SD Card which will extend its life.
Also means it will be very fast.
However when I clicked on the link I found that its development has been discontinued.

Miniand Lubuntu 12.04

was my choice  because Ubuntu has very good support for different devices and with Lubuntu I get a light version too.

Turns out Lubuntu didn't support my webcam, I had to download & compile the corresponding kernel modules manually for it to work

After that I found it doesn't support iptables because of missing kernel modules
This time compiling the corresponding modules wasn't enough.
I had to compile the kernel itself. and no matter what I do any kernel I compile fails to boot.

Debian Server


Was my next distro, I downloaded it from this link
http://romanrm.ru/en/a10
and it was really amazing.
extremely lightweight, not so many services, no X11 not even vim!
iptables and my webcam were working like a charm.

only one problem though, I couldn't see anything!
The server doesn't support any graphics card so even installing X11 didn't help. xorg won't start.

I contacted the developer "Roman Mamedov" and explained the problem to him and his answer was:

This is because the image uses a kernel which disables all graphic components
to save RAM (about 100 MB). If you want Mali, you need to replace the kernel
with a Desktop or Video variant from http://romanrm.ru/en/a10/kernel 
 
I followed that link, there you will find two other kernels along with their installation instructions.
I installed the Desktop kernel and now everything is working perfectly fine.

Thank you  Roman Mamedov for this great distro

Emulator  for MK802


The next thing I needed is an emulator to run the debian image on, install all development stuff plus kernel source to compile any extra drivers I might be missing.

For that I found qemu very handy
I followed the guide here
http://romanrm.ru/en/a10/qemu

Basically you need to download kernel files
initrd.img-3.2.0-4-vexpress


linux-image-3.2.0-4-vexpress_3.2.35-2_armhf.deb


vmlinuz-3.2.0-4-vexpress


from http://romanrm.ru/dl/a10/kernels/qemu/

Then run quemu
qemu-system-arm \
  -M vexpress-a9 \
  -kernel vmlinuz-3.2.0-4-vexpress -initrd initrd.img-3.2.0-4-vexpress \
  -append root=/dev/mmcblk0p2 \
  -drive if=sd,cache=unsafe,file=image.im

Saturday, August 31, 2013

Calling Paypal API

I have had this terrible experience with paypal trying doing something simple like doing an API call.

In my opinion Paypal has the worst nightmare for any developer unlike for example stripe which is a peace of cake compared to it.

Anyway after search many websites excluding developers.paypal.com I found this great page
http://coding.smashingmagazine.com/2011/09/05/getting-started-with-the-paypal-api/

In a nutshell the page present a very simple code for calling any paypal api method.

class Paypal {
   /**
    * Last error message(s)
    * @var array
    */
   protected $_errors = array();

   /**
    * API Credentials
    * Use the correct credentials for the environment in use (Live / Sandbox)
    * @var array
    */
   protected $_credentials = array(
      'USER' => 'seller_1297608781_biz_api1.lionite.com',
      'PWD' => '1297608792',
      'SIGNATURE' => 'A3g66.FS3NAf4mkHn3BDQdpo6JD.ACcPc4wMrInvUEqO3Uapovity47p',
   );

   /**
    * API endpoint
    * Live - https://api-3t.paypal.com/nvp
    * Sandbox - https://api-3t.sandbox.paypal.com/nvp
    * @var string
    */
   protected $_endPoint = 'https://api-3t.sandbox.paypal.com/nvp';

   /**
    * API Version
    * @var string
    */
   protected $_version = '74.0';

   /**
    * Make API request
    *
    * @param string $method string API method to request
    * @param array $params Additional request parameters
    * @return array / boolean Response array / boolean false on failure
    */
   public function request($method,$params = array()) {
      $this -> _errors = array();
      if( empty($method) ) { //Check if API method is not empty
         $this -> _errors = array('API method is missing');
         return false;
      }

      //Our request parameters
      $requestParams = array(
         'METHOD' => $method,
         'VERSION' => $this -> _version
      ) + $this -> _credentials;

      //Building our NVP string
      $request = http_build_query($requestParams + $params);

      //cURL settings
      $curlOptions = array (
         CURLOPT_URL => $this -> _endPoint,
         CURLOPT_VERBOSE => 1,
         //I (ramast) commented the following 3 lines for the sake of simplicity
         //CURLOPT_SSL_VERIFYPEER => true, 
         //CURLOPT_SSL_VERIFYHOST => 2,
         //CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem', //CA cert file
         CURLOPT_RETURNTRANSFER => 1,
         CURLOPT_POST => 1,
         CURLOPT_POSTFIELDS => $request
      );

      $ch = curl_init();
      curl_setopt_array($ch,$curlOptions);

      //Sending our request - $response will hold the API response
      $response = curl_exec($ch);

      //Checking for cURL errors
      if (curl_errno($ch)) {
         $this -> _errors = curl_error($ch);
         curl_close($ch);
         return false;
         //Handle errors
      } else  {
         curl_close($ch);
         $responseArray = array();
         parse_str($response,$responseArray); // Break the NVP string to an array
         return $responseArray;
      }
   }
}

After that you can go to https://developer.paypal.com/webapps/developer/docs/classic/api/ find the call you want (make sure you click on NVP not SOAP) Then you can make a call like this
$paypal = new PayPal();
$response = $paypal->request("DoCapture", Array(
        "AUTHORIZATIONID" => "61P02217YA6177331",
        "AMT" => "10.92",
        "COMPLETETYPE" => "Complete",
        "NOTE" => "Thank you for buying from us"));
echo json_encode($response);

Friday, August 9, 2013

avrdude: stk500_recv(): programmer is not responding

I was happily playing with me new arduino uno3 board until they error started to appear and I was unable to upload any more programs to the board

I spent long time searching for a solution or at least understanding what is the problem and in this blog post I will post summary of what I have learned so far

avrdude: stk500_recv(): programmer is not responding error basically means the computer is unable to communicate with the board.

If this is your first try to upload something then there is a possibility you have software issues or problem with drivers.
I am not going to cover this case instead I will assume your board was working fine and suddenly stopped

Why?

  • Bad usb cable
  • Something is connected to pins 0,1 (serial pins)
  • Micro controller chip is fried (atmega328)
  • The chip responsible for communication between the board and PC is fried (ATmega16U2)
  • Something else (use your imagination)

How to determine the cause?


Connect pin 0 with pin 1 on your board
Start the serial monitor window
Type anything and hit enter, did what you type appear in the output box?
If Yes, then the ATmega16U2 is working and its either the cable or the atmega328

Push the reset button, do u see the L led flashing ? If yes then the atmega328 is also fine.

Cable is cheap so u can always try another cable to verify if the cable is fine or not.

How to Fix?

You can replace the atmega328 with a new one (make sure it comes with Uno bootloader)
Like this one
You can also replace your usb cable
I am not sure if its possible to replace the ATmega16U2 IC though

Monday, August 5, 2013

Online electronic shops in Egypt (Review)

This review is about shops selling electronic components like resistors, capacitors up to arduino boards



I

hate shopping in Cairo because of the transportation hell and because of the fact that I don't live in Cairo anymore.
So when electronic fever hit me I started to look for online stores that offer shipping.
And here is my feedback about the ones I found



Future electronics

http://store.fut-electronics.com/index.php

Great online store for beginners.
It explain in details each component and its uses and some possible use cases along with the datasheet and even sometimes some tutorials

The online shop is big with really great varieties  also I like the option of payment upon delivery (so I only pay when the items reach my door)

Its also relatively cheap most components are cheap but also shipping to any place in Cairo (20le) or any place in Egypt (around 45le)

They are official reseller of Sparkfun.com

First Personal experience
I made my first order with them when I was in Cairo in short vacation.
To make the story really short they didn't deliver anything
When I called to ask for the reason of the delay he told me some of the components I ordered is currently not available (damn me!).
Why didn't you call me then? no answer.
being one day before going back home, I had to go myself to their shop and get my stuff.

Important thing to say: He charged me more for at least one component than the price indicated on the website so I would say these online prices are not very reliable.

Second Personal experience
Tried to order from them again (why again? because its cheap) but this time I wanted the items to be shipped to where I live (South Sinai)
I called asking about shipping cost to south sinai he told me it will be estimated and someone will call me to confirm it.
No body called (As expected) and no one answer my calls, emails.
I was making a 500le order so I was expecting some attention but got nothing.
I asked the order be canceled (got no response either).


RAM Electronics

https://ram-e-shop.com

The online shop is also big (bigger than Future Electronics) the option of payment upon delivery is also available

The website is not as beginners friendly as the former one.
Here they are expecting that you know what you are doing also the larger selection makes it harder for a beginner like me to decide which to buy.

You may find some datasheets but in general the website is not very beginner friendly

Prices are expensive either same item in Future Electronics can cost here any thing between 100-200% and sometimes more

Shipping is also more expensive (57le for a less than 1kg shipment to South Sinai compared to 45 in Fut-E)

This shop is also an official distributor for Sparkfun.com

First Personal experience
I knew from the first look this shop is more expensive than FutE and so I have only ordered few things from there that I didn't find in the other store.

After making online order someone called to confirm then I got an SMS few hours later confirming shipment of my items by Fedex, I received my items the next day morning.
(so it was less than 24 hour between submitting the order and receiving it)
Their prices were expensive but accurate, I payed what I expected to pay

Although that experience was good but it doesn't count because I ordered only very few things

Second Personal experience
When FutE turned me down the second time I ordered everything from RAM Electronics .. I found every thing I needed and even many things that I didn't find in FutE all for higher price of course.
Just like first time I got confirmation call from them, then another call informing me one of the items I requested is not available giving me the option to ship without this item or wait until tomorrow and ship everything

the company they use for shipping is egyptexpress/fedex which has a terrible (or rather no) customer support they never picked up the phone when I called.

Despite that the package arrived within two days as promised.
I will definitely order from them again

ElGammal Electronics


http://elgammalelectronics.com/

This shop is direct competitor fo E-Ram, it has lot of components and can be cheaper sometimes than E-Ram. Only down side is that their delivery is very expensive compared to e-ram.


Deal Extreme

Deal Extreme (or dx for short) is general electronic shop not specialized like the previous two but still you could find some electronics in dx and not in the other sites.

Dx is a Chinese so you will only find there things made in China.
Its prices are generally more expensive than those two websites mentioned above but it offer FREE shipping

First Personal experienceI ordered a few items from there to test if its gonna work or will face problem with customs and delivery.
Order was placed 24th of July
Shipped 25th of July (just one day after making the order)
Received 29th of August.

Customs charge was 50% (6$ for my 12$ order)

Monday, June 3, 2013

Xen support for sysrescuecd

In this article I will explain how you can customize sysrescuecd in a way that make it run on xen.

Here goes the steps

1. Download, extract, patch the kernel

Best way to do that is to follow this guide

2. Make menuconfig

From "Processor type and features" go to "Paravirtualized guest support " then select xen

Note:If you can't see xen and you are compiling x86 kernel then you need to disable support for High Memory Support (from Processor type and features)

From "General Setup" set "Kernel compression mode" to gzip instead of XZ (Xen doesn't recognize XZ compression)

Carry on and compile/install the kernel as explained in the guide above

2. Recompile initramfs

Now you need to include the new xen modules to your initramfs file
the guide explain how to do that, follow it but please consider those two notes

In the line that says
cp -a /lib/modules/your-kernel-modules /usr/src/initramfs/lib/modules/
This is how it should look like
mkdir /usr/src/initramfs/lib/modules/
cp -a /lib/modules/<kernel version>/ /usr/src/initramfs/lib/modules/

Also in the line that says
find . | cpio -H newc -o | xz --check=crc32 --x86 --lzma2 > /usr/src/initram.igz
Change it to be
find . | cpio -H newc -o | gzip > /usr/src/initram.igz
Because again xen doesn't recognize xz compression

3. Remaster the cd with the new kernel / initramfs.igz file


Hope that helps