I use Emacs+CIDER. I like to be able to do something akin to just evaling (quil/frame-rate 90). But Calling that function is only possible within a sketch function. So I have added a live-calls function in which I put these kinds of code, and I call live-calls at the start of the draw function. Which is a very ugly hack. What's the idiomatic way to achieve this?
I found the answer by searching in closed issues in github:
(quil.applet/with-applet sketch-name
(q/frame-rate 3))
Related
In this code headerTable and rowsTable are Java Objects. Here the same method with the same argument is being called on them:
(.setHorizontalAlignment headerTable Element/ALIGN_LEFT)
(.setHorizontalAlignment rowsTable Element/ALIGN_LEFT)
Is there a better way of doing this? I would think there must be a way to combine the two calls into one somehow. But since this is 'side effecting' code, perhaps not??
I'm thinking of an answer without writing a custom function or macro, something like "just use juxt or comp", but then maybe I'm being a bit too prescriptive...
Edit Type hinting was mentioned by Leonid Beschastny, so just in case it helps, here's the Java method signature:
public void setHorizontalAlignment(int horizontalAlignment)
And the class is PdfPTable, from iText. (This code is being used to create PDF files).
There are many possible refactorings, one would be
(run! #(.setHorizontalAlignment ^PdfPTable % Element/ALIGN_LEFT)
[headerTable rowsTable])
I am new to C++, so I would like to store a file with some methods inside that does some calculations and then I would like to call them like this, FileName.MethodName(Arguments). Is it possible to use the (.) DOT?
I am using C++ in Visual Studio.
You're thinking the wrong way. You don't want to call member functions on a file. You should use a class that wraps around the file stream which has member functions to perform the correct operations on it. Maybe if you can tell us what you're trying to do, I can better suit my answer to your intentions.
Is there a difference, performance or otherwise, between using a deffilterop and using a purse clojure function?
http://nathanmarz.com/blog/introducing-cascalog-a-clojure-based-query-language-for-hado.html mentions that filtering can be done with clojure functions like (< ?age2 ?age1) however looking at https://github.com/nathanmarz/cascalog/wiki/Guide-to-custom-operations it looks like you can define a function like (deffilterop is-2? [x] (= x 2)).
So my question is, is there any difference between these two approaches and if not which is the preferred syntax?
Note: It also looks like all of the defxxxop functions are being deprecated for defxxxfn instead. https://github.com/nathanmarz/cascalog/blob/develop/cascalog-core/src/clj/cascalog/logic/def.clj#L131
Turns out there is no difference from a performance perspective. The deffilterop is useful for making a parameterized function.
Disclaimer again: I'm a Clojure newbie. Thanks for the help.
My previous question ( Clojure's defrecord - how to use it?) resulted in a working data structure and methods: https://gist.github.com/3353281
Question: Is there a way to avoid passing in my data structure to all of the methods that operate on it? Or is this the way you're supposed to do it in idiomatic Clojure?
Data should always be passed explicitly.
If you're using nested assocs, you should probably be using assoc-in instead.
I had no problems hijacking function with Detours for a long time... When I tried to hijack class methods (in my case IHTMLDocument2::write from mshtml.dll) I encountered endless problems (mainly type mismatching). As I didn't find any relevant example on the net I began doubting this can be done.
My question is: is it possible to hijack class methods with Detours? Can I have an example, please? If not, is it possible to hijack class methods in a simpler way with another hooking library?
Thanks in advance guys!
IHTMLDocument2::write is not just a class method; it's a COM method. That implies a whole lot more. For instance, there's also an equivalent C declaration. You can use that C signature when detouring the method; it's still the same function.
http://pastebin.com/f6559d448
Yeah!