|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On March 04 2013 15:10 JeanLuc wrote: to any web devs: is it okay to be coding just html and vanilla js code in this day and age. It can be okay. It depends on what problem you're trying to solve.
|
On March 04 2013 15:10 JeanLuc wrote: to any web devs: is it okay to be coding just html and vanilla js code in this day and age.
That is what web designers do.
Web developers need at least one serverside language. Though node.js exists, the realworld use is fairly limited so i wouldn't bet on anyone getting a job as web developer purely on javascript knowledge.
|
On March 04 2013 20:09 Morfildur wrote:Show nested quote +On March 04 2013 15:10 JeanLuc wrote: to any web devs: is it okay to be coding just html and vanilla js code in this day and age. That is what web designers do. Web developers need at least one serverside language. Though node.js exists, the realworld use is fairly limited so i wouldn't bet on anyone getting a job as web developer purely on javascript knowledge.
Don't know what type of web designers you work with, but in my company a web designers job is to design, while junior developers/interns generally take care of the templating(html) and frontend logic under supervision of a frontend developer.
Maybe in small projects the designer can do some html and js, but that's generally not recommended.
To answer the original question, I don't allow any vanilla code in my company, for server-side we use frameworks, for js we use jQuery and for templating we use Twig. It's a major difference in profit margins, why reinvent the wheel?
|
On March 04 2013 23:14 Nihilnovi wrote:Show nested quote +On March 04 2013 20:09 Morfildur wrote:On March 04 2013 15:10 JeanLuc wrote: to any web devs: is it okay to be coding just html and vanilla js code in this day and age. That is what web designers do. Web developers need at least one serverside language. Though node.js exists, the realworld use is fairly limited so i wouldn't bet on anyone getting a job as web developer purely on javascript knowledge. Don't know what type of web designers you work with, but in my company a web designers job is to design, while junior developers/interns generally take care of the templating(html) and frontend logic under supervision of a frontend developer. Maybe in small projects the designer can do some html and js, but that's generally not recommended. To answer the original question, I don't allow any vanilla code in my company, for server-side we use frameworks, for js we use jQuery and for templating we use Twig. It's a major difference in profit margins, why reinvent the wheel? 
Well, if you call the websites of a multi-million dollar company small :p
In my last company the developers did the whole server side stuff and made sure the designers had all the data they needed on each page and the web designers then put it all in HTML & JS to make it look fancy since developers were too busy to bother with making all the pages look the same on all browsers and such.
It didn't work extremely well though that was just because the web designers in that company didn't learn anything in the last 10 years they worked for that company, so simple javascript and HTML4 was the limit of their abilities and we occasionally had to fix their stuff because they broke it beyond their abilities, but in general it kept the tedious work away from the higher paid developers.
The we also had the layout department who put the design together in photoshop and decided on the general UI design but never actually touched any sourcecode of any kind.
Then again, these days the lines between the development and design are getting very blurry since so much work is now done in the frontends.
|
can somebody help me in my homework in C? when i compiled it there are no errors (but it does have warnings)
+ Show Spoiler +#include<stdio.h> #include <stdbool.h>
int main(){ bool stop = false; char word[50] = "default";
while(stop == false){ printf("Enter word :\n\n"); scanf("%s",&word); if (word == "exit") stop = true; else toPigLatin(word); }
return 0; }
void toPigLatin(char *word){ if (word[0] == "a" || word[0] == "e" || word[0] == "o" || word[0] == "i" || word[0] == "u" || word[0] == "y" || word[0] == "A" || word[0] == "E" || word[0] == "O" || word[0] == "I" || word[0] == "U" || word[0] == "Y" ) { char newWord[50]; strcpy(newWord, word); strcat(newWord, "way"); printf("%s",newWord); } else { swap_last(word); toPigLatin(word); } }
void swap_last(char *str) { const size_t len = strlen(str); if(len > 1) { const char first = str[0]; memmove(str, str + 1, len - 1); str[len - 1] = first; } }
when i enter a string it just terminates =/
|
Hyrule19174 Posts
system('pause') or getch() or something should go before return in main.
|
On March 05 2013 00:29 icystorage wrote:can somebody help me in my homework in C? when i compiled it there are no errors (but it does have warnings) + Show Spoiler +#include<stdio.h> #include <stdbool.h>
int main(){ bool stop = false; char word[50] = "default";
while(stop == false){ printf("Enter word :\n\n"); scanf("%s",&word); if (word == "exit") stop = true; else toPigLatin(word); }
return 0; }
void toPigLatin(char *word){ if (word[0] == "a" || word[0] == "e" || word[0] == "o" || word[0] == "i" || word[0] == "u" || word[0] == "y" || word[0] == "A" || word[0] == "E" || word[0] == "O" || word[0] == "I" || word[0] == "U" || word[0] == "Y" ) { char newWord[50]; strcpy(newWord, word); strcat(newWord, "way"); printf("%s",newWord); } else { swap_last(word); toPigLatin(word); } }
void swap_last(char *str) { const size_t len = strlen(str); if(len > 1) { const char first = str[0]; memmove(str, str + 1, len - 1); str[len - 1] = first; } }
when i enter a string it just terminates =/
You can't compare strings like that in C, because in C strings are just arrays of chars. you should include <string.h> and use strcmp(s1,s2); to see if they're equal. Also, it does a subtraction to check for equality, so they're equal when strcmp is 0. Therefore, you're if statement will look like if(!strcmp(word,"exit")) { }. When you include string.h, your strcpy and strcat will work because they will be included.
Also, in toPigLatin(char *word) you should use single quotes to denote those as chars in your if statement, so it should be word[0] == 'a'. Thats where you're getting pointer and int comparison warnings. word[0] is an int and "a" is a pointer to the string "a".
Your code is 95% there. It just has a couple of problems that are really specific to C, and you don't have to worry about those problems with other languages.
|
On March 05 2013 00:40 bleda wrote:Show nested quote +On March 05 2013 00:29 icystorage wrote:can somebody help me in my homework in C? when i compiled it there are no errors (but it does have warnings) + Show Spoiler +#include<stdio.h> #include <stdbool.h>
int main(){ bool stop = false; char word[50] = "default";
while(stop == false){ printf("Enter word :\n\n"); scanf("%s",&word); if (word == "exit") stop = true; else toPigLatin(word); }
return 0; }
void toPigLatin(char *word){ if (word[0] == "a" || word[0] == "e" || word[0] == "o" || word[0] == "i" || word[0] == "u" || word[0] == "y" || word[0] == "A" || word[0] == "E" || word[0] == "O" || word[0] == "I" || word[0] == "U" || word[0] == "Y" ) { char newWord[50]; strcpy(newWord, word); strcat(newWord, "way"); printf("%s",newWord); } else { swap_last(word); toPigLatin(word); } }
void swap_last(char *str) { const size_t len = strlen(str); if(len > 1) { const char first = str[0]; memmove(str, str + 1, len - 1); str[len - 1] = first; } }
when i enter a string it just terminates =/ You can't compare strings like that in C, because in C strings are just arrays of chars. you should include <string.h> and use strcmp(s1,s2); to see if they're equal. Also, it does a subtraction to check for equality, so they're equal when strcmp is 0. Therefore, you're if statement will look like if(!strcmp(word,"exit")) { }. When you include string.h, your strcpy and strcat will work because they will be included. Also, in toPigLatin(char *word) you should use single quotes to denote those as chars in your if statement, so it should be word[0] == 'a'. Thats where you're getting pointer and int comparison warnings. word[0] is an int and "a" is a pointer to the string "a". Your code is 95% there. It just has a couple of problems that are really specific to C, and you don't have to worry about those problems with other languages.
wow thanks. now it's working. i'm not that much familiar with c. helped a lot!
|
Let me guess, your warnings were about comparing pointer and integer types?
|
Hey guys, I've recently moved over from windows to Ubuntu, and now I'm trying to properly get mono working with subversion.
I have this publicly available repo from our Uni, in which we keep all kinds of files related to courses, our latex source files etc. We also have a directory called Dev/ where all our source code is located.
Before, with viusal studio, I could checkout the entire repo with any svn client, and Visual Studio could detect that (with a plugin called ankhSVN), even while working on the Dev/ directory. With mono, I can checkout the entire repo, then load the solution, It wont recognize the solution as part of the repo.
That means I cant use the plugin available for mono. The plugin is pretty awesome since it streamlines alot of activities such as adding and removing files from the project, renaming etc. It would be pretty sad not to be able to use it. Anyone have any experience with this ?
|
|
|
Hyrule19174 Posts
|
On March 04 2013 23:14 Nihilnovi wrote:Show nested quote +On March 04 2013 20:09 Morfildur wrote:On March 04 2013 15:10 JeanLuc wrote: to any web devs: is it okay to be coding just html and vanilla js code in this day and age. That is what web designers do. Web developers need at least one serverside language. Though node.js exists, the realworld use is fairly limited so i wouldn't bet on anyone getting a job as web developer purely on javascript knowledge. Don't know what type of web designers you work with, but in my company a web designers job is to design, while junior developers/interns generally take care of the templating(html) and frontend logic under supervision of a frontend developer. Titles and job content vary from place to place. All you really get out of a title is a general idea of the type of work you're doing, not the specifics.
|
Where does one learn about the things posted in this thread, specifically the snippet in this post: http://forum.thegamecreators.com/?m=forum_view&t=193642&b=20&msg=2308503#m2308503 + Show Spoiler +Public Class Form1
Dim cardsDealt(52) As String Dim lastIndex As Integer Dim suits() As String = New String() {"C", "H", "D", "S"}
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load PictureBox1.Image = getImage() End Sub
Function getImage() As Image Dim asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim ResourceName As String = "cardGame." + randomCard() + ".png" Dim str As System.IO.Stream = asm.GetManifestResourceStream(ResourceName) Dim img As Image = Image.FromStream(str) Return img End Function
Function randomCard() As String Dim suit, number As Integer
Do suit = Int(4 * Rnd()) number = Int(13 * Rnd()) + 1
Loop While Not (cardsDealt.Contains(suits(suit) + number.ToString()))
cardsDealt(lastIndex) = suits(suit) + number.ToString() lastIndex += 1 Return suits(suit) + number.ToString()
End Function End Class It's in Visual Basic because that's what I know the best, but I mean the content in general.
|
A variety of places. Lessons (school, online, self-led, etc.), Googling for how to accomplish certain tasks, asking people for advice.
If you work somewhere, your more veteran colleagues will often help guide you.
|
Well I found it by googling a question I had but is that in any basic book or is that really deep into the language?
|
C# Threading question: What is the best way to manage excess Threads? Threadpool isn't what i need as some of the Threads lock various files and controls (From what i've read, if this is the case it's best not to use a Threadpool). However i'm only able to run 10 background threads at once, and would like to complete new threads as old ones finish.
Currently i don't create a thread for each new task until need to start it. I thought i could store 'p' (object) in an Array of some kind, and just empty it as i get space. Not sure this is generally a good idea or not.
+ Show Spoiler + for (; ; ) { Thread.Sleep(60000);
if (server.Pending()) { TcpClient client = server.AcceptTcpClient(); NetworkStream strm = client.GetStream(); IFormatter formatter = new BinaryFormatter(); TCPClassLibrary.GenObject p = (TCPClassLibrary.GenObject)formatter.Deserialize(strm); while(ServerFront.ThreadsInProcess == ServerFront.ProcessMaximum) { }
switch(p.Action) { case "0": ServerFront.ThreadsInProcess++; ThreadStart TasksStarter = delegate { CurrentTasks.AddTask(p, Directory, m_bgw, Status, m_currentForm, ServerFront.ThreadsInProcess); }; Thread TasksThread = new Thread(TasksStarter); TasksThread.IsBackground = true; TasksThread.Start(); break; case "1": ThreadStart TasksAborted = delegate { CurrentTasks.AbortTask(p, m_bgw, Status, m_currentForm, ServerFront.ThreadsInProcess); }; Thread TasksABThread = new Thread(TasksAborted); TasksABThread.IsBackground = true; TasksABThread.Start(); break; default: etc ........
Cheers for any ideas.
|
On March 05 2013 19:19 Rixxe wrote:C# Threading question: What is the best way to manage excess Threads? Threadpool isn't what i need as some of the Threads lock various files and controls (From what i've read, if this is the case it's best not to use a Threadpool). However i'm only able to run 10 background threads at once, and would like to complete new threads as old ones finish. Currently i don't create a thread for each new task until need to start it. I thought i could store 'p' (object) in an Array of some kind, and just empty it as i get space. Not sure this is generally a good idea or not. + Show Spoiler + for (; ; ) { Thread.Sleep(60000);
if (server.Pending()) { TcpClient client = server.AcceptTcpClient(); NetworkStream strm = client.GetStream(); IFormatter formatter = new BinaryFormatter(); TCPClassLibrary.GenObject p = (TCPClassLibrary.GenObject)formatter.Deserialize(strm); while(ServerFront.ThreadsInProcess == ServerFront.ProcessMaximum) { }
switch(p.Action) { case "0": ServerFront.ThreadsInProcess++; ThreadStart TasksStarter = delegate { CurrentTasks.AddTask(p, Directory, m_bgw, Status, m_currentForm, ServerFront.ThreadsInProcess); }; Thread TasksThread = new Thread(TasksStarter); TasksThread.IsBackground = true; TasksThread.Start(); break; case "1": ThreadStart TasksAborted = delegate { CurrentTasks.AbortTask(p, m_bgw, Status, m_currentForm, ServerFront.ThreadsInProcess); }; Thread TasksABThread = new Thread(TasksAborted); TasksABThread.IsBackground = true; TasksABThread.Start(); break; default: etc ........
Cheers for any ideas.
Is it possible to use non-blocking I/O in C#? Sounds like it would be a solution to your problem.
|
Speaking of non-blocking I/O, does anyone know the proper way to read an object from a java.nio.channels.SocketChannel? Assuming several clients and whose requests we would like to process as fast as possible.
I've been thinking of two approaches: - Using a cached thread pool and start a receiver thread every time we notice incoming data. Receiver thread would just read an object and pass it to a queue. Not sure if it could work, the structure of SocketChannel and Socket would prevent
- Preface each transmission with the size of the serialized object and do all object reads in 1 thread. This could potentially screw up the server if a malicious server sends large sizes and/or does not send the object.
|
This is more of a math question, I'm learning to measure the complexity of a function
Here's the whole function, it's in Python: + Show Spoiler + def program2(x): total = 0 for i in range(1000): total = i
while x > 0: x /= 2 total += x
return total
Directly on the while x>0, x/=2 part:
The explanation I'm given is
Because we divide x by 2 every time through the loop, we only execute this loop a logarithmic number of times. log2(n) divisions of x by 2 will get us to x = 1; we'll need one more division to get x <= 0
but I still don't get it.
x / (2 *log2(n)) = 1?
random math which might not be right (I haven't done logs since high school)
2 * log2(n) = 1 * x log2(n) = x/2
2^x/2 = n
for program2(x) = 10 10 5 2.5 1.25 .625
so n larger than 3 and less than 4
2^
wait...is that base 2 or log base 10?
i'll come back to it
|
|
|
|
|
|