Posts

Showing posts from 2015

css - Text drops down with smaller window -

i've adapted css use in website , can't quite figure out why 1 aspect of page acting way acting. basically, when shrink window below size horizontally, of text "drops down". becomes issue if user viewing website through ipad vertical orientation. can view issue here . i'm hoping make if window gets smaller, placement of text remains intact. the problem area not have enough space put both side navigation , content on 1 line. make automatically adjust page's width when exceeds decrements of width. this code example, , highly unlikely work. if see css more clearly, provide exact code. @media , (max-width:960px) { /* assuming #wrapper 960px across */ #content {width:560px;} /* opposed 720px */ } edit the content drops down @ 980px, have shrink width after there. @media , (max-width:980px) { #container {width:520px;} }

dns - Get domain name from IP address in Go -

i'm trying resolve host name ip address, apparently proving little more challenging thought it'd be. i've tried using couple of functions, including net.lookuphost method, of them seem returning ip address input. here's code using: package main import ( "fmt" "net" ) func main() { // obtained ping -c 1 stackoverflow.com, should print "stackoverflow.com" addr, err := net.lookuphost("198.252.206.16") fmt.println(addr, err) } for example, package main import ( "fmt" "net" ) func main() { // obtained ping -c 1 stackoverflow.com, should print "stackoverflow.com" addr, err := net.lookupaddr("198.252.206.16") fmt.println(addr, err) } output: [stackoverflow.com.] <nil>

Fallback condition in a mysql select statement -

i want put condition mysql statement. if possible? this current mysql select statement select * `validproduct` `visible` = 1 , `typeid` = 2 , `sizeid` = 3 group `productid` so @ moment, selecting products sizeid = 3. want select products size = 1, , if doesn't exist, select sizeid = 3. my validproducts table contains list of products 6 different sizes associated (which in turn have different pricing). want return of products, lowest sizeid (which have lowest price available product). not products have sizeid 1. so return data product (sizeid 1, $x); product b (sizeid 3, $y) etc here way it: select vp1.* validproduct vp1 inner join ( select productid, min(sizeid) minsize validproduct visible = true , typeid = 2 group productid ) vp2 on vp1.productid = vp2.productid , vp1.sizeid = vp2.minsize , vp1.visible = true , vp1.typeid = 2 group vp1.productid; exp

c# - Loading bar while cmd.exe is running -

what i'm trying do: pass command .cmd, show loading bar while command executes, exit cmd , display message box after progress bar full what's happening: when click button sends command, application hangs, command executed, cmd never exits after it's finished, application remains frozen (until manually close cmd.exe). have no idea how display loading bar while command executes. when loading bar full, that's when i'll display message box. my code: process p = new process(); p.startinfo.filename = "cmd.exe"; p.startinfo.workingdirectory = @"c:\" p.startinfo.windowstyle = processwindowstyle.normal; p.startinfo.useshellexecute = false; p.startinfo.redirectstandardoutput = true; p.startinfo.redirectstandardinput = true; p.startinfo.windowstyle = processwindowstyle.hidden; p.start(); p.standardinput.writeline(command_that's_called); ^ gets executed upon button_click event. things i've tried: p.waitforexit(); // still hangs

google maps - How to highlight only one state or a province using Fusion Table Search Query? -

i know how highlight whole country using google's fusion table api. wondering how highlight region within given country. this how works @ country level, looking @ region (state / province) level highlighting only. // javascript code var table_id = 655491; var query = "select 'kml_4326' "+table_id+" 'name_0' = '"+countryname+"';"; var option = { suppressinfowindows: true, query }; layer = new google.maps.fusiontableslayer(table_id, option); layer.setmap(map);

How to comparatively parse through objects inside a dictionary in C# -

so have person class contains info (firstname, lastname, mother, father, siblings, spouse) , want add people of class person dictionary. comparatively parse through dictionary determine relationship of objects (i.e. given person, find cousins, siblings, etc.). question 2 fold: 1) how should set dictionary<...> , 2) how access properties of each person in list? first tried: dictionary<string, object> dictionary = new dictionary<string, object>(); var human = person.addperson(); // person.addperson() returns new instance of person dictionary.add(human.name, human) // setting key full name, value person object. should try dictionary<string, string> <firstname, lastname> , once matches of people same name, start searching dictionary mother, father, etc.??? seems terribly slow , not right way go. edit: here person class , 1 of other classes (bear in mind i'm setting up, i'll handle user inputs, etc l

python - Selecting incorrect submenu item after hover action -

