Posts

Showing posts from January, 2015

php - Experiencing issue setting up incoming mail in vtiger -

when try setup incoming mail in mail manager in vtiger 5.4.0 receiving following error: deprecated: assigning return value of new reference deprecated in /home/gvs4us/public_html/ljvt/modules/mailmanager/third-party/xml/htmlsax3.php on line 161 has else experienced , have solution? thanks! this library old one. can hide deprecated errors in vtiger config file or hide them: ini_set('display_errors', 'off');

How to solve NameError while importing csv in rails -

i having problem in importing csv files.i got error "nameerror in employee_attendances#index". model class employeeattendance < activerecord::base attr_accessible :date, :emp_id, :in_time, :out_time, :status def self.import(file) csv.foreach(file.path, headers: true) |row| @employee_attendance = employeeattendance.find_by_emp_id_and_date(row['employee_id'],row['date'].to_date.strftime("%y-%m-%d")) || employeeattendance.new @employee_attendance.emp_id = row['emp_id'] @employee_attendance.in_time = row['in_time'] @employee_attendance.out_time = row['out_time'] @employee_attendance.status = row['status'] @employee_attendance.date = row['date'] @employee_attendance.save! end end end in controller class employee...

c++ - How to implement Binary Indexed Tree? -

i have read binary indexed trees efficient. couldn't more that. if knows that, please share knowledge. this solution you. there direct algorithms available , explanation 1 see this how author of blog has described binary indexed tree we need sort of data structure make our algorithms faster. in article discuss binary indexed trees structure. according peter m. fenwick, structure first used data compression. used storing frequencies , manipulating cumulative frequency tables.

xsd - UML aggregation/association to XML Schema -

long story short: want genererate xsd uml need way represent uml aggregation/association in xsd. found mapping recommend (for aggregation/association) : "reference element idref attribute , referencing associated class , keyref type saftey (key/keyref reference)". dont know how because i'm new in xsd ( < 1 week). so thought should im not sure^^ has advices or can correct if code has errors? uml: http://i39.tinypic.com/15x8ufp.png <xsd:schema elementformdefault="qualified" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:ns="namespace" targetnamespace="namespaceuri"> <xsd:import namespace="namespace" /> <xsd:element name="root"> <xsd:complextype> <xsd:sequence> <xsd:element name="classa"> <xsd:complextype> <xsd:all> <xsd:element name="attributeelement" /> ...

Unity: Keep desktop file information for detached process -

i have following desktop file [desktop entry] name=my game exec=/usr/games/mygame %u icon=mygame terminal=false type=application categories=game; comment=start game comment[de_de]=starte mein spiel and entry shown in ubuntu (13.04) unity dash . when mygame executed, spawns detached process again , unity launcher entry question mark , untitled window . is there way tell unity, (detached) process originated or desktop file assign process? try use absolute path icon file. might otherwise bug in bamf.

linux - Using grep to find function -

i need find usage of functions system("rm filename") & system("rm -r filename") . i tried grep -r --include=*.{cc,h} "system" . & grep -r --include=*.{cc,h} "rm" . giving many outcomes. how search instances of system("rm x") 'x' can anything. kind of new grep. try: grep -e "system\(\"rm [a-za-z0-9 ]*\"\)" file.txt regexp [a-za-z0-9 ] builds pattern grep needs find in x of system("rm x") . unfortunately, grep don't supports groups matching, need specify directly search.

How to use Ajax in Smarty? -

this ajax request <script type="text/javascript"> {literal} $(document).ready(function(){ $("#s1").change(function() { var idcat=this.value; alert(idcat); $.ajax({ type: "get", url: 'product_modify.php', data: {idcat:idcat}, success: function(data) { alert(data); alert("success"); } }); }); }); {/literal} </script> and php codes if(isset($_get['idcat'])){ $idc= $_get['idcat']; echo $idc; } there problem echo $idc; doesn't work ? problem ? var idcat=this.value; should be var idcat=$(this).val();

java - Generic Type From Enum & The Builder Pattern -

i'm trying create builder pattern uses generics provide type checking on of methods. have following working: parameterbuilder.start(string.class).setname("foo").setdefaultvalue("hello").build(); parameterbuilder.start(integer.class).setname(bar).setdefaultvalue(42).build(); parameterbuilder.start(boolean.class).setname(bar).setdefaultvalue(false).build(); using code: public class parameterbuilder<t> { private string name; private t defaultvalue; public static <t2> parameterbuilder<t2> start(class<t2> type) { return new parameterbuilder<t2>(); } // other methods excluded example } so type of input setdefaultvalue method defined what's passed start method, want. but want extend what's being passed start() contain little more information. want pass in "type" parameters creating. these parameters things "email", "url" etc. default value still of known type (string ...

