Posts

Showing posts from February, 2015

c# - SyntaxError: JSON.parse: unexpected character error unexpected token < -

i have html button "button-account" name in html body , want update aspx page ajax when user click button i error in google chrom syntaxerror: json.parse: unexpected character and in fire fox syntaxerror: json.parse: unexpected character here's code <script type="text/javascript" > $(document).ready(function () { $("#button-account").bind("click", "accountregister"); function accountregister() { var waitobj = "<span class='wait' > <img src='resource/images/loading.gif' alt='' /> </span>"; var user = $("[name='username']").val(); var pass = $("[name='password']").val(); var dataobj = { "username": user, "password": pass, }; $.ajax({ type: "post",

Hadoop HDFS connection in PowerCenter -

i have installed cloudera's hadoop quickstart vm , attempting pass records local database hdfs using powercenter mapping. i've set hadoop_hdfs_connection in powercenter workflow manager when run workflow following error: "unable establish connection specified hdfs host". gives "java.net.connectionexception" error when trying connect host name , port. think error may in hostname notation. on cloudera manager on vm, host name listed 'localhost.localdomain' don't know how translate in powercenter connection settings. anybody got connection work? many thanks. brian

Python XML XPath partial failure message -

in code maintain there's xml parsing using minidom library. for xml structure similar below: <a val="a1"> <b val="b1"> <c val="c1"> data </c> </b> </a> code looks like: for in doc.getelementsbytagname("a"): aid = a.getattribute("val").encode('ascii') if aid == aexpected: afound = break else: # not found raise exception("no '%s' found" % aexpected) b in afound.getelementsbytagname("b"): bid = b.getattribute("val").encode('ascii') if bid == bexpected: bfound = b break else: # not found raise exception("no b '%s' found" % bexpected) # similar c i wanted use xpath data. can (elementtree): root.findall(".//a[@val=%s]/b[@val=%s]/c[@val=%s]" % (aexpected, bexpected, cexpected)) the code looks nicer now. but, when no data can found in

sql - @ Symbol - a solution for Recursive SELECT query in Mysql? -

there lot of questions recursive select query in mysql, of answers "there no solution recursive select query in mysql". actually there solution & want know clearly, question following of previous question can found @ ( how-to-do-the-recursive-select-query-in-mysql ) suppose have table: col1 - col2 - col3 1 - - 5 5 - d - 3 3 - k - 7 6 - o - 2 2 - 0 - 8 & want find links connect value "1" in col1, i.e. want print out: 1 - - 5 5 - d - 3 3 - k - 7 then can use simple query: select col1, col2, @pv:=col3 'col3' table1 join (select @pv:=1)tmp col1=@pv ok, good, however, if table has 2 records containing "1" in col1 & 2 records containing "3" in col1, ex: col1 - col2 - col3 1 - - 5 1 - m - 9 5 - d - 3 3 - k - 7 6 - o - 2 3 - v - 10 2 - 0 - 8 then, when users search "1" in col1, should show links connecting 2 "1&q

android - How to present keyboard and not shrink background image in layout -

i have scroll view , inside there layout out. inside layout have included form (basically textfields , textviews) when in runtime. if press on textfield keyboard appear tottaly normal. there problem background image has been shrinked. is there way avoid it. background image shouldn't shrink you have change manifest file in activity tag android:windowsoftinputmode="adjustpan" add this. see http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

postgresql - Rails Article.find 1 raises ActiveRecord::StatementInvalid on legacy database -

