Posts

Max value from field Spring Data and Mongodb -

i want calculate maximum value of field code within entity "user", use spring data, have seen code as: ".find({}).sort({"updatetime" : -1}).limit(1)" but not know how integrate "repository" @query or equivalent solution, return maximum value of said field. can me? thank you. you can write custom method repository. example have: public interface userrepository extends mongorepository<user, string>, userrepositorycustom { ... } additional methods repository: public interface userrepositorycustom { user maxuser(); } and implementation of it: public class userrepositoryimpl implements userrepositorycustom { @autowired private mongotemplate mongotemplate; @override public user maxuser() { final query query = new query() .limit(1) .with(new sort(sort.direction.desc, "updatetime")); return mongotemplate.findone(query, user.class) } } ...

python - Assign init arguments automatically in decorator -

i trying assign arguments passed init class. cannot arguments, nor class self (the self init gets passed first arg): class unpack_arguments(object): def __init__(self, f): self.f = f def __call__(self, *args, **kwargs): import ipdb; ipdb.set_trace() class someobject(object): @unpack_arguments def __init__(self, one=1, two=2, three=3, four=4): pass # @ point, can # # obj = someobject() # obj.one # 1 # obj.two # 2 # obj.three # 3 # obj.four # 4 obj = someobject() i try find things can't find class instance of someobject or key names one , two , etc: ipdb> kwargs {} ipdb> args self = <__main__.unpack_arguments object @ 0x1077a3f60> args = () kwargs = {} ipdb> self.f <function someobject.__init__ @ 0x1077a06a8> ipdb> dir(self.f) ['__annotations__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__...

html - grunt-include-replace adding a folder when it compiles -

i'm @ wits end trying figure out. have include replace pulling src folder , compiling dist folder. doing that, however, it's adding src folder dist folder , putting html file that. if pull root directory instead of src folder, works fine , puts html dist folder no folder. why adding path src folder create src folder inside dist folder , how stop doing that? my code set this... distdir: 'dist', srcdir: 'src', includereplace: { dist: { options: { includesdir: '<%= srcdir %>/includes/' }, src: '<%= srcdir %>/*.html', dest: '<%= distdir %>' } } never mind. figured out. have this: files: [ { src: '*.html', dest: '<%= distdir %>/', expand: true, cwd: '<%= srcdir %>/' } ]

asp.net mvc - Sending hyperlink in the email issue -

mvc 4, c#, visual studio 2015, using smtp server. sending hyperlink in email. few people (out of email sent to) receive not complete hyperlink, part of hyperlink blue-underlined-active (represented in bold below). when clicked on, takes https://abcd.efgh.org , not page whole link points to. few use gmail receive emails. https://abcd.efgh.org /testone/testtwo/12?enr=12c873%2goyrjmhxsi%2b9g12xsmv1veb%2ccnndj3o23gi7giu5r5ypyb9ldtkqdbavgwzdpk%2kw%3d%3d ---- view sendmyemail.html.cshtml-------------------------------------------------------------------- @using actionmailer.net @model emailsend @{ layout = "~/views/shared/_email_layout.cshtml"; var emailcontent = model.email.emailcontent; // text emailcontent = emailcontent.replace("{my_hyperlink}", @viewbag.hyperlink); } <!doctype html> <html> <head> <title>mytitle.html</title> </head> <body> <div> @html.raw(em...

r - RMarkdown: preserve source code formatting in code cell -

Image
my rmarkdown source looks (screenshot rstudio): (notice empty lines) when press ctrl+shift+k got view expected (with empty lines). however, if run chunk (evaluate) , compile ( ctrl+shift+k ), get: (no empty lines) is there way how preserve empty lines in source code? (i checked knitr options: strip.white=false, tidy=true, tidy.opts=list(blank=true) no joy.) i'm using rstudio 1.0.153 other info: sessioninfo() r version 3.4.1 (2017-06-30) platform: x86_64-pc-linux-gnu (64-bit) running under: debian gnu/linux 9 (stretch) matrix products: default blas: /usr/lib/openblas-base/libblas.so.3 lapack: /usr/lib/libopenblasp-r0.2.19.so locale: [1] lc_ctype=en_us.utf-8 lc_numeric=c [3] lc_time=en_us.utf-8 lc_collate=en_us.utf-8 [5] lc_monetary=en_us.utf-8 lc_messages=en_us.utf-8 [7] lc_paper=en_us.utf-8 lc_name=c [9] lc_address=c lc_telephone=c [11] lc_measurement=en_us.utf-8 l...

lisp - Allegro CL, Debugging functions step by step -

this question has answer here: how debug in [clozure] common lisp? 3 answers i trying understand how function works in lisp, used allegro cl quite time ago, , remember had special function in repl, let see how function worked step step, in matlab. example, if had function: (+ 1 (* 2 3 (/ 6 2) ) ) you see each function step step, like: (+ 1 (* 2 3 3) ) and then: (+ 1 18) and finally: 19 many in advance. thanks jkiiski, the code showing step step function be: (step (+ 1 (* 2 3 (/ 6 2)))) and shows in detail how lisp parses data , evaluates function. after many steps gives: [step] cg-user(2): result 6: 2 6: (/ 6 2) [step] cg-user(2): result 5: 18 result 4: 18 result 3: 18 result 2: 18 2: (+ 1 18) [step] cg-user(2): result 2: 19 result 1: 19

SPARK_WORKER_INSTANCES for Spark 2.2.0 -

in spark 2.2.0, not see option spark_worker_instances launch multiple workers per node. how do this? if @ spark-env.sh file inside conf directory of spark folder, see option spark_worker_instances=1 . can change number want. so when spark started sbin/start-all.sh number of worker nodes defined should started on machine.