oop - Creating object in PHP of predefined class type -

in program try explore oops concept in php, here things different java. in sample program have created abstract class bird, class parrot extends bird class , interface flyable. after included above class , interface in php file. let have @ code <?php include 'bird.php'; include 'parrot.php'; include 'flyable.php'; //creating object $bird1=new parrot(); echo $bird1->display(); echo("<br/>"); bird $bird2=new parrot(); //shows error ?> the thing want ask when try define type of object class bird $bird1= new parrot(); @ line error thing works in java. please let me know how can accomplish thing in php. you should show error, it's bound due fact you're using java style type hinting on line: bird $bird2=new parrot(); just remove initial bird , that's not valid syntax in php. the place type hints used in php in method parameters. see php docs more information.

mySQL count occurrences with JOIN -

i have tagging system events system create 'tag cloud'. i have events, can have multiple 'categories'. here's table structure: **event_categories** (stores tags / categories) | id | name | +-----------------+ + 1 | sport | + 2 | charity | + 3 | other_tag | **events_categories** (linking table) | event_id | event_category_id | +-------------------------------+ + 1 | 1 | + 2 | 2 | + 3 | 1 | + 3 | 2 | summary: event id 1 -> sport event id 2 -> charity event id 3 -> sport, charity i'd return following: | tag_name | occurrences | +-----------+-------------+ | sport | 2 | | society | 2 | other_tag - not returned, has 0 occurrences thanks! :) this work: select c.name tag_name, count(ec.event_id) occurrences event_categories c inner join events_categories ec on c.id = ec.e...

sql server 2005 - Replicate Excel's mode function using SQL? -

how can replicate excel's mode function using sql ? if run mode function on set of numbers in excel return 1 mode value if there multiple mode values. need sql work in same way. for series of numbers excel returns mode of 8. because 8 first modal number appear. 6 7 8 3 3 8 0 2 2 if there no mode example numbers unique should return na. this code have far. how can replicate excel's mode function using sql ? if run mode function on set of numbers in excel return 1 mode value if there multiple mode values. need sql work in same way. this have far. deleting rows occurences=1 deal series no mode. --i wanted use cte mode, won't work part of union query select ric,period,inputfile,occurrences,amount #mode1 (select aa.ric,aa.period,aa.inputfile,aa.amount,count(*) occurrences temppivottable aa --where aa.ric='ustrdap' , aa.period='2006' , aa.inputfile='c:\falconingest\input\us april 2006.xls' group aa.ric,aa.period,aa.inputfile,...

javascript - HTML not displaying correctly when inserted using jQuery.html() -

i have table carries out ajax actions, returns error if 1 encountered. i'm using js insert error (which string), because string has html tags in it, it's being appended @ end of js element wish inserted, opposed in middle. var debug_error = '<span class="debug-message hidden">'+table_obj.debug_string+'</span>', row = $(id+' .row-debug'); // id definded row.html(debug_error); for example, if debug_string <h3>error</h3><p>please define email address</p> , results - <span class="debug-message hidden"> </span> <h3>error</h3> <p>please define email address</p> yet if remove html tags, use errorplease define email address , works expected - <span class="debug-message hidden">errorplease define email address</span> does body know why happening? thanks. the problem because it's not valid put block level el...

groovy - How to send and receive domain objects with rabbitMQ plugin and grails -

i've went on excellent documentation rabbitmq plugin. however, still confused few things. scenario my application take file upload user, various things file , accordingly set properties on domain object. of work can labor intensive using queue. envision requests being queued , consumer picking requests queue , consuming them. questions i want store domain object in queue. by: rabbitsend 'myqueue', colorobj . colorobj is object of domain class color however, in colorservice handlemessage(...) when fetch item queue, item not of type color . please note on rabbitmq dashboard can see items being inserted in queue, queue initiation in config.groovy fine (i using amq.direct ) how can send , fetch domain object queue? from behavior i've seen far, handlemessage not need instantiated. if don't call colorservice still executes handlemessage itself. normal behavior? below code: controller color colorobj = colorservice.newrequest(params, request.ge...

io - python open() escape backslash -

i have path file containing $ signs, escaped \ open() can handle path. open turns \$ \\$ automatically. example: open("/home/test/\$somedir\$/file.txt", "r") result in error message ioerror: [errno 2] no such file or directory: '/home/test/\\$somedir\\$/file.txt' can supress this. why open() that? can't find in docu of open, describes this. open() doesn't that. it's python, escapes special characters when representing string: >>> path = '\$' >>> path '\\$' >>> print path \$ in regular python string literal, \ has special meaning, escaped when echoing value, can pasted right python script or interpreter session recreate same value. on linux or mac, not need escape $ value in filename; $ has no special meaning in regular python string, nor in linux or mac filenames: >>> os.listdir('/tmp/$somedir$') ['test'] >>> open('/tmp/$somedir...

