Wikipedia:Reference desk/Archives/Computing/2017 July 30

Computing desk
< July 29 << Jun | July | Aug >> July 31 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


July 30 edit

Breaking a single line file into multiple lines edit

I have a 20Mb text file that's a single line long. Normal text editor on Linux have no problem handling a 20Mb file, but when it's all on the same line, most of the editors tend to choke. Is there a way using the standard Linux utilities to break this file down into multiple lines? Basically inserting a \n character every N-th byte into the file (where N can be anywhere from 50 to 200). Covfefe beans (talk) 12:24, 30 July 2017 (UTC)[reply]

You might want to look at fold (Unix). -- zzuuzz (talk) 13:10, 30 July 2017 (UTC)[reply]
Another is this using sed sed -e 's/\(.......................\)/\1\n/g' < file
the number of dots for how many chars per line.
or sed -e 's/\(.\{50,50\}\)/\1\n/g' < file
with 50 the number of characters per line. and yes fold -w 50 file works too. Graeme Bartlett (talk) 13:15, 30 July 2017 (UTC)[reply]
Thanks, guys. fold is perfect. Covfefe beans (talk) 14:03, 30 July 2017 (UTC)[reply]
  Resolved
One other comment: It may appear to all be on one line because it uses a different character to end each line than what your editor is looking for. This is a fairly common problem when a text file is created in one editor and read in another. See newline. StuRat (talk) 14:44, 30 July 2017 (UTC)[reply]
And another comment: you probably don't want your newlines inserted in the middle of a word. Use fold -s to make sure fold only breaks at whitespace. PiusImpavidus (talk) 15:10, 30 July 2017 (UTC)[reply]

Capitalizing or lowercasing the first letter in JavaScript edit

I understand that the commands may require lowercased first letter, but sometimes, when assigning something to a variable with the assignment operator, I don't get why the assignment variable also has a lowercased first letter. Is this by convention or a requirement? 50.4.236.254 (talk) 17:58, 30 July 2017 (UTC)[reply]

Try http://www.j-io.org/Javascript-Naming_Conventions/#naming-conventions
Naming conventions are just conventions, rarely technical requirements, but it's worth starting out with something widely recognised, not going your own way. For JavaScript generally, read Crockford's small O'Reilly book before you go too deep. It's not a hard language, but it is an unusual one. Almost no JavaScript coders really understand what they're doing. Andy Dingley (talk) 18:59, 30 July 2017 (UTC)[reply]
I learned HTML and CSS about ten years ago, mainly because I was a minor with a lot of free time and got a library book about web design. Because I was self-taught, I learned mostly by reading, experimenting, creating imitations, and volunteering my time helping other people with HTML/CSS static web design. When I named my CSS selectors, especially for class and id, I just labeled names that were easy for me to recognize and remember, because no one was reading my work anyway. Maybe CSS is different from JavaScript. If something works, then use it. If I create code that only I understand, then that may provide an additional level of security. 50.4.236.254 (talk) 19:24, 30 July 2017 (UTC)[reply]
"Almost no JavaScript coders really understand what they're doing." LOL, yet we get things done. A Quest For Knowledge (talk)
Naming conventions aren't just there to make things the same, they're also there to make things distinguishably different. A common approach these days is to have classes capitalised, methods and variables in dromedary camel case (uncapitalised). The convention makes these two groups obviously distinct.
With CSS, you just don't have these separate groups. You have class names - and where you have those class names, there's not much else you could have there. Even for id names, the selector syntax makes it clear which is which too. So there's less need to have conventions. Although a consistent convention for how to parse identifiers for a multi-part name is good: do you glue parts together, or separate them with hyphens or underscores? And how do you use names within the structure of a page? Lots of different issues for designing HTML page architecture, but a case-based naming convention isn't the same issue it is for programming languages. Andy Dingley (talk) 21:45, 30 July 2017 (UTC)[reply]
HTML and CSS are both markup languages. HTML is more about content. CSS is more about style. That's why it's called Cascading Style Sheets. I guess markup languages don't need any conventions, other than idiosyncratic ones that only the web designer understands. 50.4.236.254 (talk) 23:12, 30 July 2017 (UTC)[reply]
There are standards for both HTML and CSS, just as there are standards with any other language. The issue with standards is education. How many people learn HTML in a standards-based environment compared to how many learn it by trial and error? If you know standards, it is trying to look through code (HTML, CSS, or JavaScript) written by someone who has no concept of standards. Worse, I often get tasked with fixing code that isn't written. It is a steaming pile of copy-and-paste from various unrelated sources, all using a different standard. With the popularity of Stack Overflow, copy-and-paste programming is getting worse. 209.149.113.5 (talk) 19:54, 31 July 2017 (UTC)[reply]

Installing Linux/Android hybrid on an x86 tablet edit

I have an early (and crap) Windows tablet computer that came with Windows 7, which, in my opinion, isn't a great OS for tablets. I installed Android x86 on it, but whilst it worked nicely from a functionality point of view, the graphics performance was dire. openSUSE has the opposite problem: impractical from a GUI point of view, but the graphics performance was fine. I had the idea of installing a decent Linux kernel and the Android x86 userland over the top, but to be honest, I neither know how to do this, or if it's even likely to solve my problem. Does anyone have any advice either on how to execute my plan, or have a better plan?--Leon (talk) 20:29, 30 July 2017 (UTC)[reply]

It would help if you could list the stats for the tablet (RAM, clock rate, GB of storage space, etc.). But, my general suggestion is "less is more". That is, go for a single OS that uses minimal resources, to get optimal performance. Something like Puppy Linux comes to mind, but others may have a better suggestion in that regard. StuRat (talk) 21:16, 30 July 2017 (UTC)[reply]
It's this one. But, even the heavy openSUSE was fine for performance, just not really geared towards tablets. The GUI just didn't seem ideal, and Windows 7 is even worse. This doesn't mean that I'm averse to Puppy Linux, but I only want it if it's easier to install a better userland over the top.--Leon (talk) 09:21, 31 July 2017 (UTC)[reply]
If anyone knows how to install the officially unsupported Catalyst graphics drivers for Linux on Android, that might help...--Leon (talk) 13:36, 31 July 2017 (UTC)[reply]