i'm creating rails app on legacy database table. works fine locally, on server hit error whenever article.find(1) could not log "sql.active_record" event. nomethoderror: undefined method `name' nil:nilclass activerecord::statementinvalid: pg::error: error: zero-length delimited identifier @ or near """" line 1: select "articles".* "articles" "articles"."" = $1 limit 1 the legacy database has id field, schema describes id with create_table "articles", :id => false, :force => true |t| t.decimal "id", :precision => 10, :scale => 0, :null => false ... note article.find_by_id(1) returns record without problem. any ideas how fix this? updated - see below it turns out, adding following model fixes this: class article < activerecord::base set_primary_key :id ... presumably, because rails didn't create table, doesn't know field pr

C implicit extern for global variable, when does it happen, how does it work -

i'm trying understand ways in c global variable can shared between multiple files (compilation units). i've read excellent question , answer here . after doing few tests i'm still left stuff don't get: basically question be: if there's variable declared (but not defined) in header without extern keyword, ok include header in various compilation units in order make available variable compilation units? in scenario it's implied 1 (and one) compilation unit contains code initializing (defining?) variable, , called first before other compilation units try variable. if true, procedure what's called "implicit extern" ? i'll illustrate question example: header "mycommonheader.h" contains: //mycommonheader.h int* i; //pointer int file myfirstheader.h contains: //myfirstheader.h void changeit(int newvalue); file myfirstsource.c contains: //myfirstsource.c #include "myfirstheader.h" void changeit(int newvalue) {

java - Eclipse RCP authentication -

i know how implement authentication in eclipse rcp. have started app , have 2 views, 1 admin , 1 regular user. @ startup want show login dialog , depending of type of user show view. can tell me best way that? thanks! i'll suggest create single view both admin , regular user . create different widgets admin , regular user . before creating view hook login dialog , on basis of authentication login dialog load widgets in view .

Awk previous day -

for reason can not work? want compare previous day , current days file. awk 'fnr==nr{a[nr]=$2;next}{print $1,$2-a[fnr]}' router_evi_`(strftime("%y-%m-%d", systime()-86400))`.txt router_evi_`(date +"%y-%m-%d")`.txt > temp_plus_minus.txt thanks you confused awk script , shell's $(..) or `...` the command gave is: awk '....' foo_`(awkcode)`.txt bar_`(shell cmd)`.txt ^ ---problem----------| this won't work. since cannot let shell interpret , execute awk code. should write shell command/code in backticks. or this: foo_$(awk 'begin{print strftime("%y-%m-%d", systime()-86400)}').txt it better getting 2 filenames in variables first(if dynamic), , call awk script. making 1 line not best solution.

ms word - Find text and format -

i have recorded macro in word 2007 finds word, moves cursor 2 lines up, inserts 3 '***', highlights line. works on first instance of found word. struggling repeat throughout document instances of word want find. this output recorded macro. need actions repeated each instance of "b,". sub highlightnewitems() ' ' highlightnewitems macro ' ' selection.find.clearformatting selection.find .text = "b," .replacement.text = "" .forward = true .wrap = wdfindcontinue .format = false .matchcase = true .matchwholeword = false .matchwildcards = false .matchsoundslike = false .matchallwordforms = false end selection.find.execute selection.moveup unit:=wdline, count:=2 selection.moveleft unit:=wdword, count:=1 selection.typetext text:="***" selection.typeparagraph selection.endkey unit:=wdline, extend:=wdextend

Jenkins sometimes takes JUnit @Ignore tag into account, sometimes not? -

i have added @ignore tag test classes (class level, not method level). of these test classes @ignore tag ignored jenkins (correct), classes @ignore tag still executed. mind you, test classes executed not execute tests because tests have been commented away, jenkins gives "initialization error" sign there no tests execute. how possible? test classes normal unit tests, , pretty identical. try using @ignore tag @ method level instead of class level.

malloc matrix which points to malloc arrays(C) -

edit: should not use []. i have defined integer n value 5 , *malloc. #define n void* malloc (size_t size); ... int *p_mat=(int*)malloc(sizeof(int*) * n); this matrix. now need arrays. int p_arr1=(int)malloc(sizeof(int) * 4); int p_arr2=(int)malloc(sizeof(int) * 3); int p_arr3=(int)malloc(sizeof(int) * 1); int p_arr4=(int)malloc(sizeof(int) * 2); int p_arr5=(int)malloc(sizeof(int) * 5); so have 5 arrays in different sizes. how make each pointer of matrix point first cell in array? and question, how send these variables function, mean - parameters in function key? an array of n pointers arrays-of-integers of different sizes.... ( note don't cast malloc return value in c - can hide errors - see do cast result of malloc? ). int = 0; int *p[n]; size_t sizes[] = { 4, 3, ..., 5 }; // n sizes for(; < n; ++i) { p[i] = malloc(sizeof(int) * sizes[i]); } now p array of pointers-to-int. p[n] therefore nth pointer-to-int in array. int *p[n] i

mysql - Can I paralellize this foreach loop in PHP? -

currently script takes 6 minutes complete. here's snippet: $items = getsomeitems(); $results = array(); foreach ($items $index => $value) { $valuea = getvaluea($value); // 2 minute process. $valueb = getvalueb($value); // 2 minute process. $valuec = getvaluec($value); // 2 minute process. $results[] = array('a' => $valuea, 'b' => $valueb, 'c' => $valuec, ) } return $results; is there way paralellize foreach loop? don't care order in arrays added $results , order them in sql anyways. can like? parallel-foreach ($items $index => $value) { $valuea = getvaluea($value); // 2 minute process. $valueb = getvalueb($value); // 2 minute process. $valuec = getvaluec($value); // 2 minute process. $results[] = array('a' => $valuea, 'b' => $valueb, 'c' => $valuec, ) } c# has similar idea in parallel.foreach . i'm looking similar in php.

php - How to restrict global access for solr admin DIRECTLY FROM BROWSER -

when run following url can see permissions open http://localhost:8983/solr/#/ i installed solr on development server http://www.xyz.com:8983/solr/#/ here, can open , can destroy documents. how can make password protected ??? or other solution on server. edited i have added code results in 503 error. can check mistake here <web-app id="/solr" document-directory="/home/admin1/solr-4.2.1/example/" archive-path="/home/admin1/solr-4.2.1/example/webapps/solr.war" character-encoding="utf-8"> <system-property solr.solr.home="/home/admin1/solr-4.2.1/example/solr/collection1/data" /> <authenticator type="com.caucho.server.security.xmlauthenticator"> <init> <user>user:user12345:user,admin</user> <password-digest>none</password-digest> </init> </authenticator>

ios - Apple LLVM Compiler 4.2 Error exit code 1 -

Image
this has been asked lot of times, can't find solution problem. error get: clang: error: no input files command /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/clang failed exit code 1 screenshot: i hope can me. using parse sdk. (see: parse.com) you should check build settings , verify file name , path in gcc_prefix_header apple llvm compiler 4.2 - language prefix header this mine. example gcc_prefix_header = dc wire sizer/supportingfiles/dc wire sizer-prefix.pch fyi: if select prefix header build setting in xcode , copy line above when set value shouldn't include 'gcc_prefix_header = ' this incorrect: this correct setting: note: values different above because different project.

windows phone 8 - MDM Enrollment Service: Certificates in provisioning XML -

i implementing mdm solution windows phone 8. refering enterprise device management protocol , have question reqarding certificates during enrollment phase. document says response should contain: the client certificate, enterprise root ca certificate, , intermediate ca certificate. in sample provisioning xml shows: <characteristic type="certificatestore"> <characteristic type="root"> <characteristic type="system"> <characteristic type="031336c933cc7e228b88880d78824fb2909a0a2f"> <parm name="encodedcertificate" value="b64 encoded cert insert here" /> </characteristic> </characteristic> </characteristic> <characteristic type="my" > <!-- "my" , “user” case-sensitive --> <characteristic type="user"> <characteristic type="f9a4

java - Change Background color item of ListView while maintaining effect of custom Drawable -

i try change background color @ specific item within listview, while maintaining effect of custom drawable. my custom list_items : <textview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/label" style="@android:style/textappearance.holo" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background_list" android:textcolor="@color/white" /> my custom arrayadapter : public class missiondatalistadapter extends arrayadapter { private final arraylist<missiondata> list_missions; public missiondatalistadapter(context context, int textviewresourceid, arraylist<missiondata> objects) { super(context, textviewresourceid, objects); this.list_missions = objects; } @override public view getview(int position, view convertview, viewgroup parent){

Opencart filter module won't work properly -

assuming have e-shop working on opencart , category "mobile phones". trying set filter module -touch screen -yes -no -smartphone -yes -no while choosing single option list works fine , if want choose smartphones list touch screen (choosing both "yes" options), module messes , , shows phones. ideas how fix ? p.s. know better use attributes options , use attribute search extension , in case need way. thanks this extension solves it. http://www.opencart.com/index.php?route=extension/extension/info&extension_id=11707 it uses 'or' logic attributes of each filter , 'and' logic between filters. put on opencart 1.5.6 , seems working fine. edit: appears extension doesn't exist anymore. also, comment written based on opencart 1.5.6 while current version 3.0.0.

internet explorer - JavaScript functions run from local machine, but not from server -

i writing script show/hide cascading lists options selected each of 4 pull-down menus. example, when person chooses state, hides default empty list of cities, , shows instead appropriate city list state. here simplified version of html: <!doctype html> <html> <head> <script type="text/javascript" src="mapselector3.js"></script> <link rel="stylesheet" type="text/css" href="mapselectorstyles3.css" /> </head> <body onload="reset('selectstate')"> <div id="wrapper"> <h1>device installation</h1> <p>select specific printer location:</p> <form name="mapselector"> <div class="selectholder"> <label>select state:</label> <!--states list--> <select id="stateselector"

Django Database querying differences -

i going through creation of polls app again, in django docs. wanted ask again 1 particular thing in django database. code shown below: >>> polls.models import poll, choice # make sure our __unicode__() addition worked. >>> poll.objects.all() [<poll: what's up?>] # django provides rich database lookup api that's entirely driven # keyword arguments. >>> poll.objects.filter(id=1) [<poll: what's up?>] >>> poll.objects.filter(question__startswith='what') [<poll: what's up?>] # poll published year. >>> django.utils import timezone >>> current_year = timezone.now().year >>> poll.objects.get(pub_date__year=current_year) <poll: what's up?> # request id doesn't exist, raise exception. >>> poll.objects.get(id=2) traceback (most recent call last): ... doesnotexist: poll matching query not exist. lookup parameters {'id': 2} # lookup primary key commo

.net - Visual Studio: Compiler Warnings and errors appear twice in different languages -

Image
i have weird case in of visual studio projects warnings , errors appear multiple times: in case, 1 time in english , 1 time in german. does know triggers , how can turned off? according this thread , compiler messages come .net framework, controlled os language settings , whether or not have .net framework language packs installed. make compiler messages change other language, 1 simple way try uninstall .net framework language pack system.

Running sample google map in api tutorial -

i have copied html sample map from: https://developers.google.com/maps/documentation/javascript/examples/layer-kml . copied code text editor , saved html , run in ie , firefox no map showed.any advice please thanks ian you need file also: <link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet"> google's sample on server or include in place: <style type="text/css"> html, body { height: 100%; margin: 0; padding: 0; } #map-canvas, #map_canvas { height: 100%; } @media print { html, body { height: auto; } #map_canvas { height: 650px; } } #panel { position: absolute; top: 5px; left: 50%; margin-left: -180px; z-index: 5; background-color: #fff; padding: 5px; border: 1px solid #999; } </style>

Do not log supressed PHP Warning -

is there way find out if warning supressed or not using set_error_handler() function? code 2 @somethingwrong() , somethingwrong(). don't want log warnings. example functions gzuncompress() must handled way because have no way test valid input data. $handler = new errorhandler(); error_reporting(0); set_error_handler(array($handler, 'handle')); set_exception_handler(array($handler, 'exception')); register_shutdown_function(array($handler, 'shutdown')); class errorhandler { public function handle($code, $text, $file, $line) { if (($code & (e_strict | e_notice)) == 0) $this->log(...); } public function exception($exception) { ... } public function shutdown() { $e = error_get_last(); if ($e !== null) $this->log($error); } } // errors include('notexisting.file'); // should logged @gzuncompress('somenonsens'); // should not logged did try it? think if use @ in @gzuncompress not normal war

json - How to authenticate a user in wordpress [via android] -

i'm trying figure out how authenticate user via android (java). app can create user i'm not sure i've found (or @ least decent) documentation xmlrpc api wordpress has, , tried json-api auth user plugin can't figure out how post (can found here: https://github.com/mattberg/wp-json-api-auth ) i'd appreciate either on how use xmlrpc api or git hub project or other method you've found work. for question please refer plugiin json-api_auth... http://wordpress.org/support/topic/looking-for-this-in-ages#post- i hope help..

jsf - Values of h:inputText inside ui:repeat are not processed -

Image
i want process form (valuechanguelistener not valid in real case). this bean: public class testbean extends privatebasebean implements serializable { private list<string> strings; @postconstruct public void init() { strings = new arraylist<string>(); strings.add(""); strings.add(""); strings.add(""); } public void saveaction(actionevent event) { stringbuilder texttoshowinmessage = new stringbuilder(); (string string : strings) { texttoshowinmessage.append(string); texttoshowinmessage.append("; "); } facesmessage msg = new facesmessage(super.getbundle().getstring( texttoshowinmessage.tostring()), ""); facescontext.getcurrentinstance().addmessage(null, msg); } getters... setters... an view: .... <h:form> <ui:repeat var="string" value="#{testbean.strings}"> <h:inputtext value="#{string}" /> &l

oop - Finding type of the class which is calling a method in Java -

this question has answer here: how caller class of method 4 answers i'd know what's type of object calling method in class in java, e.g. : class a{ public a(){ //.. } public void method1{ //here i'd find what's type of object calling method } } class b{ public b(){ a = new a(); a.method1(); } } class c{ public c(){ a = new a(); a.method1(); } } you can inspecting stack upon method call code. check out thread.getstacktrace() , use current thread returned by thread.currentthread() you can work way stack trace array , determine chain of callers. note caveat in documentation however: some virtual machines may, under circumstances, omit 1 or more stack frames stack trace. in extreme case, virtual machine has no stack trace information concerning t

wcfGridChildObjectCheckboxViewer compile error for WebSphere Commerce 7's Management Center -

i'm using websphere commerce + it's dev environment's rad, , have made changes promotion type. result, have rebuild lobtools project (management center main business tool i'm using). however, i'm getting following compile error: undefined superclass wcfgridtextviewer class wcfgridchildobjectcheckboxviewer in checkbox.lzx file. there other files in exact same folder extend same class, , compiling fine... i've had around, , others have had exact same problem , , 2 fixes described, i've been unable work... i'm hoping here has seen before, , knows how fix it? that's question ibm software support. submit pmr , they'll fix it.

drag and drop - Dropzonejs issue with resolution of an image -

i have issue dropezonejs . apparently, when image has resolution more 72dpi, thumbnail not generated , stop here. you can try in dropzonejs website uploading different kinds of images. (images <72dpi won't displayed thumbnails) any ideas solve problem? probably you're backend doesn't accept cmyk files. i've had same issue java imageio, making change in backend support upload of cmyk file

Memory leak while opening encoders in ffmpeg -

i'm getting memory leaks in avcodec_find_encoder. although i'm cleaning resources still i'm not able rid of leak. successive commenting code found memory leaks happen after call of avcodec_find_encoder(). i've tried code different video files , found memory leaks blocks same. if open audio or video 1 memory leaks block. below part of init , clean-up code application. note part of code contains initialization , resource release. avformatcontext *m_informat; avformatcontext *m_outformat; avstream *m_in_vid_strm, *m_out_vid_strm; avstream *m_in_aud_strm, *m_out_aud_strm; int videoclipper::init(const wxstring& filename) { int ret = 0; char errbuf[64]; av_register_all(); if ((ret = avformat_open_input( &m_informat, filename.mb_str(), 0, 0)) != 0 ) { av_strerror(ret,errbuf,sizeof(errbuf)); print_val("not able open file;; ", errbuf) ret = -1; return ret; } else {

ios - How to set device orientation only landscape? -

Image
i'm writing simple app under macos using xcode . want app in landscape mode always. set landscape orientation in project properties. when add button window.subview , button doesn't appear in landscape position. i have appdelegate class. i've changed function: - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions i've added: self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; self.window.backgroundcolor = [uicolor purplecolor]; [self.window makekeyandvisible]; uibutton *button = [uibutton buttonwithtype:uibuttontyperoundedrect]; [button setbackgroundcolor:[uicolor whitecolor]]; [button setframe:cgrectmake([[uiscreen mainscreen] bounds].size.width/2 - 50, [[uiscreen mainscreen] bounds].size.height/2, 100, 100)]; [button settitle:@"button" forstate:uicontrolstatenormal]; [self.window addsubview:button]; update: added [self.window set

utf 8 - sand smtp mail php class SMTPClient -

i smtpclient class mail utf-8 post, did not anything! please me thank you class smtpclient { function smtpclient ($smtpserver, $smtpport, $smtpuser, $smtppass, $from, $to, $subject, $body) { $this->smtpserver = $smtpserver; $this->smtpuser = base64_encode ($smtpuser); $this->smtppass = base64_encode ($smtppass); $this->from = $from; $this->to = $to; $this->subject = $subject; $this->body = $body; if ($smtpport == "") { $this->portsmtp = 25; }else{ $this->portsmtp = $smtpport; } } /////////////////////////////////////////////////////////////////////// $to = $_post['to']; $from =$_post['from']; $subject = $_post['sub']; $body = $_post['message']; $smtpmail = new smtpclient ($smtpserver, $smtpport, $smtpuser, $smtppass, $from, $to, $subject, $body); $smtpchat = $smtpmail->sendmail(); i found code here: http://url.lid.ir/kpyhfu change defintion of sendmail method in smtpclient function s

coldfusion - Any way to get multiple CFIFs displaying inside CFSET? -

at moment have code working great - <cfif (dailycount mod 2) eq 0> <cfset via = '<td style="background-color: dbefb6;">#src#<br><font color="blue">#get_info.csuseragent#</font></td>'> <cfelse> <cfset via = '<td>#src#<br><font color="blue">#get_info.csuseragent#</font></td>'> </cfif> in #get_info.csuseragent# field, @ moment displaying whole ua string eg - mozilla/5.0 (windows nt 6.1; wow64; rv:23.0) gecko/20130406 firefox/23.0 i want put code below #get_info.csuseragent# tag displays broswer/device. works out of setup cannot work out how display in cell. can shed light on how these cfif statements appear within cfset? <cfif '#get_info.csuseragent#' contains "blackberry">blackberry</cfif> <cfif '#get_info.csuseragent#' contains "iphone">iphone</cfif> <cfif '#get_info.csu

java - LoaderManager reference not found with API Level 17 -

i writing android sample app , trying create sample of listview using sample code here . , can't resolve loadermanager. idea wrong? i using eclipse toolkit latest android sdk. the function loadermanager need use in example available api 17 : http://developer.android.com/reference/android/app/loadermanager.html i guess using api inferior 17 project cannot find it. in case need use function on older api versions, can still have try using "support" version available in support library: http://developer.android.com/reference/android/support/v4/app/package-summary.html using package can import loadermanager class using: import android.support.v4.app.loadermanager; instead of: import android.app.loadermanager;

locking - Detect when iOS device wakes up from sleep -

is there anyway can detect when device wakes up? sleep mean device screen off, , wakes mean when device's screen on or when lock screen showed (when home or power button pressed). thanks! you can detect when app stops being active application with: - (void)applicationdidenterbackground:(uiapplication *)application in app delegate. also, can detect when comes view with: - (void)applicationdidbecomeactive:(uiapplication *)application there isn't way detect device locked vs detecting if user switched app app. can know user leaving app , can know when they've returned app.

c# - Read the Description of a Windows Service -

i'm using c:\windows\system32\sc.exe (via system.diagnostics.process ) create several windows services via custom install wizard i've built. each service created contain program 1 or more modules loaded (chosen user via wizard). when wizard loaded want able inform user of services modules installed. have used service description ( sc description "....." ) write modules part of each service. however, cannot find method read service's description programmatically. find surprising it's not part of system.serviceprocess.servicecontroller is there way read service's description via c#? thanks here 1 way of doing it: using system; using system.management; public static string getservicedescription(string servicename) { using (managementobject service = new managementobject(new managementpath(string.format("win32_service.name='{0}'", servicename)))) { return service["description"].tostring()

javascript - How to convert an array tree to Json tree? -

i have array keep data in tree structure i'd transform data json. example of data : [object] 0: object children: array[1] 0: object children: array[1] 0: object children: array[10] 0: object children: array[6] value: object 1: object 2: object 3: object 4: object 5: object 6: object 7: object 8: object 9: object value: object id: "00145e5bb2641ee284f811a7907757a3" parent: "00145e5bb2641ee284f811a7907737a3" ref: undefined text: "functional areas" type: "twb" no

jquery - How to render an element from a controller in cakephp? -

i having trouble figuring out. have element named quoteform in default layout. element has form has few textboxes, checkboxes, submit button etc. submit form , send mail data. on sending mail, replace current div div says message sent successfully. i have used cakephp ajax on submit, doesnt send mail or refresh div message. following code quotes/quoteform.ctp <?php $this->requestaction('quotes/index'); ?> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <div id="quotenext"> <?php echo $this->form->create('quote'); ?> <div class="inputboxa"><?php echo $this->form->input( 'name', array( 'id' => 'name', 'style' => 'width:440px;height:20px;font-size:8pt; background-color:black;color:white;resize:none;border:none;padding-left:5px;padding-top:5px;

javascript - Parse response using Jquery -

i have parse response server, response like.. [4,"1.0",1368544417760] [1,"great west road","222",1368544595000] [1,"ruislip manor station","114",1368544479000] [1,"bank station / threadneedle street","26",1368544731000] [1,"belvue school","e10",1368545955000] [1,"brunel road","283",1368544706000] [1,"annesley avenue","303",1368545930000] [1,"brixton station road","35",1368545854000] [1,"southampton row","91",1368545537000] [1,"camden road station","29",1368545008000] [1,"fulham cemetery","74",1368545210000] the response doesn't seem json or xml. please me know how parse such type of response using jquery. have update dom based on response , response getting updated @ regular interval automatically. the first number may indicator of sort of data in re

scala - convert timestamps to intervals -

i wrote scala function converts list of timestamps intervals def tointervals(timestamps: list[string]) = { def helper(timestamps: list[string], accu: list[long]): list[long] = { if (timestamps.tail.isempty) accu.reverse else { val first = timestamps.head.tolong val second = timestamps.tail.head.tolong val newhead = second - first helper(timestamps.tail, newhead :: accu) } } helper(timestamps, list()) } and without tailcall def tointervals(timestamps: list[string]) : list[long] = { if (timestamps.tail.isempty) list() else { val first = timestamps.head.tolong val second = timestamps.tail.head.tolong val newhead = second - first newhead :: tointervals(timestamps.tail) } } but have feeling there one/two liner e.g map2 . advice? (timestamps.tail, timestamps).zipped.map(_.tolong - _.tolong) is one-liner; it's more efficient val times = timestam

asp.net mvc - How to list DB data like this in MVC4? -

Image
it's easy list data in rows. controller: return view(xxx.tolist()); view: @model ienumerable<mvcproject.models.table1> @foreach (var item in model) { <table style="width: 100%"> ........ ..... </table> } but how can list data in viewpage in mvc4? without changing data structure, following (assuming model doesn't have lot of items in it): edit: requested in comments, i've added each header row contains 5 items: <table> <tr> @for (int = 0; < model.count(); i++) { <th>@item.id</th> @if ((i + 1) % 5 == 0) { @:</tr><tr> } } </tr> @foreach(var item in model) { <tr> <td>@* data on item *@</td> </tr> } </table>

python - add a new value to array while keeping existing one -

i have below example of data: { "id": "2", "items": { "3" : { "blocks" : { "3" : { "txt" : 'xx' } } }, "4" : { "blocks" : { "1" : { "txt" : 'yy'}, "2" : { "txt" : 'zz'} } } } } i want make looks below example data. append new value items.3.blocks.3.txt while keeping existing value of it: { "id": "2", "items": { "3" : { "blocks" : { "3" : { "txt" : 'xx, tt' } } }, "4" : { "blocks" : { "1" : { "txt" : 'yy'}, "2" : { "txt" : 'zz'} } } } } i run below did not make difference dbx.test.update({"_id": objectid(&quo

ios6 - iOS animation: Drop down that keeps it position -

i´m trying create drop down menu display set of controls. got animation working whole "button" moves animation. my button uiview named settingspanel, code far: [uiview animatewithduration:1.0f animations:^{ self.settingspanel.bounds = cgrectmake(self.settingspanel.bounds.origin.x, self.settingspanel.bounds.origin.y, self.settingspanel.bounds.size.width, self.settingspanel.bounds.size.height + 300); }]; i want height of panel change, , does, whole view moves bit well. how can create animation justs increases height downwards? you need set frame , not bounds . [uiview animatewithduration:1.0f animations:^{ self.settingspanel.frame = cgrectmake(self.settingspanel.frame.origin.x, self.settingspanel.frame.origin.y, self.settingspanel.frame.size.width, self.settingspanel.frame.size.height + 300); }]; frame external coordinate. when change frame, change actual position of view

java - spring interceptor is never called -

i have following interceptor: @component public class externallinkinterceptor extends handlerinterceptoradapter { private static final logger logger = logger.getlogger(externallinkinterceptor.class); @override public boolean prehandle(httpservletrequest request, httpservletresponse response, object handler) throws exception { logger.info("prehandle ~ invoked"); } } it supposed intercept before request handle following controller method: @controller @preauthorize("isauthenticated()") @requestmapping("/assay/process") public class variantprioritizationscontroller extends assaybasecontroller{ private static final logger logger = logger.getlogger(variantprioritizationscontroller.class); @requestmapping("/openanalyticalprojectforassay") public modelandview openanalyticalprojectforassay(httpsession session,@requestparam(value = "analyticalprojid", required=true)string projectid) throws pand

java - How to create and use a two dimensional array of classes -

i experimenting 2 dimensional array of classes in java. wrote following (wrong) code: public class gameevent { static int launch_alien = 0; static int end = 1; long time; long cum_time; int alien_type; int event_code; } then gameevent[][] event_array = new gameevent[max_levels][max_events]; and accessed code below (read comment in code): event_array[lev][ctr].event_code = code; // nullpointer exception @ runtime so question is, least painful way change code works. gameevent[][] event_array = new gameevent[max_levels][max_events]; this allocates array of references gameevent objects not objects themselves. to allocate obects necessary every cell of array: for (int = 0; < max_levels; ++i) (int j = 0; j < max_events; ++j) event_array[i][j] = new gameevent();

XML CDATA not returning properly with simplexml_load_string() nor SimpleXMLElement() (PHP) -

i can pull of non-cdata fields. not summary field. i've exhausted know try. below close get, summary field returning blank. return if var_dump of whole file of course, can't access specific fields. please help! thanks! xml sample <?xml version="1.0" encoding="utf-8"?> <zatom:feed xmlns:zatom="http://www.w3.org/2005/atom" xmlns:z4m="http://namespaces.zope.com/zc/syndication" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us"> <zatom:updated>2013-05-09t14:46:12z</zatom:updated> <zatom:title>partner feeds</zatom:title> <zatom:author><zatom:name>zillow</zatom:name></zatom:author> <zatom:id>urn:zillow:wsls20130509:0000</zatom:id> <zatom:entry z4m:content-type="zc.z4mcontent.story" z4m:status="published"> <zatom:updated>2013-05-09t14:46:12z</zatom:updated> <z4m:dateline term="syndicated"/

jstree Drag node is not selected -

i can click on node select it, marks node selected. multi select works great well. i can drag selected node(s) however, without above mentioned selection dragging node not select (.bind("select_node.jstree", function (e, data) fires on mouseup) if have nodes selected , drag node ; these selected nodes not deselected. basically,how emulate windows explorer drag , drop functionality ? to deselect selected nodes, call function before selecting current node. $("#tree").jstree("deselect_all"); call above function , go on selecting current node followed code. cheers!

java - When i need to use hashMap because it is not synchronized -

i know hashtable synchronized, whereas hashmap not. as per knowledge synchronization means accessing object @ time 1 thread. so there no problem while using hashtable. in project using hashmap. used in many places. till did not problem hashmap. so when synchronization concept come picture(i.e using hashmap). can use hashmap in places using hashtable? can use hashtable in places using hashmap? so there no problem while using hashtable not - in situations, hashtables require external synchronization (for example while iterating). when synchronization concept come picture (i.e using hashmap)? if have class holds hashmap: public class someclass { private map map = new hashmap(); } and access map several threads, might unexpected behaviour , should use adequate synchronization. as long access map single thread or local variable within method, fine. can use hashmap in places using hashtable? cf. above: yes if map not accessed seve

node.js - adding a new route to node express -

i'm trying add new route in express app keep getting error when trying start server. error c:\development\node\express_app\node_modules\express\lib\router\index.js:252 throw new error(msg); ^ error: .get() requires callback functions got [object undefined] here files, i'm new node let me know if left out important file routes/furniture.js exports.furniture = function(req, res){ res.render('furniture', { title: '4\267pli' }); }; routes/index.js /* * home page. */ exports.index = function(req, res){ res.render('index', { title: '4\267pli' }); }; views/furniture.ejs <!doctype html> <html> <head> <title>4&middot;pli -- architecture</title> <link rel='stylesheet' href='/stylesheets/style.css'/> <link href='http://fonts.googleapis.com/css?family=didact+gothic' rel='stylesheet' type='text/css'> </head> <bod