Posts

list - Sort depending on variable in Scala -

is there way in scala sort list of objects specific field using variable set order (asc or desc)? i know sortwith can like mylist.sortwith((x, y) => x < y) or mylist.sortwith((x, y) => x > y) to sort ascending or descending, want use variable. so, tried this: case class person(firstname: string, lastname: string, age: int) private def sortdocuments(sortfield: string, sortdirection: string, people: list[person]): list[person] = { sortfield match { case "age" => people.sortby(if (sortdirection == "desc") -_.age else _.age) case "firstname" => people.sortwith { sortstring(a.firstname, b.firstname, sortdirection) } case "lastname" => people.sortwith { sortstring(a.firstname, b.lastname, sortdirection) } } } private def sortstring(fielda: string = null, fieldb: string = null, direction: string = "asc") = { val fieldavaild = option(fielda).getorelse("") val fieldbvaild =...

windows - UAC Elevation vs. Impersonation -

(skip bottom tldr version.) ok - have searched (really!) , other uac articles have found seem center on enabling, disabling, detecting or hiding uac. issue not 1 of those, here goes: my user used have standard dual-token setup in administrators group , uac's consent ui ask me if wanted proceed. now, have separate administrative-level accounts need use, , have authenticate new user. problem having previously, starting app administrator elevated current user, if use credentials of new administrative user, whatever running runs as new user. as example, elevating cmd , typing whoami command prompt used return normal/current user, returns new administrative user. this has serious negative consequences - since new user, , administrative-level one, if files created using new user, normal user cannot write or delete them unless manually adjust permissions , ownership. if use development environment under new account (e.g. need debug service or work driver) , rebuild so...

c++11 - Linker refers to, supposedly, undefined reference to vtable -

i trying use abstract class represent common base subtypes. however, (the linker seems) keeps moaning vtables , undefined references no matter do. judging error messages, problem must related destructors in way. wierdldy enough, keeps talking a "undefined reference 'abstractbase::~abstractbase()'" in child.cpp makes no sense. like last time, can't show code, here example in essence same thing: first abstract class, "abstractbase.h": #ifndef abstractbase #define abstractbase class abstractbase { public: virtual ~abstractbase() = 0; } #endif the child uses abstractbase, "child.h": #ifndef child #define child class child : public abstractbase { public: ~child() override; } #endif the implementation in "child.cpp": #include "child.h" child::~child() obviously there far more functions, in essence that's how real class's destructors look. after scouring web ways of using abst...

app store - Upload IPA to iTunes Connect from a different Mac -

i confirm understanding , check whether can done or not. have imac , macbook development. have created ipa app store need upload itunes. now question have generated ipa imac contains profiles , certificates. can upload ipa macbook using application loader 3.0, macbook not contain of profiles , certificates. from understanding should doable ipa contains required, still wants confirm other developers in community. this can done , application loader has no dependency on certificates , profiles. need login using proper credential , select proper ipa required uploaded.

regex - Notepad++: Reducing multiple line breaks to single -

Image
my text document has multiple line breaks @ random places. want use notepad++ reduce multiple line breaks single line break. how can accomplish that? i on lines of using \n in extended find/replace mode can't quite it. you can use regular expression s&r: (?:\r\n){2,} or \r{2,} in find what field and \r\n in replace with field. may adjust replacement pattern per needs.

shell - Daemonizing an executable in ansible -

i trying create task in ansible executes shell command run executable in daemon mode using &. following -name: start daemon shell: myexeprogram arg1 arg2 & what seeing if keep & task returns , process not started . if remove & ansible task waits quite time without returning. appreciate suggestion on proper way start program in daemon mode through ansible. pls note dont want run service adhoc background process based on conditions. running program '&' not make program daemon, runs in background. make "true daemon" program should steps described here . if program written in c, can call daemon() function, you. can start program without '&' @ end , running daemon. the other option call program using daemon , should job well. - name: start daemon shell: daemon -- myexeprogram arg1 arg2

python - Why use re.match(), when re.search() can do the same thing? -

from documentation, it's clear that: match() -> apply pattern match @ beginning of string search() -> search through string , return first match and search '^' , without re.m flag work same match . then why python have match() ? isn't redundant? there performance benefits keeping match() in python? "why" questions hard answer. matter of fact, define function re.match() this: def match(pattern, string, flags): return re.search(r"\a(?:" + pattern + ")", string, flags) (because \a matches @ start of string, regardless of re.m flag status´). so re.match useful shortcut not strictly necessary. it's confusing java programmers have pattern.matches() anchors search start and end of string (which more common use case anchoring start). it's different match , search methods of regex objects , though, eric has pointed out.