« first day (1920 days earlier)      last day (3033 days later) » 

12:04 AM
hello
 
@JorgeAlberto Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
ok thx @CapricaSix
Who is up to help me to improve my code? codereview.stackexchange.com/questions/117105/…
Also I want few tips of how to improve my programming style and tips about functions on jquery, any help is welcome, thanks
 
don't keep wrapping your nodes with $()
node = $(node)
if you must
I strongly suggest using { and } for your blocks
and indent properly
it helps a shit load with readability
 
agree
 
don't use == when you should be using ===
html strings in js is messy, but I'm like on the 60% camp on that
seems like a lot of devs don't mind it
 
12:08 AM
what's the difference between using == or using ===
 
crl
=
 
@JorgeAlberto === checks type and value essentially.
1 == "1"; // true
1 === "1"; // false
be concise with your code. don't make the reader guess
1 === Number("1");
is better than
1 == "1";
 
@rlemon I did not know it, thanks
 
            $(imagenes[0]).addClass("activa");
            $(bullets[0]).addClass("activa");
this stuff can be a one liner
$(imagenes[0]).add(bullets[0]).addClass('activa');
all of this is little stuff
I'm not even looking at the overall function or design of the code
I'll leave that to the codereview people
 
12:14 AM
Thanks for that @rlemon I'm begginer programming, any tip is welcome
 
@JorgeAlberto no problem
just remember, being 'clever' is often discouraged over being readable and concise
'tricks' are cool and all. but pretend the next person reading your code is a rage-roiding lunatic and knows where you live.
 
Because I am.
 
(not that I see this in your code now, but it is a good tip to take forward)
 
regex: how can I define "first of line" in javascript-regex?
 
Yeah you're right, I'll have that on mind
 
12:16 AM
/something.*\n$/
 
tnx
 
@Shafizadeh I have no clue by the way
$ means match from the end
??
so yea, idk.
what are you actually trying to do?
 