i'm developing test case in python webdriver click through menu items on http://www.ym.com , , particular 1 meant go through menu item , click on sub-menu item. when running test, looks tries access nested menu items, never clicks on final item. here code go through menu: food = driver.find_element_by_id("menu-item-1654") hov = actionchains(driver).move_to_element(food).move_to_element(driver.find_element_by_xpath("/html/body/div[4]/div/div/ul/li[2]/ul/li/a")).click() hov.perform() the problem here trying click "recipes" submenu "food" menu, happens submenu "france" being clicked under menu "travel" situated right next "recipes. i've tried using find_element_by_id, find_element_by_css_locator, find_element_by_link_text seems select france submenu under travel , not recipes submenu under food. any ideas? edit i using python code run test now: food = driver.find_element_by_xpath("//a[contain

javascript - Does jquery's $.get(...) ajax success function trigger when the file has completed downloading? -

basically want know if 'success function' of jquery's $.get() method fired when whole file has finished downloading. suspect is, want make sure. i'm using series of $.get() requests load files of page (css, javascript, etc) while display 'loading screen'. on each success callback of request, load next file until they're finished, , remove loading screen. the issue randomly, on slow connections (site designed mobile browsing) loading screen disappear css site has not been applied until ~1-2 seconds later user see non-styled site briefly before css applied buttons, etc. here code i'm using loading resources if(!window.myresourceloader) window.myresourceloader = {}; // list of resources load myresourceloader.myresources = new array( "include/resources/.....css", "include/resources/.....css", "include/modules/.......js", "include/...............js", "include/...............js"); // r

sql server - Find the exact line number of error in sql script -

i trying insert 1000 records each insert statement in table called zoneplaces. table having index. when try run script insert on table throws error msg 2601, level 14, state 1, line 56 cannot insert duplicate key row in object 'dbo.zoneplaces' unique index 'ix_zoneplaces'. line 56 start of insert statement. know inserting duplicate value there way find exact line number has error? hope clear.

HTML5-how to open more than one cameras -

i have successful video streaming of local camera use getusermedia() in html5.but 1 camera.i have 2 cameras,how video streaming @ same time. unfortunately not appear possible, yet. see here , comments below article here . user decides via browser settings camera primary, , no option secondary, etc, camera exists of yet.

mysql - Search database for specific tags -

i have image table column called tags . typical entry this: id link tags ------------------- 1 [link] funny,not-cool,work i have search page users can enter tags search images. enter amount of tags separated comma search: funny, fall, fail question is, best way search database these tags? simple like it? know may have been more ideal add each tag in different table , not have them comma separated if need change way tags work will. it better have multiple tables here. first table called images , id , link . second table called tags each row being 1 specific tag such columns id , tag . third table join table called imagetags columns id , image , , tag . image column in imagetags foreign key images , tag column foreign key tags . using example search sql like: select images.link images join imagetags on images.id = imagetags.image join tags on tags.id = imagetags.tag tags.tag in ('funny','fall','fail')

unit testing - How to JUnit test for any output in Java -

i'd test 2 methods below, because based on random output go-to assertequals() won't work. i want test ensure methods producing kind of output. ideas? novice programmer, appreciate help. public void comprandomchoice() { double choice = (math.random() * 100 / 100); if (choice > 0 && choice <= 0.34) { computer.setchoice(handthrow.rock); } else if (choice > 0.34 && choice <= 0.67) { computer.setchoice(handthrow.paper); } else { computer.setchoice(handthrow.scissors); } } public string gamewinner() { string gameresult; if (human.getchoice() == computer.getchoice()) { gameresult = "its tie!"; } else if (human.getchoice() == handthrow.rock && computer.getchoice() == handthrow.scissors || human.getchoice() == handthrow.paper && computer.getchoice() == handthrow.rock || human.getchoice() == handthr

scope - write parent function var in javascript -

how change value of variable in parent function in javascript for example: function parent() { var changeme = 0; function child() { changeme = 1; } } thanks help! the variable changeme within child() referring changeme in parent() . call child() , change it. jsfiddle function parent() { var changeme = 0; function child() { changeme = 1; } child(); alert(changeme); } parent();

javascript - CRM 2011 - Set field's 'requiredlevel' to REQUIRED based on another field's value -

i working on opportunity form in crm 2011. i have 2 fields working with: azdb_payment1type & new_payment1cclast4orcheckgc azdb_payment1type has option set values: visa = 807,370,000 mastercard = 807,370,001 american express = 807,370,002 discover = 807,370,003 check = 807,370,004 cash = 807,370,005 credit rollover = 807,370,006 if value of field (azdb_payment1type) 807,370,004 or less, i'd require new_paymentcclast4orcheckgc field filled out. i created function azdb_payment1type field called "requirecclast_onchange", added below code form's main library: function requirecclast_onchange() { var payment1type = xrm.page.getattribute('azdb_payment1type').getvalue(); alert(payment1type); if (payment1type <= '807,370,004') { xrm.page.getattribute("new_payment1cclast4orcheckgc").setrequiredlevel("required"); } } with code inserted onchange, nothing happens when select cc, tab off field. if chan

how to plot power trendline showing equation and regression coefficient (like in the image below) in gnuplot? -

Image
i trying recreate plot created in ms excel using gnuplot. can done in gnuplot shows power trendline equation corresponding regression coefficient? data has plotted file:'data.txt' , data 'x' column 10 , 'y' column 11. thanks! i managed produce working version of above excel figure. improvement highly appreciated. thanks. code in gnuplot set terminal svg enhanced fname "times-new-roman,12" set xlabel "x" set ylabel "y" set xrange [0:*] set yrange [0:*] set format x "%0.3f" set format y '%0.3f' set title sprintf("y=f(x)") # plot filename="data.txt" plotfile="out.svg" set output plotfile f(x)=a*x**b fit f(x) filename using 10:11 via a,b set label gpfun_f @ graph .15,.95 set label sprintf("a = %g",a) @ graph .15,.90 set label sprintf("b = %g",b) @ g

asp.net - How can we open raddatepicker popup window up the Radwindow popup -

Image
i have raddatepicker control in radwindow.the size of radwindow fixed. when open raddatepicker popup shows scroll bar in radwindow due less space. i don't want show scroll bar. question can open datepicker popup upon radwindow . use contenttemplate of radwindow have controls inside on same page, instead of in iframe: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx .

javascript - clearing div content through php and ajax -

echo '<script type="text/javascript" src="../jquery.js" src="../play.js"> $("#txtcreatureinfo").remove(); </script>'; i wondering why id not working. have line in php file , need remove text inside div . using ajax , all. if want remove text inside div, cannot use .remove(). .remove() delete element. instead should use .html(""). clear text , not remove div. so can write way. echo '<script type="text/javascript">$("#txtcreatureinfo").html("");</script>';

checkbox - how to get the sum of selected checkboxes in android? -

i'am newer. problem @ java. in xml, if have 2 checkboxes, o book o pencil total : . . . i want sum of selected checkboxes. if book=10 , pencil=5. how? give each of checkboxes unique id in xml ( android:id="@+id/book" , android:id="@+id/pencil" ) , in code check if checked so: int sum = 0; if (((checkbox)findviewbyid(r.id.book)).ischecked()) sum += 10; if (((checkbox)findviewbyid(r.id.pencil)).ischecked()) sum += 5;

r - How to use facet_grid correctly in ggplot2? -

Image
i'm trying generate 1 chart per profile following code, keep getting "at least 1 layer must contain variables used facetting." errors. spent last few hours trying make work couldn't. i believe anwser must simple, can help? d = structure(list(category = structure(c(2l, 2l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 3l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 3l, 3l, 3l, 3l, 3l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l), .label = c("4x4", "hatch", "sedan"), class = "factor"), profile = structure(c(1l, 1l, 1l, 1l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 1l, 1l, 1l), .label = c("fixed", "free", "mobile"), class = "factor"), value = c(6440.32, 6287.22, 9324, 7532, 7287.63, 6827.27, 6880.48, 7795.1

php - Force file download PDF 'open with' box says its a Firefox document ?? -

Image
i trying force download pdf file, works fine. problem when show "download box" says "firefox document" should "adobe acrobat document". see images, , below code using 1) force download box gmail, works fine 2) force download box application, says "firefox document" header("pragma: public"); header('expires: mon, 26 jul 1997 05:00:00 gmt'); header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("content-type: application/pdf"); header("content-disposition: attachment; filename=\"".basename($file)."\";" ); header("content-transfer-encoding: binary"); header("content-length: ".filesize(getcwd().$file)); readfile(getcwd().$file); for searching same issue. the ts go solution : add exit @ end (for reasons firefox needs this) header("content-type: application/pdf"); echo $pdf; exit;

c# - Live Tile Update -

i have media application needs display track image , title on live tile. right have following code:- private void setlivetile() { var livetile = @"<tile> <visual version=""1""> <binding template=""tilewidesmallimageandtext01""> <text id=""1"">" + mediacontrol.artistname + " - " + mediacontrol.trackname + @"</text> <image id=""1"" src=" + mediacontrol.albumart + @"""/> </binding> <binding template=""tilesquarepeekimageandtext02""> <text id=""1"">" + mediacontrol.artistname + " - " + mediacontrol.trackname + @"</text>

c# - How to resolve Format Exception Error in asp.net? -

i getting error while debugging. when converting string date time object parse string take date before putting each variable in date time object can 1 suggest me solution how resolve it? protected void btnsubmit_click(object sender, eventargs e) { var employeeid = payrollhelper.context.payroll_personaldetails.where(a => a.employee_code == txtemploycode.text).select(a => a.employee_id).first(); var source = payrollhelper.context.payroll_salarydetails.where(a => a.fkemployee_id == convert.toint32(employeeid) && a.salaryofmonth.value.month == convert.todatetime(lbmonth.text).month).select(a => a); if (source.count() == 0) { var count = payrollhelper.context.payroll_advancemanagements.where(a => a.fkemployee_id == employeeid).select(a => a); if (count.count() != 0) { var salary_ad = payrollhelper.context.payroll_advancemanagements.where(a => a.fkemployee_id

python - Formencode and empty values -

how can write custom validator executed, when user has submitted empty or missing value? i've tried overriding to_python, validate_python, _to_python, _validate_python (and more) methods none of these seem run if user has submitted empty or none value i found able prevalidator i'm not sure if it's best way. problem doing way nothing else gets validated if captcha fails. can use chained_validators instead of pre_validators has inverse effect captcha validated if other fields pass. class loginform(formencode.schema): ... captcha = formencode.validators.string(if_missing=none) pre_validators = [validators.captcha('captcha')] class captcha(formencode.validators.formvalidator): def __init__(self, captcha_name): self.captcha_name = captcha_name def validate_python(self, value_dict, state): if not captcha.test_captcha(value_dict.get(self.captcha_name)): raise formencode.invalid('captcha error', s

How do I integrate Google Talk in my iOS social networking app? -

how integrate google talk in ios social networking app? found this , didn't me. google talk uses xmpp, , has no gdata api. i suggest at: http://code.google.com/apis/talk/talk_developers_home.html you can try following link http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-xmpp-integration/

ios6 - How to disable edit mode in particular cell ios? -

i created tableview in editable mode tableview rows contain (-) symbol, need cells not under editable mode ,if possible, according apple documentation of uitableviewdatasource https://developer.apple.com/library/ios/#documentation/uikit/reference/uitableviewdatasource_protocol/reference/reference.html you can use tableview:caneditrowatindexpath:

unicode - What is this ASCII character code ? -

Image
i want ascii character code of character code red circle. want display symbol in word using c#. ! the u+24b6, b u+24b7, c u+24b8, d u+24b9. this unicode because not in ascii range (\x00-\x7f). see http://www.fileformat.info/info/unicode/char/24b6/index.htm .

node.js - NodeJS + Express + Socket.IO + SSL -

so i'm trying use nodejs express + socket.io. i've looked @ 5 other stack overflow questions, , looked on documentation point eyes feel they're going bleed! i've got work following: var fs = require('fs'), privatekey = fs.readfilesync('/path/to/private.key').tostring(), certificate = fs.readfilesync('/path/to/certificate.crt').tostring(); var options = { key: privatekey, cert: certificate }; var express = require('express'), app = express(express.logger()), https = require('https'), server = https.createserver(options, app), io = require('socket.io').listen(server), routes = require('./routes'); app.configure(function() { app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); app.use(express.bodyparser()); app.use(express.me

c# - Is it possible to open a word document in Rad Editor -

i new use rad editor , want open word document in rad editor edit , save back. possible open word document in rad editor , save file using rad editor. first convert doc file html page try this try link also here then html page code assign rad control radcontrol.text = (html page code)

java - Why does String.split() return extra elements here? -

i trying split string using regexp returns element in array. please help. following program: public class test { public static void main(string[] arg){ string str1 = "{abc}{def}"; string delim = "[{}]+"; string[] tokens = str1.split(delim); (int = 0; < tokens.length; i++) { system.out.println("token value: "+ tokens[i]); } } } output: token value: token value: abc token value: def why first token empty string? how can fixed? the reason have empty initial element target string starts delimiter. splitting ",1,2" on , result in 3 entries, first being blank, same result. (you don't blank @ end because string#split explicitly removes them unless give negative second argument.) if know string start delimiter , it's 1 character, remove it: string[] tokens = str1.substring(1).split(delim); edit: or general case, see bohemian's answer removes first matchi

c - Eclipse + OpenCV + Cygwin --> cv.h: No such file or directory -

Image
hi i'm having troubles in eclipse including opencv library. follow lot of tutorials can't compile anything. here output console. building file: ../hand.c invoking: cygwin c compiler gcc -o2 -g -wall -c -fmessage-length=0 -mmd -mp -mf"hand.d" -mt"hand.d" -o"hand.o" "../hand.c" cygwin warning: ms-dos style path detected: d:\eclipse_workspace_c++\helloworld\default preferred posix equivalent is: /cygdrive/d/eclipse_workspace_c++/helloworld/default cygwin environment variable option "nodosfilewarning" turns off warning. consult user's guide more details posix paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames ../hand.c:3:16: fatal error: cv.h: no such file or directory compilation terminated. subdir.mk:18: recipe target `hand.o' failed make: *** [hand.o] error 1 i'm using opencv2.0. i configured in proyect properties c/c++ build -> settings -> tool settings tab -> compiler ,

html - The closing braces of my C# code are not recognized in a Razor partial view -

i working on asp.net mvc 3 application. use razor views. had problem friday , thought have fixed see private case things worked reason. i have table 4 columns, each row may have different number of fields in 1 cell i'm working on sort of algorithm fill cells info belong them. have : @{ int tempcolumn = 1; } <tr> @foreach (var field in model) { if (field != null) { <td> @for (int = 0; < field.count; i++) { if (field[i].columnno == tempcolumn) { @field[i].questiontext; @field[i].fieldvalue; } else if (field[i] != null) { tempcolumn++; @:</td> @:<td> @field[i].questiontext; @field[i].fieldvalue; } } } @:</td> } </tr> basically idea no matter how many pairs of @field[i].questiontext;

visual c++ - how to enable/disable checkbox on cgridctrl in mfc -

i using mfc grid control 2.27 ( http://www.codeproject.com/articles/8/mfc-grid-control-2-27 ) in project.i enable/disable checkbox on cgridctrl. i'm not able find direct method disable check box.in fact when write folowing line,it disables gridcell on checkbox shown,while checkbox remains enable. m_grid2.getcell(row,col)->setstate(gvis_readonly); plz suggest way disable/enable both checkbox , gridcell @ runtime.

php - prestashop module not showing in left and right column? -

i newbie prestashop modules development. have developed module. working fine in backend (like update , delete inserted values). when tried check function of module frontend not showing. code install module this public function install() { if(!parent::install()) return false; if (!$this->registerhook('leftcolumn')) return false; if (!$this->registerhook('header')) return false; if (!$this->registerhook('rightcolumn')) return false; return true; } the code hook this public function hookhome($params) { global $cookie, $smarty; $value=array(); ..................... ............ return $this->display(__file__, 'filename.tpl'); } i have tried many methods show module in left column , right column of page not showing there. but when tried transplant module admin->modules->positions->transplant module->hook into->displayhome (homepage content) .

using ajax call to popup jquery dialog form -

i have link parameters. when click it, ajax called. when goes action.php, have form php values(from mysql). want pop jquery dialog. i not sure how this. <script> $(document).ready(function(){ $.ajax({ type: "get", url: this.href, cache:false, success: function(response){ if (response.length > 0) { document.getelementbyid('display').innerhtml=wrapperelement; wrapperelement.innerhtml = response; $( "#dialog-form" ).dialog( "open" ); } } }); }); </script> updated codes the body of file <body> <div id="display"></div> echo '<a href="action.php?pldid=' . $pldid . '" class="editbt">edit</a>'; </body> so action.php if (isset($_get['pldid'])&& $_get['pldid&#

networking - Go package syscall conn.Read() is non-blocking and cause high CPU usage -

strangely, in case read() non-blocking , caused high cpu usage. my code: in function main : l, err := net.listen("tcp", ":13798") if err != nil { log.fatal(err) } { // wait connection. conn, err := l.accept() if err != nil { log.fatal(err) } // handle connection in new goroutine. // loop returns accepting, // multiple connections may served concurrently. go reqhandler.tcphandler(conn) runtime.gosched() } function tcphandler : func tcphandler(conn net.conn) { request := make([]byte, 4096) { read_len, err := conn.read(request) if err != nil { if err.error() == "use of closed network connection" { log("conn closed, error might happened") break } neterr, ok := err.(net.error); if ok && neterr.timeout() { fmt.println(neterr) log("client timeout!") break } } if read_len ==

mysql - mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/domain/public_html/config.php on line 31 -

i know problem. have 2 hosting , b , 1 mysql base. on hosting site works same web page (i copy file b) on hosting b doesn't work perfectly. host, login , password date base ok because see news etc. when try login admin panel see: warning: mysql_num_rows() expects parameter 1 resource, boolean given in /home/dmcmetal/domains/mydomain.com/public_html/config.php on line 31 i add config.php file mysql_error(); , see: wrong in syntax obok '=='1' limit 1' w linii 1 here part of config.php file: function get_user_data($id=-1) { if($id==-1) { $id=$_session['id']; } $result= mysql_query("select * `users` `id`=='{$id}' limit 1"); if($result==false) die(mysql_error()); if(mysql_num_rows($result)==0) { // 31 line return false; } return mysql_fetch_assoc($result); } can have idea why works on hosting , doesn't work on hosting b ? there syntax error in query, using double equals when mysql syntax requires si

Access array with variable name inside php stdClass? -

stdclass object ( [tip1] => array ( [text] => <p>test text</p> [format] => 1 ) ) i trying loop of object of objects array for ($i=1;$i<=10;$i++) { echo $fromform->{'tip$i'}['text']; } never worked? use double quotes, echo $fromform->{"tip$i"}['text']; or wiht single quotes, $fromform->{'tip'.$i}['text'];

Confused about Matcher group in Java regex -

i have following line, typename="abc:xxxxx;"; i need fetch word abc , i wrote following code snippet, pattern pattern4=pattern.compile("(.*):"); matcher=pattern4.matcher(typename); string namestr=""; if(matcher.find()) { namestr=matcher.group(1); } so if put group(0) abc: if put group(1) abc , want know what 0 , 1 mean? better if can explain me examples. the regex pattern contains : in it, why group(1) result omits that? group 1 detects words inside parenthesis? so, if put 2 more parenthesis such as, \\s*(\d*)(.*) : then, there 2 groups? group(1) return (\d*) part , group(2) return (.*) part? the code snippet given in purpose clear confusions. not code dealing with. code given above can done string.split() in easier way. capturing , grouping capturing group (pattern) creates group has capturing property. a related 1 might see (and use) (?:pattern) , creates group without capturing property, hence n

java - Select webapp start up page based on domain name -

how select start page of tomcat 7 webapp? there 2 page in webapp , want select based on domain name. example if admin.foo.com show admin.jsp if user.foo.com show user.jsp and if foo.com show index.jsp you have build logic filter or servlet in webapplication. basically, use httpservletrequest.getrequesturl() parse out subomain of request, , redirect visitor appropriate page.

text - How do I make a random word generator in python programming? -

im doing flash card game , must pull data out of text doc , make random word generator each word showing right , 2 wrong answers import random f=open('z:/desktop/keywords.txt','r') lines=f.readlines() words= [] words.append(lines[0]) words.append(lines[2]) words.append(lines[4]) words.append(lines[6]) words.append(lines[7]) words.append(lines[8]) words.append(lines[10]) words.append(lines[12]) words.append(lines[14]) words.append(lines[16]) words.append(lines[18]) words.append(lines[20]) words.append(lines[22]) words.append(lines[24]) words.append(lines[26]) you haven't stated how right answer determined, i'm going assume file 1 question, first line correct, while remaining lines incorrect. illustrate how use python random module . import random f=open('z:/desktop/keywords.txt','r') lines = f.readlines() correct = lines[0] wrong = lines[1:] words = [correct] + random.sample(wrong, 2) print "\n".

java - When saving data it stored only first iterated value -

here code: form<tenantitem> tenantitemform = form(tenantitem.class).bindfromrequest(); string[] itemid = request().body().asformurlencoded().get("idd"); string[] postaction = request().body().asformurlencoded().get("action"); if (postaction == null || postaction.length == 0) { return badrequest("you must provide valid action"); } else { string action = postaction[0]; if ("add".equals(action)) { (string item: itemid){ tenantitemform.get().name = tenantitem.findbyid(item).name; tenantitemform.get().description = tenantitem.findbyid(item).description; tenantitemform.get().image_url = tenantitem.findbyid(item).image_url; tenantitemform.get().price = tenantitem.findbyid(item).price; tenantitemform.get().tenant_id = tenantitemform.get().tenant_id; tenantitemform.get().tenant_location_id = tenantitemform.get().tenant_location_id; tenant

javascript - EaselJS update text object dynamically with onClick -

in code below when click on circle meant update text property of txt using txt.text = "gffdfgdsgsdgsdg"; wont work? know how todo this? function init() { var canvas = document.getelementbyid('easel'); var stage = new createjs.stage(canvas); var circle = new createjs.shape(); circle.graphics.beginfill("rgba(255,255,255,1)").drawcircle(40, 40, 40); var shape = new createjs.shape(); shape.graphics.s('red').ss(10, 'round', 'round').mt(50, 50).lt(250, 250).lt(50, 250).cp(); var shape2 = new createjs.shape(); shape2.graphics.s('blue').ss(20, 'round', 'round').mt(200, 50).lt(250, 250).lt(50, 250).cp(); var txt = new createjs.text("hello createjs!", "15px arial", "#fff"); txt.y = 45; shape.onclick = function (event) { this.x -= 1; }; shape2.onclick = function (event) { this.x += 3; }; circle.onclick

php - Alphabet navigation for magento categories -

Image
i trying implement easier form of navigation list of categories, wondering if point me in right direction of how go setting alphabetic navigation system above list of categories. user must able press on either "a" or "b" , display categories name begins letter. i populating list of categories follows: <?php $children = explode( ",", $this->getcurrentcategory()->getchildren() ); ?> <div class="category-products"> <ul class="products-list"> <?php foreach( $children $child ): ?> <?php $_child = mage::getmodel( 'catalog/category' )->load( $child ); ?> <li class="item"> <img class="product-image" src="<?php echo $_child->getimageurl(); ?>" /> <h3> <?php echo $_child->getname() ?> </h3> <div class="cat-desc"

c# - asp:ImageButton doesn't work as expected -

i have problem asp.net imagebutton control. what is: when click on image redirect login page of google, facebook or twitter, doesn't happen. code login page: <section id="socialloginform"> <h2>use service log in.</h2> <uc:openauthproviders runat="server" id="openauthlogin" /> <asp:listview runat="server" id="providerdetails" itemtype="microsoft.aspnet.membership.openauth.providerdetails" selectmethod="getprovidernames" viewstatemode="disabled"> <itemtemplate> <asp:imagebutton id="login" runat="server" width="40" height="40" imageurl='<%# item.extradata["icon"] %>' alternatetext="log in using <%#: item.providerdisplayname %> account." /> </itemtemplate> <emptydatatemplate> <p>there n

python - Make 2 HTTP-requests in a session through Tor with the same exit-node -

i use library requests make 2 http-requests within session. don't know whether ip adresses same both http-requests (within session). can tell me whether use same ip (important me) or whether tor use 2 different exit-nodes? if remember, tor changes routes after pre-specified number of minutes. i'm tempted time period 10 minutes, i'm not entirely certain. either way, long 2 requests made within time-frame they'll have same ip address.

ios - TableView as subview of UIView not appearing when app lunches in landscape mode -

i developing application in created tableview subview 2 rows contains label , textfield take username , password user. i took this site create kind of want i replace following line uiview *contentview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, 480)]; with uiview *contentview = [[uiview alloc] initwithframe:[[uiscreen mainscreen] bounds]]; and replace tableview = [[uitableview alloc] initwithframe:cgrectmake(0, 0, 320, 440) style:uitableviewstyleplain]; this line tableview = [[uitableview alloc] initwithframe:cgrectmake(self.contentview.bounds.size.width/ 2 - 300, 0, 600, 300) style:uitableviewstyleplain]; this code works fine in portrait mode in landscape mode table view not visible first time , have write code handle view on change in orientation resets view on change in orientation both landscape , portrait thank in advance.. try use methods in view controller: -(void) didrotatefrominterfaceorientation:(uiinterfaceorientation); -(voi

xml - XSLT usage to reach attribute value in structured elements with the same name -

i hope can me problem found no solution @ moment. using xslt first time convert xml. trouble finding using template message element attribute value. btw i'm not generating xml , can't change structure <?xml version="1.0" encoding="utf-8"?> <ns1:message > <ns1:notification> <ns22:message> <ns1:message value="timestamp"> </ns1:message> </ns22:message> </ns1:notification> </ns1:message> assuming namespace declarations missing example have given, can access timestamp xslt looks this: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:ns1="http://ns1.com/" xmlns:ns22="http://ns22.com/"> <xsl:template match="/"> <xsl:value-of select="/ns1:message/ns1:n

html - How to pre-populate specific text from specific referrers URLs to a search form? -

here´s problem: have html page search form, , need take specific parts of specific referrers urls , pre-populate them search form. so user have click on search without manually entering query (as there). here 2 examples referrers urls parameters , directories 1) http://www.bing.com/search?q=tiny+cats&form=mozsbr&pc=mozi (so if referrer bing.com, text "q" param. = "tiny+cats" in case) 2) http://cutestcatpics.com/tag/tiny-cats/pages/1.php (so if referrer cutestcatpics.com, text 2nd. level directory = "tiny-cats" in case) here html page search form: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1- transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <form action="http://search.yahoo.com/search?p=" target="_blank" id="search-box"> <input type="

java - What am I to make of the layout of IDEAs default project structure? -

Image
so ... go file > new project > java module , type in (1) project name , (2) module name , project structure makes sense me: modules nested within project .idea file left outside scope of project tool window: why that? i'd assume 1 .idea file show here? and can crankier if go file > new project > java module , swap order fill in project , module names (so type (1) module name followed (2) project name). in case illogical project structure (i think) later modules, along .idea file, become nested in initial module : this time can peruse .idea file project tool window, though don't see why nested in module: now am aware 1 may tweak project , module paths in wizard, don't default behaviour , not way of nesting modules within modules along project .idea file. in perfect dreamworld, have structure in projectnamefirst project above, along .idea file in project tool window. so ... why aren't things in perfect dreamworld? make of modu

sql - Arithmetic overflow error converting nvarchar to data type numeric when creating string -

trying figure out why getting error happens when creating string exec set @sqlinsertstringfinal = @sqlinsertstring + @suggested_qty+''','''+ @required_qty+''','''+ @system_cost+''','''+ @revised_cost these 4 variables populated convert(numeric(7,2),ltrim(rtrim(floor((case when r.calc_qty > 99999 99999 else r.calc_qty end)/(case when s.plbcf_1 null or s.plbcf_1 =0 1 else s.plbcf_1 end))))), convert(numeric(7,2),ltrim(rtrim(floor((case when r.po_number <> 'none' r.calc_qty else case when r.adj_qty > 99999 99999 else r.adj_qty end end)/(case when s.plbcf_1 null or s.plbcf_1 = 0 1 else s.plbcf_1 end))))), convert(numeric(9,4),ltrim(rtrim(case when s.std_cost null r.std_cost else s.std_cost end))), convert(numeric(9,4),ltrim(rtrim(r.std_cost))) i've check every table used , consistent in column type. non numeric in there r.po_number can of value 'none'

Migrating from restful_authentication to Devise with Rails 2.3.14 -

i in process of using rails upgrade plugin ( https://github.com/rails/rails_upgrade ) bring application 2.3.14 3.2. plugin identified "restful_authentication" needed replaced. after research decided try migrate devise. started looking @ https://github.com/plataformatec/devise/wiki/how-to:-migrate-from-restful_authentication-to-devise , issue ran these instructions not meant rails 2.3.14. can figure out how make of work 2.3.14, biggest block have ran not sure versions of devise, devise-encryptable , other gems use. there simple way check? alliteratively making mistake in trying migrate devise before upgrade, should done other way around? re: there simple way check? short answer no. to know devise gems use, follow directions in devise wiki - need devise , devise-encryptable according wiki. re: 1 first: whatever decide do, idea have stable branch before attempting upgrade. either a) upgrade rails + restful_auth working, or b) use devise + upgrade rails - avoi

bash - Loop through list of names and copy file explained? -

i've written script copy new user account file new user location. works reading list of usernames , copying file location. can't understand why needed done < $user @ end. can please explain this? thanks user=/home/example/new.txt newuser=$user loc=/var/account/ cd /home/example while read newuser cp _newuser.txt $loc/$newuser done < $user to iterate on each line in file /home/example/new.txt , value of variable user pls @ http://en.kioskea.net/faq/1757-how-to-read-a-file-line-by-line < input redirection operator ( http://www.tldp.org/ldp/abs/html/io-redirection.html ) you can delete newuser=$user , since not see use of newuser except while loop. due while , newuser assigned new value each iteration.

How to access Groovy nested enum in Scala? -

scala has trouble accessing: // groovy class outer { enum enum { value } } what needs done allow scala access enum? unlike java, enum in groovy isn't implicitly static. following makes accessible scala: // groovy class outer { static enum enum { value } }

mysql - Trying to compare a rowvalue to form value while in a query using cfif and performing the query -

Image
i know, title sounds confusing literally couldn't think of way word it. anyway, here's mean <cfquery name="search_all" datasource="contactdata"> select distinct people.first_name, people.last_name, state_lkp.state, zip_lkp.zip, number_lkp.phone_number, email_lkp.email, country_lkp.country, address_lkp.address, city_lkp.city, count(distinct email_lkp.email_id) mail_count, count(distinct number_lkp.phone_number_id) number_count, people.people_id people left join state_lkp on state_lkp.people_id = people.people_id left join zip_lkp on zip_lkp.people_id = people.people_id left join number_lkp on number_lkp.people_id = people.people_id left join email_lkp on email_lkp.people_id = people.people_id left join country_lkp on country_lkp.people_id = people.peop