Posts

Showing posts from February, 2014

android - ParseCloud httpRequest post exception -

i trying execute http request in using cloud code module parse.com. invoke android app keep getting exception : com.parse.parseexception:java.lang.illegalargumentexception trying execute post command without body parameters. code below , keeps giving me parse.cloud.define('httprequest', function(request, response) { var requestparams = { 'apikey': '{api_key}', 'currency':'gbp', 'locale':'en-gb', 'adults':'1', 'children':'0', 'infants':'0', 'originplace':'11235', 'destinationplace':'13554', 'outbounddate':'2015-08-19', 'inbounddate':'2015-08-26', 'locationschema':'default', 'cabinclass':'economy', 'grouppricing':'true', 'country':'gb...

java - FetchPlan orientDB incorrect results -

Image
i using orient 2.1-rc4, executed following commands: motive fetch outgoing vertices path. 1. correct result simple graph create class depends extends e create vertex set name="persians" create vertex set name="vikings" create vertex set name="teutons" create vertex set name="mayans" create vertex set name="aztecs" select * v \# |@rid|@class|name 0 |#9:0|v |persians 1 |#9:1|v |vikings 2 |#9:2|v |teutons 3 |#9:3|v |mayans 4 |#9:4|v |aztecs create edge depends #9:0 #9:2 create edge depends #9:1 #9:2 create edge depends #9:2 #9:3 create edge depends #9:2 #9:4 select @this.tojson('fetchplan:in_*:-2 *:-1') #9:2 {"out_depends":[{"out":"#9:2","in":{"name":"mayans","in_depends":["#11:2"]}},{"out":"#9:2","in":{"name":"aztecs","in_depends":[...

python - Fail to understand to me strange re behaviour -

can please explain me, why getting different result when remove lines containing '# duplicate'? import re def nysiis(term: str) -> str: """ returns new york state identification , intelligence algorithm (nysiis) code given term """ if not len(term): return '' else: term = term.upper() table = { r'\w+': '', # remove whitespace , non-word characters r'^mac': 'mcc', r'^kn': 'nn', r'k': 'c', r'ph|pf': 'ff', r'sch': 'sss', r'(ee|ie)$': 'y', r'(dt|nd|nt|rd|rt)$': 'd', # on first letter must no longer change. r'(?<!^)ev': 'af', r'(?<!^)[aeiou]': 'a', r'(?<!^)q': 'g', r'(?<!^)z': 's', ...

java - Exceptions with Spring Data Rest -

i'm starting on concepts of microservices springboot , spring data rest me confusing how can few lines of code. my main question is: have entities , repositories, spring data rest "generates" paths post requests, etc. , repository performs correctly. but how exception handling? example, send post without "name" field , accepted but want return error . how do that? entity @document public class veiculo{ @id private string id; @indexed(unique = true) private string nome; private string tipo; @dbref list<contato> contatos; @dbref list<cliente> clientes; public string getid() { return this.id; } public veiculo setid(string id) { this.id = id; return this; } public string getnome() { return this.nome; } public veiculo setnome(string nome) { this.nome = nome; return this; } public string gettipo() { return this...

sql - MYSQL - Combine rows with multiple duplicate values and delete duplicates afterwards -

so have database set single table. in table have collected source url , description (i scraping product description number of pages). unfortunately have ended multiple rows in database url/source page if there more 1 paragraph. what is, if there multiple rows same url, combine description each row , delete duplicate rows url. my table literally structured so: table +----+----------------------------+-------------+ | id | url | description | +----+----------------------------+-------------+ | 1 | http://example.com/page-a | paragraph 1 | | 2 | http://example.com/page-a | paragraph 2 | | 3 | http://example.com/page-a | paragraph 3 | | 4 | http://example.com/page-b | paragraph 1 | | 5 | http://example.com/page-b | paragraph 2 | +----+----------------------------+-------------+ how want like: table +----+----------------------------+-------------------------------------+ | id | url | description...

ruby on rails - how to remove records from the joined table? -

please solve problem. table posts create_table "posts", force: :cascade |t| t.string "title" t.text "body" end table tags create_table "tags", force: :cascade |t| t.string "tagname" end joined table create_table "posts_tags", id: false, force: :cascade |t| t.integer "post_id" t.integer "tag_id" end model post class post < activerecord::base has_and_belongs_to_many :tags end model tag class tag < activerecord::base has_and_belongs_to_many :posts end i need remove of association table posts_tags. i form set id tags: [3, 18, 21] here controller handles set id_tags: def update if @post.update_attributes(post_params) #add_new_tags(@post) p '------------------1' p params['delete_tags'] p '------------------2' destroy_tags(params['delete_tags'], @post) flash[:success] = t :post_up...

unix - Determine Which Hard Drive the Database-Files/Transaction-Files are Stored -

i have old sybase server database acting up. have tried rebuilding file-system , database file. problem returns. want replace hard drive database-files , transaction-files stored. want determine hard drive because not familiar unix. moreover, want see if files stored in same hard drive operating system or not; if are, need re-install operating system restoring database new hard drive. better if database-files , transaction-files not in same hard drive operating system. please me determine these 2 things. so far, have found these: (1) use sp_helpdb command , find database files , transaction files stored in these logical devices: sybdbs syblogs master sybdbs2 (2) use sp_helpdevice command 4 logical devices shown above, , find logical devices in these physical devices: /dev/rdsk/c0t0d0s1 /dev/rdsk/c0t3d0s4 d_master /dev/rdsk/sybdbs2 (3) when use sp_helpdevice show physical devices, see this: device_name physical_name des...

c++ - Copying text from an MFC CDialog -

i'm working on code inherited. there class (i'll refer logwindow) inherits cdialog. overall logwindow class creates window , prints out text. what need copy text automatically generated in window. i know need sort of mouse , keyboard listener, i'm little lost on how , how select text. i have working code different log window written same person. code has class (i'll refer copylist) inherits clistbox. unfortunately code isn't documented or managed, difficult figure out functions related copying text , functions related other things such auto scrolling. i apologize if unspecific, because of i'm working on i'm limited in how can post. update question information can. you can use getwindowtext or cwnd::getwindowtext text control holds text, copy text inside control, have tinker text if want filtering. you said have clistbox example working know how iterate on items. then can use link clipboard: using windows clipboard , check how handle ...

regex - Regular expression to remove lines containing word with exceptions -

i using regex in powergrep, (this regex search strings lab rad tran) .*((lab)|(rad)|(tran)).*\r\n to search , remove lines in plain text contains strings or part of string , works great. now need more. want keep word laber, remove every other string containing lab, such labor, lab1, alab, alaba, etc. there way "protect" string laber , remove every other string containing lab? tried alter above regex using * includes word laber need keep. solution? you can add exclusions regex in form means of look-ahead: (?m)^.*(lab(?!(?:er|ov)\b)|rad|tran).*$ the (?!(?:er|ov)\b) lookahead check if sequence lab not followed er or ov , word boundary. i adding alternation look-ahead because ask "protect" laber , labov . also, since looking whole lines, can make use of multiline mode (?m) , ^ / $ anchors.

php - How to multiply each element of N vectors to each other N^N times -

the problem have multiply each element of n vectors each other. example, if there 2 vectors name x,y . each has 3 elements. such x={x1,x2,x3} , y={y1,y2,y3} . multiplication following m1={x1*y1}, m2={x1*y2}, m3={x1*y3}, m4={x2*y1}, m5={x2*y2}, m6={x2*y3}, m7={x3*y1}, m8={x3*y2}, m9={x4*y3} i can using 2 'for' loops. problem number of vector variable. can x,y,z or x,y or w,x,y,z . how can multiply them? there mathematical name of operation. one of idea consider vectors 1 matrix. here solution problem. syntax may different or depends on programming language using. store first element , perform multiplication of upcoming arrays. each , every element of arrays being multiplied 1 one. <?php function multiplyvector($a=array(),$b) { $count_a = count($a); $count_b = count($b); if($count_a) { for($i=0;$i<$count_a;$i++) { for($j=0;$j<$count_b;$j++) { $result[] = $a[$i] * ...

How to use jquery to load external html data in a variable in phonegap -

i using phonegap create small app. have url points server somewhere giving me simple html either has "available" in body or has else. i trying write jquery recognize "available" , populate element information. it's enough shows word "available". this have now, doesn't append paragraph: <p class="result">x</p> <script> $( "#result" ).load( "http://someurl.com", function() { $('p.result').append(result); }); </script> thank in advance, antonio your code wrong. do not complicate this. wrote: <script> // $(function() { ... }); same $(document).ready(function() { ... }); // calls function after dom ready manipulations. $(function() { $(".result").load("test.html"); }); </script>

Executing an URL from MQL4 -

Image
on mql4 code need execute external url/link in order update table, i have added url in allowed url list option. however got following error : any idea how solve problem ? . ps: using mt4 build 840 this warning reminds set ( check [ x ] ref. fig1 below ) permit(s) in mt4 terminal tools -> options ( ctrl + o ) both [allow automated trading (expert advisor per se )] , [ allow webrequest listed url: / add formatted link...] must checked [ x ] allow... for further problem resolution, the mcve-compliant pieces of information needed . as minimum ( there yet nothing posted ) the following pieces needed reproduce / verify trouble indicate having webrequest() call, ( noted earlier, stackoverflow encourages post whole expert advisor code-snippet, having full context, right in question, helps form mcve-compliant part of stackoverflow original post right when asking it. image erased url part not provide valuable reproducing error claim have problem ) : /...

arrays - Ranking Values in Javascript object -

what @ values "water" , rank them lowest highest adding new key:value in. however if value of water same want assign same rank. so far have this, works in orders assigns rank, unsure how can check other values see if same. if same guess assign 'index' instead of 'index + 1' var results = { schedules: [ { water: 10326.11, milk: 231.27, cola: 171.85 }, { water: 10326.11, milk: 231.27, cola: 171.85 }, { water: 1500, milk: 231.27, cola: 171.85 } ] }; results = _(_.sortby(results.schedules, "water")).foreach(function (water, index) { water.waterrank = index + 1; }); console.log(results); js fiddle here store previous value , previous index, check if value repeating , assign index. this var index = 0, prevvalue = 0; _(_.sortby(results.schedules, "water")).foreach(function (water, i) { if(prevvalue != water.water) index++; prevvalue = water.water; results.schedules[i].waterran...

eclipse - Maven SCM - Git time out -

i tried import existing project eclipse using git scm plugin maven. if use git command line , import maven project manually works fine, scm plugin throws time out error: read timed out after 30.000 ms in eclipse preferences, changed remote connection time out git without effect. effects egit. how change settings maven git scm plugin? thanks in advance! you raise bug against m2e project @ https://bugs.eclipse.org if think it's missing feature maven support.

jsp - Which role plays URI in identifying JSTL tag libraries? -

when using jstl tags in .jsp files or jsf facelets have declare tag libraries want use. example (jsp): <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> example (jsf): <html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core"> it said uri not play role other making namespace unambiguous , provide additional documentation. not believe this. know facelet/.jsp not load information uri via internet. correct uri must somehow used identify correct tag library. could explain how done? i checked this: if change 1 letter in uri exception: org.apache.jasper.jasperexception: /todolist.jsp(10,61) pwc6188: absolute uri: http://java.sux.com/jsp/jstl/core cannot resolved in either web.xml or jar files deployed application the uri defined within taglib defintion file. without correct uri reference cannot resolved. name or key. for example core.tld <description>...

javascript - How the dialog window is updating the main table in angularjs? -

i have list of tasks, each task can edited new dialog window. after closing dialog shows edited tasks. question how table ng-model connected ng-model of dialog window. please see demo task in table filling through ng-repeat , and expression. when click edit open new dialog. in dialog ng-model="selectedtask.description" defined , in angulur ` $scope.selectedtask = task;' define. till here every thing o.k, how when dialog closed how updated info showed in table. <body ng-app="myapp" ng-controller="tasksctrl"> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#">todo api client demo</a> </div> </div> <div> <table class="table table-striped"> <tbody> <tr> <td style="width: 1px;"></td> <td> <b>task</b...

multithreading - Onchanged c# appending form -

i trying append textbox everytime there change in log text file in c#. below code cant seem it. keep tells me access textbox component in main form thread c# public form1() { initializecomponent(); string currentpath = system.environment.currentdirectory; filesystemwatcher watcher = new filesystemwatcher(); watcher.path = currentpath; watcher.notifyfilter = notifyfilters.lastaccess | notifyfilters.lastwrite | notifyfilters.filename | notifyfilters.directoryname; watcher.filter = "*.*"; watcher.changed += new filesystemeventhandler(onchanged); watcher.enableraisingevents = true; } private void onchanged(object source, filesystemeventargs e) { textbox1.appendtext("hello ah"); } filesystemwatcher delivers events on different thread, have marshall appendtext calls ui dispatcher: textbox1.dispatcher.begininvoke(new action(() => { textbox1.appendtext("hello...

How to extract tgz file using java -

is there java code extracts 'tgz' file. searched lot didn't any. first converted tar file , used code extract tar file. tar file contains xml, sh , tgz files getting stucked. code is: public class test1 { public static void main(string[] args) throws exception{ file file = new file("d:\\delta\\interactive\\qml_windows\\development\\onemedia\\"); final list<file> untaredfiles = new linkedlist<file>(); final inputstream = new fileinputstream("d:\\onemedia\\onemedia-dal-504-v4.tar"); final tararchiveinputstream debinputstream = (tararchiveinputstream) new archivestreamfactory().createarchiveinputstream("tar", is); tararchiveentry entry = null; while ((entry = (tararchiveentry)debinputstream.getnextentry()) != null) { final file outputfile = new file(file, entry.getname()); if (entry.isdirectory()) { if (!outputfile.exists()) { ...

date - Misaligned data and duplicate keys using Deedle? F# -

i have data has reference date , publish date. similar economic reports published/released on different dates reference (i.e. q4 gdp 2014 references date 12/31/2014 published following week on 01/07/2015). multiple references date values can published on single publish date. want able add data has similar structure misaligned , duplicate reference , publish dates. below sample of data item a: publish_itema reference_itema value_itema 2002-01-10 00:00:00.000 2001-09-30 00:00:00.000 83 2002-02-14 00:00:00.000 2001-12-31 00:00:00.000 48 2002-05-23 00:00:00.000 2002-03-31 00:00:00.000 57 2002-08-15 00:00:00.000 2002-06-30 00:00:00.000 41 2002-12-31 00:00:00.000 2002-09-30 00:00:00.000 18 2003-02-13 00:00:00.000 2002-12-31 00:00:00.000 18 2003-05-22 00:00:00.000 2003-03-31 00:00:00.000 29 2003-08-21 00:00:00.000 2003-06-30 00:00:00.000 40 2003-12-31 00:00:00.000 2003-09-30 00:00:00.000 51 2004-12-16 00:00:00.000 2002-12-31 00:00:00.000 17 2004-12-16 00:00:00.000 20...

java - How to prevent all project from attack, seems like spring didn't protect all site -

spring security i have prevent attack (xss , xframe ,x-content) but resault owasp zap , seems pretect jsp file ,not project for example, these site under webcontent still can't prevent attack http://localhost:8080/my_project/javascript/login.js http://localhost:8080/my_project/javascript/manager.js http://localhost:8080/my_project/ui/bootstrap/dist/css/bootstrap.min.css how can protect web site ? here method now: add securityheadersinterceptor.java public class securityheadersinterceptor extends handlerinterceptoradapter { @override public void posthandle(httpservletrequest request, httpservletresponse response, object handler, modelandview modelandview) throws exception { response.setheader("x-content-type-options", "nosniff"); response.setheader("x-frame-options", "deny"); response.setheader("x-xss-protection", "1; mode=block"); super.po...

html - Responsively scale css-animated logo made up of multiple, overlayed, different-sized images -

so i'm having trouble making multi-image, overlayed, animated logo become responsive. here recreation of logo: https://jsfiddle.net/vk0w42z6/ i've been struggling few hours now, , have tried could. i've used css transforms, html trickery, , doesn't seem working. the main problem images differently-sized, can largest image shrink using simple max-width:90vw; but smaller, overlayed images aren't scaling down. so please me make logo responsive? things i've tried: make container relative, , children absolute some css display trickery. (will keep adding people recommend things) well, if absolutely need html/css responsive logo only, i've managed achieve implementation follows: jsfiddle you can play around percent values until satisfied. should meet of needs. p.s. removed animation because there lot of unnecessary css there interfering layout. can implement again. html: <body style="background-color:#1c1c1c;"...

Bootstrap validation not working with bootstrap select -

when apply bootstrap validation on form , have drop downs (select) bootstrap chosen list. it validates not showing error message validator drop downs. basically when apply bootstrap dropdown make select list fancy , easy use hides native html select , creates new custom options. when native drop down hidden hides validation message applying inline css property display:none . so here quick fix it. #country { display: block !important; height: 0; margin-top: -14px; visibility: hidden; } by default set display block , set visibility hidden , work magic.

c# - ASP.NET Web Api - Target URI and deployment -

so i'm brand new developing api, have existing mvc website published on azure, , create api using asp.net web api template in new project. my question in deployment. how can deploy api target address like: www.mymvcwebsite.com/api/etc... i don't want modify existing mvc site contain api i've seen posts mention less secure, , tutorials i've seen web api template , i'm learning scratch. within publish azure settings in visual studio gives option publish existing site...would achieve want or there more it? jk you need configure routes want be. routes.maphttproute( name: "api default", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional } ); see here

solrj - How to configure and run Solr full dataimport from MySQL using Java? -

i want run dataimport in solr using java. have gone through link solrj full-import not working , there have given how run full import command java, , in other links found how query solr indexed data, requirement is, data import write configuration file below <?xml version="1.0" encoding="utf-8" ?> <dataconfig> <datasource type="jdbcdatasource" driver="com.mysql.jdbc.driver" url="jdbc:mysql://localhost:3306/test_db" user="root" password="cloudera"/> <document> <entity name="emp" query="select id,name emp"> <field column="id" name="id"/> <field column="name" name="name"/> </entity> </document> </dataconfig> and configuration file information provide in solrconfig.xml below <requesthandler name="/dataimport...

api - How to pull nested fields out when serializing -- Django Rest Framework -

i have serialized model looks below: { name: "...." section: [ { section_name: "..." group:[ {"group_name": "..."} ] }, ] } is there way can pull out group_name under django rest framework such that: { name: "...." section: [ { section_name: "..."}, ] group_name:[ { group_name: "..." } ] } the reason why want such can use django filter filter on group_name. for reason, couldn't seem make relatedfilter work under django rest framework filter (third party package: https://github.com/philipn/django-rest-framework-filters/blob/master/rest_framework_filters/filters.py ), , looking workaround this. would love hear better ways approach problem. thank in advance! you can use source attribute of serializer field bring related object fields top level. class myserializer(serializer...

php - PhpMailer - Is sending message but not pulling the form data -

this question has answer here: what difference between single-quoted , double-quoted strings in php? 10 answers i have tried make simple php contact form, turned out needed use smtp , phpmailer because it's hosted on windows server. have set contact form using example document on phpmailer website. having trouble pulling data form. email send in body shows as: > name: $name > > email: $email > > message: $comment i know there lots of questions on here stackoverflow, can't seem figure out. php <?php require 'phpmailer/phpmailerautoload.php'; $name = $_request['name']; $email = $_request['email']; $comment = $_request['comment']; $mail = new phpmailer; $mail->smtpdebug = 2; // enable verbose debug output $mail->issmtp(); /...

RegEx to swap only the first 2 digits of a middle part of a string? -

i seem have quite difficult task ahead need solve xquery , regular expressions. the case: have alphanumeric string variable length of 20 30 chars first 2 digits of middle part (char 5 char(length-5)) of string should swapped , if there no or 1 digit in middle part 10th , 11th char of string should swapped. so, few examples: string: abcde12345fghij67890 (more 1 digit) output: abcde21345fghij67890 (swap first 2) string: 1a2b3c4d5e6f7g8h9i0j1k2l3m4 (more 1 non adjacent digits) output: 1a2b3c5d4e6f7g8h9i0j1k2l3m4 (swap first 2 of middle part) string: 34gf7asjkabaa4sfdlencxnkil9qrx (only 1 digit in middle part) output: 34gf7asjkbaaa4sfdlencxnkil9qrx (so, swap char 10 , 11) my pseudocode this: function changestring(orgstring) newstring:=replace(orgstring, regex-1st-digits-in-middle-pattern, regex-swap) if newstring=orgstring #when there no 2 digits swap newstring:=replace(orgstring, regex-10/11char, regex-swap) return newstring i r...

c# - Count DataGridCells according to a boolean AttachedProperty -

i have e highlighting mechanism changes background of datagridcell according searched pattern. <setter property="converters:datagridtextsearch.istextmatch"> <setter.value> <multibinding converter="{staticresource searchvalueconverter}"> <binding relativesource="{relativesource self}" path="content.text"/> <binding relativesource="{relativesource self}" path="(converters:datagridtextsearch.searchvalue)" /> <binding relativesource="{relativesource self}" path="column.header" /> </multibinding> </setter.value> </setter> and trigger defined : <style.triggers> <trigger property="converters:datagridtextsearch.istextmatch" value="true"> <se...

delphi - Can't open bitmap file using default program -

i have form has timage component on displays images directory. clicking timage component opens file using default program. for example, clicking jpeg image file launch windows photo viewer. reason when clicking bitmap image file doesn't open, doesn't anything. opening file outside program through windows open via windows photo viewer. below code i'm doing when clicking timage component. procedure tfrmcase.imageclick(sender: tobject); begin shellexecute(handle, 'open',pchar(filen), nil,nil,sw_shownormal) ; end; you have known wrong if had done error checking david suggested. check following code: uses winapi.shellapi; procedure tform22.button1click(sender: tobject); var command: string; info: tshellexecuteinfo; myfilename: string; begin myfilename:= 'c:\windows\syswow64\oobe\background.bmp'; fillchar(info,sizeof(info),#0); info.cbsize:= sizeof(info); info.fmask:= see_mask_default; info.lpfile:= pwidechar(myfilena...

Does network service discovery on android allows automatic connection after first connection (persistent connection)? -

i want have automatic connection between 2 devices after first connection has happened. nsd on android provide such functionality? have refered link nsd on android http://developer.android.com/training/connect-devices-wirelessly/nsd.html also,we can discover multiple devices on same network, can connect multiple devices on same network? you have use socket connection. once service resolved, application receives detailed service information including ip address , port number. need create own network connection service.

mysql - using multiple list menu and checkbox php -

am retrieving data db , allowing users make multiple selection via check box , selecting level each selected check box. when saving, see selected check boxes in db not level selected. code making selection include ('mysql_connect.php'); $sql = mysql_query("select * competency department = '$department'"); while($row = mysql_fetch_array($sql)) { echo "<tr>"; echo "<td>"; echo"<input type='checkbox' name='comp[]' value= ".$row['id']." /> ".$row['competency']." <br /> </td>"; echo"<td> <select name='level[]'value= ".$row['id']." > <option></option> <option>level 1</option> <option>level 2</option> <option>level 3</option> <option>level 4</option> <option>level 5...

javascript - Passing id to modal box -

i want pass id modal box table showing data database when click on edit button specific information against appear on modal box editing. here html modal , table <table class="table table-striped table-bordered bootstrap-datatable datatable responsive"> <thead> <tr> <th>hall name</th> <th>description</th> <th>capacity</th> <th>price</th> <th>action</th> </tr> </thead> <?php foreach ($data $item) { ?> <tbody> <tr> <td class="center"> <?php echo $item->hallname; ?></td> <td class="center"> <?php echo $item->description; ?></td> <td class="center"> <?php echo $item->capacity; ?></td> ...

Link color to other color xml in Android -

can link 1 color color in android xml? something this: <color name="ring_enabled_color"><color name="ring_disabled_color"/></color> can link 1 color color in android xml? yes can, using @color/color_name . e.g. <color name="ring_enabled_color">@color/ring_disabled_color</color>

Viewing server logs in Eclipse when running a MobileFirst Hybrid App on Android Emulator -

i running ibm mobilefirst platform hybrid app in android emulator. i want see debug messages in eclipse console (wl.logger.debug() statements in main.js). possible? when run same app in xcode on ios simulator,i can see these debug messages in xcode's console. please let me know how can this. did in logcat...? in eclipse, go window > show view > other... > search "logcat". when run application in android emulator (or physical device, doesn't matter), make sure in logcat view. you may need first select device "devices" view (add while adding "logcat" view). you see wl.logger.debug statements client-side file (not adapters) in logcat.

haskell - Sieve gets stuck at the beginning -

i wrote following sieve: isprime :: integer -> [integer] -> bool isprime n = (\i -> n `mod` /= 0) sieve :: [integer] sieve = 2 : [i | <- [3,5..], isprime sieve] but don't understand why gets stuck after first value. running take 10 sieve results in [2, , nothing happens. has infinite recursion. may problem sieve growing , @ same time it's used inside isprime ? reason tried modifying isprime follows, without success: isprime :: integer -> [integer] -> bool isprime n = (\i -> n `mod` /= 0) . takewhile (<n) edit : surprisingly, @jubobs's modification works: isprime :: integer -> [integer] -> bool isprime n = (\i -> n `mod` /= 0) . takewhile (\p -> p^2 <= n) i cannot understand why version of takewhile works while other not. see previous version tested many unnecessary divisors, in finite number nontheless. the code should equivalent following python code: def is_prime(n, ps): in ps: if n % == 0: re...

html - PHP not storing the date in MySQL table column -

i'm having problem storing date correctly in mysql database table under column name 'publicationdate' via html form. // contruct of data public function __construct($data=array()) { if (isset($data['id'])) $this->id = (int) $data['id']; if (isset($data['publicationdate'])) $this->publicationdate = (int) $data['publicationdate']; if (isset($data['content'])) $this->content = $data['content']; } // values post/store webpage forms public function storeformvalues ($params) { $this->__construct($params); if (isset($params['publicationdate'])) { $publicationdate = explode ('-', $params['publicationdate']); if (count($publicationdate) == 3) { list ($y, $m, $d) = $publicationdate; $this->publicationdate = mktime (0, 0, 0, $m, $d, $y); } } } the sql column 'publicationdate' datatype 'timestamp()' 'not null' default 'current_timestamp...

twitter bootstrap - add scrollable option into multiselect jquery -

i use dropdownlist in this demo . list larger demo that's why want add scrollable option. how can add scrollable option dropdown for ul element in example, can set fixed height , set overflow-y property scroll. example in link; ul {height:50px;overflow-y:scroll;}

php - showing syntax error, unexpected ' please can any one know why this error? -

this question has answer here: php parse/syntax errors; , how solve them? 11 answers function multiform_test_menu() { return array( 'multiform_test' => array( 'access callback' => true, 'type' => menu_callback, 'page callback' => 'multiform_get_form', 'page arguments' => array(array('multiform_test1'), array('multiform_test2')), ) ) } showing syntax error, unexpected ' please can 1 know why error?? function multiform_test_menu(){ return array( 'multiform_test' => array( 'access_callback' => true, 'type' => menu_callback, 'page_callback' => 'multiform_get_form', 'page_arguments' => array(array('multiform_te...

python - using reserved words in column names in pandas -

using reserved names column names in pandas not provide error or warning message. code runs through without doing anything. there way turn on kind of warning prevent use of reserved words column names? mwe: import pandas pd index_names = ['1','2','3'] col_names = ['median','a'] df = pd.dataframe(index = index_names, columns = col_names) df.fillna(0, inplace = true) df.ix[1].a = 12 df.ix[1].median = 12 print df output: median 1 0 0 2 0 12 3 0 0 in python, unlike other languages there isn't concept of variables. python has names point objects. since python not strict typed (unlike java or c++ example), have flexibility assign names other objects, names point functions (since functions are, else, object). although extremely flexible (it allows overwrite functionality of objects overwriting names of functions), mean python not warn if try impacts built-in name . called shadowing . it 1 of tradeof...

php - Is server side validation and jQuery Validation both necessary today? -

i have complete jquery validate() validations accross fields in forms, complex , simple validation custom methods. the question ask considering 2015 , browsers support javascript , have enabled default. how necessary server-side validation today, , worth it? if so, latest ideal way know few ways such checking post data , outputting error on submit, going few years now. yes. javascript in browser can disabled user can edit javascript code in browser(not reliable) client side validations save network requests. minimizes load on server. if error, request goes server , respond error. better user experience

drupal 7 - Compass error: File to import not found or unreadable: breakpoint -

for unknown reasons drupal omega 4 subtheme dev environment stopped working of sudden. have narrowed problem down compass issue: % compass watch >>> compass watching changes. press ctrl-c stop. error sass/layouts/sidebar/sidebar.layout.scss (line 3: file import not found or unreadable: breakpoint. load paths: compass::spriteimporter /home/<myproject>/public_html/sites/all/themes/<myproject-theme>/sass /usr/share/rvm/gems/ruby-2.2.1@omega.<myproject-theme>/gems/compass-core-1.0.3/stylesheets /usr/share/rvm/gems/ruby-2.2.1@omega.<myproject-theme>/gems/compass-normalize-1.5/stylesheets /usr/share/rvm/gems/ruby-2.2.1@omega.<myproject-theme>/gems/susy-2.2.5/sass) error sass/layouts/sidebar/<myproject>-sidebar.layout.scss (line 4: file import not found or unreadable: breakpoint. guard running without errors not compiling on scss file changes. % guard start -i 07:25:07 - info - guard watching @ '/home/<myproject...

hadoop - Impala shell hangs when invoked for LDAP users -

i've installed cluster impala , sentry (cdh 5.2) on centos 6.5 using command line , have set openldap (without tls) well. both operating without issues independently. to hadoop cluster configured openldap, i've created required ldap groups hadoop services have made required entries in core-site.xml , impala config file listing ldap uri etc mentioned documentation. when invoke impala-shell ldap users using "impala-shell -l -u test1" test1 valid openldap user, asks password, supply. problem once done - hangs. there absolutely no response @ impala-shell , neither impala logs nor ldap logs reacord activity. tried capturing tcpdump on port 389 (where ldap runs), seems there no communication there impala there no packets exchanged @ all. in contrast, works when invoked without "-l" directive normal centos users. below impala config file: **impala_catalog_service_host=master.server.com impala_state_store_host=master.server.com impala_state_store_port=240...