Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,208,814 members, 8,003,858 topics. Date: Friday, 15 November 2024 at 09:19 PM

READING SOURCE CODES - One Of The Best Developer Practice - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / READING SOURCE CODES - One Of The Best Developer Practice (1825 Views)

Hire The Best Developer/Programmer To Develop Your Website Now / With This 10 Tips You Would Hire The Best Developer For Your StartupĀ idea. / Download Free Project Source Codes And Materials From Projectbasket (2) (3) (4)

(1) (Reply) (Go Down)

READING SOURCE CODES - One Of The Best Developer Practice by melodyogonna(m): 1:56am On Sep 15, 2016
i was on www.tutorialspoint.com yesterday morning looking for nothing but everything in particular when i jammed a topic, tutorialspoint.com is my first choice on any programming tutorial because of it's wide variety of coverage in almost all( if not all) languages.
so as i was browsing the page aimlessly when i got bored with the python tutorial i was learning, then i ventured into their tutorials library //--fastforward
i saw a tutorial called developer's best pratices(i recommend it) and in one of the practices the tutor mentioned reading source codes as a best practice with the following arguments. . .
-you can't just start writing novels! you read hundreds of novels before you can write a good one.
-you can't just start singing! you do alot of rehersals before you can sing well.
-as such you can't just start coding!! you need to read -- yes read!! . . read source codes to code well.
Re: READING SOURCE CODES - One Of The Best Developer Practice by melodyogonna(m): 2:20am On Sep 15, 2016
so here is what we are gonna do,
we are gonna be posting source codes for every language we lays our hands on i.e webpages , apps , webapps, softwares e.t.c,
with the language name i.e this is a html,css and javascript source code (page, appname e.g nairaland homepage.), this is a python source code (a simple calculator ) e.t.c, than
we are gonna look for bugs or some areas which needs upgrade and don't say you din't find a bug coz there ain't code that is bug free.
note: this is for learning purpose as am still a learner.
some pros and gurus can help with answers to questions--where are they? lordzouga, javanian ,ajibel etc, abeg make una come helep us.
you opinion is most valued as i stand to be corrected.
post the bugs you identified here.
Re: READING SOURCE CODES - One Of The Best Developer Practice by melodyogonna(m): 2:28am On Sep 15, 2016
i can't post source code now as am using a java phone to type this . . . maybe later, but somebody should help us even if it is nairaland homepage sourcecode

and please try to identify the bug only on your language(s) of specialization.
Re: READING SOURCE CODES - One Of The Best Developer Practice by destino24(m): 7:56am On Sep 15, 2016
Great idea. Following...
Re: READING SOURCE CODES - One Of The Best Developer Practice by Ajibel(m): 8:40am On Sep 15, 2016
Can I post Django's source code? grin

Because I do more of web programming these days.

Or should I visit snippets sites like djangosnippets.org and post one code here that interests me?

I don't think it'll be proper to just copy and paste the source of a web page here. Most times, the designers have minified their codes except you saw a cool css 3d transformation you'll like to learn and share with others.

Small chunks of snippets/ functions that solve something would be cool for a start. Lets see how it goes.

Op, oya set the ball rolling.
Re: READING SOURCE CODES - One Of The Best Developer Practice by melodyogonna(m): 10:55pm On Sep 15, 2016
Ajibel:
Can I post Django's source code? grin

Because I do more of web programming these days.

Or should I visit snippets sites like djangosnippets.org and post one code here that interests me?

I don't think it'll be proper to just copy and paste the source of a web page here. Most times, the designers have minified their codes except you saw a cool css 3d transformation you'll like to learn and share with others.

Small chunks of snippets/ functions that solve something would be cool for a start. Lets see how it goes.

Op, oya set the ball rolling.
anytin can serve!!!
Re: READING SOURCE CODES - One Of The Best Developer Practice by KvnqPrezo(m): 7:12pm On Sep 16, 2016
Nairaland don't have good developers board...
.
When you share code now you'll start seeing smiley...
.
Even if I can understand what of others??
Re: READING SOURCE CODES - One Of The Best Developer Practice by ojodombe(m): 7:25pm On Sep 16, 2016
I appreciate the efforts made here. But patiently waiting to start learning as I am a total novice with a little knowledge of HTML and css only.
How do I fit in? Somebody help.
Re: READING SOURCE CODES - One Of The Best Developer Practice by melodyogonna(m): 8:35pm On Sep 16, 2016
KvnqPrezo:
Nairaland don't have good developers board...
.
When you share code now you'll start seeing smiley...
.
Even if I can understand what of others??
they can ask questions
Re: READING SOURCE CODES - One Of The Best Developer Practice by KvnqPrezo(m): 8:37pm On Sep 16, 2016
Torh u any code
Re: READING SOURCE CODES - One Of The Best Developer Practice by ANTONINEUTRON(m): 11:26am On Sep 17, 2016
explain




