« first day (2240 days earlier)      last day (2711 days later) » 

6:00 PM
but apparently I can't cast an Integral to a Float right away -_-
factors :: (Integral a) => a -> [a]
factors x = [ y | y <- [2..(floor ( sqrt ( fromIntegral x ) ) ) ], mod x y == 0 ]
now somehow factors 10 returns [2]
only the first factor is given, if any
ooooh no that does make sense
it's only candidate primes, so less than sqrt 10
factors 100 correctly returns [2,4,5,10]
 
so how do you keep yourself captivated with Haskell? studying math?
omg, what happened to my mad eye skills, I can't figure out anymore when things are aligned without Gimp
 
6:48 PM
hey is anybody in here familiar with node.js? i'm not and i have a question about configuration on a system i'm working on.
 
!!tell JasonC welcome
 
@FilipDupanović Don't be annoying, drop the @, nobody likes a double-ping.
@JasonC Welcome to the JavaScript chat! Please review the room 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.
 
lol
second time's a charm i guess.
 
theehe :D
 
well anyways, i have a raspberry pi. there's a node.js app running on it, at /home/user/app/index.js. i need to move that content directory, but i can't figure out how it's being started.
i see "node /home/user/app/index.js" in ps, and it's parented by pm2. i've been grepping config files and stuff for a while.
how is this probably being started and how is that path being specified to nodejs?
 
6:53 PM
you'll probably have to edit the PM2 configuration file
 
i see on the internet that pm2 is some sort of node-related process manager thing.
@Filip do you know where it is? there's this folder /root/.pm2 but there's no config file in there that contains the path at least. hold on lemme check in etc again
no all i've got there is /etc/init.d/pm2-init.sh, and that script doesn't reference any config files.
 
hmm,I think /root/.pm2 is dynamically created when PM2 is started
 
yeah it just looks like logs and stuff
i guess i can just grep the entire filesystem for "user/app", it'll take a minute, let's see...
 
@copy Ping me please if you wanna play in the next couple of hours
 
@FilipDupanović desperation? :P
I started learning haskell 2 days ago. It's more of a spur of the moment than having motivation
 
6:57 PM
can you throw the PM2 init script on hastebin... it's generated by pm2 startup probably, but the internets is weak where I am atm to install and play
 
@FilipDupanović pastebin.com/tzev7udh
 
@JasonC I wonder if you move your app to a different path and re-run pm2 startup whether this would do it for you
 
so pm2 startup generates init scripts and stuff? like you'd normally run it once when you're setting up your application and then it's set from there on out?
 
yeah and my guess it tries to be smart and writes everything it resolved to the PM2 home directory
 
cool, thanks. that's a good google starting point let's see how far i get.
 
7:01 PM
might want to back up both just in case I'm wrong
 
psh, backups are for the weak.
 
I know I had issues running PM2 in different containers that shared the same home directory
 
yeah pm2 didn't have any man pages so i was kind of at a loss.
 
try pm2 --help directly, it was installed with npm install -g pm2, I'm not sure whether they're distributing any system packages
oh @JasonC, what is /etc/default/pm2, looks like that might contain some settings for pm2
 
doesn't exist i checked that
i'm sure startup or some other pm2 command is the right way to go i just have to figure out what it all means. found some documentation pm2.keymetrics.io/docs/usage/startup. checked the dump file, there's lots of info in it. so i just have to figure out how to not blow away environment vars and stuff configured there. but i'm on the right track now. thanks.
 
7:11 PM
good luck! if all else fails, search the disk for the app directory and do a dirty fix :P
 
i'm thinking i have to stop the current app, move it, start it again, the save the new state with pm2, and it will magically stay that way.
yup, thanks!
 
or symlink it and watch your Raspberry Pi weep as it loads the app :D
 
lol I just fell for the oldest trick in the book
typeof null
I shall recite hail crockford 8 times
 
geeeeeeez >.>
hope you at least got a sensible TypeError
 
nah, crashed and burned
 
7:21 PM
@towc My suggestion is to use fromIntegral (or possibly fromInteger)
 
no worries though
 
@KendallFrey I did it in the end :) Thanks for coming though
 
const isObject = value => typeof value === 'object';
what was I thinking
I've come a long way in a year
that I would think typeof value === 'object' checks that the type of a value is an object
the nerve
 
You pleb
 
@towc What was your solution?
 
7:24 PM
@KendallFrey fromIntegral I think
 
oh right missed that I see it now
I can't help but notice your extensive use of parentheses ;)
 
why do we use both length and size for container types?
 
floor . sqrt . fromIntegral ftw
 
@KendallFrey yeah, still ain't too comfortable with order of operations or using . and $
but I'm getting there :D
 
keep pluggin
 
7:26 PM
lied-to interviewer would be proud of me
 
how do I set NODE_ENV for tests cross platform?
from the command line
don't tell me, I have to install a package
 
