<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Name Generators Blog &#187; name generator</title>
	<atom:link href="http://www.name-generators.com/tag/name-generator/feed" rel="self" type="application/rss+xml" />
	<link>http://www.name-generators.com</link>
	<description>Blogging about name generators</description>
	<lastBuildDate>Sun, 04 Dec 2011 17:28:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Random name generator in Python</title>
		<link>http://www.name-generators.com/name-generators/random-name-generator-in-python.htm</link>
		<comments>http://www.name-generators.com/name-generators/random-name-generator-in-python.htm#comments</comments>
		<pubDate>Sat, 04 Sep 2010 19:25:52 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Name generator stuff]]></category>
		<category><![CDATA[name generator]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=254</guid>
		<description><![CDATA[In this short tutorial I will show you how to make a random name generator in Python. If you came here looking for some cool random names visit the online name generators. The name generator script Open IDLE which is &#8230; <a href="http://www.name-generators.com/name-generators/random-name-generator-in-python.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this short tutorial I will show you how to make a random name generator in Python.</p>
<p>If you came here looking for some cool random names visit the online<strong> <a title="Name generators" href="http://online-generator.com/" target="_blank">name generators</a></strong>.</p>
<h3>The name generator script</h3>
<p>Open IDLE which is the Python supplied IDE or editor (Go to the bottom of the post to see, how you get started with Python).</p>
<p>Open a new window from the file menu and write the following name generator script into this window.</p>
<pre lang="python" line="1">def name_generator():
  import random
  color = ["Red","Blue","Black","White"]
  tool = ["Hammer","Drill","Cutter","Knife"]
  randomNumber1 = random.randrange(0,len(color))
  randomNumber2 = random.randrange(0,len(tool))
  name = color[randomNumber1] + " " + tool[randomNumber2]
  print(name)

name_generator()

(Be aware that copy-paste from the blog may give syntax errors!
 A correct indent is an important element Python syntax!)
</pre>
<p>Save it as name-generator.py.  Now you can run the python program by pressing F5.</p>
<h3>Name generator walk through</h3>
<p>Lets walk through the python script, line by line.</p>
<ol>
<li>In the first line we define our name generator function.</li>
<li>Then we import the random module, so we can call the random function later on.</li>
<li>In line define 2 arrays (color and tool) and asign values to them</li>
<li>Then we make 2 random numbers based on the length of our arrays. The randrage() function returns an integer in the range defined by the parameters. As parameters we use 0 and the len() function to count the numbers of words in the arrays.</li>
<li>In line 7 and 8 we make the final name and print it on the screen.</li>
<li>Finally we call the name generator function, we have just written.</li>
</ol>
<p>That&#8217;s all it takes to make a simple Python random name generator. When you this basic functionality it&#8217;s easy to experiment and develop the random name generator to suit your needs and wishes.</p>
<h3>Name generator inspiration</h3>
<p>For inspiration visit the <a title="Name generators" href="http://online-generator.com/" target="_blank">name generators</a> where you can find a lot of name generators in several genres. From random names over fantasy and nicknames to band and business names.</p>
<h3>Python Beginner guides and tutorials</h3>
<p>Python is a free scripting language running on all platforms from  Linux to Windows. Python is a relative easy programming language and a  name generator is a simple application so it&#8217;s a good place to start if  you wanna learn some programming.</p>
<p>If you haven&#8217;t Python installed at your computer you can download it at <a title="Download Python" href="http://www.python.org/download/" target="_blank">Python.org</a>. This name generator script is based on python 3.12, which is the newest stable version at the moment.</p>
<p>At python.org you can find an excellent <a title="Python tutorial" href="http://docs.python.org/py3k/tutorial/index.html" target="_blank">Python tutorial</a>. And you can find much more about how to use the <a title="Random module in Python" href="http://docs.python.org/py3k/library/random.html">Random function in Python</a>.</p>
<p>Or visit this <a title="Python beginner guide" href="http://wiki.python.org/moin/BeginnersGuide" target="_blank">beginner guide to Python</a> which contains lots of links and resources.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/name-generators/random-name-generator-in-python.htm/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Name generator widget</title>
		<link>http://www.name-generators.com/name-generators/name-generator-widget.htm</link>
		<comments>http://www.name-generators.com/name-generators/name-generator-widget.htm#comments</comments>
		<pubDate>Mon, 12 Jul 2010 09:27:17 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Name generator stuff]]></category>
		<category><![CDATA[name generator]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=189</guid>
		<description><![CDATA[I continue to give away stuff.  This time it&#8217;s a name generator widget. The name generator widget integrates seamlessly with the web site. The widget contains all the necessary code to run very easily on a web page. Just add &#8230; <a href="http://www.name-generators.com/name-generators/name-generator-widget.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I continue to give away stuff.  This time it&#8217;s a name generator widget.</p>
<p>The name generator widget integrates seamlessly with the web site. The  widget contains all the necessary code to run very easily on a web   page. Just add a single line of code to your page.</p>
<p>The name generator widget makes <a title="Code names from the code name generator" href="http://online-generator.com/name-generator/codename-generator.php" target="_blank">code names</a>, that can be used in various ways.  Use the  widget to make code names for bands, projects, blog names etc.</p>
<p>See how the widget works at my sidebar. &#8212;&#8211;&gt;</p>
<h3>How to install the widget</h3>
<p>Just insert this line of simple  code, where you want the  name generator to  run, and you got a fully functional name generator on your site.</p>
<blockquote><p>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;http://name-generators.com/widgets/name-generator-widget-beta.js&#8221;&gt;&lt;/script&gt;</p></blockquote>
<p>The widget takes care of the rest. From name generation to styling.</p>
<h3>How to customize the name widget.</h3>
<p>Use firebug or other developer tool to see the unique id&#8217;s and classes on  all elements.  Just add these to your style sheet with the styles you want. In this way it&#8217;s easy to add background images or cool buttons to the widget.</p>
<h3>Name widget specs</h3>
<p>The widget is programmed in JavaScript. It is minified to minimize the load time for your users.</p>
<p>The name widget  works crossbrowser. It is tested in Firefox, Internet Explorer 7+8, Opera and Chrome.</p>
<p>It follows the XHTML standarad set by the w3.org and validate as XHTML 1.1.</p>
<h3>Do you want another name widget?</h3>
<p>Do you want a business, superhero or maybe a fantasy name widget on your  site, blog  or  favorite forum?</p>
<p>Please contact me and let&#8217;s see if we can work out something. I&#8217;m   always interested in some serious text link cooperation. <img src='http://www.name-generators.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>For another working example check this <a title="Band name widget" href="http://www.name-generators.com/name-generators/band-name-widget.htm">band name generator widget</a>.</p>
<h3>Other free name generator stuff</h3>
<p>Also remember to check out the:</p>
<p><a title="How to make a name generator" href="http://www.name-generators.com/name-generators/how-to-make-name-generator.htm">How to make a name generator</a></p>
<p><a title="Name generator script" href="http://www.name-generators.com/name-generators/name-generator-script.htm">Name generator script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/name-generators/name-generator-widget.htm/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to make a name generator</title>
		<link>http://www.name-generators.com/name-generators/how-to-make-name-generator.htm</link>
		<comments>http://www.name-generators.com/name-generators/how-to-make-name-generator.htm#comments</comments>
		<pubDate>Sat, 08 May 2010 18:26:05 +0000</pubDate>
		<dc:creator>Niels</dc:creator>
				<category><![CDATA[Name generator stuff]]></category>
		<category><![CDATA[name generator]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.name-generators.com/?p=143</guid>
		<description><![CDATA[In this tutorial I&#8217;ll show how to make a simple name generator. A sort of  &#8220;build your own name generator&#8221; to experiment with. You just need to add your own word lists and you&#8217;re up and running.  But you can &#8230; <a href="http://www.name-generators.com/name-generators/how-to-make-name-generator.htm">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;ll show how to make a simple name generator. A sort of  &#8220;build your own name generator&#8221; to experiment with. You just need to add your own word lists and you&#8217;re up and running.  But you can expand and modify the  name generator code to your own likings   and abilities.</p>
<p>The name generator tutorial is very simple and are aimed at absolute beginners in web programming.</p>
<p>But enough talk, here is some name generator code that makes superhero names:</p>
<pre lang="javascript">function generator(){
  // Add your own words to the wordlist. Be carefull to obey the showed syntax
  var adjectives = ["Cool","Masked","Bloody","Lame"]
  var animals = ["Hamster","Moose","Lama","Duck"]

  // Random numbers are made
  var randomNumber1 = parseInt(Math.random() * adjectives.length);
  var randomNumber2 = parseInt(Math.random() * animals.length);
  var name = adjectives[randomNumber1] + " " + animals[randomNumber2];

  alert(name); //Delete this when the below works            

  //If there's already a name it is removed  
  if(document.getElementById("result")){
    document.getElementById("placeholder").removeChild(document.getElementById("result"));
  }
  // A div element is created to show the generated name.
  //The Name is added as a textnode. Textnode is added to the placeholder.
  var element = document.createElement("div");
  element.setAttribute("id", "result");
  element.appendChild(document.createTextNode(name));
  document.getElementById("placeholder").appendChild(element);
}</pre>
<p>The script is a simplified version of the one I use to make <a title="Superhero names" href="http://online-generator.com/name-generator/superhero-name-generator.php" target="_blank">superhero names</a> with my superhero generator.</p>
<h3 style="font-size: 20px; margin-bottom: 10px;">The name generator piece by piece</h3>
<h3>The arrays</h3>
<p>The most important part of  the name generator is the word lists. The more words in the list the more variety in the output. So the first part to do is to create a couple of arrays holding all our cool words:</p>
<pre lang="javascript">var adjectives = ["cool","masked","bloody","lame"];
var animals = ["hamster","moose","lama","duck"]</pre>
<p>To retrieve data  from the list we call the name of array with the count of the word as a parameter in a square bracket.  Be aware that counting in programming almost always starts at zero and not at 1.</p>
<p>So adjectives[0] is cool and  animals[1] gives moose</p>
<h3>Randomness</h3>
<p>We of course want random names, so we need to replace the hard coded numbers with random numbers. In our case numbers between 0 and 3 because we have 4 words in our lists. Instead of counting the words ourself, we do that we let the JavaScript length function do the counting. Then we multiply it with a random floating-point number between 0 and 0.9999999999999. Finally we use the parseInt funktion to make the floating-point number into a integer.</p>
<p>All sounds a bit complicated but code wise  it&#8217;s  quite easy.</p>
<pre lang="javascript">randomNumber1 = parseInt(Math.random() * adjectives.length);
randomNumber2 = parseInt(Math.random() * animals.length);</pre>
<h3>The output</h3>
<p>The most simple way to output the name is using the alert function. I use it only to check the generated name cause,  the alert box is  very annoying. So just delete the line, when the code below is up an running.</p>
<p>We will use 7 extra lines to integrate the result into the web page in a more natural way.</p>
<p>But before we begin you need to make an empty div tag in your HTML:</p>
<p>&lt;div id=&#8221;placeholder&#8221;&gt;&lt;/div&gt;</p>
<p>And here are the 7 lines that write the result in the page..</p>
<pre lang="javascript">if(document.getElementById("result")){
  document.getElementById("placeholder").removeChild(document.getElementById("result"));
}

element = document.createElement("div");
element.setAttribute("id", "result");
element.appendChild(document.createTextNode(name));
document.getElementById("placeholder").appendChild(element);</pre>
<p>In short it works like this:</p>
<ol>
<li>If there&#8217;s already a result it is removed</li>
<li>Then a new div element to hold the result  is created</li>
<li>The name is added as a text node</li>
<li>Finally the element is appended to a placeholder in the HTML.</li>
</ol>
<p>When this part works, you can delete the alert(name) from the script.</p>
<h3>Putting it all together</h3>
<p>The generator function can either be included in the head of the HTML document or you can place it in a external JavaScript file.</p>
<p>Now you can call the function from your HTML page.  I always do it 2 places. First in the body tag with an onload event. The generator function then also runs when the page is loaded.</p>
<p>&lt;body onload=&#8221;generator()&#8221;&gt;</p>
<p>And then I also call the JavaScript function on a button:</p>
<p>&lt;input type=&#8221;button&#8221; onclick=&#8221;generator()&#8221; /&gt;</p>
<h3>Download the name generator script</h3>
<p><a title="Download name generator script as zip file" href="http://www.name-generators.com/name-generators/download/name-generator-script.zip">Download name generator script here</a> and read the description of <a title="Name generator script" href="http://www.name-generators.com/name-generators/name-generator-script.htm">how to make the name generator script work</a>.</p>
<h3>Extra funcionality</h3>
<p>The random functions in this guide is very simple. At some time you&#8217;ll probably want to make more complex and interesting names. Here you can see <a title="Make more complex random names" href="http://www.name-generators.com/name-generators/complex-random-names.htm">how to make more complex random names</a>.</p>
<p>On all of my name generators I also have a save list, which saves all the generated names to a list. Read here <a title="Add a save list to name generator" href="http://www.name-generators.com/name-generators/save-name-generator-names.htm">how to add a save list to the name generator</a>.</p>
<h3>Want a review of your name generator?</h3>
<p>Write a comment if  you make a cool name generator with this script. I might very well  write a review of it.  <img src='http://www.name-generators.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Also remember to visit my name generators to see  how I make <a title="Superhero name" href="http://online-generator.com/name-generator/superhero-name-generator.php" target="_blank">superhero names</a> with the superhero generator.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.name-generators.com/name-generators/how-to-make-name-generator.htm/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

