The Best Cyprus Community

Skip to content


What programming language would you suggest me??

Feel free to talk about anything that you want.

Re: What programming language would you suggest me??

Postby Sotos » Wed Apr 01, 2015 1:13 am

You are both much superior than me in programming so I can't really judge anyone.


GR is just farting. I bet you are much better than he is ;)

So what programming language/s do you usually use for your programs?

I do web related work, so I mainly use PHP for the back-end and Javascript for the front-end. I see you do a lot of file manipulation things, which is not what I am doing but I assume that something like Python would be a good choice for that. But something like parsing Stockwatch.com data can be best done with something like PHP and Javascript. With PHP you can easily write a bot that visits Stockwatch.com several times a day, parses the data, stores them in a database and then you can analyze and do whatever you want with that data. And you would use HTML/CSS/Javascript to create a nice interface and even excellent interactive charts with something like d3.js (http://d3js.org/)
User avatar
Sotos
Leading Contributor
Leading Contributor
 
Posts: 11357
Joined: Wed Aug 17, 2005 2:50 am

Re: What programming language would you suggest me??

Postby Get Real! » Wed Apr 01, 2015 1:48 am

Sotos wrote:I already wrote it for you. You want it in a nice format? :roll: Here:
Code: Select all
var fs = require("fs"), f = process.argv[2];
fs.readFile(f, 'utf8', function(error, text) {
   fs.writeFile(f, text.replace(/(“|”)/g, '"').replace(/’/g, "'"));
});

Assuming you name the above file "modify.js" and you place your text in "test.txt" then in cmd you type: node modify.js test.txt and test.txt will be modified accordingly. Now show it to me with "document.write()" using Node NOT the Javascript engine of a browser ( and Chromium is a browser) :lol:

FAIL! :lol:

Here's your output string...

You don’t need Internet access to use this facility and you don’t need to upload anything to strangers because you can always use “Get” or “Set” to fix the problem, and best of all you get to retain your 뿯½ copyright!

You basically managed to ruin the copyright symbol at the end and none of the quotes have changed at all! :)

What do you think went wrong Sotos?

Btw, do you have Node installed on your home PC because I doubt you checked the output.

I know why your code is failing but I want YOU to figure it out.

It’s by no accident that I gave you this specific challenge because I wanted to see if you’re a good programmer and not just if you can put 3 lines of code together that almost anyone can do.

That’s why I INSISTED that you DISPLAY the output so you could see that it’s not as straightforward as you think! Please try again.
User avatar
Get Real!
Forum Addict
Forum Addict
 
Posts: 48333
Joined: Mon Feb 26, 2007 12:25 am
Location: Nicosia

Re: What programming language would you suggest me??

Postby Sotos » Wed Apr 01, 2015 2:28 am

:roll: It works perfectly fine. It seems that it is you who doesn't even have node installed. I am still waiting for you to show me how you do document.write() with just node :lol: Here... I even made a video for you (watch full screen at 1080p). I am not going to waste any more of my time with your bullshit. It is obvious that you will not admit that you are cluless but we all know that you are ;)

User avatar
Sotos
Leading Contributor
Leading Contributor
 
Posts: 11357
Joined: Wed Aug 17, 2005 2:50 am

Re: What programming language would you suggest me??

Postby Get Real! » Wed Apr 01, 2015 2:50 am

Sotos wrote::roll: It works perfectly fine. It seems that it is you who doesn't even have node installed. I am still waiting for you to show me how you do document.write() with just node :lol: Here... I even made a video for you (watch full screen at 1080p). I am not going to waste any more of my time with your bullshit. It is obvious that you will not admit that you are cluless but we all know that you are ;)

With the video you have indeed proven that it works correctly at your end, but not mine. I did notice the file’s timestamp update as you executed the code so it’s a genuine video and not a trick you’ve pulled… so congrats! Btw, which version is this?

The question now is, why is Node behaving different over here; run from within the node-webkit “packaging”? And would the result be the same if you were to just display it with console.log? This raises serious disk I/O issues that need to be looked into.
User avatar
Get Real!
Forum Addict
Forum Addict
 
Posts: 48333
Joined: Mon Feb 26, 2007 12:25 am
Location: Nicosia

Re: What programming language would you suggest me??

Postby Sotos » Wed Apr 01, 2015 3:00 am

Node is version 0.12.0 but I don't think that this is what makes the difference. Maybe your file is using a different unicode encoding. My file was using UTF8 which is the most popular unicode encoding but if your file is UTF16 then you would have to run something like this:

Code: Select all
var fs = require("fs"), f = process.argv[2];
fs.readFile(f, 'utf16le', function(error, text) {
   fs.writeFile(f, text.replace(/(“|”)/g, '"').replace(/’/g, "'"),'utf16le');
});