@Mosho process.env.NODE_ENV = 'production'/'development'?
You can assign it via your node config files
Or via command line export NODE_ENV=production
 
I don't have any
config files
nor do I want any
I did set NODE_ENV=development
 
Well, you can do it via any node.js file, but command line differs from OS
 
but idk if that runs outside windows
 
7:31 PM
You can also set it before you run the file
NODE_ENV=production node app.js
 
doesn't work
 
hmm, that's weird
can you use npm scripts?
 
yeah
 
"scripts": {
     "start": "NODE_ENV=production node ./app"
 }
 
oh
 
7:33 PM
You can try something like this as well
 
I may be retarded
 
You may
 
ok set NODE_ENV=development&& node blarh works
 
Possibly
Nice! You can write a small bash script to run prod/dev but i suggest it via npm scripts. It's easier
Though obviously you'd need a package.json
 
but I doubt it would work on linux
I have a package.json
 
7:35 PM
Yeah, SET doesn't work on linux, you'd have to determine the OS before you run it
 
meh fuck it
 
So maybe a bash to determine OS before running would work, because you either need to use set or export
 
yeah no
 
this shall suffice for now
thanks
 
7:36 PM
no problem, let me know your final solution for cross-OS devprod
 
I had to install some python packages earlier
the thing with the c++ compiler path is utterly comical
on windows
 
Compilation in general is hard, with the include paths and linker paths
 
also, python is fucking awful
at least django
 
watusayboutmymomma?
 
items.exclude(id__in=items_to_exclude)
what the fuck is that
 
7:40 PM
subpaths
 
yeah that
 
{fee: {fii: {foo}}} => fee__fii__foo
 
it's retarded
 
I didn't like django, I used it sparingly. So far flask has been a really good lib for all my python stuffs
epsecially restful api
 
it's doubly retarded when everything is in snake-case
 
7:42 PM
I don't think Django and Flask are comparable
 
I write all my js in snake_case now
 
@KendallFrey this could theoretically work, right? Maybe it's just that the laziness isn't advanced enough? The objective is to get the nth prime
    isPrime x y
      | y == length primes = True
      | mod x ( primes !! y ) == 0 = False
      | otherwise = isPrime x (y+1)

    primes = primeList [2,3] 5

    primeList xs x
      | isPrime x 0 = xs ++ ( x:primeList xs (x+1) )
      | otherwise = xs ++ (   primeList xs (x+1) )


nthPrime n = primes !! n
 
and everything is way too class based for me
 
@Mosho it's because it's using **kwargs to expand query arguments on the other end
 
also ('1', '2', '3') vs ('1', '2', '3',)
 
7:44 PM
tuples are fun
 
@towc I'm already super confused by the fact that isPrime accepts two arguments
 
and I dislike indentation based syntax to begin with
 
@KendallFrey the second argument would always be 0 when needed. To make it clean I'd have another function that calls that recursive function which only takes 1 argument
 
and PyCharm gave me cancer
 
and calls the function that's already there with a second argument of 0
 
7:46 PM
And there's the thing of passing a list into a function which is supposed to generate a list
 
something like cleanIsPrime x = isPrime x 0
 
That is really confusing
 
@Mosho you know what I really hate, when people bring rules from X and force it onto Y
 
I'd define primes as something like filter isPrime [2..]
 
@KendallFrey sure. But in theory it should work, right? The idea behind it is the one I normally use for imperative languages: compare number against all previous primes to see if it is a multiple of one of them
 
7:48 PM
@towc I have no idea if it should work, I don't understand it
 
@FilipDupanović what do you mean
classes in ES6?
 
@Mosho He's saying you're a pussy
 
lol
obvi
 
@Mosho "please find me a package on NPM that uses tabs for indentation", "we use C, so we're used to tabs"
 
yeah that's dumb
but everything knows it's dumb
 
7:49 PM
in imperative languages:
1 - start with x and primes (array)
2 - if x is divisible by any number in primes
 3 - then add x to primes
4 - add 1 to x and start at 1
this is what I've tried to implement in haskell
 
Yeah don't think of "adding" to lists
 
Oh god towc is using haskell
He's turning into Bartek
 
but as both step 2 and 3 require a list, it's going to hell
either way, dinner, brb
 
@towc "add x to primes" is imperative talk
 
exactly
 
8:03 PM
isPrime x = not . any ((== 0) . (x `mod`)) . takeWhile (<= (floor . sqrt . fromIntegral $ x)) $ primes
primes = 2 : filter isPrime [3..]
Well, it works
 
8:15 PM
@towc you don't iterate by one in prime algos
 
Hi, not a JS guy I'm afraid (and still entering this room I know), but anyone with Java+Embedded Tomcat experience here?
 
@MayukhNair Welcome to the JavaScript chat! Please review the room 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.
 
