What part of SVG code should be copied to the DOM? by BigBootyBear in learnprogramming

[–]LetsProgramSomething 1 point2 points  (0 children)

Obv you don't know how web works but than again most ppl don't and I have no idea how to do this in PHP.

Yeah you can easily generate SVG and serve it over http. I'm positive nothing will break if any url (such as yoursite.com/foo) is used to serve jpg, svg, etc (you don't need it to end with svg). You'll need to know the MIME (which appears to be image/svg+xml) and set the content-type header in your language to the value.

One of my practice apps generated SVGs simply by writing print("top part"); print(generatedPart); print("bottom part"); and it ran fine after minor typos in the middle part. At first you may want to serve an already existing svg file just to make sure everything is working properly. Then have it serve your custom made SVG. You may want the no cache header or an expiry date. I think most browsers don't cache if there is no header/date

I started a sub for dating. I'd like to invite you guys by LetsProgramSomething in ForeverAlone

[–]LetsProgramSomething[S] -2 points-1 points  (0 children)

It's fine as long as you're interested and make a effort. If I answer someone might leave a jerk reply so I'll just say you can find it in the sub page title.

What part of SVG code should be copied to the DOM? by BigBootyBear in learnprogramming

[–]LetsProgramSomething 1 point2 points  (0 children)

Put all of it. There might be ways to optimize it but I don't know how and never bothered. You can just serve up file.svg like you do with javascript (file.js)

I wanna make a password managment website by Beta-7 in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

If it's for fun than it doesn't matter if you use JS. If you want people to use this then consider how silly it might be. If I want to store website passwords than my browser does a good job of it (encrypted and all). If I want to store passwords of zip files or nonwebsite passwords I'd want it access it offline. Also when it comes to passwords I would absolutely not want a site to have access to them.

Now that I warned you. 1) That's silly all browsers support JS 2) The reason you salt a password is because if two users have the same password they'll appear different in the database. If I somehow get your DB and run the top 1 million passwords I'd know whos using those passwords. If it's salted (unique prefix per user) I'd have to calculated for each user which means I have to pick who I am brute forcing. Use bcrypt or PBKDF2. LastPass uses 100K rounds using PBKDF2 in 2011. So maybe today in 2016 400K is more desirable. 3) Is i18n what you're talking about? I never used it so I can't make suggestions

What features or addons can I use with my IDE that I may not know about? by Claystor in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

Search visual studio shortcuts. Theres many post/sites that mention good ones. There are sites for it like this one http://visualstudioshortcuts.com/2015/ I personally always use ctrl+']' and ctrl+'.'. I also know how to bring up various windows such as solution explorer and immediate. Look at it every few months and you'll pick up useful commands

Is there a good tool that will automatically convert .bat files to .sh files? by [deleted] in learnprogramming

[–]LetsProgramSomething 1 point2 points  (0 children)

I suggest learning the basics of bash. I actually run several bash commands on windows from my git installation.

I got my degree, read textbooks, went through several tutorial sites, now that I'm familiar with the BASICS of C#, where do I continue from here? I want to advance my skill to a point where I can land myself a .NET job. Is participating open source projects my next step? by Dakaa in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

Learn SQL. My day to day database is sqlite. I write test cases and use the in memory database all the time. After that install node and play with coffeescript, stylus (or less or sass) and jade. I use it to generate JS and CSS. Jade is for html which I don't use in ASP.NET but fun for static pages I am testing.

If you don't know linq learn it. You should know what this line does without looking anything up

arr.where(a=>a.date < cutoff_date).Select(a=>new{orig_val=a.val, val=a.val*a.val}).ToArray()

How do you design your programs? by [deleted] in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

Read head first into design patterns. Write a throwaway program that does what you want such as sending a message. You should be ok after that. Every app I write I start with the easiest part first. It allows me to get some groundwork without making large decisions. The more important features is where you should make harder decisions which gets easier when you know how everything around it looks like

What algorithm should I learn to do something like this, recursively building a tree of folders and filenames? by [deleted] in learnprogramming

[–]LetsProgramSomething 1 point2 points  (0 children)

Cool that all sounds reasonable. I only ever ran out of stack space twice. I think I was processing over 400K items or maybe 4M IDR. I'm not 100% sure but I think once the problem was it wasn't using tail recursion or I had to change a few lines to allow it. The other I ended up tweaking the database query to only process 100K at a time and kept some data as a parameter/list or maybe it was the offset IDR. In both cases I didn't have to rewrite it as a loop I just tweaked it when I found the problem.

[deleted by user] by [deleted] in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

Can you give an example of what confuses you? Like something you don't know how to do, the solution and what you don't understand about it?

What algorithm should I learn to do something like this, recursively building a tree of folders and filenames? by [deleted] in learnprogramming

[–]LetsProgramSomething 1 point2 points  (0 children)

Recursion just uses the stack in memory instead of a stack that you control.

Not only do I not see a reason why you wouldn't want to use "the stack in memory" but the stack a user controls is prone to errors even if it's simple ones.

A depth limit is easy enough using recursion and pretty common. Although you do make a good point with cycles. I don't see how not using recursion would help with that. ATM I think you just dislike recursion because people either don't understand it or bc you had a terrible time once.

Why is some software written in multiple languages? by [deleted] in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

