Fork me on GitHub
#beginners
<
2017-05-19
>
matan06:05:02

Not going to paste an example, but I had noticed that sometimes an exception stack will not show the actual function where it was thrown, but rather just an upstream call line, that triggered materialization of a cascade of lazy sequences / function calls. And then it is a nightmare to figure out where the problem actually lies in the code.

matan06:05:07

Have you ever noticed the same?

matan06:05:41

At least when the code is run from leiningen

Alex Miller (Clojure team)12:05:33

Yes, that happens sometimes

bj14:05:00

Is there a good way to avoid getting into that situation?

lepistane16:05:23

off clojure question

lepistane16:05:28

how is paganation implemented?

lepistane16:05:27

you take parameteres say marked 5 pieces of data per page page number request to server get from database first 5 pieces of data

lepistane16:05:08

when you switch to page 2 same deal. next 5 ?

jumar17:05:50

lepistane: I would typically accept optional query string params like offset and count, order the records by time or another key to get deterministic results, and select the proper page starting at offset and going up to the offset + count - 1. I'd also recommend to limit the results at datastore level to avoid transmission of unnecessary data but it depends on the use case / technology stack.

lepistane18:05:37

thank you very much

lepistane18:05:52

that is what i had in mind

vitruvia18:05:29

I'm trying to install lein on ubuntu. After downloading the bin via wget, I can't seem to make it into an executable with chmod

vitruvia18:05:53

the command runs with any errors but calling lein brings an error lein: command not found

noisesmith18:05:59

@vitruvia it needs to be on your path

vitruvia18:05:03

its on ~/bin

noisesmith18:05:16

are you sure ~/bin is on your path?

vitruvia18:05:39

oh, I thought it was on the path on installation

noisesmith18:05:41

usually you have to add it yourself, sometimes .profile is set up to check if ~/bin exists on login, and only adds it to path if it exists

noisesmith18:05:01

but if lein is executable, and you can run it, then the problem is likely that it’s not on the path

vitruvia18:05:46

hm I don't know, the instructions say it should be on the path

vitruvia18:05:12

I have $HOME/bin on the path, is that tha same as ~/bin?

john18:05:39

if you ./lein from within ~/bin does it run?

noisesmith18:05:57

@vitruvia well you said it ran without errors, how did you run it?

john18:05:36

I think he said chmod ran without errors

vitruvia18:05:33

yes I meant chmod

vitruvia18:05:07

@john yes it ran when I used it that way

john18:05:18

def your path

john18:05:07

I can't remember which, but either .profile or .bashrc only runs in a login sh. So I update my path in both.

noisesmith18:05:02

profile is login only, bashrc is read every time a shell is started

vitruvia18:05:02

I read that profile is the one that makes a permanent change

vitruvia18:05:20

I'll research again once I'm back from school

noisesmith18:05:26

@vitruvia try running bash -l, then running lein

noisesmith18:05:43

bash -l gives you a new bash instance that has read your login config

dpsutton18:05:11

and can always just source ~/.bashrc

vitruvia18:05:36

@noisesmith this one doesn't work

noisesmith18:05:38

@dpsutton but there’s multiple files (bashrc, profile, bash_profile…)

dpsutton18:05:01

i mean call source on whichever file you update to include lein on the path

noisesmith18:05:04

bash -l ensures all of them have been used as would happen on a fresh login, so it’s the thing to check if you are setting up for the future

noisesmith18:05:09

which is why I recommend it

dpsutton18:05:10

ah nice thanks

dpsutton18:05:25

thanks for the explanation as to why as well

noisesmith18:05:26

oh and also /etc/bashrc… there’s a list 😄

dpsutton18:05:08

so many rumors about how to use a unix proficiently i never really know the "proper" way

noisesmith18:05:42

yeah - the web is full of instructions for using unix that were put together by people that know just enough to be dangerous

vitruvia19:05:36

@noisesmith but where should I include bin so it remains in my path?

noisesmith19:05:22

do you have something in your .profile or .bashrc that already sets your path? if so I’d add it there

vitruvia19:05:11

Yes there is something in .profile. I'm at my notebook which doesn't have linux right now, but I remember seeing something there

vitruvia19:05:22

So I add it there then call bash -l?

john19:05:50

If you copy your path statement from your .profile to your .bashrc, you should be good

john19:05:56

just restart your shell

vitruvia19:05:56

Alright. I'll do that when I get home. Thanks!

vitruvia21:05:52

@john @noisesmith Just got home and copied my path statement from profile to .bashrc and it worked. I haven't logged off yet to make sure it stays that way but thanks!

noisesmith21:05:33

cool - if it was in profile it would have been applied after a future login (or even in a new terminal usually…)

john21:05:37

noisesmith: only for the login sh, on Ubuntu, iirc

john21:05:43

not for bash

vitruvia21:05:38

what is sh login?

john21:05:40

it's a reduced version of the full bash, used for system boot up, I believe.

john21:05:49

Still based on bash, I believe

john21:05:56

It's been a while since I read about it, since I just always migrate the path conf over to .bashrc after a fresh install anyway.

noisesmith21:05:03

john bash reads .profile

noisesmith21:05:09

I use bash, I have a .profile

noisesmith21:05:23

.bashrc is read every time a shell is created

noisesmith21:05:44

.profile is read on every login, unless there’s a .bash_profile, in which case that’s used instead

noisesmith21:05:15

but .profile is the right place for things that would be valid even if your shell wasn’t bash, and should be set on login

john21:05:49

For some reason, launching a graphical terminal would never read my .profile. This was a long time ago...

john21:05:07

hunting down the answer, I ended up always using .bashrc

noisesmith21:05:21

you can usually tell your terminal whether new windows should read your login config- sometimes people do things on login that should not run with every shell they start up

noisesmith21:05:49

but bash will definitely use the .profile file unless it finds something more specific that overrides it (which most people don’t use)

john21:05:30

hmm, I just updated my .profile, restarted my bash, ran $PATH, and I can't see my update there.

john21:05:58

could be something about me setup

noisesmith21:05:18

did you give the -l arg to bash which specifies that it should be a login shell?

noisesmith21:05:25

otherwise profile will never be loaded

john21:05:12

So open a graphical terminal, and then open another shell inside every time I want to use my path?

noisesmith22:05:52

my terminal emulator starts my shell as a login shell

noisesmith22:05:11

if yours doesn’t do that, then putting things in login config is not very useful, sure

dpsutton22:05:09

i think fedora 25 changed this when it adopted wayland if you're running either of those john

ballpointcarrot22:05:13

although minor pet peeve - I don’t like the use of “environmental variables” vs. “environment variables” in that doc - but, it has the usual profile load order specified, which is what I wanted to call out.

john22:05:27

@dpsutton I'm on ubuntu

john22:05:43

ah, right... ssh will give you a login shell

john22:05:37

Digital ocean has great docs

vitruvia23:05:48

How can I set profiles.clj for leiningen on ubuntu? In my case I downloaded lein, installed, and can even run a REPL, but I don't see a profiles.clj file under .lein. I tried making one but it caused errors when running a new REPL

john23:05:08

potentially a bad profiles.clj file?

vitruvia23:05:56

Possibly. But in this case I don't know what is wrong with it. I didn't find a default one on my installation or on the internet

john23:05:43

{:user {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]]
        :dependencies [[org.clojure/tools.nrepl "0.2.7"]]}}

john23:05:46

for instance

vitruvia23:05:12

I thought you needed to specify the location of jdk... the one I have on windows did that so that's probably what is wrong