I'm trying to create a toolbar for my markdown-editor. And I end to detect selected-text is from the first of new line or not (for code method {}-icon)
if it is first of line, then I append 4 space behind it, else I put it between this `
 
so you have a string, and you wanna match the first text uptil a new line?
 
no, I just need to check whether selected-text is in the first of new line or it is in the middle of line
 
12:22 AM
define first?
like first word.
or first actual highlighted selection
 
highlighted selection (Note: I can get selected-text using a method, I just need to check it now)
I want something exactly like SO, what happens when you click on this {}
 
return pg.connectAsync(configs.dbConnectionString).bind({})
@rlemon why are you binding {}?
 
just sets up a fresh object
 
To return or to populate the results?
 
to save the close function even if the function throws, I'm guessing
can also use a closure
 
12:29 AM
honestly, I can't remember. I was stealing this from my own code from like a year ago
benji or florian explained why I needed to do that then
 
12:46 AM
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
(precise)jordan@localhost:~/SourceUndead$
Bah
 
you jsut install postgres? did it start?
 
sudo service --status-all
 
[ ? ]  alsa-restore
 [ ? ]  alsa-store
 [ - ]  bootlogd
 [ ? ]  console-setup
 [ ? ]  cron
 [ ? ]  dbus
 [ ? ]  dmesg
 [ ? ]  hostname
 [ ? ]  hwclock
 [ ? ]  hwclock-save
 [ ? ]  killprocs
 [ ? ]  module-init-tools
 [ ? ]  network-interface
 [ ? ]  network-interface-container
 [ ? ]  network-interface-security
 [ ? ]  networking
 [ ? ]  ondemand
 [ ? ]  passwd
 [ ? ]  plymouth
 [ ? ]  plymouth-log
 [ ? ]  plymouth-ready
 [ ? ]  plymouth-splash
 [ ? ]  plymouth-stop
 [ ? ]  plymouth-upstart-bridge
I have.. no idea what I'm doing.
This distro must be coming with some package that ruins dbs
 
sudo service postgresql restart
and check /var/log/postgres/(soemthing).log
 
12:53 AM
restarted
 
if psql still won't connect
 
Is this an accurate guide? The root login seems weird, I can't figure out how to make a user
 
you get connected?
 
psql: FATAL: role "jordan" does not exist
um, I think I broke it
 
ok, good.
 
12:56 AM
alsa is the bane of my existance
 
no, it's ok.
so, postgres integrates with unix users. switch to user postgres, then you'll ahve access to add your own accout
sudo -u postgres createuser --interactive
then add a user with the same name as your linux user
 
unrecognized option '--interactive'
 
odd..
 
Looks like postgre 9.1, is that why?
 
eww
yea. you want newer.
what ubuntu are you on?
 
1:00 AM
Kubuntu
KDE Plasma
 
what ubuntu is that based on?
your desktop window manager is not of importantce here
14.04?
 
I think 14.04
 
or did you go 'werewolf'?
looks like it should hav installed 9.3 or 9.4, never 9.1..
 
All this because I don't want to vim as my text editor -_- this is turning into a nightmare of server stuff
 
postgresql > mysql
so it was a good upgrade
 
1:07 AM
why do you think you are on 9.1? what command told you that?
 
psql --version
 
psql (PostgreSQL) 9.1.19
 
wtf? did you d/l kubuntu from 1998?
 
crouton lol
it's the version it came with
trusty was too slow
 
a chromebook?
 
1:10 AM
yessir
 
honestly, it really shouldn't make a difference
make sure your production db is up to date
 
if you are gonna use that shit, you better get used to building code from source.
9.1 is old, though
 
Can I not upgrade or something?
 
yea but aside from being less secure, it really doesn't change how he will use it.
 
no JSON data type, too
 
1:11 AM
well yea
but you can easily get around that for local testing
 
you can upgrade, but if you are new to linux, you should use a distro with more up-to-date packages
 
just saying, he doesn't need to pull out his hair over a local version being off here
 
I'm not sure if that's an option
 
not one you'll end up having to do manual installs for
yea, 9.1 shoudl work
 
production db otoh, yea
 
1:13 AM
but it's an indication he's going to have more issues
 
make sure that had all security upgrades
@Luggage well his production db is just regular Ubuntu server
I hope 15.x
 
How can I write id-name of element instead of window in this code? (I'm newbie to js)
var selection = window.getSelection();
 
new linux users should be one a more mainstream distro
 
My production is 14.04
 
still decent
LTS
for now
 
1:18 AM
Can I just uninstall postgre and install the latest version?
 
sure
 
This upgrade google is not making any sense
 
apt-cache search postgres 9.3
 
Errors were encountered while processing:
 postgresql-9.1
E: Sub-process /usr/bin/dpkg returned an error code (1)
Da fuq
 
sudo?
 
1:21 AM
yeah
 
what were you doing, uninstalling?
 
postgres, so I can install the latest
 
1:32 AM
New approach. I ssh into my server. It's command line -- can I install sublime text onto it and open it somehow onto a remote display?
I seriously hate developing in vim, this is my only issue
 
dude
dev ST local
have it sync with the remote dev env
 
install forever on the remote
have it watch the files
done and done
 
I know
 
1:35 AM
I need a breather. This is overwhelming
 
I was where you are right now like 1.5 years ago
honestly, once you get into it, it seems easy
 
This would be easier if I could just install a full blown ubuntu onto this computer
Remove ChromeOS
14.04 desktop. Life is simple from there.
These crouton distros aren't normal.
 
@SterlingArcher you are balling now
get a linux laptop
I have the Kudu
 
Yeah I don't have the expendable cash yet lol
I'm uninstalling this POS. brb
 
I'm tempted to just get you to buy a rpi2 and install everything for you and mail you the SD card
 
1:55 AM
Some people are recommending the use of functional programming in JavaScript, why is that? Don't they know all the problems that comes with functional programming?
 
like what?
 
Performance. It is also hard to find people used to functional style to maintain the code.
 
<input type="file" capture="camera" ... /> Allows users on mobile browsers to capture images via phone camera, but it also gives them the option to upload images saved on their phones.

Anyone know if it's possible to coerce the phone to only be able to 'capture' images rather than 'upload'?
 
if you're doing things right, there is very few cases for high performance js.
most of them revolve around gaming
 
2:00 AM
JS is not used only in browsers now. Servers have js running in them now also.
 
true.
 
@Waterscroll with that said....
2 mins ago, by rlemon
if you're doing things right, there is very few cases for high performance js.
 
mostly your code is waiting for IO anyway.
cpus are fast enough to sacrifice a few cycles in favor of a a beneficial programming style.
which is why i'm not a c developer.
 
But how is that a beneficial style, since it is harder to find people used to functional style to maintain the code.
 
because there's usually less code to maintain
and it's more readable
and easier to reason about
 
2:03 AM
functional programming isn't a "hard" style to maintain and it isn't inherently slow.
 
and there's like 3 concepts they need to learn that are a core part of the language so if they don't know them, don't hire them
 
It is hard to find good programmers already, good programmers on functional style is even harder. Where is the benefit?
 
how did you come to this conclusion?
 
I rather have more code with people able to maintain it, than less code that I can't find people to maintain it.
By trying to find people to maintain my code.
 
good luck trying to keep your code lowest-common-demoninator
 
2:06 AM
The other projects don't share this problem of demanding rare programmers.
 
If you expect people to come onto your project without having to teach them anything new, you're not going to have a good time.
 
It is easer to teach a new language than to teach functional style, it is too different from the way they are used to think about the problem.
 
That's total shit
 
Yes, if you want to continue hiring only knuckle-draggers, then may avoid functional programming
Sucks you have to sacrifice good code for high turnover, tough.
one leads to the other
 
I do not run a charity, time is money, and functional gave me more headaches than solutions.
And why functional is equal to higher quality anyway?
 
2:10 AM
199
Q: Why functional languages?

MattBelangerI see a lot of talk on here about functional languages and stuff. Why would you use one over a "traditional" language? What do they do better? What are they worse at? What's the ideal functional programming application?

 
What would you rather reason about:
let arr = [1, 2, 3, 4];
let squared = [];
for (let i = 0; i < arr.length; i += 1) {
    squared.push(arr[i] * arr[i]);
}
or
let arr = [1, 2, 3, 4];
let squared = arr.map(x => x*x)
 
The first one.
 
Come on..
 
m59
I'm switching off my wifi after a page is loaded and socket.io connected, then switching it back on. socket.io reconnects, but my events aren't firing anymore.
Anyone ever had that?
 
2:18 AM
I am sorry, I am used to it. I have been programming in C for a long time.
 
@m59 it's normal. you need to handle re-subscribing.
 
Doing something because that's the way it has always been done is a terrible idea.
 
if you subscribed to any 'rooms'
 
m59
I thought of that and did:
 
Unless I'm iterating over a few hundred million objects, I'd go with the second one.
 
m59
2:19 AM
socket.on('connect', function() {
  // socket.emit('lemme-join-dem-rooms')
})
still broken
 
I .map() things all day long and the old long form is just unacceptable.
 
@Luggage unacceptable? why?
 
agreed
prone to errors
and just yuck
 
ugly
 
There are use cases for it too..
 
2:21 AM
of course
 
I understand that math looks better on functional, but not everything looks better on functional like not everything looks better on OO. You can write some very difficult to read code if you don't use loops. The most straight forward way of creating a range is using a for, for example.
 
you use the right technique for the job
JS lets you so a bit of functionel-ish, some OOP-ish, etc.
 
If you really care about looks, use a nice font.
 
People are advocating not using "for" anywhere in your code. JLinst gives you a warning by default if you use for. And some people say you shouldn't use a for anywhere.
 
I use it rarely. I don't try, it just don't need it
I'm usually mapping or reducing.
 
2:24 AM
where's my bug?
 
How do you transform your array? Do you use array = array.map()?
 
There is a reason people use that style. You won't get it until you use it some. I can't say anything more to convince you that locking into one style of programming isn't helpful.
 
m59
Don't transform your array =D
 
yes, array = array.map() is usually good.
 
mutation is bad
 
2:26 AM
Doesn't that create a new array? I think a for is better for that.
 
forever shall the array be static
 
Is there a "text-editor" that kicks vims ass?
 
don't try to optimize memory usage like that in JS.
 
But if you don't mutate anything you may run out of memory.
 
@Waterscroll hahahahahahaha
 
2:27 AM
no, JS is a garbage collected langauge. it'll clean up unused memory.
 
Why is that funny?
 
Run out of memory?
 
m59
I'm running my JS like
hope I don't run out of memory
@Waterscroll Just playing with you. Hope you can appreciate a joke. :)
 
emacs or vim
and why
 
2:30 AM
it's hard to hire programmers with a sense of humor, so no jokes.
 
How's everyone doing?
 
I am not thinking only at browsers. You could want to process a large csv file, and if you do a = a.map() you may lose too much time. A for here would make much more sense to me. I know there is probably a way to do that using FS, but a for looks so straight forward to me.
 
Haha cuz I'm lemony
 
@Waterscroll Watch the video about pirates and perfs
 
2:34 AM
also, you'd use streams for that, which means you aren't using a for loop.
 
The video is half an hour long. I am watching it, but it won't take less than a half an hour to watch it.
 
@Waterscroll put it on chipmunk mode
 
So I spent about a week and a half on this: https://jsfiddle.net/Lemony_Andrew/qbh3twcy/

Just to realize I think I like React more
 
oh wait they don't have that on youtube
 
m59
@Lemony-Andrew cycle.js.org
 
2:35 AM
@Lemony-Andrew origin?
 
@Waterscroll It's much faster than map. Also, fuck those people. Fuck JSLint too.
 
@Shmiddty yeah I made it. I mean, it works and kind of nicely, but it needs more work and React will probably be better.
@m59 I see it supports time traveling, this might be what I'm looking for
 
m59
Once you learn RxJS, it's way easier on the brain.
Reactive Programming is WAY better.
 
@pootis Nice :)
 
Just use jQuery
 
m59
2:38 AM
lol, sumbody is trollin'.
 
I see you trollin'. I hatin'.
 
FVEYVFBUWP#IFBUW*PFBEWPGBF EWPCHNP(*EQ
reimaging my computer for the 6th time today
 
I'll stick with jQuery since that's all I'll ever know. Thanks!
 
I see you picked emacs.
 
!!afk reimage
 
2:39 AM
@SterlingArcher hi sterling's cat
 
- I never said
 
lol shut up i fucked things up
I BROKE EVERYTHING
 
did you save it first?
checkpoints === time travel
Technically, that should be congruent instead of equivalent, but the difference is negligible
 
rolls eyes
 
m59
@Lemony-Andrew The author isn't an expert at cycle, but this was the most helpful thing I've seen github.com/Cmdv/cycle-webpack-boilerplate
 
2:43 AM
@m59 I can't even comprehend a lot of the stuff on the front page of cycle.js. Mostly because I haven't gotten around to ES6 yet, and I'm not 100% familiar with React.
 
m59
Yeah, much to learn.
Worth it, I assure you.
 
It puts hair on your chest.
 
m59
It's just functional programming over time. Learn functional stuff first, like ES6 features.
 
@m59 is cycle.js an extension of React, something that works with react, or something else entirely?
 
m59
cycle** something else entirely
It's a VERY light library
It just facilitates basically 2 things: the user as an input (parameter, argument, whatever) and Reactive programming.
bye bye side-effects
React is not what it says it is.
 
2:49 AM
Would it be good for building a level editing software? Such as something that emulates a window's like interface
 
m59
It's good for everything.
 
It looks like it took out JSX though
 
m59
Nah, but I don't recommend using JSX, though you can.
JSX just gets rewritten into JS when transpiled
better to just write the JS, imo.
div('Hey') vs <div>Hey</div>
 
I thought JSX translates into react. How does babel compile it? I never learned the details, I suppose it was translated to some sort of react implementation or document.createElement....
 
m59
2:51 AM
It literally just replaces the markup with function calls
 
Looks functional enough ?
 
Interesting
 
m59
<div>Hey</div> becomes div('Hey'), or something to that effect
 
@Lemony-Andrew jsx is just syntactic sugar
nothing else
 
m59
I don't find it to be sweet =D
I did at first.
 
2:51 AM
hi guys how would I do a jquery media query add class?
add css class
 
Should be using web components anyways
 
I understand that, but under the hood it doesn't make much sense. It sounds like a wrapper of webcomponents
 
m59
What JSX is letting you do is basically use JS logic in markup. That's the point. So, then the problem is that you're adding the cognitive load of HTML and JS at the same time.
 
I know how to add a class in jQuery its the media query part
 
m59
It's easier just to use a real programming language.
 
2:52 AM
that I struggle with
 
Media queries are probably not what you think they are... even if they are this isn't the place.
 
@Skullomania what are you actually trying to do?
 
Alright, makes sense. I tried learning Polymer a while back and React and I didn't like either. I stuck with Polymer longer and it ended up having some real issues.
@m59 You said cycle was basically something else on its own. That means I could just get right into it, right?
 
You want to select an element with jQuery, but only for certain media?
 
m59
@Lemony-Andrew yeah man. Download the repo I linked above and start screwing around =D
 
2:54 AM
so I have a products page on my clients website barbilinpools.net/What-We-Carry/Above-Ground-Solutions/…
 
m59
but, read the docs and slowly work through the examples first.
 
I changed it to list as default
 
nobody cares about your products page
 
m59
@Lemony-Andrew actually, mess with RxJS first, then cycle.
argggg
ES6, then RxJS, then Cycle
2
 
@m59 Thanks for letting me know about it. I'm going to take a look! -- Okay es6, rxjs, cylce haha got it
 
2:55 AM
but lets say the user wanted to select grid and move the page inward...I would like to switch it back to list when the page reaches 767px
using a media query
 
use css..?
 
Honestly 99% of all user interfaces are basically the same
what does that tell you?
 
Whoever designed the logo has a special place in heaven
 
@pootis I am using css...but if the user selects the 'grid' view then the page will not be as responsive when the page goes to 767px
@pootis yea...I know....they were rather attached to it
 

« first day (1920 days earlier)      last day (3033 days later) »