css - How do I center an absolute-positioned image with percentage width? -

i have image following css: element.style { right: 50%; margin-right: -220px; top: 31%; width: 440px; position: absolute; } i need change width set in percent instead(35.4%). can still center , keep position absolute? of course, if want same way above use 35.4/2 = 17.7 margin ( demo ): element.style { right: 50%; margin-right: -17.7%; top: 31%; width: 35.4%; position: absolute; }

rest - Symfony2 form submit invalid boolean value -

i have strange problem symfony (v 2.3.2) form. it's simple form without relations. should noted form used in rest api only. so have published field (boolean). on entity it's set false default. on update, rest api client sends put request correct aka ...&[entity]published=0&... . value shown in symfony profiler in form parameters. however i've noticed actual value in database set true (or 1 it's tinyint). so, find out what's problem, added throw statement after $form->submit($request); throw new \exception(sprintf('request: %s, form: %s', $request->get('entity')['published'], $form->get('published')->getdata())); or throw new \exception(sprintf('request: %s, form: %s', $request->get('entity')['published'], $form->getdata()->getpublished())); the exception message says: request: 0, form: 1 . means somewhere in submit method string value '0' converted 1. t...

vb.net - Merging Documents with Open XML -

i looking mail merge alternatives in vb.net app. have used mail merge feature of word, , find quite buggy when dealing large volume of documents. looking @ alternate methods of generating merge, , have come across open xml. think answer looking for. have come understand merge entirely code-driven in vb.net. have started playing around following code: dim wordprocessingdocument wordprocessingdocument = wordprocessingdocument.open("c:\users\jasonb\documents\test.docx", true) 'for each simplefield (mergefield) each field in wordprocessingdocument.maindocumentpart.document.body.descendants(of simplefield)() 'get document instruction values dim instruction string() = field.instruction.value.split(splitchar, stringsplitoptions.removeemptyentries) 'if mergefield if instruction(0).tolower.equals("mergefield") dim fieldname string = instruction(1) each fieldtext in field.descendants(o...

php - json_decode returns NULL for a json data retrieved from an api -

i retreiving json data cloudmade api using php, , using json_decode parse it. returns null. ideas why happening helpful. code shown below: $url = 'http://routes.cloudmade.com/81aa79a9504e4430a8a32f491ef96f07/api/0.3/'.$curr_x.','.$curr_y.','.$dest_x.','.$dest_y.'/car.js'; $acontext = array( 'http' => array( 'proxy' => 'tcp://10.3.100.212:8080', 'request_fulluri' => true, 'header' => 'accept-charset: utf-8, *;q=0' ), ); $cxcontext = stream_context_create($acontext); $sfile = file_get_contents($url, false, $cxcontext); //echo $sfile; $obj = json_decode($sfile); print $obj; print $obj->{'total_time'}; below sample json data retrieving: {"version":0.3,"status":0,"route_summary":{"total_distance":280574,"total_time":11505,"start_poin...

powershell - Store new document to specific collection in RavenDB via REST -

i'm uploading documents ravendb powershell script. here is: $timestamp = (get-date).tobinary() $url = "http://127.0.0.1:8080/databases/diskstat/docs" $diskobject = new-object psobject @{ "@metadata" = new-object psobject @{ "raven-entity-name" = "entries" } timestamp = $timestamp computer = $comp disk = $disk.deviceid size = $disk.size free = $disk.freespace } [string]$diskjson = (convertto-json $diskobject) invoke-restmethod -uri $url -method put -body $diskjson | out-null the problem new documents not belong collection , @metadata ignored . documents looking in database: { "size": 52427931648, "timestamp": -8588258377456088029, "computer": "710h0001", "free": 27922563072, "disk": "c:", "@metadata": { "@id": "423b5bdf-fe59-4530-8047-bc48d98ee363", "last-modified": ...

jquery - Javascript function dosn't works when I work with templates -

i have html file in javascript code. <div id="star_rating"> <a id="one">&#9734;</a><a id="two">&#9734;</a><a id="three">&#9734;</a> </div> <script type="text/javascript"> $(document).on("ready", function() { $("#one").hover( function () { markhover("true", "false", "false", "false", "false"); },function () { markhover("false", "false", "false", "false", "false"); } ); $("#two").hover( function () { markhover("true", "false", "false", "false", "false"); },function () { markhover("false", "false", "false", "false", "false"); ...

javascript - Creating a chart using jchartfx -