You could add error checking, encoding checking etc ... but that would be way more than 3 lines of code ;)
User avatar
Sotos
Leading Contributor
Leading Contributor
 
Posts: 11357
Joined: Wed Aug 17, 2005 2:50 am

Re: What programming language would you suggest me??

Postby Get Real! » Wed Apr 01, 2015 3:08 am

Sotos wrote:Node is version 0.12.0 but I don't think that this is what makes the difference. Maybe your file is using a different unicode encoding. My file was using UTF8 which is the most popular unicode encoding but if your file is UTF16 then you would have to run something like this:

Code: Select all
var fs = require("fs"), f = process.argv[2];
fs.readFile(f, 'utf16le', function(error, text) {
   fs.writeFile(f, text.replace(/(“|”)/g, '"').replace(/’/g, "'"),'utf16le');
});


You could add error checking, encoding checking etc ... but that would be way more than 3 lines of code ;)

This is a serious problem for us and I have to raise this issue tomorrow!

With the setup that node-webkit users are using Node.js (myself included), this function would fail regardless of the encoding you request. Binary completely chews up the characters and replaces them with nulls, utf8 replaces them with any old junk and ucs2 doesn’t have a clue! As for the rest like ascii, utf16le, base64, etc well… they're just not suitable.

The revelation here is that Node.js *can* and *may* behave different if not run directly!
User avatar
Get Real!
Forum Addict
Forum Addict
 
Posts: 48333
Joined: Mon Feb 26, 2007 12:25 am
Location: Nicosia

Re: What programming language would you suggest me??

Postby Get Real! » Wed Apr 01, 2015 3:17 am

I had to come up with a workaround for now but I didn’t really like it because it’s not solid! Look what I’ve done to GUESS which character it is… :lol: works about 95% correctly! (relevant lines in blue)

function LoadTxtFile(Name){
var Filter=/(?![\x00-\xFF])./g;
fs=require('fs');
if (fs.existsSync(Name)){
var Source=fs.readFileSync(Name,'utf8');
Source=Source.replace(/\…/g,'...').replace(Filter,'©').replace(/ © /g,' XES ').replace(/© /g,'" ').replace(/ ©/g,' "').replace(/©\./g,'".').replace(/©/g,'\'').replace(/ XES /g,' © ').replace(/\t/g,' ');

var A=Source.split('~');
LoadWordCont(A.length-1);
for (i=1; i<A.length; i++){
Z=A[i].indexOf('\r\n');
document.getElementById('SA'+i).value=A[i].substr(0,Z).trim();
S=A[i].substr(Z+2).trim();
if(S!==''){S=S+'\r\n';}
document.getElementById('SB'+i).innerHTML=S;}
GenerateHTML();}}
User avatar
Get Real!
Forum Addict
Forum Addict
 
Posts: 48333
Joined: Mon Feb 26, 2007 12:25 am
Location: Nicosia

Re: What programming language would you suggest me??

Postby Get Real! » Wed Apr 01, 2015 3:33 am

:idea: Do you suppose that your readFile() works better than my readFileSync() ??? :?

I'd better check that out tommorow... yours is async... needs callback.
User avatar
Get Real!
Forum Addict
Forum Addict
 
Posts: 48333
Joined: Mon Feb 26, 2007 12:25 am
Location: Nicosia

Re: What programming language would you suggest me??

Postby Sotos » Wed Apr 01, 2015 5:39 am

ok ... I see what is all this about now. It is your "save designs" thing. What I don't understand is how those unwanted characters end up in your files to begin with. Are they entered by the user? If that's the case then you should be doing the validation and any conversion before you write the file, not when you read it. You should also make sure you use the same encoding everywhere. In the head of your HTML (<meta charset="utf-8">), in the fs read/write functions (sync or async shouldn't make a difference), maybe there is a setting in Chromium/node-webkit for setting character encoding? (never used those myself). If everything is set correctly then maybe there is bug in that stack you are using... a quick search turned this: http://stackoverflow.com/questions/2329 ... ode-webkit So maybe try utf16le for the read/write functions.
User avatar
Sotos
Leading Contributor
Leading Contributor
 
Posts: 11357
Joined: Wed Aug 17, 2005 2:50 am

Re: What programming language would you suggest me??

Postby B25 » Wed Apr 01, 2015 8:54 am

Ok so are you two now friends :)
User avatar
B25
Main Contributor
Main Contributor
 
Posts: 6543
Joined: Wed Sep 30, 2009 7:03 pm
Location: ** Classified **

PreviousNext

Return to General Chat

Who is online

Users browsing this forum: No registered users and 0 guests