Posts

oop - Models getting out of hand -

we use laravel in our company , follow 2 simple conventions: controllers should thin. models represents database entities (user, roles, cars) now we're facing dilemma: have screen complicated data graphs represented require long , heavy logic produce. should put of logic? controllers should thin - not in controllers. models represent data entities, can't model since screen displays data of other models don't have actual table/database entity. services doesn't sound normal place. i wondering how did approach similar situations i put logic service. in service can run other services (in case logic in other service or if service complicated) , use repositories (or models in case don't use repositories). of course there no point put big code or logic controllers because run services return desired output.

c# - if statement whit DataBinder.Eval -

the code : <asp:repeater id="repeater2" runat="server"> <headertemplate> <table cellspacing="0" cellpadding="0" border="0" width="100%"> </headertemplate> <itemtemplate> <tr> <td colspan="3" style="height: 1px; width: 100%; " align="center"> <div style="height: 1px; width: 90%; background-color: #cccccc;"></div> </td> </tr> <% if (databinder.eval(container.dataitem, "productid").tostring() == "32668" || databinder.eval(container.dataitem, "productid").tostring() == "33829" || databinder.eval(container.dataitem, "productid").tostring() == "33831") { %> <tr> <td style="height: 132px; width: 25%; padding-left:20px;"><a href='product_detail_<%# databinder.eval(contain...

c++11 - Convert chrono duration to time_point -

how can convert chrono duration time_point, later clock's epoch given duration? tried find epoch time in chrono clock without success. from synopsis in 20.12.6 [time.point]: template <class clock, class duration = typename clock::duration> class time_point { public: constexpr explicit time_point(const duration& d); // same time_point() + d this can used (for example) like: using namespace std::chrono; system_clock::time_point tp{30min}; // needs c++14 literal though system_clock::time_point not specified in standard, in practice creates time_point referring 1970-01-01 00:30:00 utc.

c++ - Qt QAudioInput how to send a fixed number of samples -

i'm tryng send audio stream qt application other device udp protocol. problem target device wants fixed number of samples(in case 320) every packet receives. think must use setbuffersize function of qaudioinput object use catch sound, documentation odd , poor whole qaudioinput object. how can control number of samples send? thank you. this how send stream: qaudioformat format; format.setsamplerate(48000); format.setchannelcount(1); format.setsamplesize(16); format.setcodec("audio/pcm"); format.setbyteorder(qaudioformat::littleendian); format.setsampletype(qaudioformat::unsignedint); //if format isn't supported find nearest supported qaudiodeviceinfo info(qaudiodeviceinfo::defaultinputdevice()); if (!info.isformatsupported(format)) format = info.nearestformat(format); input = new qaudioinput(format); socket = new qudpsocket(); socket->connecttohost(ip, port); input->start(socket); this way qbytearray: qaudioformat format; format.setsamplerate(...

python - Pivot each group in Pandas -

using pandas i've invoked groupby on dataframe , obtained following: >>>grouped = df.groupby(['cid']) key, gr in grouped: print(key) print(gr) out: cid price 121 12 121 10 121 9 i want have each group pivoted like: cid price1 price2 price3 121 12 10 9 what correct way pandas? assuming have frame looking like >>> df = pd.dataframe({"cid": np.arange(64)//8, "price": np.arange(64)}) >>> df.head() cid price 0 0 0 1 0 1 2 0 2 3 0 3 4 0 4 then think can want combining groupby , pivot : df = pd.dataframe({"cid": np.arange(64)//8, "price": np.arange(64)}) df["num"] = df.groupby("cid")["price"].cumcount() + 1 pivoted = df.pivot(index="cid", columns="num", values="price") pivoted.columns = "price" + pivoted.columns.astype(str) piv...

python - Reset Tkinter Widget to its default value -

in need make generic function on event return focused-out widget default value. there way accomplish this? example: entry1 = tkinter.entry() entry1.grid(..) entry1.insert(0,"hello") entry1.bind("<focusin>", entryfocusedin) entry1.bind("<focusout>", entryfocusedout) entry2 = tkinter.entry() entry2.grid(..) entry2.insert(0,"again") entry2.bind("<focusin>", entryfocusedin) entry2.bind("<focusout>", entryfocusedout) def entryfocusedin(params): params.widget.delete(0, tkinter.end) def entryfocusedout(params): # return widget default value # in case of entry1 "hello" # , in case of entry2 "again" you subclass entry widget add attribute store default value, , reference attribute in event handler. however, there's nothing stopping adding own attribute each entry widget directly, e.g. entry1.default_value = 'hello' , entry1.default_valu...

maven - no main manifest attribute, in jar -

i trying run jar created maven shade plugin. configuring main class following way: <project> ... <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>2.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.manifestresourcetransformer"> <manifestentries> <main-class>org.comany.mainclass</main-class> <build-number>123</build-number> </manifestentries> </transformer> </transformers> </configuration> </ex...