i need create chart through dynamic data. <script type="text/javascript" language="javascript"> // step 1 // on window load data using ajax window.onload = function () { getajaxdata(); } // step 2 // after getting data, call chart function , pass data function getajaxdata() { var values; $.ajax({ cache : false, type : "get", url : 'chartvalues', format:'json', success: function(values) { onloaddoc(values); } }); } // step 3 // process chart using passed data function onloaddoc(values) { var chart1; chart1 = new cfx.chart();chart1.getanimations().getload().setenabled(true); var axisy = chart1.getaxisy(); axisy.setmin(0); axisy.setmax(30); //----assign data fields-------- var fields = chart1.getdatasourcesetting...

How to highlight Python modules that are not used in Emacs -

Image
something 6 months ago, met developer using emacs. writing django code , python. there feature has enabled (wrote himself ?) highlight imported modules not used. i willing have this, unfortunately didn't find related past 15 minutes. guess wrote himself. far lisp guru guys be, hence here am, asking directions such task ;]. for automatic checking using imported modules need install flycheck , python-mode , , later execute command flycheck-verify-setup . later must install python packages, example, pep8, pylint, flake8 , other. install him pip on system side ( recommended ) or in virtual environment.

c# - How to set Textbox's Text as an querystring argument for LinkButton without having codebhind file? -

i having user control file without codebehind file in dotnentnuke. in have put form in have 1 textbox , 1 linkbutton. i want pass textbox's value when press button querystring access in page. for have written following code not work. <asp:textbox id="txtemail" runat="server" class="txtbox" placeholder="enter email here"></asp:textbox> <asp:linkbutton id="linkbutton1" class="lbsubscrb" runat="server" postbackurl="~/portals/_default/skins/gravity/dummy.aspx?add=<% txtemail.text %>" forecolor="white">subscribe</asp:linkbutton> all answers appreciated... it sounds need own custom module, instead of trying take existing module, without source code, , make different? that being said, if want take existing module , make that, jquery going method of choice. basically wan hijack ...

sockets - .net - SocketException 10054 -

i writing small udp client-server app. server allows connect more 1 client. send message clients use code: // ipendpoints - list<ipendpoint> store clients' ipendpoints // packet - byte[] data (int = 0; < ipendpoints.count; ++i) server.send(packet, packet.length, ipendpoints[i]); to recieve messages use this: //packet - byte[] store data //endpoint - ipendpoint packet = server.receive(ref endpoint); but, when 1 of clients closes connection still try send message endpointand socketexception code 10054. question is, how find out client disconnected? how client's ipendpoint remove ipendpoints list? thought ipendpoint stored in endpoint (passed ref), when exception fired, endpoint remains untouched.

.net - View Shared Folders on a Mapped Drive -