8:37 PM
@KendallFrey oh, I guess that makes a lot of sense
@Shmiddty wut?
@Zirak in the heading I said: in imperative languages:. Was trying to port a similar idea to functional
 
@towc That's almost always a mistake
 
I realized
which is yet again why I love haskell
everything I know is no longer applicable :D
 
lol yeah
 
@KendallFrey dunno how I feel about using composites instead of lambdas... like your (==0) . (mod x)
are lambdas not cached or something?
as in, the property for which as long as a function is called with the same inputs, it will always give out the same output
 
I just don't like lambda syntax
It feels like a hack compared to composition
 
8:52 PM
I agree that they kind of remove the beauty from haskell, but it's also true that they're a lot more readable
also, kinda hate that I can't do isPrime x = not . ( any (\y -> mod x y == 0) [ y | y <- primes, y < floor . sqrt . fromIntegral x ] )
 
@towc subjective :P
 
(yes, I can remove parenthesis)
 
@towc You mean that you can't use . as $?
 
and have to deal with length of the array instead, as I guess the compiler can't instantly decide if the prime sequence is strictly monotonic increasing
 
oh, you mean replacing takeWhile?
 
8:53 PM
@KendallFrey I mean using list comprehensions on infinite lists that are not immediately classifiable in certain ways
@KendallFrey yeah
I love list comprehensions. I guess you don't :P
I'm probably going to grow to hate them as well, but for now they just seem so neat
 
@towc They're fine, I just never found the need to use them
 
well, if this case worked, I, again, find it a lot more readable than a takeWhile statement
 
as for the takeWhile, could you do y <- take x primes?
 
oh, true!
 
user2620028
do you not like the lambda in js?
 
8:55 PM
not optimal ofc
@HatterisMad lambdas are fantastic in JS
 
user2620028
just don't like their syntax in haskell?
 
But only because JS doesn't have an operator for composition
 
well no, it's up to the index of the previous prime from x
otherwise there are never enough elements to evaluate the list
I guess I can use ramanujan's lower boundary of the number of primes, as the lower boundary of the count of primes at x is still higher than the sqrt of x
urgh...
or I can just say bye to list comprehensions
 
anyone know how to PM a user on this site?
 
@TheCoder you can't. You can start a room with them though
 
9:02 PM
how do i do that?
 
@TheCoder click on their avatar. Under actions: start a new room with this user
back to haskell: this is as clean as it gets for me
 
ah, so that's only if they're in chat?
 
isPrime x = not ( any (\y -> mod x y == 0) ( takeWhile (<= ( floor . sqrt . fromIntegral ) x ) primes ) )
@TheCoder you can do that from their user profile page
@KendallFrey what's the right way to dot it?
 
i see no 'actions' button on their profile page
 
@TheCoder it's not a button
 
9:08 PM
@towc can you direct me?
 
@TheCoder the first orange button under the avatar
 
it lists his communities there
 
Does anyone know how I check if I have these 2?
Privilege Type: Communication Privilege
Awarded At: 100 Reputation
This privilege

Create new chat rooms

You earned this privilege
I have it
mm, dont see create a room link
 
@TheCoder chat.stackoverflow.com there is a link at the bottom
 
9:29 PM
tfw you try to answer a question and they say thank you but don't accept it.
Man I'm only here for internet self worth points.
 
that's cool, means you'll have a chance to eventually earn stackoverflow.com/help/badges/226/unsung-hero
 
Didn't even realize that was a badge :o
 
@towc To what?
 
composite it
 
composite what
 
9:42 PM
the functions
 
I have no idea what you want from me
 
right now it's in a whole lot of parenthesis that can probably be omitted
 
an isPrime function
 
if I resorted to . and $
. = dot
 
Well, (f) x is the same as f $ x
so ( floor . sqrt . fromIntegral ) x is floor . sqrt . fromIntegral $ x
And you can not . any . takeWhile $ primes
Generally you think of . as chaining operations, followed by $ to apply the value
 
9:45 PM
@KendallFrey but then that evaluates in the same way as ((<= floor . sqrt .fromIntegral) x) which is wrong...
 
I think the new goal is going to be going for 1k points @FilipDupanović
 
This is similar to the |> operator in F#, except x |> f = f x
 
so I'd have to add a pair of parenthesis anyway to distinguish from the <=
 
@towc oh right, that needs to be in prns
 
is there a better way to do that too?
 
9:46 PM
In F#, you can do basically the opposite
 
this library works perfectly
 
as in x |> fromIntegral |> sqrt |> floor
 
in place of seamless immutable
 
should I learn F# in parallel to haskell?
 
That's up to you
I focused on Haskell because I found the syntax much cleaner
 
9:47 PM
if anyone needs cheap immutability: github.com/Mosho1/changeless
 
However, F# has dimensional types
:)
 
or just to admire my codes
 
@Luggage ping
 

« first day (2240 days earlier)      last day (2711 days later) »