Posts

Showing posts from July, 2012

c# - What is the correct way to store and then display DateTimes in .Net? -

i think may have been living in cave time complexities of datetime has sunk in today. i've read few articles recommend storing datetime utc in database , display them local time in view. however, hit articles said not simple , need consider "instants" , converting user inputted datetime utc hard due timezone id or using touniversaltime() not safe or let javascript post utc datetime , use js display local times if have razor view datetime model property? relying on tolocaltime() cannot considered safe apparently. i've heard of noda time jon skeet i'm hoping solves although know has commented not perfect. so in hell people using simple web applications in .net ? is there correct example provide or link posts , renders value timezone sympathetic? it appears ignorance bliss. update: example, user has datetimepicker jquery , select datetime of event. users of application global if choose 10am eastern time should appear in view 6pm uk u

php - how to align text in textarea in html -

i have textarea , writing php code prefill textarea upon refresh. "prefill" part working fine. my problem when start type in textarea , text not left aligned. starting @ random point in textarea box. want left aligned normal text box. here code: <textarea rows = 10 cols = 95 name = answer5> <?php echo stripslashes(htmlentities($_post['answer5'])); ?> </textarea> try 2 things: put on 1 line trim echoed value so this <textarea rows = 10 cols = 95 name = answer5><?php echo trim(stripslashes(htmlentities($_post['answer5']))); ?></textarea> this because textarea has special rules defy (as call it) normal markup rules. never understood it. data inside textarea used is, including leading , multiple spaces, etc. html comments inside textareas outputted.

ruby - Link_to and Ajax request Rails -

hopefully can explain people can understand trying achieve. have multiple posts being created , shown @ url public view /tynewyddnews as opposed standard /posts/:id which available admin user the page split 2, latest post on taking of page , historical posts listed down left hand side of page, each rendered different through scope scope scope :tynewydd_posts, :include => :department, :conditions => {"departments.name" => "ty newydd"}, :order => "posts.published_on desc" latest post @tynewyddpostlatest = post.tynewydd_posts.first historical posts tynewyddpost = post.tynewydd_posts.reverse tynewyddpost.pop @tynewyddpost = tynewyddpost in view render each so left hand side <% @tynewyddpost.reverse.each |t| %> <%= link_to t.title, t %> main <%= @tynewyddpostlatest.title %> what achieve when clicking link post on left hand side render in place of main post in center via ajax. have come far work

can't populate the array with mongoose in node.js -

this schema on course var courseschema = mongoose.schema({ students:[{ type: objectid, ref: 'user' }] }); var coursemodel = mongoose.model('course',courseschema); var userschema = mongoose.schema({ name:string}) var usermodel = mongoose.model('user',userschema); in mongodb, have created existing courses , users, , when user want participate course, user reference added students array in course model. here how try add user reference students function joincourse(cid,uid,callback){ var options = { new: false }; var uid = mongoose.types.objectid(uid); coursemodel.findoneandupdate({'_id':cid},{'$addtoset':{'students':uid}},options,function(err,ref){ if(err) { console.log('update joincourse'.red,err); callback(err, null); }else{ console.log('update joincourse '.green+ref); callback(null,ref); } }) } w

c++ - 'Button_Click' : is not a member of 'ButtonTest::MainPage' -

i'm new c++ , windows store programming, , i'm stuck defining click handlers on buttons. i'm referring these instructions: add button control parent container. to assign name button, set x:name attribute string value. refer control in code, must have name. otherwise, name not required. to assign label button, set content property string value. to perform action when user clicks button, add handler click event. in click event handler, add code perform action. <button x:name="button1" content="button" click="button_click" /> void mainpage::button_click(object^ sender, routedeventargs^ e) { // add code perform action here. } i've added <button x:name="button1" content="button" click="button_click" /> inside grid block in mainpage.xaml . i've added void mainpage::button_click(object^ sender, routedeventargs^ e) {...} in mainpa

php - Cannot use invoke magic method within another object -

