Fork me on GitHub
#beginners
<
2016-01-17
>
grounded_sage07:01:44

I am following Eric Normand's Web with Clojure tutorial and I am completely stuck with Postgres. I can't seem to get it to work with 'creatdb'

grounded_sage09:01:59

Ok I see. It has a different terminal. Seems the best option for installing it is the Postgres app.

shanekilkelly10:01:13

@grounded_sage: are you sure postgres is installed correctly on your system? what is the output of which postgres ?

grounded_sage12:01:27

@shanekilkelly: It's giving me nothing now. The previous installs gave me something but weren't working so I thought I would try it this way... still confused.

shanekilkelly12:01:20

How is it installed now? Are you using postgres.app on a mac?

grounded_sage12:01:45

Yep that's how I have installed it now

grounded_sage12:01:07

Which is now giving me nothing when I ask which postgres

grounded_sage12:01:14

The Brew installed ones and enterprise ones both gave me something back. I think the enterprise one kept setting up a new user on the computer... which I didn't like.

shanekilkelly12:01:49

Ok, when you use brew it installs the postgres binaries to /usr/local, which is visible on your shell path. Postgres.app keeps everything inside the app package, so those programs are not visible on the shell path.

grounded_sage12:01:01

I haven't installed the command line tools... I don't know where ~/.bash_profiles is http://postgresapp.com/documentation/cli-tools.html

shanekilkelly12:01:09

If you just want to creat a database, then I suggest launching postgres.app and then using a graphical tool like pgadmin to connect and create your database

shanekilkelly12:01:02

.bash_profile should be in your home directory

grounded_sage12:01:05

In the Clojure Web Development course. He just types in..... createdb app-name

shanekilkelly12:01:35

Ok, let's back up, do you have much experience using the terminal? :)

grounded_sage12:01:54

Yes I have forced myself to use it a lot

grounded_sage12:01:06

I actually prefer it over GUI apps for doing stuff like this

grounded_sage12:01:25

I tried doing a search earlier for .bash_profile and nothing came up so I created my own... didn't do anything lol

shanekilkelly12:01:53

Ok, then you know that '~/.bash_profile' is a file in your home directory? If you can edit that then the instructions in the linked article should allow you to get this working

shanekilkelly12:01:16

Ah, it's also possible you may need to creat it

grounded_sage12:01:34

find: .bash_profile : No such file or directory Wades-Air:home wade$

grounded_sage12:01:02

Umm... I don't know what happened but it's finding it now...

grounded_sage12:01:27

which psql that is

shanekilkelly12:01:09

Cool, createdb should now also work

grounded_sage12:01:47

Wades-Air:webdev wade$ lein run 8000 2016-01-17 22:37:51.076:INFO::main: Logging initialized @3705ms Exception in thread "main" org.postgresql.util.PSQLException: ERROR: syntax error at or near "NOT" Position: 133, compiling:(/private/var/folders/m9/rcs8n7hd74q_qw084n6bc93c0000gn/T/form-init6970411645438536527.clj:1:124) at clojure.lang.Compiler.load(Compiler.java:7142) at clojure.lang.Compiler.loadFile(Compiler.java:7086) at clojure.main$load_script.invoke(main.clj:274) at clojure.main$init_opt.invoke(main.clj:279) at clojure.main$initialize.invoke(main.clj:307) at clojure.main$null_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:420) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:383) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "NOT" Position: 133 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334) at clojure.java.jdbc$db_do_execute_prepared_statement$fn__371.invoke(jdbc.clj:753) at clojure.java.jdbc$db_transaction_STAR_.doInvoke(jdbc.clj:595) at clojure.lang.RestFn.invoke(RestFn.java:425) at clojure.java.jdbc$db_do_execute_prepared_statement.invoke(jdbc.clj:752) at clojure.java.jdbc$db_do_prepared.doInvoke(jdbc.clj:786) at clojure.lang.RestFn.invoke(RestFn.java:442) at clojure.java.jdbc$execute_BANG_$execute_helper__404.invoke(jdbc.clj:892) at clojure.java.jdbc$execute_BANG_.doInvoke(jdbc.clj:896) at clojure.lang.RestFn.invoke(RestFn.java:425) at webdev.item.model$create_table.invoke(model.clj:8) at webdev.core$devmain.invoke(core.clj:69) at clojure.lang.Var.invoke(Var.java:379) at user$eval5.invoke(form-init6970411645438536527.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6703) at clojure.lang.Compiler.eval(Compiler.java:6693) at clojure.lang.Compiler.load(Compiler.java:7130) ... 11 more

grounded_sage12:01:26

I have no idea what the error message is saying at all lol

grounded_sage13:01:24

Got it working. There was an error in the video training. On that note I am off to bed. Thanks @shanekilkelly for helping out simple_smile

t0by16:01:19

Hi, does a series of progressive exercises to obtain basic fluency in Clojure exist anywhere that you know of?