function hasAttr(o, attr) {
return $(o).attr(attr) != undefined;
}


(function ( $ ) {
$.fn.rooster = function(action, options) {
/****************************************
* Jquery Rooster!
* A simple countdown timer.
*
* Currently does not accept date time formats
*
*****************************************/

var INTERVAL = 100;

var el = $(this);

var defaults = {
seconds: el.data('rooster-seconds') || 0,
onComplete: el.data('rooster-oncomplete') || null,
onStart: el.data('rooster-onstart') || null,
onStop: el.data('rooster-onstop') || null,
includeMinutes: hasAttr(el, 'data-rooster-includeminutes') ? el.data('rooster-includeminutes') : true,

state: el.data('state') || 'idle',
};

var opts = $.extend({}, defaults, options);

var milliseconds = opts.seconds * 1000 + INTERVAL;

function updateTimer() {
var displayTime;
var seconds;
if (opts.includeMinutes) {
var minutes = Math.floor((milliseconds / 1000) / 60);
minutes = minutes.toString();
while (minutes.length < 2) minutes = '0' + minutes;

seconds = Math.floor(milliseconds / 1000) % 60;
seconds = seconds.toString();
while (seconds.length < 2) seconds = '0' + seconds;

displayTime = minutes + ':' + seconds;
} else {
seconds = Math.floor(milliseconds / 1000);
seconds = seconds.toString();

displayTime = seconds;
}
el.html(displayTime);
}

function clearRoosterTimer() {
clearInterval(el.data('countdown'));
el.data('countdown', null);
}

function onInterval() {
milliseconds -= INTERVAL;
updateTimer();
if (milliseconds > 0) {
return;
}
clearRoosterTimer();
if (opts.onComplete) {
if (typeof(opts.onComplete) == 'string') {
eval(opts.onComplete);
} else if (typeof(opts.onComplete) == 'function') {
opts.onComplete();
}
}
}

switch (action) {
case 'start':
// Start the Timer
el.data('state', 'active');
el.data('countdown', setInterval(onInterval, INTERVAL));
return this;
case 'stop':
el.data('state', 'idle');
clearRoosterTimer();
return this;
default:
// Initialize
updateTimer();
return this;
}
};

}( jQuery ));
Re: READING SOURCE CODES - One Of The Best Developer Practice by ANTONINEUTRON(m): 11:29am On Sep 17, 2016
 and this