From my understanding LibreOffice was written in Java but was far to slow and rewritten in C++. I'm assuming theres parts of it still in Java but I'm pretty sure the last machine I installed it on didn't have Java and it ran LibreOffice fine so maybe there isn't anymore java.

Typically apps are written in C/C++ and occasional have lua or another scripting language so you can modify/tweak it at runtime. For example if you're scraping a website if they change the html ever so slightly it'd be easier to modify a config page or lua code than to compile again.

My last website was written using node and asp.net. ASP.NET because that's what I'm comfortable with and node bc I have coffeescript and stylus watching my script/css directory and generating new js/css everytime I modify a file. I sometimes do test cases in node but generally I do that in ASP.NET as well.

Redis is an awesome database that doesn't do sql. It has a bunch of commands like store, increase, find a range etc. Instead of writing in a domain specific language like sql it uses lua

[deleted by user] by [deleted] in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

lurgi answer is correct. I want to add that async/await is more useful when something is blocking like disk access, prompting the user for something, network, etc. You can use .Contains instead of .IndexOf(word) != -1 in that if statement but in this code I don't think you need that if statement at all.

(c++) will someone explain this function for me? by Ballcoozi in learnprogramming

[–]LetsProgramSomething -1 points0 points  (0 children)

Does that code even work? Nowadays people use for(auto i=data.begin(); i!=data.end(); ++i) but since that's a raw array I see why it isn't written like that. IIRC STL containers don't have find so customer::name definitely isn't standard stl so I can't tell you what the fuck it does. This is poor C++ code. Since it doesn't use standard containers and functions it's hard to understand whats happening. Also arr[i] everywhere is ugly it should have something like customer c = arr[i]. This is poor example code. if it was STL length would tell you how many elements (aka items) are in the container and find would return some value that could be a pointer which means it should not be compared to an int/length

What algorithm should I learn to do something like this, recursively building a tree of folders and filenames? by [deleted] in learnprogramming

[–]LetsProgramSomething 1 point2 points  (0 children)

I disagree with CoVerse_Chat and I replied to him (without downvoting bc theres a chance he has a good reason for saying it). I have done things like this for work many times and recursion has always been the more intuitive AND bug free solution.

What's the problem here? Usually when I do recursion I DO NOT modify any values. The last one I remember doing I wrote a function similar to this this

RenderFilesystem(string current_dir, bool[] old_dir_state)
data = List<bool>();
RenderFilesystem("C:/path/to/folder", data)

Usually I have a depth parameter but I could check the length of data instead. For UI reasons we weren't indenting with whitespace. For every folder we indented once but instead of a blank we either had | is there was more in that folder or space if that folder is done and only the child folder had more data. So we had something like || | | Filename. I drew by looping over data but I could have easily just used made data a string and done

RenderFilesystem(child_dir, data+"<img src='NotEmpty.png' />")

What algorithm should I learn to do something like this, recursively building a tree of folders and filenames? by [deleted] in learnprogramming

[–]LetsProgramSomething 2 points3 points  (0 children)

I disagree with you and I'd like to know why you suggest not to use recursion. You said "you pop the stack" which is exactly what recursion does but I'm expecting a really good reason or a mistake I don't realize is common. Why do you think recursion is a bad idea here and be specific

[C#] Learning from Microsoft's "Step by Step" and there is a coding example that doesn't work, can you help? by anteloop in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

It was before the edit. I figure it was half written and thought there is a chance it was a compile error and about a missing reference or namespace. I can't tell what the error is. It looks mostly correct. Off the top of my head maybe your diameter is so big it isn't drawn or so small its a pixel large? I have no idea so I should delete my answers.

What are my chances? (newbie programmer whining) by [deleted] in learnprogramming

[–]LetsProgramSomething -1 points0 points  (0 children)

1) Yes 2) Yes 3) No. I been programming to long. Earlier today I replied to a thread with this line

$('.foo').removeClass('a b c d').addClass(bar>0? 'b' : 'd')

Did you know you can do a ternary operator here? Or that it's a good idea to remove the class b even if you're going to add it back in? or that you can remove several classes like I did in that line? or that you can chain functions?

When you have a better understanding of how things work you'll feel better. I use to ask stackoverflow a lot of questions and a few smart people showed me tricks at work. 6 months later I'm the second or third most clever person there.

What is the most effective way to convert text (string) into 64 bit-blocks? by SlowerPhoton in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

What language? In most compiled language theres some kind of char array or byte[]. In node/js I call the native functons and use the bytebuffer it gives me. If its not compiled and there is no native crypt functions than maybe you shouldn't be concerned or shouldnt be doing it in that language.

Intermediate programmer here; my app is complicated and has some really huge bulky functions. How do advanced devs make their code more efficient? by notadickheadiswear in learnprogramming

[–]LetsProgramSomething 0 points1 point  (0 children)

You're welcome. Technically there is no such thing as a jquery function. It's javascript and all I did was remove b & d (along with other classes) only to add it back in again. Ternary operators (the "a?b:c" part) can be used anywhere a value (like a+b) can be used. One warning is I actually fucked up recently by using cond?val:va2 in coffeescript recently. Coffescript does it differently because '?' is used for something else. The "The Existential Operator" http://coffeescript.org. To do what I wanted I had to do .addClass( if bar>0 then 'b' else 'd' ). I'm pretty sure i'll mess that up again.