i have experienced think it's bug, i'm not sure. come here ask people know more me, is php bug? @ following lines: <h1>tests</h1> <?php class foo { public function __invoke() { return 'called correctly'; } } class boo { public function __construct() { $this->foo = new foo(); } } $foo = new foo(); echo $foo(); echo "<br><br><hr><br><br>"; $boo = new boo(); echo $boo->foo(); according the specification , since the __invoke() method called when script tries call object function , should obtain this: called correctly called correctly but last echo not executed. instead, this: php fatal error: call undefined method boo::foo() in [...]/index.php on line 26 is bug or expected behaviour? if it's bug, how submit highly appreciated. edit based on jon answer show further ugly behaviour class doo { public function __construct()

javascript - JQuery events cause page reload. How to fix? -

i'm observing behavior onclick events cause page reload. $('#target').click(function(){ $('#target').hide(); }) so object shown, hides on click, page reloads , object shown again. i'm working on website setup before me, i'm not entirely aware of parts. idea might cause behavior , how fix it? add a return false; as last statement link not called, function (onclick) executed.

javascript - A potentially dangerous Request.Form value was detected from the client tbpassword="9<Grfs-&3E" -

this question has answer here: a potentially dangerous request.form value detected client 36 answers net, getting error saying "a potentially dangerous request.form value detected client" when entering password special characters "<" , ">" in it, found solutions on online saying add validrequest="false" , requestvalidationmode="2.0" did add both statements in web.config file , on top of page web config looks this <system.web> <authorization> <allow roles="target.drp.admins, target.drp.business_admins, target.drp.device_mngrs, target.drp.users, target.drp.manufacturers"/> <deny users="?"/> </authorization> <httpruntime requestvalidationmode="2.0"/> <compilation debug="true"/> <pa

exc bad access - glGenBuffers and many OpenGL function EXC_BAD_ACCESS in Macbook Air -

i have weird problem lot of opengl functions failed exc_bad_access in macbook air. simple function glgenbuffers or glgetstring(gl_vendor) result. run in xcode. , segmentation fault: 11 if run in terminal. a example code failed: #include<glut/glut.h> #include<opengl/gl.h> #include<opengl/glu.h> #include<opengl/glext.h> int main(){ unsigned int test[3]; glgenbuffers(3, test); return 0; } i not sure whether problem system or not. using 2012 version of macbook air osx 10.8.2 . where's opengl context creation code? need valid, active opengl context can access opengl @ all. including glext.h declare glgenbuffers function pointer must initialized through extension loading mechanism. without initializing pointer right opengl function, dereferencing (= calling it) cause segfault. in macos x don't need glext.h because opengl functions supported available version of macos x present in os x framework. using extension mechanism

java - Netbeans/JavaFX Application Subclass Missing -