so want view shared folders on mapped network drive. know can use: net share in command prompt view shared folders on local drive. , i've tried below try view shared folders in my mapped drive, l:\ l:\ cd\ net share but again shared folders in local drive shown. searched around internet while , couldn't find anything. forum has similar question none of them seem right really. if there way using .net accept well. only computer hosting files knows folders shared. (try sharing folder on mapped drive.) in order correct way™, you'll have run process ( net share ) on machine serving directory have mapped l:. i believe windows stores share information in registry: hkey_local_machine\system\currentcontrolset\services\lanmanserver\shares if knew machine name serving share you've mapped l: (we'll call server-32), like reg query \\server-32\hklm\system\currentcontrolset\services\lanmanserver\shares this doesn't show of admin shares ( ipc...

c++ - QImage RGB32 to QImage RGB24, bad result with some kind of image -

i try convert qimage rgb32 qimage rgb24. code doesn't work in case: when image has additional 1024 bytes in bmp header, size of image x*y*3+54+an unknown 1024 byte. the strange thing code works if image resolution x == resolution y, example: 512x512 or 1024x1024. whatever situation: when have or don't have additional 1024 byte in header. if bmp not have additional 1024 byte in header, every thing works fine if resolution x different resolution y. code : qimage * img=new qimage("test.jpg");//load img rgb32 32bit per pixel whatever format of input qimage * tmp_img=new qimage(img->width(),img->height(),qimage::format_rgb888);// image dest 24bit per pixel uchar * ptr1=img->bits(); uchar * ptr2=tmp_img->bits(); for( int k1=0,k2=0;k1<img->width()*img->height()*4;k1+=4,k2+=3)//increment k1 4 because img format rgb32 //increment k2 3 because tmp_img format rgb888 { ...

c# - How to publish assets using web-api -

i using mvc web api server application generating client data. in addition, want publish collection of javascript, xap (silverlight) , xml files client-side application. currently, have project structure in directories mixed through .net implementation code (what not like), client app uses uris request these files can not changed. nevertheless, want separate client data server application implementation in different folder. therefore, there way store client data in separate folder, e.g. /clientdata/javascript /clientdata/xap /clientdata/xml /clientdata/... in project, while still being able access these files using uris like /javascript /xap/ /xml/ which urls used client app , again can not changed. this main method of global.asax arearegistration.registerallareas(); routetable.routes.maproute( name: "default", url: string.empty, defaults: new { controller = "home", action = "index", i...

symfony - How to handle confirm popup with phantomjs + behat + mink -

in tests use step confirm javascript confirm popup: /** * @when /^(?:|i )confirm popup$/ */ public function confirmpopup() { $this->getsession()->getdriver()->getwebdriversession()->accept_alert(); } this step work fine selenium2 , chrome/firefox, doesn't work phantomjs . how can handle confirm popup phantomjs ? for informations: symfony: 2.0.23 behat: 2.4.6 mink: 1.5.0 symfony2extension: 1.0.2 minkextension: 1.1.4 minkbrowserkitdriver: 1.1.0 minkselenium2driver: 1.1.0 phamtomjs 1.9.1 behat.yml default: extensions: behat\symfony2extension\extension: mink_driver: true behat\minkextension\extension: base_url: "http://localhost:8000/app_test.php" default_session: selenium2 selenium2: wd_host: "http://localhost:9876/wd/hub" thanks! ps: here gist : https://gist.github.com/blazarecki/2888851 i updated "selenium2driver.php...

.net - Eventhandler for serial port data receiving work only in debug mode -

it's quite strange. eventhandlers serial port seem working in debug mode. problem is, @ hardware side, rx , tx pins connected, means share same data line. in case, there 2 datareceived events triggered after every send. first 1 command itself, , second answer need. here code part: private sub mspserialport_datareceived(byval sender object, _ byval e serialdatareceivedeventargs) _ handles mspserialport.datareceived 'handles serial data received events dim inum integer = mspserialport.bytestoread updateformdelegate1 = new updateformdelegate(addressof updatedisplay) if inum > 0 redim mbreceivebuffer(inum - 1) mspserialport.read(mbreceivebuffer, 0, inum) if inum > 1 me.invoke(updateformdelegate1) end if end if end sub the if-condition "inum > 1" intended neglect first received byte, command itself. works fine in debug ...

Overriding unwanted page size in SOLR -

i have web application uses solr backend search service. all requests control searches requests: user (type something, choose page size, sort critera) and, after pressing search button, corresponding servlet on web app calls solr. now, parameters sent servlet exposed in browser address bar; because 1) each page on webapp can stored permalink 2) search can controlled changing directly url on top of that, specific parameter, page size, impose constraint. mean: if select menu on web app proposes 3 choices (5,10,15) don't want other values. now, know can in servlet wondering if possible on solr side too...local params? don't know. briefly: "rows" parameters on solr must 5,10 or 20: if value > 20 comes 20 applied. within solr searchhandlers can predefine configuration settings outlined in configuration section. allows set following parameter behaviors defaults - provides default param values used if param not have value specified @ r...

python - Evaluation of multilabel and multiclass data labels -

are there evaluation metrics available multiclass-multilabel classification? example, i'm taking part in following competition @ kaggle , requires roc auc evaluation metric.: http://www.kaggle.com/c/mlsp-2013-birds is possible using sklearn? there's library kaggle's director of engineering: https://github.com/benhamner/metrics/tree/master/python

android - Cipher AES, no error exception, but init not works -

i try cipher outputs after "cipher.init" won't output. no exceptions..and don't know why...(new on android) public void login() { logindata logindata = this.fragmentbox.getupdatedlogindata(); string finishstring = new string(); try { cipher cipher = cipher.getinstance("aes"); byte[] output = null; secretkeyspec secretkey = new secretkeyspec( globals.encryptpw.getbytes(), "aes"); system.out.println(secretkey.getencoded().tostring() + "----" + globals.encryptpw); cipher.init(cipher.encrypt_mode, secretkey); output = cipher.dofinal(logindata.getpassword().getbytes()); byte[] encryptedusernamestring = base64.encode(output, 0); finishstring = new string(encryptedusernamestring, "utf-8"); } catch (invalidkeyexception e) { e.getstacktrace(); log.v("...

ruby on rails - Submitting an array in a form -

i've been reading question ( ruby on rails: submitting array in form ) didn't answer question. i have form: <div class="signup pull-right"> <div> <p style="color: white">create doctor:</p> <%= form_for(@doctor) |d| %> <%= d.text_field :name[1], :placeholder => "name" %> <%= d.text_field :name[2], :placeholder => "surname" %> <%= d.text_field :email, :placeholder => "email" %> <%= d.text_field :password, :placeholder => "password" %> <%= d.text_field :password_confirmation, :placeholder => "password confirmation" %> ...

Does Groovy have support for something like Ruby Modules? -

ruby modules make things passing database connection or other dependencies various objects easier while allowing separation of concerns. groovy support similar functionality? , if called? in ruby modules used either mixins or namespace class (e.g. net::http ). to mixin behavior can use @mixin annotation. examples here http://groovy.codehaus.org/category+and+mixin+transformations . to namespace, groovy uses same mechanism java i.e. using packages (e.g. groovy.sql.sql ). i not sure if answered question or not. dependency injection, while common mixin way in ruby (or in scala/play), have not seen done lot using @mixin in groovy. di container spring used.

c - ioctl IOCGIWSCAN : invalid arguments, -

hi i'm trying information iwlist command. got invalid arguments errno, , don't understand why, i'm fellowing paper deals : ioctl & iwreq . code fellowing : #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> #include <string.h> #include <errno.h> #include <stdlib.h> #include <stdio.h> #include <netpacket/packet.h> #include <netinet/if_ether.h> #include "ioctlcmd.h" #include <arpa/inet.h> /* siocgiwname 0x8b01 power siocgiwtxpow 0x8b27 siocsiwfreq 0x8b04 set channel/frequency (hz) */ int check_ifname_exist(char * ifname) { int sock = socket(af_packet,sock_raw,0) ; if (sock == ret_err) { printf("error while checking ifname [errno : %d], [strerror : %s]\n",errno,strerror(errno)); return ret_err ; } struct ifreq ifr ; strncpy(ifr.ifr_name,ifname,ifnamsiz) ; int ret = ioctl(sock,siocgifin...

serialization - Callback when GameObject is serialized -

is there callback (or other way) notified before unity3d serializes gameobject ? i need similar onserializenetworkview regular gameobject . useful scenarios: store non-serializable fields serializable classes several possible optimizations on class fields any idea? you can have @ this function . if implement custom assetmodificationprocessor, should able preprocess custom gameobject.

.net - IEquatable<T> - Best practice override for .Equals(object obj) in C# -

whenever write new class or struct hold data, may need compared, implement iequatable<t> provides class/struct typed .equals(t other) method. example: public struct radius : iequatable<radius> { public int32 topleft { get; set; } public int32 topright { get; set; } public int32 bottomleft { get; set; } public int32 bottomright { get; set; } public bool equals(radius other) { return this.topleft == other.topleft && this.topright == other.topright && this.bottomleft == other.bottomleft && this.bottomright == other.bottomright; } } as providing implementation .equals(radius other) , should override default implementation ( .equals(object obj) ) i have 2 options here, , question is, of these implementations better? option 1 use casting: public override bool equals(object obj) { return this.equals((radius)obj); } option 2 use "as" keyword: publi...

php - Can't obtain the desired template for my arrays -

i'd remove [0] [and on] .php can use them separately , create charts using rickshaw librairy. this json code : array ( [0] => [{"x":"0","y":"35"},{"x":"1","y":"34"},{"x":"2","y":"36"},{"x":"3","y":"35"},{"x":"4","y":"40"},{"x":"5","y":"35"},{"x":"6","y":"37"},{"x":"7","y":"40"},{"x":"8","y":"45"},{"x":"9","y":"46"},{"x":"10","y":"55"},{"x":"11","y":"63"},{"x":"12","y":"61"},{"x":"13","y":"45"},{"x":"14...

class - Simple C++ getter/setters -

lately i'm writing getter , setters (note: real classes more things in getter/setter): struct { const int& value() const { return value_; } // getter int& value() { return value_; } // getter/setter private: int value_; }; which allows me following: auto = a{2}; // non-const object // create copies "default" (value returns ref!): int b = a.value(); // b = 2, copy of value :) auto c = a.value(); // c = 2, copy of value :) // create references explicitly: auto& d = a.value(); // d ref a.value_ :) decltype(a.value()) e = a.value(); // e ref a.value_ :) a.value() = 3; // sets a.value_ = 3 :) cout << b << " " << c << " " << d << " " << e << endl; // 2 2 3 3 const auto ca = a{1}; const auto& f = ca.value(); // f const ref ca.value_ :) auto& g = ca.value(); // no compiler error! :( // g = 4; // compiler error :) decltype(ca.value()) h = ca.value()...

c# - Why doesn't this Regex match the date part of the input? -

i attempting take object's text value, obtain information through regex, , type output notepad. below code, , object references correct. have been able type other information notepad, including full text of object regex trying extract, assume there problem match.groups[1].value, can't seem figure out. string pattern= @".*[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}\s[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\s(a|p)m$"; string input = repo.changedbydate.element.getattributevaluetext("text"); match match = regex.match(input, pattern); string dateregex = match.groups[1].value; notepad.textbox.presskeys(dateregex); edit: apologies, posted , without more pertinent information. the above code meant match date/time portion of string original text is: current date , time is: 8/7/2013 12:15:02 pm so want extract 8/7/2013 12:15:02 pm regex assigned pattern . as of now, no output being placed notepad. however, if change code following: string input = repo.changedbydate....

php - Customize 400-401-403-404-500 error page -

i trying customize 400-401-403-404-500 errorr page on website .htaccess file: errordocument 500 /500.php errordocument 404 /404.php errordocument 403 /403.php errordocument 401 /401.php errordocument 400 /400.php it works error 401/403/404 ...but doesn't error 400 , 500..the server don't find pages 500.php , 400.php . any tips? thank indeed http://wiki.dreamhost.com/custom_error_pages try following link might

ios - replace segue, with animation? -

a colleague of mine showed me "replace segue" can use split-view controller. work well. but i'd "cross-fade" old view new view. i've done fades setting alpha property of view, not sure how work using segues. try this: select segue in storyboard in attributes inspector, set style of segue 'modal'. set transition 'cross dissolve' try out , see if that's you're looking for.

python - many-to-many in list display django -

class purchaseorder(models.model): product = models.manytomanyfield('product') vendor = models.foreignkey('vendorprofile') dollar_amount = models.floatfield(verbose_name='price') class product(models.model): products = models.charfield(max_length=256) def __unicode__(self): return self.products i have code. unfortunately, error comes in admin.py "manytomanyfield" class purchaseorderadmin(admin.modeladmin): fields = ['product', 'dollar_amount'] list_display = ('product', 'vendor') the error says "'purchaseorderadmin.list_display[0]', 'product' manytomanyfield not supported." however, compiles when take 'product' out of list_display. how can display 'product' in list_display without giving errors? edit: maybe better question how display manytomanyfield in list_display? you may not able directly. from documentation of list_d...

javascript - Button click event on $.post-loaded button -

after filling div $(mydiv).load() call, want catch click event on button inside div. now reason $('.mybutton').click not invoked when click on button loaded through jquery's load function. what best way around this? you have catch event of dynamic object, have use .on() try this: $(document).on('click', '.mybutton', function(){ //your code }); instead of $('.mybutton').click(function(){ //your code });

excel - Finding maximum value in range containing same value -

i have data: b 1 100 1 300 1 200 2 100 2 500 3 100 3 300 3 200 i want select maximumof(b) same value in column1. output should be: b c 1 100 300 1 300 300 1 200 300 2 100 500 2 500 500 3 100 300 3 300 300 3 200 300 i have tried: ={max(if(a:a=a1,b:b))} this gives me maximum value 1 i.e. 300 . how can copy formula other group of cells? gives message you can not move array values . how can achieve this? i suggest delete columnc , start again - using formula in c1. either drag c1 down far required or copy , past c2:c whatever. make sure = inside curly brace.

include - C header file dependencies -

i typically include dependencies in header files when adding header source file, don't need dig around other required headers make compile. however, after reviewing other coding standards, appears banned, requirement header file not contain #include statements. i can't find discussion on - reason banning such practice, or purely down preference? -- e.g. typedef.h contains typedef u8. my_header.h declares void display_message(u8 arg); should reference typedef.h go my_source_file.c or my_header.h ?? i see no reason not allowing headers include prerequisites. consider deleting #include source file. example, suppose code has been modified no longer use foo.h , #include being deleted. source files has dozen #include statements. other ones should delete because no longer needed? hopefully, foo.h documents prerequisites, can identify candidates deletion. however, if delete #include statements, might deleting prerequisite needed different header file. must...

Read from a text file and parse lines into words in C -

i'm beginner in c , system programming. homework assignment, need write program reads input stdin parsing lines words , sending words sort sub-processes using system v message queues (e.g., count words). got stuck @ input part. i'm trying process input, remove non-alpha characters, put alpha words in lower case , lastly, split line of words multiple words. far can print alpha words in lower case, there lines between words, believe isn't correct. can take , give me suggestions? example text file: project gutenberg ebook of iliad of homer, homer i think correct output should be: the project gutenberg ebook of iliad of homer homer but output following: project gutenberg ebook of iliad of homer <------there line there homer i think empty line caused space between "," , "by". tried things "if isspace(c) nothing", doesn't work. code below. or suggestion appreciated. #include <stdio.h> #in...

java - Adding Keys in CountingBloomFilter Hadoop -

i trying use implementation of countingbloomfilter proposed hadoop. after importing libraries , creating classe, want use method add(org.apache.hadoop.util.bloom.key key) however need add strings filter, how can convert string key function accept? key has constructor accepts byte arrays., can call string's getbytes()

animation - CSS3 onclick activate another DIV's hide/show -

i'm starting in css3, i'm trying make menu this: http://codecanyon.net/item/metro-navigation-menu/full_screen_preview/4573382 the idea when click button, hides parent div , open div daughter other buttons. i saw post css3 onclick activate div's animation points example http://jsfiddle.net/kevinphpkevin/k8hax/ , code: css: #box1 { display:none; } #box1:target { display:block; } html: <a href="#box1">click me</a> <div id="box1">test test</div> that clicking on link, opens div. want click link, hide div, open other , reverse. i use css3 tks help if want use css3 can use checkbox hack ( http://css-tricks.com/the-checkbox-hack/ ). it far ideal css usage setting boxes radio boxes quite each 1 deactivates others. (ie set "width:0px" default, change "width:200px" on check combined "transition: width 0.5s;-webkit-transition: width 0.5s;" bit of animation). in honest...

javascript - how to send html with mailto? -

i have following html form... <form id="mform" method="get" enctype="text/plain"> <input name="firstname" type="text" id="firstname"> <input type="submit" class="submit-sponsor-btn" name="submit" value="submit" onclick="javascript:domailto(); return false;" id="submit"> </form> and javascript looks this... var msubject = "become sponsor start connection future talent"; var mfirstname = $('#firstname').val(); var mbody = "<h1>sponsor information below:</h1><p>firstname:"+mfirstname + "</p>"; var smailto = "mailto:memail@something.com?subject="+ msubject + "&body="+ mbody; function domailto() { window.open(smailto); } what need code, enable html tags rendered within e-mail? because of right now, shows element tags along content. thanks...

c# - Disable Enter Key in Textboxes -

i developing chatting system. , have button send text in text box chat log. how going stop user press enter key , disable enter key. know there many posts out there this, solutions haven't worked me. i think not need stop user pressing enter instead send chat other person on press of enter. also if have other shortcuts allowed can have @ c#: how make pressing enter in text box trigger button, yet still allow shortcuts such "ctrl+a" through? using same can block private void textboxtosubmit_keydown(object sender, keyeventargs e) { if (e.keycode == keys.enter) { e.suppresskeypress=true; } }

Need some clarification on the ** operator in Python -

i wanted start asking here this. given me part of exercise @ codeacademy.com , confused me better part of hour. take @ following code block: bool_one = 40 / 20 * 4 >= -4**2 now, evaluated being "8 >= 16" false. however, codeacademy.com terminal says it's true. when started writing debug code lines, found issue in how "-4**2" gets evaluated. when run on terminal @ codeacademy on local linux system, "-4**2" in python comes out "-16"... contrary everything have learned in math classes every single calculator have run on. whether run "-4 * -4" or "-4^2" or even, using "x^y" key, "-4 [x^y] 2", still comes out "16". so, how python coming out "-16" "-4**2"? can please clarify me? tia. if have -4 without parentheses, negative sign considered unary operator "multiply negative one." (-4)**2 16, because negative 4 squared, -4**2 uses...

c - copying pointer characters not working as expected -

in following code, doing wrong? run code in eclipse , using mingw c compiler. when run eclipse stops responding. when debug code, breaks on line *start = *end; i verified value of *start , *end in debug mode , none null. void func1(char *str) { char *end, *start; end = start = str; char tmp; if (str) { while (*end) ++end; --end; while (start < end) { tmp = *start; *start = *end; *end = tmp; start++; end--; } } } any tips/ideas? so according feedback passing string literal, "hello world" func1 , modifying string literal undefined behavior, alternatively use , work: char arr1[] = "hello world" ; func1(arr1) ; although adam , kerrek pointed out need add more error checking code should fix immediate problem.

Avoiding too many Angularjs Directives -

i have following directive: .directive('mydirective', function() { restrict: 'a', templateurl: 'app/templates/sometemplate/html', }); in template (sometemplate.html) have following: <div> <div>some div</div> <input type="button" value="button" /> </div> i want add behavior button , div. can go route of adding directives so: <div> <div div-click>some div</div> <input type="button" value="button" button-click /> </div> and adding more directives , binding click events via element.bind(... there best practice? should adding behavior in 'mydirective' containing elements? via jquery or jqlite . clickable elements inside template not meant resuable..so should use jquery find elements , bind event listeners them? can see how can directives explosion using directive route, best practice? the question me on directives...