Friday, February 28, 2014
Thursday, February 27, 2014
Computer Programming in 5 minutes & Tiny-Robots
I have wondered several times how I would introduce 'programming' to someone who has never done it, not even a little bit.
Below is Larry Wall's take on it. He is the creator of Perl programming language.
The rest of this post is based on an idea from the above video - the idea of robots being at your disposal to do certain tasks.
We can probably explain programming-constructs, by :
And that is probably half the battle won right at the start.
------------------------------------------------------------------------
More complex point that can be introduced after a couple of programs -
------------------------------------------------------------------------
Example:
PROBLEM:
Print numbers 1 to 100 on screen
TINY-ROBOTS AT YOUR DISPOSAL:
1. LOOP tiny-robot
2. PRINT-TO-SCREEN tiny-robot
Info about the LOOP tiny-robot -
obviously since it is a robot, we have to tell it exactly how many times it has to loop;
once we give tiny-robot this number, it stores it and starts looping; it keeps track of how many loops it has completed, how many are remaining, etc; the LOOP tiny-robot is quite smart in this aspect.
Info about PRINT-TO-SCREEN tiny-robot -
this tiny-robot does nothing but print to screen whatever you give it.
SOLUTION:
Instructions from us (programmer) to the tiny-robots will be:
"LOOP tiny robot - please loop 100 times"
"During each loop, since you keep track of how many loops you have already done, give that number to the PRINT-ON-SCREEN tiny-robot, and ask it to print that number on screen.
-------------------------------------------------------------------------------
(In the above example, I have tried to tackle the 'loop' construct, which is a slightly advanced concept for an absolute beginner.
Have to try and add IF-THEN-ELSE construct example;
If idea seems good, perhaps, I will try to create examples for all the main programming-constructs.
In the worst-case, it can be a good way for me to try out while trying to understand new concepts)
Below is Larry Wall's take on it. He is the creator of Perl programming language.
The rest of this post is based on an idea from the above video - the idea of robots being at your disposal to do certain tasks.
We can probably explain programming-constructs, by :
- asking the student to imagine that each programming-construct is actually a tiny-robot. So, for e.g., a for-loop, is actually a tiny-robot that is capable of just doing a 'loop'. Similarly, we can imagine a if-then-else tiny-robot, print-to-screen tiny-robot, etc
- Notice that I modified 'robots' to 'tiny robots' so as to convey the idea/feeling that a tiny-robot can do a 'tiny' task
- This idea might work because everyone knows that robots need to be instructed what to do i.e. robots need to be given 'commands'.
- And it is also easy to add that the commands have to be very specific, otherwise the robot will not understand what to do. We would have introduced concept of 'syntax' by doing that.
And that is probably half the battle won right at the start.
------------------------------------------------------------------------
More complex point that can be introduced after a couple of programs -
- We can ask the tiny-robots to give commands to each other.
------------------------------------------------------------------------
Example:
PROBLEM:
Print numbers 1 to 100 on screen
TINY-ROBOTS AT YOUR DISPOSAL:
1. LOOP tiny-robot
2. PRINT-TO-SCREEN tiny-robot
Info about the LOOP tiny-robot -
obviously since it is a robot, we have to tell it exactly how many times it has to loop;
once we give tiny-robot this number, it stores it and starts looping; it keeps track of how many loops it has completed, how many are remaining, etc; the LOOP tiny-robot is quite smart in this aspect.
Info about PRINT-TO-SCREEN tiny-robot -
this tiny-robot does nothing but print to screen whatever you give it.
SOLUTION:
Instructions from us (programmer) to the tiny-robots will be:
"LOOP tiny robot - please loop 100 times"
"During each loop, since you keep track of how many loops you have already done, give that number to the PRINT-ON-SCREEN tiny-robot, and ask it to print that number on screen.
-------------------------------------------------------------------------------
(In the above example, I have tried to tackle the 'loop' construct, which is a slightly advanced concept for an absolute beginner.
Have to try and add IF-THEN-ELSE construct example;
If idea seems good, perhaps, I will try to create examples for all the main programming-constructs.
In the worst-case, it can be a good way for me to try out while trying to understand new concepts)
Sunday, February 23, 2014
Wednesday, February 19, 2014
git add -p
http://johnkary.net/blog/git-add-p-the-most-powerful-git-feature-youre-not-using-yet/
If you use git, you've used the commandgit add
. But do you know about git add's "patch mode" usinggit add -p
?Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history.
10-signs-that-you-are-an-awesome-web-developer
http://tutorialzine.com/2014/02/10-signs-that-you-are-an-awesome-web-developer/
Above link seems to have some useful links.
Above link seems to have some useful links.
Sunday, February 16, 2014
Google Charts: removing padding
http://stackoverflow.com/questions/4271390/remove-padding-in-google-chart
options.chartArea = { left: '8%', top: '8%', width: "70%", height: "70%" };https://developers.google.com/chart/interactive/docs/gallery/piechart#Configuration_Options
Friday, February 14, 2014
Rails: Turn off assets precompile
We would want to do this in Dev environment.config.assets.enabled = false
Wednesday, February 12, 2014
Sticky toastr
http://stackoverflow.com/questions/17411171/toastr-how-to-prevent-fade-out-with-sticky-toast-on-mouseover
http://blog.decayingcode.com/post/Better-JavaScript-notifications-with-Toastr
toastr.options = {timeOut: 0, extendedTimeOut: 0}
(observe that 'O' in timeOut is upper-case)
http://blog.decayingcode.com/post/Better-JavaScript-notifications-with-Toastr
toastr.options = {timeOut: 0, extendedTimeOut: 0}
(observe that 'O' in timeOut is upper-case)
Tuesday, February 11, 2014
MySql: find out which tables contain a certain column
To search for a column 'rank' in a database 'mydb':
select * From INFORMATION_SCHEMA.COLUMNS Where column_name like '%rank%' and TABLE_SCHEMA = "mydb"
select * From INFORMATION_SCHEMA.COLUMNS Where column_name like '%rank%' and TABLE_SCHEMA = "mydb"
Sunday, February 9, 2014
XSS, Browser Exploitation Framework, Alice & Bob & Eve & Mallory, Rails & XSS
Cross-Site Scripting - Persistent, Non-Persistent (Reflective)
http://en.wikipedia.org/wiki/Cross-site_scripting
http://en.wikipedia.org/wiki/Cross-site_scripting
Who are Alice and Bob and Eve and Mallory ?
http://en.wikipedia.org/wiki/Alice_and_Bob
Browser Exploitation Framework
http://en.wikipedia.org/wiki/BeEF_(Browser_Exploitation_Framework)
Rails & XSS:
http://guides.rubyonrails.org/security.html#cross-site-scripting-xss
Browser Exploitation Framework
http://en.wikipedia.org/wiki/BeEF_(Browser_Exploitation_Framework)
Rails & XSS:
http://guides.rubyonrails.org/security.html#cross-site-scripting-xss
Friday, February 7, 2014
Security related
https://www.owasp.org/index.php/Ruby_on_Rails_Cheatsheet
There are links to Cheatsheets for .Net, HTML5, Javascript, iOS, etc. also in the above page.
There are links to Cheatsheets for .Net, HTML5, Javascript, iOS, etc. also in the above page.
Monday, February 3, 2014
Ruby: inject
http://ruby-doc.org/core-2.0/Enumerable.html#method-i-inject
What does it do ?
-- Combines all elements of enum
-- by applying a binary operation, specified by a block
For each element in enum -
- the block is passed an accumulator value (memo) and the element
- the result becomes the new value for memo.
Variation:
-------------------------
inject { |memo, obj| block } → obj
What is the initial value for memo ?
- If you do not explicitly specify an initial value for memo, then the first element of collection is used as the initial value of memo.
inject( initial ) { |memo, obj| block } → obj
def sum_of_cubes(a, b)
sum = 0
(a..b).inject(sum) { |sum, x| sum + (x*x*x) }
end
-- Combines all elements of enum
-- by applying a binary operation, specified by a block
For each element in enum -
- the block is passed an accumulator value (memo) and the element
- the result becomes the new value for memo.
At the end of the iteration -
the final value of memo is the return value for the method.
the final value of memo is the return value for the method.
Variation:
-------------------------
inject { |memo, obj| block } → obj
What is the initial value for memo ?
- If you do not explicitly specify an initial value for memo, then the first element of collection is used as the initial value of memo.
Sunday, February 2, 2014
Subscribe to:
Posts (Atom)
Followers
Blog Archive
-
▼
2014
(134)
-
▼
February
(20)
- 'Best Advice'
- Ruby: decorators, modules
- Computer Programming in 5 minutes & Tiny-Robots
- Google Hangout for Remote Workers
- git add -p
- 10-signs-that-you-are-an-awesome-web-developer
- sqlfiddle.com
- Google Charts: removing padding
- Google Charts - Playground
- Rails: Turn off assets precompile
- Sticky toastr
- MySql: find out which tables contain a certain column
- XSS, Browser Exploitation Framework, Alice & Bob &...
- ScoreCleaner app
- Security related
- Ruby: Get/set an object's property using a string/...
- drive.draw.io - mockup tool
- Ruby: yield
- Ruby: inject
- F# - Getting Started tutorial
-
▼
February
(20)