Error when writing metadata to mp3 in Clojure with zsau/id3 - audio

I'm new to Clojure and I'm trying to write some metadata to a mp3 file. I decided to use zsau/id3 for this task.
After I created a new project with lein new app, I added zsau/id3 as a dependency in my project.clj:
:dependencies [[org.clojure/clojure "1.10.0"]
[zsau/id3 "0.1.2"]]
This is my core.clj file:
(ns demo.core
(:require [id3])
(:gen-class))
(defn -main
[& args]
(id3/overwrite-tag "t.mp3"
(id3/with-mp3 [mp3 "t.mp3"]
(assoc (:id3/tag mp3) :id3.frame.name/genre ["Rock"]))))
I've copied the code for writing the metadata from the official docs of the package.
When I try to run -main I get the following error:
(-main)
Execution error (ExceptionInfo) at org.clojars.smee.binary.core/constant$fn (core.clj:278).
value 'ÿû' should have had the constant value 'ID3'
What am I doing wrong? Should I just use another package instead of zsau/id3?

Related

How to make cljs files works with figwheel repl via fireplace.vim?

I have a project on ClojureScript and I'm using vim for code editing, so I want to access repl inside editor, what is accessible using fireplace.vim.
It works well if you have a brand new flat project - you just open the directory, start clojure repl, open vim in the same directory, create an expression and evaluate it using cpp.
https://youtu.be/vHDLDNoAdLE
But when I working with figwheel project I want to connect to figwheel repl in order to calculate something from cljs file, so I start a figwheel which starts the repl on port 7888 eventually and connect to that repl with fireplace using :Connect command and it works for only clj files, not for cljs.
https://youtu.be/ue42Yh0v6UQ
When I'm trying to evaluate an expression in .cljs file fireplace throwing this error:
Error detected while processing function
37_printop1..37_opfunc[35]..fireplace#client: line 10:
E605: Exception not caught: Fireplace: class
java.lang.ClassNotFoundException
Does anyone have any idea how to make it work (fireplace + .cjls files)?
The problem was in fireplace.vim plugin
at line 323 in fireplace.vim
let response = connection.eval("((or (resolve 'cider.piggieback/cljs-repl)"
must be line:
let response = connection.eval("((or (resolve 'cider.piggieback/wrap-cljs-repl)"
because cider.piggieback defines wrap-cljs-repl function in line 299:
(defn wrap-cljs-repl [handler]
Have you "Piggiebacked" ("enable the use of a ClojureScript REPL on top of an nREPL session") to connect Fireplace to the Figwheel REPL?
:Piggieback (figwheel-sidecar.repl-api/repl-env)
See https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-with-Vim#still-in-vim-piggieback-on-clojurescript
Related to ClassNotFound Exception cemmerick.piggieback:
You have to include cemerick.piggieback in your project.clj or profiles.clj. See https://github.com/nrepl/piggieback:
:profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.1"]
[figwheel-sidecar "0.5.18"]]
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}}
Here is a sequence of steps I took to make work figwheel REPL with vim fireplace:
Add these dependencies to /home/{username}/.clojure/deps.edn:
...
:aliases {:nrepl
{:extra-deps
{nrepl/nrepl {:mvn/version "0.6.0"}
cider/cider-nrepl {:mvn/version "0.23.0"}
cider/piggieback {:mvn/version "0.4.2"}}}}
...
Add these ones to the project:
...
:deps {com.bhauman/figwheel-main {:mvn/version "0.2.3"}
figwheel-sidecar {:mvn/version "0.5.19"}}
...
Run a project from a terminal with the next command:
clj -R:nrepl -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware cider.piggieback/wrap-cljs-repl]"
Connect to an nREPL from vim using:
:Connect nrepl://localhost:{port}
Start a figwheel REPL and connect to it:
:CljEval (do (require 'figwheel.main.api) (figwheel.main.api/start "dev"))
:CljEval (do (use 'figwheel.main.api) (figwheel.main.api/cljs-repl "dev"))

eb create ERROR: LargeZipFile :: Files count would require ZIP64 extensions

Not sure what I'm doing wrong here but when I do an eb create for my node js express app I get this error.
$ eb create app-test
Creating application version archive "app-170215_091947".
ERROR: LargeZipFile :: Files count would require ZIP64 extensions
So it seems like that the size of your code base is too big for eb-cli/python's zipfile library to handle.
The limit seems to be 4GB:
exception zipfile.LargeZipFile The error raised when a ZIP file would
require ZIP64 functionality but that has not been enabled.
Can you do a ls -l to check the size of your current code base?
with zipfile.ZipFile(
zip_file, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) as myzip:
myzip.write(os.path.join(SAVE_PATH, sql))
“allowZip64=True” should be used.

REPL session for a ClojureScript library in the vein of `lein try`

Sometimes I want to try out a library in a REPL. For example when I need to know the date 100 days from now, I do:
lein try clj-time
(require '[clj-time.core :as t])
(t/plus (t/today) (t/days 100))
Or with boot:
boot -d clj-time repl -e "(require '[clj-time.core :as t])"
(t/plus (t/today) (t/days 100))
This is already great, but this still has a few seconds of start up time.
My question: can I get the same functionality using ClojureScript and Node and perhaps have a faster startup time? How can I get the example above with cljs-time?
You can use Planck with the jar you're wanting to try by adding it to Planck's "classpath" (it's not an actual classpath since there's no JVM involved). See the Planck Dependencies documentation.
E.g.:
planck -c ~/.m2/repository/com/andrewmcveigh/cljs-time/0.4.0/cljs-time-0.4.0.jar

Clojurescript + Node.js 0.12.7 issue (error "process.binding('evals') No such module: evals")

I'm trying to use Node.js + ClojureScript, and I found an article for it.
http://www.mase.io/code/clojure/node/2015/01/24/getting-started-with-clojurecript-and-node/
Following the instruction to find this error:
process.binding('evals').NodeScript.runInThisContext.call(
^
Error: No such module: evals
at Error (native)
The issue seems that I need to use old version of node: https://groups.google.com/forum/#!topic/clojurescript/VneLWVpwe6o and https://github.com/kanso/kanso/issues/422
Mine is 0.12.7
pow> node --version
v0.12.7
In this case, I may need to use old version of node, but better yet, is there a way to bypass this issue? If none exists, how to use the old version of node.js in Mac OS X?
Edit
Following https://github.com/creationix/nvm, I could install 0.10.32 version of node.js.
pow> nvm install 0.10.32
pow> node --version
v0.10.32
However, it gives me another error message:
pow> node entrypoint.js
Hello world!
/Users/smcho/Desktop/clojurescript/pow/out/server/cljs/core.js:12133
var fixed_arity = f.cljs$lang$maxFixedArity;
^
TypeError: Cannot read property 'cljs$lang$maxFixedArity' of null
Edit2
The error was because I forgot to update the core.cljs module to include ((set! *main-cli-fn* -main). It's mentioned in the original article, together with https://groups.google.com/forum/#!topic/clojurescript/DYpsiCmsyIs and https://github.com/clojure/clojurescript/wiki/Quick-Start#running-clojurescript-on-nodejs.
From the post, there are two ways to make it working, with Mac OSX, the two approaches require different version of node.js, and this is not clearly explained in the post.
The version that works with old node.js
_project.clj
(defproject pow "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2725"]]
:node-dependencies [[source-map-support "0.2.8"]]
:plugins [[lein-cljsbuild "1.0.4"]
[lein-npm "0.4.0"]]
:source-paths ["src" "target/classes"]
:clean-targets ["out/server/pow" "out/server/pow.js"]
:cljsbuild {
:builds [{:id "server"
:source-paths ["src/server"]
:compiler {
:main pow.core
:output-to "out/server/pow.js"
:output-dir "out/server"
:optimizations :none
:target :nodejs
:cache-analysis true
:source-map true}}
]})
entry.js
// entrypoint.js
require("./out/server/goog/bootstrap/nodejs");
require("./out/server/pow");
require("./out/server/pow/core");
Run the script that executes the old node.js
#!/bin/bash
lein new mies pow
cd pow
cp ../_project.clj project.clj
mkdir src/server
mv src/pow src/server/
lein cljsbuild once
cp ../entrypoint.js .
/Users/smcho/.nvm/v0.10.32/bin/node entrypoint.js
The version that works with new node.js
Modify the _project.clj
:optimizations :simple <-
:source-map "out/server/pow.js.map" <-
Run first part of runme.sh
lein new mies pow
cd pow
cp ../_project.clj project.clj
mkdir src/server
mv src/pow src/server/
MOdify core.clj
(ns pow.core
(:require
[clojure.browser.repl :as repl]))
(enable-console-print!)
(defn -main []
(println "Hello world!"))
(set! *main-cli-fn* -main)
Then the second part of shell script
cd pow
lein cljsbuild once
node out/server/pow.js
One more note
I wanted to use ClojureScript/Node.js in order to test clojureScript code without using web browsers. I found LightTable, and
a good tutorial about it. All I need to is open the LightTable, connect to LightTable UI as an output, then execute the script. So, I have much less reason to use ClojureScript/Node.js as of now.
I fixed this with two steps:
1) Declaring a main function
(ns testproj.core
(:require
[clojure.browser.repl :as repl]))
(enable-console-print!)
(defn -main []
(println "Hello world!"))
(set! *main-cli-fn* -main)
2) Setting optimizations: simple in my project.clj, as noted at the very bottom of this blog post. For reasons unknown to me, optimizations: none breaks things.

LUAROCKS on windows installs rocks oddly

On Linux, luarocks installs rocks to
/usr/local/lib/luarocks/rock
and puts a corresponding lua file into
/usr/local/share/lua/5.3
On Windows(LUA 5.1), the rocks are in:
C:\Program Files (x86)\LuaRocks\systree\lib\luarocks
and the lua files are in:
C:\Program Files (x86)\LuaRocks\systree\share\lua\5.1
but lua cannot find them on the windows install.
I must have a PATH problem
This is some of my PATH:
Path=C:\Program Files (x86)\Lua\5.1\lua\;C:\Program Files (x86)\LuaRocks\2.2;C:\Program Files (x86)\LuaRocks\2.2\lua\luarocks;C:\Program Files (x86)\LuaRocks\systree\bin;C:\Perl64\site\bin;C:\UnxUpdts;C:\Perl64\bin;C:\Program Files (x86)\Lua\5.1;C:\Program Files (x86)\Lua\5.1\clibs
I am trying ZeroBraneStudio as the IDE and my system prefs specify this path
path.lua = 'C:\Program Files (x86)\Lua\5.1'
I ran
luarocks install inspect
and that generated the necessary files. Then I wrote this simple test code:
require "inspect"
assert(inspect(1) == "1")
assert(inspect("Hello") == '"Hello"')
and got this error
Program starting as '"E:\Anonamouse\ZeroBraneStudio\bin\lua.exe" -e "io.stdout:setvbuf('no')" "E:\Anonamouse\ZeroBraneStudio\myprograms\DemoInspectModule.lua"'.
Program 'lua.exe' started in 'E:\Anonamouse\ZeroBraneStudio\myprograms' (pid: 14776).
E:\Anonamouse\ZeroBraneStudio\bin\lua.exe: ...namouse\ZeroBraneStudio\myprograms\DemoInspectModule.lua:2: attempt to call global 'inspect' (a nil value)
stack traceback:
...namouse\ZeroBraneStudio\myprograms\DemoInspectModule.lua:2: in main chunk
[C]: at 0x00402a57
Program completed in 0.04 seconds (pid: 14776).
I get the same error when I execute the same simple app directly in the console.(That tells me that PATH variable for lua is working)
What am I missing?
Judging from the error message you quoted the require "inspect" worked just fine, but the module didn't set a global variable inspect. For some time now it has been policy to not set globals from within modules, but instead return something (usually the module table) from the module code, which in turn gets passed down via require. So probably something like
local inspect = require "inspect"
assert(inspect(1) == "1")
assert(inspect("Hello") == '"Hello"')
or
local inspect = require "inspect"
assert(inspect.inspect(1) == "1")
assert(inspect.inspect("Hello") == '"Hello"')
should work.

Resources