meow16:01:19

perhaps the clojure katanas

meow16:01:54

someone should compile a list somewhere

t0by16:01:02

pkobrien: alexmiller: thank you so very much. Bookmarked.

t0by16:01:59

"At this time, http://4clojure.com does not provide information regarding the sale of foreclosed homes, and has no plans of doing so in the future." I actually laughed out loud.

kyle_schmidt18:01:22

Is there a better way to write this:

clojure
(zipmap (keys (stasis/slurp-directory "resources/articles/" #"\.md$")) (map #(md/md-to-html-string %) (vals (stasis/slurp-directory "resources/articles/" #"\.md$"))))

kyle_schmidt18:01:59

Essentially I would like to keep the keys of a persistent array map and just operate on their values

kyle_schmidt18:01:20

returning a new map representing the change

meow18:01:00

so that sounds like a data transformation problem

meow18:01:18

step 1 for me is to always look at into

meow18:01:00

it isn't always the right solution, but quite often it is

kyle_schmidt18:01:59

into an empty map {} and then destructure the data structure that I am trying to work with? In this case

(stasis/slurp-directory "resources/articles/" #"\.md$")

meow18:01:03

(defn zipmapf [f coll]
  (zipmap coll (map f coll)))

meow18:01:01

similar to what you need, perhaps

meow18:01:43

I feel like I always struggle with this type of manipulation in clojure, as if the elegant approach isn't there to be found in core.

meow18:01:09

and I'm not sold on my own attempts

kyle_schmidt18:01:36

Yes, this has been the biggest hurdle for me - manipulating data structures.

kyle_schmidt18:01:49

I like your into approach though! That's exactly what I need

meow18:01:20

manipulating vectors using into with optional transducers is a joy

meow18:01:23

versus the lack of ability to do something like this using a core function:

(defn hashmap-set
  [keyvals]
  (persistent!
    (reduce
      (fn [ret [k v]]
        (assoc! ret k (conj (get ret k #{}) v)))
      (transient {}) keyvals)))

meow18:01:04

my favorite exploitation of clojure data transforms:

(defn produce
  "Returns a lazy sequence of colls from a recursive, axiomatic,
   transformative process."
  [seed prep-f get-xf]
  (letfn [(process
            [coll]
            (lazy-seq
              (when (seq coll)
                (let [new-coll (into (empty coll) (get-xf coll) (prep-f coll))]
                  (cons new-coll (process new-coll))))))]
    (process seed)))

leontalbot19:01:42

hello! My web form send form params to server that connect to google spreadsheet api, writes new line, and return response up to client

leontalbot19:01:51

locally this works fine.

leontalbot19:01:53

when I run the app in my hosting provider, I see that a new line is created in my spreadsheet but the server doesn't return anyresponse to client

leontalbot19:01:15

anyone would have a clue?

leontalbot19:01:31

I am using cljs-ajax for posting to server

leontalbot19:01:55

in chrome the console indicates Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error

leontalbot19:01:30

in safari : kCFErrorDomainCFNetwork Code=303

kopasetik22:01:19

Just to create the schedule based on n, this is what I was trying...

mfikes22:01:37

@kopasetik: the recur passes 2 arguments. You could fix the loop binding to be

(loop [n n
       vctr vctr]
or just eliminate loop and let it recur to createSchedule.

meow22:01:26

I don't like loop very often

meow22:01:46

maybe the feeling is mutual

mfikes22:01:16

But loop sure likes recur

mfikes22:01:43

@kopasetik: That just fixes the shape of the code. I haven’t looked into what it is really doing.

meow22:01:31

avoid loop like the complement of recur

kopasetik22:01:58

OK, i’m not sure how to make an arithmetic series using iterate. Is that possible?

mfikes22:01:23

You can use iterate, as in (take 5 (iterate inc 5))

meow22:01:25

(iterate inc 5)

mfikes22:01:31

But, range is indeed geared to work with numbers

mfikes22:01:51

Speaking of that, the ClojureScript docstring for range indicates it returns a lazy seq. Wonder if that is strictly speaking, true.

meow22:01:55

partition is a fun function

meow22:01:46

ignoring chunking I'd be surprised if rangewasn't lazy in cljs

mfikes22:01:07

Well, range in ClojureScript has an interesting implementation.

mfikes22:01:05

Try (nth (range) 5e8) in Clojure and in ClojureScript. simple_smile

mfikes22:01:27

Hmm… Clojure doesn’t have indexed?

meow23:01:50

I'm on a borrowed laptop and don't have clojure installed yet. 😞

mfikes23:01:32

Well, suffice it to say, in ClojureScript, it returns a deftype that conspires to implement things like IIndexed in O (1) as opposed to O (n).

mfikes23:01:02

Same for ICounted, it is a nice trick that makes (count (range 1 1e8)) instant by doing something we all learned how to do before computers existed. simple_smile

meow23:01:54

its turtles and magiks all the way down