Talk:Main Page
From CodeCodex
Protection
This page has been temporarily protected from anon edits to deal with spambots. -WikiSysop 16:41, 17 July 2006 (CDT)
Recently edited code
Isn't it somwhat misleading to show Recently Edited Java Code and Recently Edited C Code?
Spinoza1111 21:41, 5 June 2006 (CDT)
- Feel free to update the main page however you see fit! We could add more languages or anything really... When I made the main page I just wanted to let people know what code is new and being worked on. -Nostromo 09:11, 6 June 2006 (CDT)
C# / VB
Very interesting. Thanks for creating this. Do you want or will you stock C Sharp or Visual Basic code?
Edward G. Nilges, author of <shamelessPlug>Build Your Own .Net Language and Compiler (Apress 2004)</shamelessPlug>
- Hi Edward. Yeah, we can add all types of languages. Feel free to build whatever you'd like to see. -Nostromo 09:11, 6 June 2006 (CDT)
Copyright
I just discovered that site by chance from wikipedia:OCaml. I like it. I think it would be nice to have a way to contact the managers/admins of the project, and know a little more about who they are. Is the wiki source distributed under some kind of very flexible license? I don't want to annoy programmers who would copy-paste some code into their programs, it's more about granting the right of cloning the web site in case it is not maintained anymore or something like that. --Martin 05:38, 24 June 2006 (CDT)
- Hi Martin. I haven't selected a license yet -- mainly because I'm not a lawyer. :-) I was thinking either Public Domain or GPL -- but really it's up to what the community thinks is best. The issue I'm mainly concerned with is that I want code from open source projects of all types to be available, which all have their own governing license. That means that the license would depend on the code that is submitted. (What happens when that code evolves is still an open question.) However, any license we as a community choose should be open to complete cloning / redundancy for back-up purposes, etc. Let me know your thoughts! -WikiSysop 12:05, 27 June 2006 (CDT)
Hi All. I've just a question. Can I use a class from this site in my open source project? My open source project needs no GPL license, I need a free code and eventually I'll add some modification to the current implementation of the class. let me know -g.migliavacca 16:36, 22 May 2007 (CDT)
- Hello g.migliavacca. All of the code on this wiki is available under the GFDL (full text of the licence), a copyleft licensing scheme, meaning that anyone may use, modify and distribute it, but the resulting work which they distribute must also be 'copylefted'. Hope this (and the links) help. Cheers. --Why My Fleece? 18:52, 22 May 2007 (CDT)
Web Programming
Great site! I hope it will grow and become even better! However - as I'm mainly a web programmer I miss JavaScript and VBScript. I would gladly contribute with loads and loads of functions in those languages. --Megalobrainiac 02:14, 26 June 2006 (CDT)
- I too would like to see more web programing and scripting languages. I'm trying to bring in as much content as possible, so keep checking back -- and feel free to add your favorite functions! -WikiSysop 12:05, 27 June 2006 (CDT)
VB.net
Am I allowed to contribute code in VB.net ? Lcarsdata 15:22, 15 February 2007 (CST)
- Please do! Contribute in any way you feel is appropriate. We even have some 'recipes' for non-languages, like XML. -Nostromo 15:47, 15 February 2007 (CST)
Full classes
This is fantastic, I've been thinking of doing something like this for quite a while now, glad I found this wiki first.
One thought (for now): It would be nice if, at least for java, every snippet was entered as a full class or at least method. Java has very little overhead for this, and it really leads to ease of use as plug-in code and reusability.
After looking at it a bit more, I realize that you are really targeting smaller code snips. My ideal would be more along a library--is there room for both styles on there? (I put an XML class I wrote in the Java area as an example--what do you think?)
Perhaps a new category tag could be used to indicate a fully-formed library style class, or a snip tag to indicate code that is not?
Also, a summary of categories at the bottom of each edit page with a line on how to use them might help--It took me a while to figure out how to do the whole category thing. Added groovy category as a test...
Why not a merger
Having more than one competing site which provides a wiki code repository makes picking and contributing to one difficult for new users such as myself. Moreover, I'm disturbed by an apparent lack of discourse about a possible merger among such sites, firstly of Code Codex and Rosetta Code. Such a merger of such sites is a highly warranted for several obvious reasons. I hope you won't let personal pride (if any), or trivial code licensing issues, or manageable technical issues come in the way of a better unified future for all. I look forward to continued discussion with regards to this, until compromise and consensus has been achieved, and such non-trivial sites have been merged into one. --Borg 01:06, 31 March 2007 (CDT)
- Truth be told, I have no problem if CC includes RC code with attribution. However, I'm not sure that a merger is the best idea, because I've had a different vision of what I want to make Rosetta Code than what I've seen of CC. RC is intended as a learning tool (for me as much as anyone), and a way to increase general knowledge of programming and programming languages. Eventually, I want to see it blossom into an encyclopedia for programmers.
- However, I'm not totally adverse to the idea of a merger. If the CodeCodex admins are interested in that, they should send me an email. --Short Circuit 09:14, 31 March 2007 (CDT)
- I can understand a merger possibly being less than ideal when there is a serious uncompromisable difference in the site's vision, such as say with LiteratePrograms. However, I personally don't see a big difference in visions of CC and RC. What is the difference as per you? --Borg 12:01, 31 March 2007 (CDT)
- Hi all -- thanks for brining this discussion here. While I'm certainly not opposed to merging projects at some point, I think I agree with Short Circuit for the time being. The difference in vision, as I understand it, is that Rosetta Code is more focused on showing similarities between languages on common tasks. While that's possible on CodeCodex, it's less of a focus. For example, we have code on CodeCodex that only really makes sense in one language, such as JavaScript or VBA. I think the vision long-term for CodeCodex is to be a code clearing house, while RC is more focused on common tasks across languages as a method for learning different syntaxes. (Please correct me if I'm off here SC -- I certainly don't want to mischaracterize your great project.)
- Also, I'm not sure of the benefits of having only one player in this space this early in the game. Since both CC and RC have lenient licenses, content can flow back and forth freely as both projects see fit. -Nostromo 10:09, 2 April 2007 (CDT)
Online Image Optimizer
<a href="http://tools.dynamicdrive.com/imageoptimizer/"><img src="http://tools.dynamicdrive.com/imageoptimizer/export/optimizelogo2.jpg" border="0" alt="Free online tool- optimize your gifs, jpg, and png images" /></a>
LCD Clock
<script> </script>
analog clock II
<v:group id="clock" coordsize="100 100" style="position: relative;"> <v:oval style="width: 100%; height: 100%"> <v:stroke weight="10px" color="gray"/>
</v:oval>
<v:group id="secondsPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;"> <v:line from="50,50" to="50,5"> <v:stroke weight="2px" endcap="round" color="navy"/> </v:line> </v:group>
<v:group id="minutesPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;"> <v:line from="50,50" to="50,8"> <v:stroke weight="4px" endcap="round" color="navy"/> </v:line> </v:group>
<v:group id="hoursPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;"> <v:line from="50,50" to="50,18"> <v:stroke weight="7px" endcap="round" color="navy"/> </v:line> </v:group>
</v:group>
Basic Calendar
<style type="text/css">
.main { width:200px; border:1px solid black; }
.month { background-color:black; font:bold 12px verdana; color:white; }
.daysofweek { background-color:gray; font:bold 12px verdana; color:white; }
.days { font-size: 12px; font-family:verdana; color:black; background-color: lightyellow; padding: 2px; }
.days #today{ font-weight: bold; color: red; }
</style>
<script type="text/javascript" src="basiccalendar.js">
/***********************************************
- Basic Calendar-By Brian Gosselin at http://scriptasylum.com/bgaudiodr/
- Script featured on Dynamic Drive (http://www.dynamicdrive.com)
- This notice must stay intact for use
- Visit http://www.dynamicdrive.com/ for full source code
- /
</script>
Drop-down Document Viewer
<form name="jumpy"> <select name="example" size="1" onChange="gone()"> <option value="http://www.yahoo.com" selected>Yahoo.com</option> <option value="http://www.google.com">Google</option> <option value="http://www.lycos.com">Lycos</option> <option value="http://www.AltaVista.com">AltaVista</option> </select>
<input type="button" name="test" value="Go!" onClick="gone()"> </form>
<script language="javascript"> </script>
Email Riddler (online tool)
<script type="text/javascript"> /*<![CDATA[*/
/***********************************************
- Encrypt Email script- Please keep notice intact
- Tool URL: http://www.dynamicdrive.com/emailriddler/
- **********************************************/
var emailriddlerarray=[106,97,99,107,121,48,48,56,95,99,104,97,110,110,64,121,97,104,111,111,46,99,111,109] var encryptedemail_id52= //variable to contain encrypted email for (var i=0; i<emailriddlerarray.length; i++)
encryptedemail_id52+=String.fromCharCode(emailriddlerarray[i])
document.write('<a href="mailto:'+encryptedemail_id52+'?subject=I wnat this code">Hello</a>')
/*]]>*/ </script>
Show Hint script
<style type="text/css">
- hintbox{ /*CSS for pop up hint box */
position:absolute; top: 0; background-color: lightyellow; width: 150px; /*Default width of hint.*/ padding: 3px; border:1px solid black; font:normal 11px Verdana; line-height:18px; z-index:100; border-right: 3px solid black; border-bottom: 3px solid black; visibility: hidden; }
.hintanchor{ /*CSS for link that shows hint onmouseover*/ font-weight: bold; color: navy; margin: 3px 8px; }
</style>
<script type="text/javascript">
/***********************************************
- Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
- This notice MUST stay intact for legal use
- Visit http://www.dynamicdrive.com/ for this script and 100s more.
- /
var horizontal_offset="9px" //horizontal offset of hint box from anchor link
/////No further editting needed
var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change. var ie=document.all var ns6=document.getElementById&&!document.all
function getposOffset(what, offsettype){ var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; var parentEl=what.offsetParent; while (parentEl!=null){ totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; parentEl=parentEl.offsetParent; } return totaloffset; }
function iecompattest(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body }
function clearbrowseredge(obj, whichedge){ var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1 if (whichedge=="rightedge"){ var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40 dropmenuobj.contentmeasure=dropmenuobj.offsetWidth if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure) edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset) } else{ var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18 dropmenuobj.contentmeasure=dropmenuobj.offsetHeight if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure) edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight } return edgeoffset }
function showhint(menucontents, obj, e, tipwidth){ if ((ie||ns6) && document.getElementById("hintbox")){ dropmenuobj=document.getElementById("hintbox") dropmenuobj.innerHTML=menucontents dropmenuobj.style.left=dropmenuobj.style.top=-500 if (tipwidth!=""){ dropmenuobj.widthobj=dropmenuobj.style dropmenuobj.widthobj.width=tipwidth } dropmenuobj.x=getposOffset(obj, "left") dropmenuobj.y=getposOffset(obj, "top") dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px" dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px" dropmenuobj.style.visibility="visible" obj.onmouseout=hidetip } }
function hidetip(e){ dropmenuobj.style.visibility="hidden" dropmenuobj.style.left="-500px" }
function createhintbox(){ var divblock=document.createElement("div") divblock.setAttribute("id", "hintbox") document.body.appendChild(divblock) }
if (window.addEventListener) window.addEventListener("load", createhintbox, false) else if (window.attachEvent) window.attachEvent("onload", createhintbox) else if (document.getElementById) window.onload=createhintbox
</script>
Switch Menu
<style type="text/css"> .menutitle{ cursor:pointer; margin-bottom: 5px; background-color:#ECECFF; color:#000000; width:140px; padding:2px; text-align:center; font-weight:bold; /*/*/border:1px solid #000000;/* */ }
.submenu{ margin-bottom: 0.5em; } </style>
<script type="text/javascript">
/***********************************************
- Switch Menu script- by Martial B of http://getElementById.com/
- Modified by Dynamic Drive for format & NS4/IE4 compatibility
- Visit http://www.dynamicdrive.com/ for full source code
- /
var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc) var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only
if (document.getElementById){ //DynamicDrive.com change document.write('<style type="text/css">\n') document.write('.submenu{display: none;}\n') document.write('</style>\n') }
function SwitchMenu(obj){ if(document.getElementById){ var el = document.getElementById(obj); var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change if(el.style.display != "block"){ //DynamicDrive.com change for (var i=0; i<ar.length; i++){ if (ar[i].className=="submenu") //DynamicDrive.com change ar[i].style.display = "none"; } el.style.display = "block"; }else{ el.style.display = "none"; } } }
function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { offset += search.length end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; }
function onloadfunction(){ if (persistmenu=="yes"){ var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname var cookievalue=get_cookie(cookiename) if (cookievalue!="") document.getElementById(cookievalue).style.display="block" } }
function savemenustate(){ var inc=1, blockid="" while (document.getElementById("sub"+inc)){ if (document.getElementById("sub"+inc).style.display=="block"){ blockid="sub"+inc break } inc++ } var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid document.cookie=cookiename+"="+cookievalue }
if (window.addEventListener) window.addEventListener("load", onloadfunction, false) else if (window.attachEvent) window.attachEvent("onload", onloadfunction) else if (document.getElementById) window.onload=onloadfunction
if (persistmenu=="yes" && document.getElementById) window.onunload=savemenustate
</script>
Static Menu Script
<SCRIPT Language="Javascript1.2"> </SCRIPT>
Pop-it menu
<style type="text/css">
- popitmenu{
position: absolute; background-color: white; border:1px solid black; font: normal 12px Verdana; line-height: 18px; z-index: 100; visibility: hidden; }
- popitmenu a{
text-decoration: none; padding-left: 6px; color: black; display: block; }
- popitmenu a:hover{ /*hover background color*/
background-color: #CCFF9D; }
</style>
<script type="text/javascript">
/***********************************************
- Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
- This notice MUST stay intact for legal use
- Visit http://www.dynamicdrive.com/ for full source code
- /
var defaultMenuWidth="150px" //set default menu width.
var linkset=new Array() //SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
linkset[0]='<a href="http://dynamicdrive.com">Dynamic Drive</a>'
linkset[0]+='' //Optional Separator
linkset[0]+='<a href="http://www.javascriptkit.com">JavaScript Kit</a>' linkset[0]+='<a href="http://www.codingforums.com">Coding Forums</a>' linkset[0]+='<a href="http://www.cssdrive.com">CSS Drive</a>' linkset[0]+='<a href="http://freewarejava.com">Freewarejava</a>'
linkset[1]='<a href="http://msnbc.com">MSNBC</a>' linkset[1]+='<a href="http://cnn.com">CNN</a>' linkset[1]+='<a href="http://news.bbc.co.uk">BBC News</a>' linkset[1]+='<a href="http://www.washingtonpost.com">Washington Post</a>'
////No need to edit beyond here
var ie5=document.all && !window.opera var ns6=document.getElementById
if (ie5||ns6)
document.write('')function iecompattest(){ return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body }
function showmenu(e, which, optWidth){ if (!document.all&&!document.getElementById) return clearhidemenu() menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu") menuobj.innerHTML=which menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth menuobj.contentwidth=menuobj.offsetWidth menuobj.contentheight=menuobj.offsetHeight eventX=ie5? event.clientX : e.clientX eventY=ie5? event.clientY : e.clientY //Find out how close the mouse is to the corner of the window var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY //if the horizontal distance isn't enough to accomodate the width of the context menu if (rightedge<menuobj.contentwidth) //move the horizontal position of the menu to the left by it's width menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px" else //position the horizontal position of the menu where the mouse was clicked menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px" //same concept with the vertical position if (bottomedge<menuobj.contentheight) menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px" else menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px" menuobj.style.visibility="visible" return false }
function contains_ns6(a, b) { //Determines if 1 element in contained in another- by Brainjar.com while (b.parentNode) if ((b = b.parentNode) == a) return true; return false; }
function hidemenu(){ if (window.menuobj) menuobj.style.visibility="hidden" }
function dynamichide(e){ if (ie5&&!menuobj.contains(e.toElement)) hidemenu() else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)) hidemenu() }
function delayhidemenu(){ delayhide=setTimeout("hidemenu()",500) }
function clearhidemenu(){ if (window.delayhide) clearTimeout(delayhide) }
if (ie5||ns6) document.onclick=hidemenu
</script>
Fancy Cursor Script
style="cursor:ne-resize"
Circling text trail
<SCRIPT LANGUAGE="JavaScript1.2"> </SCRIPT>
Fade-away cursor trail script
<SCRIPT language="Javascript1.2"> </SCRIPT>
Open offsite links in new window
<script type="text/javascript" src="ddwindowlinks.js">
/***********************************************
- Open offsite links in new window- (c) Dynamic Drive (www.dynamicdrive.com)
- This notice MUST stay intact for legal use
- Visit http://www.dynamicdrive.com/ for full source code
- /
</script>
Disable right mouse click script II (on images)
<script language="JavaScript1.2">
/* Disable right click script II (on images)- By Dynamicdrive.com For full source, Terms of service, and 100s DTHML scripts Visit http://www.dynamicdrive.com
- /
var clickmessage="Right click disabled on images!"
function disableclick(e) { if (document.all) { if (event.button==2||event.button==3) { if (event.srcElement.tagName=="IMG"){ alert(clickmessage); return false; } } } else if (document.layers) { if (e.which == 3) { alert(clickmessage); return false; } } else if (document.getElementById){ if (e.which==3&&e.target.tagName=="IMG"){ alert(clickmessage) return false } } }
function associateimages(){ for(i=0;i<document.images.length;i++) document.images[i].onmousedown=disableclick; }
if (document.all) document.onmousedown=disableclick else if (document.getElementById) document.onmouseup=disableclick else if (document.layers) associateimages() </script>
Screen Size Redirect Script
<script language="JavaScript1.2"> </script>
Encrypted Password script
<script> //Encrypted Password script- By Rob Heslop //Script featured on Dynamic Drive //Visit http://www.dynamicdrive.com
function submitentry(){ password = document.password1.password2.value.toLowerCase() username = document.password1.username2.value.toLowerCase() passcode = 1 usercode = 1 for(i = 0; i < password.length; i++) { passcode *= password.charCodeAt(i); } for(x = 0; x < username.length; x++) { usercode *= username.charCodeAt(x); } //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD if(usercode==134603040&&passcode==126906300) //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD { window.location=password+".htm"} else{ alert("password/username combination wrong")} } </script>
<form name="password1">
Enter username:
<input type="text" name="username2" size="15">
Enter password:
<input type="password" name="password2" size="15">
<input type="button" value="Submit" onClick="submitentry()"> </form>
Disable Text Selection script
<script type="text/javascript">
/***********************************************
- Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
- This notice MUST stay intact for legal use
- Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
- /
function disableSelection(target){ if (typeof target.onselectstart!="undefined") //IE route target.onselectstart=function(){return false} else if (typeof target.style.MozUserSelect!="undefined") //Firefox route target.style.MozUserSelect="none" else //All other route (ie: Opera) target.onmousedown=function(){return false} target.style.cursor = "default" }
//Sample usages //disableSelection(document.body) //Disable text selection on entire body //disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"
</script>
JavaScript Sound effect
<bgsound src="#" id="soundeffect" loop=1 autostart="true" />
<script type="text/javascript">
/***********************************************
- JavaScript Sound effect- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
- Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
- This notice must stay intact for legal use
- /
var soundfile="sidebar.wav" //path to sound file, or pass in filename directly into playsound()
function playsound(soundfile){ if (document.all && document.getElementById){ document.getElementById("soundeffect").src="" //reset first in case of problems document.getElementById("soundeffect").src=soundfile } }
function bindsound(tag, soundfile, masterElement){ if (!window.event) return var source=event.srcElement while (source!=masterElement && source.tagName!="HTML"){ if (source.tagName==tag.toUpperCase()){ playsound(soundfile) break } source=source.parentElement } }
</script>
Find In Page Script
<script> </script>
<form name="form1" onSubmit="search(document.form1, frametosearch); return false"><input type="text" name="findthis" size="15" title="Press 'ALT s' after clicking submit to repeatedly search page"> <input type="submit" value="Find in Page" ACCESSKEY="s"></form>
CAPTCHA
Your CAPTCHA implementation is a bit intrusive. On my site, I use these settings:
$wgCaptchaTriggers['edit'] = true; $wgGroupPermissions['user']['skipcaptcha'] = true; $wgGroupPermissions['bot']['skipcaptcha'] = true;
Once we identified and blocked the users that had been created by spambots, we ceased getting spam edits, so these settings seem alright. --Short Circuit 00:51, 17 February 2009 (EST)