Image
when create new javafx application in netbeans 7.3 (and choose "create application class") no such class created. not package -- empty default package. i assume create manually extending 'application' class maybe behaviour symptomatic of setup anomaly. any idea why happens? btw, had same issue netbeans 7.1. cheers! i cannot replicate issue. this works me. in netbeans 7.3: create new javafx project: file | new project | javafx | javafx application (click next ) enter project name, example testproject (click `finish): the screen has checked checkbox create application class . default application class name testproject.testproject can edit default application class name change , package located in if like. a skeleton application class created: the testproject class extends application , resides in testproject package. to create more applications in same project: right click on project, choose: new | other | javafx | javafx

graphing columns from a CSV that includes null values- python -

i relatively new python , running lot of issues. trying create graph using 2 columns csv file contains many null values. there way convert null value 0 or delete row contains null values in columns? your question asked underspecified, think if pick concrete example, should able figure out how adapt actual use case. so, let's values either string representation of float, or empty string representing null: a,b 1.0,2.0 2.0, ,3.0 4.0,5.0 and let's you're reading using csv.reader , , you're explicitly handling rows 1 one do_stuff_with function: with open('foo.csv') f: next(reader) # skip header row in csv.reader(f): a, b = map(float, row) do_stuff_with(a, b) now, if want treat null values 0.0, need replace float function returns float(x) non-empty x , , 0.0 empty x : def nullable_float(x): return float(x) if x else 0.0 open('foo.csv') f: next(reader) # skip header row in csv.reader(f):

visual studio 2010 - c++ Calling class method inside same method -

i´m writing clslog class: // main dll file. #include "stdafx.h" #include <time.h> #include <fstream> #include <iostream> #include <string> #include "clslog.h" std::string m_strcurloguser; int m_icurlogaction; int m_icurloglevel; std::ofstream m_ocurlogfile; // // loginit // initilize log parameters of system. // filename file name system log messages (log.txt default if no names given). // databasename , tablename specifies database , table name used log. default "log_database" , "log_table" // done. // action shall or options. att: if option giver (ex: database) , invalid name given, error occur. // // default log level 0 (0). every log level upper logged. change level must done // using setloglevel method. // // return = 0: success // 1: failure // int loginit (std::string filename, // initialize log file/connection. std::string databasenam

mysql - How to insert or update based on some condition? -

can please me this! have 2 tables: 1.existing pricing table custom date-dependent pricing windows: id | prod id | start | stop | price -----+---------+------------+------------+----------- 1 | 65210 | 2012-01-01 | 2013-01-01 | 5.00 2 | 54841 | 2012-02-05 | 2013-03-01 | 15.00 3 | 51518 | 2012-01-01 | 2013-01-01 | 5.00 4 | 8402 | 2012-01-01 | 2017-01-01 | 5.00 5 | 1520 | 2012-01-01 | 2050-01-01 | 12.00 6 | 959 | 2013-10-01 | 2018-01-01 | 5.00 2."new" pricing data table (used update table above each unique prod id ): prod id | start | stop | price -------+------------+------------+----------- 65210 | 2013-01-01 | 2025-01-01 | 5.00 54841 | 2013-02-05 | 2017-03-01 | 15.00 959 | 2013-01-01 | 2017-01-01 | 5.00 what's best way update stop date in table 1 stop date in table 2 assuming it's still "in window"? if existing stop

debugging - Android Device, Internal Disk Space runs out real quick -

i'm having problem 1 of applications i'm developing. so far, i'm using usb debugging mode install/update app in android device, that's huawei mediapad 7 lite (android ics 4.0.3). the app using (according internal storage in applications menu) 4.91 mb. we've been testing it, , disk space being consumed 1gb per week ratio... waaaay space. i've checked application , couldn't find @ first sight memory leak. i've searched lot, , in few places, i've seen turning usb debugging off helps. my question is... can caused logging or other functionality don't know of in "usb debugging mode", or coding problem on side? thanks lot the problem comes os itself. android has option log gps information, apparently, enabled on devices. the solution disable gps log, device needs rooted , need edit file located in /system/etc/gps/glconfig.xml find block <hal acportname="/dev/ttys3" ibaudrate="115200" cl

javascript - unable to assign QQuickText to QString -

i trying dynamically create objects in qml-javascript.the function creates object is: function createspriteobjects(xpos,ypos,cnt,imgsrc,jsonobject) { var title; title = jsonobject.matches[cnt].recipename; var component = qt.createcomponent("flickitem.qml"); component.createobject(wall.contentitem, {"color":"white", "x":xpos,"y":ypos,"src":imgsrc,"opacity":1,"title":title}); } the recieving file(flickitem.qml) has property string title later assigned text field of text item: import qtquick 2.0 rectangle { id: name opacity: 0 property string title: "" width:100 height:100 color:"white" property string src: "" image { id:recipeimages source: src width:240 height:160 } text { id: title anchors.bottom: recipeimages.bottom anchors.horizontalcenter: recipeimages.horizontalcenter anchors.bottommargin: 5 color: "white"

javascript - setting canvas height increments height -

so i've got complex html5 app draws on canvas , i've made html page 3 column, 3 row layout canvas in center, filling majority of space. problem is, when resize canvas(no matter how) increments height of canvas. so resize window(width, height, or both) canvas element gets increasingly taller. i've checked , html height attribute showing increment. i've narrowed down 1 line, if line commented out, stops. context.canvas.height = $("#canvas").innerheight(); it thought right side of equation problem. i've tried several variations (each referencing elements height) , none have worked. other fun facts: this line called when window resized this problem happens when reference canvas or 1 of parents elements' height on left it absolutely line, doesn't happen when comment out line. i run similar line, replacing 'height' 'width' , problem doesn't happen on axis all want update canvas size when resize window. seems sho

javascript - AngularJS bind specific data to template -

i'm making switch knockout angular. main problem i'm having right in transferring original templates angular recognise. specifically, here's bit of code i'm having trouble transferring: <!-- ko template: { name: 'squaretempl', data: squares[5] } --><!-- /ko --> in knockout, attach squares[5] squaretempl, when template gets rendered, using members within squares[5](or whatever data gets attached). i need repeat process squares[0]~squares[11]. can't use ng-repeat though since won't iterating through them in numerical order. ideally, nice if along lines of <td class="square" id="five" ng-include src="'squaretempl.html'" ng-data="squares[5]"> any ideas? here's jsfiddle i've written outline failed attempt i've tried using ng-model. http://jsfiddle.net/fzz3w/9/ two things: first, can make ng-data available implementing yourapp.directive("ngdata&quo

php - Adding anchor tags to first record for each group -

i'm trying setup twitter bootstrap nav-list (similar use on own site: http://twitter.github.io/bootstrap/getting-started.html ). my page grabs "table" , groups results "col_a". want able add anchor link first record returned each group. $query = "select * table group col_a, col_b"; $result = $mysqli->query($query); while ($row = $result->fetch_array()) { <tr class="<?php echo $tr_owned_class ?>"> <td><?php echo $row['col_a'] ?></td> ... this returns (grp_x returned col_a): row 1: grp_1, data, data... row 2: grp_1, data, data... row 3: grp_1, data, data... row 4: grp_2, data, data... row 5: grp_2, data, data... row 6: grp_3, data, data... so, in example, i'd want anchor tag on rows 1, 4, , 6. i store group variable first time it's encountered - this: $last_group = ''; while ($row = $result->fetch_array()) { $group = $row['col_a

Sass and Compass weird css errors after install -

i installed compass , can't compile css properly. have no idea what's causing it. thou stackoverflow asking me write more. installed scout. created simple css , html file. tried compile css file. got error. could not find answer on google. my css: body { background: black; } output: /* syntax error: invalid css after "black": expected expression (e.g. 1px, bold), ";" on line 2 of c:/users/andrej/documents/my dropbox/web projects/first website/sass/main.sass 1: c:/users/andrej/documents/my dropbox/web projects/first website/sass/main.sass backtrace: c:/users/andrej/documents/my dropbox/web projects/first website/sass/main.sass:2 d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/scss/parser.rb:1129:in `expected' d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/script/lexer.rb:199:in `expected!' d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/s

.net - Is it possible to have one endpoint in an NServiceBus SOA use a different serializer from the rest? -

somewhat related to: is possible nservicebus endpoint handle , publish using different serializers? we have wide deployment of nservicebus in our infrastructure , configured using xmlserializer . however, one-off situation has come in xmlserializer not going meet our requirements, i'm considering jsonserializer or binaryserializer . changing every single endpoint in entire infrastructure use different serializer highly disruptive , time-wasting in terms of deployments, i'm having trouble figuring out how introduce 1 new endpoint uses different serializer... or rather, it's easy configure endpoint itself use alternate serializer, i'm not sure how can other endpoint talk it . am stuck 1 serializer type used throughout entire architecture if i'm using nservicebus 3.x? seem remember reading once, think on nservicebus message boards, serialization defined @ endpoint level, there weren't many details given , person wrote answer may have been overlooking o

Editing an XML document in C# -

i'm new c#. attempting edit spreadsheetxml 2003 document adding bunch of nodes different worksheets in it. here example of structure: <workbook> <worksheet ss:name="contact"> <table> <column /> <row /> </table> </worksheet> <worksheet ss:name="facility"> <table> <column /> <row /> </table> </worksheet> </workbook> what need load xml , insert new nodes @ places. i'm pretty sure know how create new xelement nodes under need (there's plenty of tutorials online that). i'm having trouble finding how find node , add nodes under it. far i've got: xelement xmldoc = xelement.load(environment.getfolderpath(environment.specialfolder.applicationdata) + "\\autodesk\\revit\\addins\\2013\\cobiev2.4template.xml"); so, how find "facility" worksheet , add new row under table node in it? need able in such way @ end of routine c

ios - Cannot flip layer again,CALayer,CATransform3DRotate. -

what trying do : click botton vertical flip. click botton again, layer wil flip , on... codes following : @interface viewcontroller (){ calayer *plane; } @end @implementation viewcontroller -(void)viewdidload { [super viewdidload]; [self addalayer]; } - (void)addalayer{ plane = [calayer layer]; plane.backgroundcolor = [[uicolor orangecolor] cgcolor]; //[plane insertsublayer:normalbackground atindex:0]; plane.opacity = 1; plane.frame = cgrectmake(0, 0, 300, 100); plane.position = cgpointmake(250, 150); plane.anchorpoint = cgpointmake(0.5, 0.5); plane.bordercolor = [uicolor whitecolor].cgcolor; plane.borderwidth = 3; plane.cornerradius = 10; [self.view.layer addsublayer:plane]; } - (ibaction)click:(id)sender { bool isclick

How to Save Date in Yii with Oracle -

how 1 save date in yii oracle? $trx->date_trx=date('y-m-d'); cdbcommand failed execute sql statement: sqlstate[hy000]: general error: 1861 ocistmtexecute: ora-01861: literal not match format string (ext\pdo_oci\oci_statement.c:148). sql statement executed was: insert "trx" ("idmember", "date_trx") values (:yp0, :yp1) returning "id" :return_id i guess you're supplying character literal date, in format such 'yyyy-mm-dd'. if should explicitly convert date part of insert statement ... insert "trx" ("idmember", "date_trx") values (:yp0, to_date(:yp1,'yyyy-mm-dd')) returning "id" :return_id

asp.net mvc 4 - MVC4 Web-API - Route mapping help required -

i have controller named products , have 3 actions in it product : takes int returns model(class) object category : takes string returns array of model(class) object all : no parameters return array of model(class) object what trying following mapping product -> api / products / product / 1 category -> api / product / category / sauces all -> api / product / all as names of action support url structure trying general route is config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{action}/{id}", defaults: new { id = routeparameter.optional } ); all else working getting following error when use http://localhost:2271/api/products/category/2 url <error> <message> no http resource found matches request uri 'http://localhost:2271/api/products/category/2'. </message> <messagedetail> no action found on controller 'products' matches request. </messagedetail>

C# to ASP.NET MVC FileStream Crossover -

this question has answer here: why can't use system.io.file methods in mvc controller? 1 answer i have written code in c# , printed results terminal confirm working. in process of transferring of code on mvc 4 controller , have been able successively merge of having issues 1 part. i wish read database file (database.dat) , later on wish write same file. in controller have: using (filestream stream = file.openread("database.dat")) database = (list)formatter.deserialize(stream); and using (stream stream = file.open("database.dat", filemode.create)) formatter.serialize(stream, database); in both cases 'file' in file.openread , file.open underlined , receive error: 'system.web.mvc.controller.file(byte[], string)' 'method', not valid in given context ..."

php - onChange event on two web pages -

i hava 2 web pages. 1 main.php , other combo.php. combo.php contains dropdown list , have included page in main.php. what want when select option in dropdown, there should alert box indicating selected item. main.php <html> <body> <form> //some elements <?php include 'combo.php';?> </form> </body> </html> combo.php <html> <body> <form> //some elements <select name="combo"> <option value="1">america</option> <option value="2">england</option> <option value="3">india</option> <option value="4">japan</option> </select> //some elements </form> </body> </html> i can't changes combo.php. onchange event , script should in main.php. have no idea how this, , don't no whether possible.

c# - Uniquely identifying a pendrive -

i working on usb devices , can identify usb device. have theoretical question.is shows usb device portable cd drive or flash drives? nt check possibilities due lack of these hardwares :). there method identify if flash drive or usb device. please don't beat have tried. googled regarding same because of least experience couldn't find any. thanks please use class usbserialnumber usbserialnumber usb = new usbserialnumber(); string serial = usb.getserialnumberfromdriveletter("f:\"); messagebox.show(serial); each pendrive has serial number unique. you can use class purpose. download following link: http://www.cfdan.com/posts/retrieving_non-volatile_usb_serial_number_using_c_sharp.cfm

convert netbeans php project to war file to deploy in remote web server -

i have been searching build , clean convert netbeans php project war file,after searches found java project.so have tried configure path var/www ,but shows invalid path,can 1 me how can convert netbeans project war file.i test project on system how can access netbeans project in computer test functionalities,i stuck help thank you i recommend used wamp server. follow steps below. cut php project netbeans projects , paste on c:\wamp\www. it assumed you've ran wamp server. go netbeans, open php project in c:\wamp\www directory. right-click php project>properties>run configuration. have match port number of php project web server(wamp server). see httpd.conf if want change port. default, listens port 80. single-click php project , hit f6. voila! :d this way run php project on netbeans. web servers netbeans designed java apps only. web server wamp designed php. hope helps -_-

PostgreSQL locking mode -

from doc http://www.postgresql.org/docs/current/static/explicit-locking.html i knew postgresql provides various lock modes control concurrent access data in tables. my problem have many sessions accessing db , i'm confuse should made 1 big table 40 column or many tables fewer column (one 1 relationship). because when select data select of ---> takes more time when select many tables using inner join, takes less time select 1 big table. php respond slower if i'm using many tables. but when use 1 table meanwhile many session update data in table, i'm afraid of deadlocks or delay because commands update, delete, , insert acquire row exclusive lock mode on target table. in general, lock mode acquired command modifies data in table. could suggested best approach should made? 1 big table or many tables? it true insert , update or delete must acquire row exclusive lock on table updated. however, lock not prevent select working normally. select req

java - GWT: SelectionChangeEvent.Handler does not detect deselect of row on CellTable -

so have piece of code same on gwt showcase selectionmodel = new singleselectionmodel<t>(keyprovider); celltable.setselectionmodel(selectionmodel); selectionmodel.addselectionchangehandler(new selectionchangeevent.handler() { public void onselectionchange(selectionchangeevent event) { selectedrow = ((singleselectionmodel<t>).selectionmodel) .getselectedobject(); }); column<t, boolean> checkcolumn = new column<t, boolean>(new checkboxcell(true, false)) { @override public boolean getvalue(t object) { return celltable.getselectionmodel().isselected(object); } }; celltable.addcolumn(checkcolumn, safehtmlutils.fromsafeconstant("<br/>")); the problem is, when uncheck checkbox selectionchangeevent doesn't handle it. instance onselectionchange being called, when select record, deselecting record doesn't invoke method. any help?

How to add android phone contact to groups according to group_id -

i working on contact list project , far can want add contacts in phone group according group id. have find group id following code. final string[] group_projection = new string[] {contactscontract.groups._id, contactscontract.groups.title }; cursor cursor = managedquery(contactscontract.groups.content_uri,group_projection, null, null, contactscontract.groups.title+ " asc"); now want pick contact phone , insert these contact specific group according these group ids. thank in advance

ios - Programmatically get WiFi Gateway, DNS info -

i able wifi ip address information code found online: is possible identify dns & gateway information well? code it? thanks, this done using code #include <resolv.h> #include <dns.h> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<sys/socket.h> #include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc #include<netinet/in.h> #include<unistd.h> -(void) get_dns_servers { res_state res = malloc(sizeof(struct __res_state)); int result = res_ninit(res); if(result==0) { nslog(@"no of dns ip : %d",res->nscount); ( int i= 0; < res->nscount; i++) { nsstring *s = [nsstring stringwithutf8string : inet_ntoa(res->nsaddr_list[i].sin_addr)]; nslog(@"dns ip : %@",s); [server_dns addobject:s]; } } }

php - Codeigniter Value Not Setting -

i having issue code , on submit selected value user_support_documentaries not being submitted array i can view html source before page submit , shows value tag populated - cannot why selected item not being put array. html: <label> <input type="radio" id="user_dafapp_1" name="user_dafapp" value="1" class="checkbox" <?php echo selected_checkbox(set_value('user_dafapp',$grant['user_dafapp']) == 1) ?> /> <br /> </label> <div id="user_support_documentaries_container" style="display: none;"> <?php echo form_dropdown('user_support_documentaries', $film_list, set_value('user_support_documentaries',$grant['user_support_documentaries']), 'id="user_support_documentaries"'); ?> </div> js: // checkout form enhancement if ($("#user_dafapp_1").is(":checked")) // if checked

php - What is the best way to select the first two records of each group by a "SELECT" command? -

for instance have following table: id group data 1 1 aaa 2 1 aaa 3 2 aaa 4 2 aaa 5 2 aaa 6 3 aaa 7 3 aaa 8 3 aaa what best way select first 2 records of each group "select" command? if there no way so, routine suggest?(in php) (model outcome) 1 1 aaa 2 1 aaa 3 2 aaa 4 2 aaa 6 3 aaa 7 3 aaa i knew cross-joining a.id >= b.id in sub-query can working looking more scalable solution can applied on table millions of records. thanks select a.* tablename ( select count(*) tablename b a.group = b.group , a.id >= b.id ) <= 2 sqlfiddle demo

php - How should I link these models to query multi tables via CakePHP associations? -

i using cakephp 2.3.2 , need query on multi tables. i have database: -------------------------------------------------------------- | users | agents | companies | ads | -------------------------------------------------------------- | id | id | id | id | | username | name | company | title | | password | lastname | sector | message | | | user_id | user_id | user_id | -------------------------------------------------------------- these associations (models): user hasone agent hasone company hasmany ads agent belongsto user company belongsto user ad belongsto user ( note: please, keep in mind when add new user user agent or company .) question: in adscontroller have action named view , there read 2 params receve route: $this->params['id'] $this->params['sector'] i need query check

html - jQuery hide() doesn't work well -

dear all, i've faced following problem while. please me out! here's code: html <html> <head> <meta charset="utf-8" /> <!--css stylesheet--> <link href="style.css" rel="stylesheet" /> <!--jquery external javascript - cdn--> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> <link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="stylesheet" /> </head> <body> <div class="header"></div> <div class="content"><input type="button" id="senddata" value="send data" align="center"></div> <div class="barchart"><input type="button" id="reenterbutton"

c# - #if DEBUG doesn't seem to work in my VS 2010 -

i've been doing following in c# code: #if debug //debugger code #endif but reason when same in c# console application (that built windows service in vs 2010) doesn't seem work , both release , debug configurations looks debug not defined. do need set preprocessor constant work? when using 'debug' configuration, have go project's properties -> build , tick 'define debug constant' box. either that, or define conditional compilation symbol: debug. can other custom compilation symbol :)

How to handle escape character (`) in string under PowerShell -

i using powershell read string , xml file cdata sectiona , contains powershell esacpe character (`) part of string content. when powershell reading , writing content, removing escape character , causing problems in usage of same content. i not able add double escape sequence `` in input since provided user , cannot restrict user same. how processed correctly powershell? i can't reproduce problem. need more information. test.xml <?xml version="1.0" encoding="iso-8859-1"?> <exampleofacdata> <![cdata[ graimer`s [cdata[]] test. notice used backtick in text, powershell's escape character. i'm gonna store in `$s` in ps. ]]> </exampleofacdata> powershell ps > $xml = [xml](get-content .\desktop\test.xml) $s = $xml.exampleofacdata."#cdata-section" $s graimer`s [cdata[]] test. notice used backtick in text, powershell's escape character. i'm gonna store in `$s` in

c# - Using same entity in two models -

i making library used talk database using entity framework. different workflows need different tables database. decided have separate models separate workflows. workflows 1 entity used in multiple models. 1 model have modified entity class (changed getters/setters , added custom functions). when create new model different workflow model generate entity default names. have edit again , code duplicated. both in different namespaces (one model1namespace, second model2namespace). so need if entity used in different classes single code used (no duplicate code). best practices? ef provide or need implement ourself? example: database tables: tablea, tableb, tablec, tabled models: model1 -> tablea, tableb model2 -> tablea, tablec, model3 -> tablec, tabled edit: have database containing 4 tables (tablea, tableb, tablec, tabled). create entity data model of database contains tablea , tableb. in entity designer view modified names of properties of tablea enti

Fail to install 'PAR::Packer' Perl module on Windows 7 - 64 bit - using DWIM Perl -

i working on ms-windows 7 pc - 64 bit. using "dwim perl windows" ( http://dwimperl.com/windows.html ) - strawberry perl derivative. i trying run 'install par::packer' cpan - , fails. see below full text. i did see suggestions here run 'look par::packer' cpan "command line". - fails too, following error message: c:\dwimperl\perl\bin\perl.exe encode_append.pl dynamic.in par.exe dynamic.pm c:\dwimperl\perl\bin\perl.exe file2c.pl -c 30000 par.exe c:\dwimperl\perl\bin\pe rl514.dll c:\dwimperl\perl\bin\libgcc_s_sjlj-1.dll c:./program > boot_embedded_files.c open input file 'c:./program': no such file or directory @ file2c.pl line 43. dmake: error code 130, while making 'boot_embedded_files.c' dmake: 'boot_embedded_files.c' removed. dmake: error code 255, while making 'subdirs' here fail of 'install par::packer': cpan> install par::packer running install module 'par::packer' runnin