<script language="JavaScript"> $('.cont').addClass('hide'); $('#que1').removeclass('hide); var count = $('.questions').length; /*next button*/ $(document).on('click','.next',function(){ var element = $(this).attr('id'); var last =parseInt(element.substr(element.length -1)); var nex = last+1; $('#que1'+last).addClass('hide'); $('#que1'+nex).removeClass('hide'); }); </script>
Re: READING SOURCE CODES - One Of The Best Developer Practice by KvnqPrezo(m): 12:16pm On Sep 17, 2016
Am coming back for this code..
Re: READING SOURCE CODES - One Of The Best Developer Practice by ojodombe(m): 1:17pm On Sep 17, 2016
[quote author=ANTONINEUTRON post=49436874]explain




function hasAttr(o, attr) {
return $(o).attr(attr) != undefined;
}


(function ( $ ) {
$.fn.rooster = function(action, options) {
/****************************************
* Jquery Rooster!
* A simple countdown timer.
*
* Currently does not accept date time formats
*
*****************************************/

var INTERVAL = 100;

var el = $(this);

var defaults = {
seconds: el.data('rooster-seconds') || 0,
onComplete: el.data('rooster-oncomplete') || null,
onStart: el.data('rooster-onstart') || null,
onStop: el.data('rooster-onstop') || null,
includeMinutes: hasAttr(el, 'data-rooster-includeminutes') ? el.data('rooster-includeminutes') : true,

state: el.data('state') || 'idle',
};

var opts = $.extend({}, defaults, options);

var milliseconds = opts.seconds * 1000 + INTERVAL;

function updateTimer() {
var displayTime;
var seconds;
if (opts.includeMinutes) {
var minutes = Math.floor((milliseconds / 1000) / 60);
minutes = minutes.toString();
while (minutes.length < 2) minutes = '0' + minutes;

seconds = Math.floor(milliseconds / 1000) % 60;
seconds = seconds.toString();
while (seconds.length < 2) seconds = '0' + seconds;

displayTime = minutes + ':' + seconds;
} else {
seconds = Math.floor(milliseconds / 1000);
seconds = seconds.toString();

displayTime = seconds;
}
el.html(displayTime);
}

function clearRoosterTimer() {
clearInterval(el.data('countdown'));
el.data('countdown', null);
}

function onInterval() {
milliseconds -= INTERVAL;
updateTimer();
if (milliseconds > 0) {
return;
}
clearRoosterTimer();
if (opts.onComplete) {
if (typeof(opts.onComplete) == 'string') {
eval(opts.onComplete);
} else if (typeof(opts.onComplete) == 'function') {
opts.onComplete();
}
}
}

switch (action) {
case 'start':
// Start the Timer
el.data('state', 'active');
el.data('countdown', setInterval(onInterval, INTERVAL));
return this;
case 'stop':
el.data('state', 'idle');
clearRoosterTimer();
return this;
default:
// Initialize
updateTimer();
return this;
}
};

}( jQuery ));
[/quote
What language is this?
Re: READING SOURCE CODES - One Of The Best Developer Practice by KvnqPrezo(m): 1:22pm On Sep 17, 2016
ojodombe:
what language is this?

I think it's JavaScript and jQuery
Re: READING SOURCE CODES - One Of The Best Developer Practice by KvnqPrezo(m): 4:12pm On Sep 17, 2016
ANTONINEUTRON:

and this

<script language="JavaScript">
$('.cont').addClass('hide');
$('#que1').removeclass('hide);
var count = $('.questions').length;
/*next button*/
$(document).on('click','.next',function(){
var element = $(this).attr('id');
var last =parseInt(element.substr(element.length -1));
var nex = last+1;
$('#que1'+last).addClass('hide');
$('#que1'+nex).removeClass('hide');
});
</script>

I don't understand but before the comment I noticed you want to count how many letters are in a text...

Don't say it yet ...
I'll come back for this code lemme go let about function...
Re: READING SOURCE CODES - One Of The Best Developer Practice by ANTONINEUTRON(m): 6:49pm On Sep 18, 2016
[quote author=ojodombe post=49439631][/quote] JavaScript
Re: READING SOURCE CODES - One Of The Best Developer Practice by francollimasso: 2:30pm On Sep 19, 2016
ANTONINEUTRON:

and this

<script language="JavaScript">
$('.cont').addClass('hide');
$('#que1').removeclass('hide);
var count = $('.questions').length;
/*next button*/
$(document).on('click','.next',function(){
var element = $(this).attr('id');
var last =parseInt(element.substr(element.length -1));
var nex = last+1;
$('#que1'+last).addClass('hide');
$('#que1'+nex).removeClass('hide');
});
</script>
This jquery, am still a learner, I believe the program can be simplied by toggling
Re: READING SOURCE CODES - One Of The Best Developer Practice by melodyogonna(m): 6:19pm On Sep 19, 2016
plz can we try to find a bug from this code

1 Like

Re: READING SOURCE CODES - One Of The Best Developer Practice by romme2u: 9:24am On Sep 20, 2016
ANTONINEUTRON:

JavaScript

the hasAttr function is supposed to check if the object passed to it is a jquery object or dom object so that it can return the appropriate result.

something like this:

function hasAttr(el, attribute){
if(el is jquery object){
//this is jquery object so attr method can be called safely
return el.attr('attribute') != undefined;
}
else{
//maybe dom or normal html element
return $(el).attr('attribute') != undefined;
}
}
Re: READING SOURCE CODES - One Of The Best Developer Practice by melodyogonna(m): 4:16pm On Sep 29, 2016
a simple javascript game <SCRIPT LANGUAGE="JavaScript">
<!--
var display_text = "Sadly, Denmark is an unlikely place "
+ "to find gray elephants and orange kangaroos! "
+ " There are more cool stuff like this "
+ "throughout my site! Check 'em out!!!!!!!!!!"
var display_text; var place; var meter;
var out = " "; var place = 50;
function scroll_text(){
for (meter = 0; meter < place; meter++){
out += " "
}
if (place >= 0)
out += display_text
else out = display_text.substring(-place,display_text.length)
document.scroll_form.field.value = out
out = " "
place--
if (place < -(display_text.length)){
place = 50
}
setTimeout('scroll_text()',100)
}
// -->
</SCRIPT> bounced into this site while searching for javascript source codes, www.javascriptkit.com for much more source codes for ur site

(1) (Reply)

Today is good / Building A Payment App / Java Or .net Mvc Frameworks

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 37
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.