Posts

Showing posts from January, 2010

jsp - How to handle cq component with same html structure and different css? -

i have 2 jsps 2 cq components have same html structure css different. what best practices refactoring in case? one scenario have single component , set css classes based on input provided author in dialog (component type 1, component type 2), gets messy cause need if checks , set different values css classes. becomes more complicated if add 3rd component same html structure , different css. i suggest use 1 of next approaches: create base component html structure , each design create components have sling:resourcesupertype of base component. , in child components can override css file specific one. base component should made of (at least) 2 jsp files: container class (unique among different designs) contains include of actual component content. class should used in selectors in css file. .container-design-1 .title {} . container can overwritten in child components. jsp content. also can still use component dialogue, populate dropdown menu available designs

excel vba - Setting the cursor in a userform after invalid data entered -

i using following code (in excel 2013 windows 8.1): private sub txtdatebox_exit(byval cancel msforms.returnboolean) if isdate(txtdatebox.value) = false msgbox "enter valid date, such jan 23, 2015" txtdatebox.setfocus end if end sub if enter invalid date msgbox pops when sub exited cursor has moved next textbox on userform. how can cursor believe me want go txtdatebox user enter valid date? codes work fine, cursor i'm having trouble with. same thing happens when user puts invalid data 'bin' text box i.e. cursor jumps next textbox (when function returns "no") instead of ask cursor 'setfocus". private sub txtbin1_exit(byval cancel msforms.returnboolean) isitabin (val(txtbin1)) if binnumfound = "no" msgbox "bin not found, please re-enter" txtbin1.setfocus end if end sub thanks in advance help. if write in cancel = true , prevents cursor leaving textbox

Watir Element exists but not present, but is visible in screenshot -

for reason watir saying footer of page not visible. i have tests setup take screenshots, , can see footer on screenshot of page. i take screenshot doing: @browser.driver.save_screenshot(output + "/" + screenshot) testing lines in code: puts "waiting bottom sticker" watir::wait.until { @browser.div(:id => "bottom-sticker").exists? } puts "bottom sticker found" puts "bottom sticker exists: " + @browser.div(:id => "bottom-sticker").exists?.to_s puts "bottom sticker present: " + @browser.div(:id => "bottom-sticker").present?.to_s puts "bottom sticker visible: " + @browser.div(:id => "bottom-sticker").visible?.to_s test log: waiting bottom sticker bottom sticker found bottom sticker exists: true bottom sticker present: false bottom sticker visible: false watir reporting other elements in page visible , present. bottom-sticker div child of body not b

ruby on rails - rake db:reset throws error -

i'm following napa api framework tutorial on how create apis. on running rake db:reset raising following error warn: unresolved specs during gem::specification.reset: minitest (~> 4.2) warn: clearing out unresolved specs. please report bug if causes problems. rake aborted! nameerror: uninitialized constant virtus::configuration::coercible /home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/virtus-1.0.5/lib/virtus/configuration.rb:40:in `initialize' /home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/virtus-1.0.5/lib/virtus/builder.rb:28:in `new' /home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/virtus-1.0.5/lib/virtus/builder.rb:28:in `call' /home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/virtus-1.0.5/lib/virtus.rb:152:in `model' /home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/representable-1.8.5/lib/representable/coercion.rb:5:in `<class:coercer>' /home/jay/.rbenv/versions/2.0.0-p576

html - Bootstrap variable column height and count without breaking flow -

Image
in actual project there bunch of boxes. using bootstraps grid , column system number displayed horizontally changes based on window size. works wonderfully long boxes equal height. in little example have 11 boxes 1 that's taller others. how can i, without using bootstrap rows or js, have not break flow of boxes? provided couple images demonstrate mean. css .box{ border: solid 1px black; height: 200px; } .taller{ height: 300px; } html <div class="container-fluid"> <div class ="col-xs-12 col-sm-4 col-md-3 col-lg-2 box"></div> <div class ="col-xs-12 col-sm-4 col-md-3 col-lg-2 box"></div> <div class ="col-xs-12 col-sm-4 col-md-3 col-lg-2 box"></div> <div class ="col-xs-12 col-sm-4 col-md-3 col-lg-2 box taller"></div> <div class ="col-xs-12 col-sm-4 col-md-3 col-lg-2 box"></div> <div class ="col-xs-12 col-

twitter bootstrap - appending dynamic buttons to div with jquery -

i'm trying append remove , submit buttons submit , remove div's, div's aren't receiving buttons: <div class="container" style="width:80%"> <div class="panel panel-default"> <div class="panel-heading">image id <div class="btn-group btn-group-sm pull-right"> <div class="btn btn-default submit-button">submit <span class="glyphicon glyphicon-plus"></span> </div> <div class="btn btn-danger remove-button">remove <span class="glyphicon glyphicon-remove-circle"></span> </div> </div> </div> </div> $(function () { $removebutton = $('<button class="btn btn-default remove">') .text('remove ' + imageid.value).appendto($(".remove-button")) .on('click', function () {

javascript - How to clone select options without cloning the select -

say have select: <select id="myselect"> <option value="1">first</option> <option value="2">second</option> <option value="3">third</option> </select> i clone options without having clone select. possible? cloning select not possible in situation. i thought of doing this: $('#myselect').html().clone(); but did not work. update: i have select change on time. have second select in modal. when modal called, need update modal's select same options first modal. both selects have different attributes, can't clone select. the straightforward way copy options primary select secondary select use html() follows: var options = $('#myselect').html(); $('#myselect2').html(options); or in 1 line: $('#myselect2').html($('#myselect').html()); if want manipulate options before copying other select, use clone() array of individual

website - Bootstrap 3 multiple Modal Issues -

i have page open in multiple modals. able have modal appear id="mymodal" example im trying replicate. created second 1 id="redcarpet" , cannot same window popup. im hoping can see error in code , can me fix it. <li class="dropdown"> <a href="#" class="dropdown-toggle dropdown" data-toggle="dropdown" data-hover="dropdown" data-delay="200" data-close-others="false"><span style="color: black; font-family: 'modern regular';">photos</span></a> <ul class="dropdown-menu"> <li> <a href="#redcarpet">red carpet</a> </li> <li> <a href="#" data-t

vba - Form Where User Enters Multiple Fields to Run a Report, Leave Blank to Show All -

Image
i have working form/query/report user enters start date, end date, , type, run report of deposits based on parameters. the user enters info on form (called 'typeanddateselectdeposit'): a report generated using query: i want user able either select 'all types' option, or leave type blank, , have types show on report. how make happen? @ point, if type left blank, nothing shows on report, because every deposit has have type. if user selects value other 'all types' , want rows match value. but if user selects 'all types' or leaves combo blank, don't want filtering based on deposittype . you can write conditions query's where clause ... where [put date selection criteria here] , ( deposittype = forms!typeanddateselectdeposit!type or forms!typeanddateselectdeposit!type = 'all types' or forms!typeanddateselectdeposit!type null )

How to place a wildcard character in a bash string -

i have directory usr/src/code and since use different , people can place anywhere in work space want make long src/code available in directory work such */src/code here have tried , has not worked: #!/bin/bash directory="/src/code" if [ -d "\*$directory" ]; # enter here if $directory exists, if contains spaces echo "true" fi #!/bin/bash directory="*/src/code" if [ -d "\$directory" ]; # enter here if $directory exists, if contains spaces echo "true" fi #!/bin/bash directory="\*/src/code" if [ -d "\$directory" ]; # enter here if $directory exists, if contains spaces echo "true" fi globs can match multiple files, it's better store them in array: #!/bin/bash shopt -s nullglob globstar # enable recursion , 0 matching directories=( **/src/code ) case "${#directories[@]}" in 1) echo "found directory:

string - VB.net- Data type mismatch in criteria expression -

i trying add vote count after selected user ddl. don't see did wrong. dim str string str = "update [vote] set [voteweight] = [voteweight]+1 [userid] = 'dropdownlist4.selectedvalue'" dim conn new oledbconnection("provider=microsoft.jet.oledb.4.0;; data source=" & server.mappath("app_data/final.mdb")) dim cmd new oledbcommand(str, conn) conn.open() cmd.executenonquery() conn.close() the correct way pass value sql command through parameterized query. otherwise errors embedded in string numerous , subtle. in code, single quotes around control value, transform in literal string and, of course, userid field numeric field cannot compared against string if dropdownlist4.selectedvalue = nothing return end if dim str = "update [vote] set [voteweight] = [voteweight]+1 " & _ "where [userid] = @userid" using conn = new oledbconnection(.....)

php - while loop not ending as expected -

i might crazy here, pretty confused why while loop seems never end, causes page continuously load , chokes server several min afterwords. basically have table of photo albums +----+--------+--------+ | id | title | parent | +----+--------+--------+ | 1 | album1 | 0 | +----+--------+--------+ | 2 | album2 | 0 | +----+--------+--------+ | 3 | album3 | 2 | +----+--------+--------+ | 4 | album4 | 3 | +----+--------+--------+ | 5 | album5 | 4 | +----+--------+--------+ | 6 | album6 | 1 | +----+--------+--------+ so have here hierarchy of albums this - album1 ^- album6 - album2 ^- album3 ^- album4 ^- album5 i have table of photos themselves +----+--------+-------+--------+ | id | title | album | master | +----+--------+-------+--------+ | 1 | photo1 | 1 | 1 | +----+--------+-------+--------+ | 2 | photo2 | 2 | 2 | +----+--------+-------+--------+ | 3 | photo3 | 6 | 1 | +----+--------+-------

html5 - How do I add header to each video in a row of videos? -

i have row of videos this: <!-- video #1 start --> <video width="30%" controls> <source src="videos/video1.mp4" type="video/mp4"> should seeing video right now, have failed webmasters. </video> <!-- video #1 end --> <!-- video #2 start --> <video width="30%" controls> <source src="videos/video2.mp4" type="video/mp4"> should seeing video right now, have failed webmasters. </video> <!-- video #2 end --> <!-- video #3 start --> <video width="30%" controls> <source src="videos/video3.mp4" type="video/mp4"> should seeing video right now, have failed webmasters. </video> <!-- video #3 end --> i trying add titles each video layout this: title #1 title #2 title #3 video #1 video #2 video #3 here best attempt, despite failure: <

tfs - How to populate data for SharePoint Team Foundation Server web part burndown, bug progress chart -

we configuring team foundation server web part show dashboards associated burndown, user stories, etc. added active when click on bug progress link, chart not display data. click on burndown link add issues data. when click on task burndown or user story progress, following message "the error occured during attempt establish connection external data source. following connections failed refresh: tfsolareport" i see data correctly populated in chart. appreciated. you need administrator fix this. they need validate configuration , rebuild data warehouse , cube. this occurs because dba thinks know how configure sql, rs, or better microsoft. don't, , should not have permission of tfs subsystems. tfs owns , manages subsystems itself. don't change outside of tfs admin console without direct direction product team.

css - Bootstrap modal stop scrolling on Chrome 41 with mouse scroll/touchpad (but works with up/down keys) -

my objective scrollable bootstrap modal taller screen. problem : on chrome 41 (but not 40) running on yosemite os, bootstrap modal stop scrolling after pops if content height taller screen. what have tried is : - straight bootstrap(v.3.3.1) automatically adds '.modal-open' body tag property of 'overflow: hidden;'. causes modal scrollable. - adjusted widow size , moving pixel, modal scrollable again. - have tried applying overflow: visible; , etc. both body tag , modal no luck. does know problem is? bug chrome 41 introduced on yosemite? using bootstrap 3.3.1 currently. updated scrolling up/down arrow keys work fine not mouse/touchpad scrolling. i experiencing same issue. after quick search found reported on their github , there actual fix proposed 6 days ago, hasn't been accepted yet, means it's not in stable version right now. you can apply proposed fix in css easily: .modal.in { -webkit-transform: translatez(0); tran

user interface - AHK GUI card view flow issue -

gui, 1:add, tab, x-11 y-21 w493 h405 vcardtabs, tab1|tab2|tab3 gui, tab, tab1 gui, 1:add, text,, tab 1 gui, 1:add, button, x352 y330 w100 h30 , next gui, tab, tab2 gui, 1:add, text,, tab 2 gui, 1:add, button, x352 y330 w100 h30 , next gui, 1:add, button, x242 y330 w90 h30 , gui, tab, tab3 gui, 1:add, text,, tab 3 gui, 1:add, button, x242 y330 w90 h30 , gui, 1:show, x-1246 y259 h379 w479, card view gui return 1guiclose: exitapp buttonback: send ^+{tab} return buttonnext: send ^{tab} return i have created card view layout in ahk have problem, have used method of creating set of tabs, , hiding tabs user view outside of viewable program window, users able send commands window cycle through tabs e.g control + tab i wondering if there better way of forming type of gui , have more control, e.g pass onto next tab (panel?) button press if there type of panel view have missed can added avoid issue me alot thankyou i went under assumption w

Neo4j collection function error? -

i running following query meant compare 2 collections nodes set1 , set2. nodes in set2 in set1, , identify nodes in set1 not in set2. however, query returns set of nodes includes of nodes in set1. running query on v2.1.7. suggestions? query: match p=(a:objectconcept{sctid:233604007})<-[:isa*]-(b:objectconcept) nodes(p) set1, p match q=(a:objectconcept{sctid:34020007})<-[:isa*]-(b:objectconcept) nodes(q) set2,set1, p all(x in set2 not x in set1) nodes(p) pneumo unwind pneumo pneumolist return distinct pneumolist.fsn,pneumolist.sctid alternative query, same result: query: match p=(a:objectconcept{sctid:233604007})<-[:isa*]-(b:objectconcept) nodes(p) set1, p match q=(a:objectconcept{sctid:34020007})<-[:isa*]-(b:objectconcept) nodes(q) set2,set1, p none(x in set2 x in set1) nodes(p) pneumo unwind pneumo pneumolist return distinct pneumolist.fsn,pneumolist.sctid your matches don't return 1 row might expect many rows, , comparison done between

java - Fastest/Easiest Way to Parse Text -

i trying parse text looking fastest/easiest solution so. i've tried using regex, taking forever java... here's structure of text trying parse: ***************** id: 1234567 // 7 digit uuid mistakes: there may mistakes here, or there may not mistakes //optional mistake type: mistake background // "yes" or "no" report: <xml><item>blah, blah</item></xml> ***************** in reality file might such: ***************** id: 1234567 mistakes: no: happened on playground report: <xml><item>black eye when playing basketball</item><reason>elbow</reason></xml> ***************** ***************** id: 1234568 mistakes: teacher not watching students @ time of incident yes: teacher turned after seeing altercation report: <xml><item>fight</item><reason>none</reason></xml> ***************** ***************** id: 1234569 mistakes: no report: <xml><it

java - Need to scrape an url from a web page -

i need scrape url website located within javascript code. <script type="text/javascript"> (function() { // somewhere.. $.get("http://someurl.com?q=34343&b=343434&c=343434")... }); </script> i know url starts http://someurl.com?q= , needs have @ least second query parameter ( &b= ) inside, rest of content unknown. i tried jsoup , it's not suitable task. manually fetching page , applying regex pattern on not preferable option since page huge. url quick , safe? you can use regex /\$\.get\("(http:\/\/someurl\.com\?q=[\w.\-%#\/]*&b=[\w.\-%&=\/]*)"\)/g this regex search directly string: $.get("http://someurl.com?q= it allow number of url valid characters occur value of q. it match &b= and again number of valid characters followed opposing quotation marks. tested with match - $.get("http://someurl.com?q=34343&b=343434&c=343434") match - $.ge

java - Get request url from solrj -

i using solrj query index , @ times kick off reindex. we having server issues, want verify url solrj constructing. have tried: public void indexsolr() throws solrserverexception, ioexception { httpsolrserver solr = new httpsolrserver(solrindexpath); logger.info("indexing cp solr @ " + solrindexpath); // reindex pickup new articles modifiablesolrparams params = new modifiablesolrparams(); params.set("qt", "/" + solrdataimportpath); params.set("command", "full-import"); params.set("clean", "true"); params.set("commit", "true"); queryresponse response = solr.query(params); logger.info("index url: " + response.getrequesturl()); } the problem in last line. getrequesturl() null. know solrj indeed calling solr, because in fact kick off index request (most of time). how can intercept or retrieve url solrj constructing request? as des

c++ - Is there a well known algorithm to find self-overlaps within a tolerance distance for linestrings/polygonal chains? -

Image
in following example, taking following linestring input, 2 sub-linestrings output i’m interested in 2 parts between c/d, cutting lines. it's trivially easy between 2 distinct linestrings, within same 1 harder. known problem/is there obvious approach missing ?

xaml - DataTemplate not found in merged ResourceDictionary -

i'm developing universal app windows phone 8.1 , windows 8.1. share of code, i'm willing keep style resources appart. some context : first, right i've started wp8.1 projects related platform. in wp8.1 project, have mainpage.xaml contains pivot control. 1 of pivotitem usercontrol called, clarity purposes, myusercontrol . i created resource dictionary styles.xaml "assets" directory, in both platform projects. then, registered 2 new files shared app.xaml : <application.resources> <vm:viewmodellocator x:key="locator" d:isdatasource="true" /> <resourcedictionary x:key="resourcedictionary"> <resourcedictionary.mergeddictionaries> <resourcedictionary source="/assets/styles.xaml"></resourcedictionary> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources> in wp8.1 project styles.xaml file

jenkins - how to pass a value from bash to groovy? -

i'm working on jenkins install 2 script components. bash bits run first , groovy . i'd able pass value (property? other?) bash script->groovy script. is possible? need write value property file , read in groovy? edit: goal generate build # in bash , pass groovy set description , build # in jenkins display. appears groovy isn't available on build server i'm looking direction. experimenting 'postbuild' plugin , 'env-inject' plugin. open suggestions. here few things consider make successful: make sure you're trying accomplish 1 "execute shell" in jenkins or script. export shell variable variable present in child process execute groovy script. # foo.sh export foo=bar groovy myscript.groovy # myscript.groovy def env = system.getenv() string myvar=env['foo'] println myvar running foo.sh should produce following: ./foo.sh bar

java - I don't understand how to display my calculations -

this program lets user enter loan amount , loan period in number of years. the monthly , total payments should displayed interest rate increments 1/8. far, have gotten far enough calculate 1 amount correctly don't understand how display results. i took picture of instructions problem below: http://imgur.com/s9jebtu import java.util.scanner; class computeloan { public static void main(string[] args) { scanner input = new scanner(system.in); //enter number of years system.out.print("enter number of years integer: "); int numberofyears = input.nextint(); //enter loan amount system.out.print("enter loan amount: "); double loanamount = input.nextdouble(); //declare interest rate double interestrate = 5.000; //obtain monthly interest rate double monthlyinterestrate = interestrate / 1200; //calculate payment double monthlypayment = loanamount * monthlyinterestrate / (1 - 1 /

c# - How to use TPL's ActionBlock to write to a file? -

i building pipeline in .net tpl goes through bunch of data transformation steps , need write output file. thinking using actionblock write file. however, not sure whether can run problems...e.g. multiple threads trying write same file. do need worry write contentions? wondering whether idea set executiondataflowblockoptions.maxdegreeofparallelism value higher 1. cause problems? is there better alternative? i wondering whether idea set executiondataflowblockoptions.maxdegreeofparallelism value higher 1. cause problems? yes, could, depending on do. types in .net not thread-safe, means can't use same object multiple threads @ same time. includes system.io objects filestream . on other hand, if leave maxdegreeofparallelism set 1, shouldn't have issues.

node.js - How to restrict database ports on a cloud host? -

i want set node.js/mongodb app on digital ocean. it's not going see ton of traffic, 1 virtual machine instance plenty. when mongodb starts up, attaches default port 27017. mean port available hits myip:27017 or myserver.com:27017? how make database accessible app? assuming no advanced/customized firewall settings: if mongodb bound 127.0.0.1 accessible machine or local network. if bound 0.0.0.0 or actual network interface connected server, on open internet.

c# - Why is my mock set empty? -

i starting learn unit testing , mocking. i've spent day reading different tutorials, trying find best 1 practice with. i've settled on testing mocking framework (ef6 onwards) using ef6 (modern), seems popular mocking framework (moq). also, quite vanilla , hosted on msdn webset. has decent, right? i've set project specified in example , running debugger through test examples make sure understand going on. test i'm working through follows: [testclass] public class querytests { [testmethod] public void getallblogs_orders_by_name() { var data = new list<blog> { new blog { name = "bbb" }, new blog { name = "zzz" }, new blog { name = "aaa" }, }.asqueryable(); var mockset = new mock<dbset<blog>>(); mockset.as<iqueryable<blog>>().setup(m => m.provider).returns(data.provider); mockset.as<iqueryab

html5 - Html multiple video tags -

i want include video animation website using tag in html5. saw http://www.wildstar-online.com/en/ include video animation on website. question why include 3 video sources ( video/mp4 , video/ogg , video/webm )? used video/mp4 website , worked major browsers. purpose of including 3 sources of video? "multiple source files can specified using element in order provide video or audio encoded in different formats different browsers... allows browser make more intelligent decisions" https://developer.mozilla.org/en-us/docs/web/guide/html/using_html5_audio_and_video

datetime - Accurate Timers in Vanilla JavaScript -

i work creating timers / stopwatches , i've come upon problem. when using setinterval(); , rather ever accurate. i'm using safari 8, , after 20 seconds , can off +-8 seconds . i'm trying time every 10ms requestframeanimation won't cut because i'm not animating. i've come following uses date object var runs = 0, speed = 10, timeout = speed, time = math.floor(new date().gettime() / speed); function timer () { runs += 1; console.log(runs, new date().gettime() / speed); if (math.floor(new date().gettime() / speed) > time + 1) { timeout = speed - (math.floor(new date().gettime() / speed) - time); } else if (math.floor(new date().gettime() / speed) < time + 1) { timeout = speed + (time - math.floor(new date().gettime() / speed)); } else { timeout = speed; } time = math.floor(new date().gettime() / speed); settimeout(function () { timer(); //repeat }, timeout); } t

eclipse - Android - Call requires API level 11 (current min is 8): android.widget.ImageView#setAlpha -

its showing me error on setalpha private void updatenextbutton(){ if(currentposition == totalitem - 1){ nextbtn.setalpha(0.5f); nextbtn.setclickable(false); } else{ nextbtn.setalpha(1f); nextbtn.setclickable(true); } } and log giving following error -- java.lang.nosuchmethoderror: android.widget.imageview.setalpha please me devices giving error. what means defined app run on android versions down version 8. feature want use requires api 11. can set min sdk 11 fix or 3rd party library run feature on api 8. http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

C - Program only doing 1 part of a if else statement -

hey trying create program ask user letter count how many times letter appears in .txt document. have code 99% done whatever if statement put first 1 gives correct amount. #include<stdio.h> #include<string.h> #include<ctype.h> #define n 61 // maximum size of file name file* open_file(void) { char file_name[n]; file* input_file; printf("enter name of input file: "); scanf("%s", file_name); input_file = fopen(file_name, "r"); while (input_file == null) { printf("\nerror: file not found \"%s\"\n", file_name); printf("re-enter file name: "); scanf("%s", file_name); input_file = fopen(file_name, "r");} return input_file;} void main() { char inputletter; char lowerletter; char upperletter; char chr; int upper; int lower; file* input_file = open_file(); printf("enter letter: "); scanf(" %c", &inputletter

sql - Add a proactive counter in SELECT -

i have table this: row# id indicator 1 001 yes 2 001 no 3 001 no 4 001 no 5 001 no 6 001 yes 7 001 no 8 002 no 9 002 no 10 002 no 11 002 no 12 002 no 13 002 no 14 002 yes 15 002 no 16 003 no 17 003 yes 18 003 no 19 003 no 20 003 no 21 003 no 22 004 no . . . . . . 100 020 yes i want have counter count number of every 3 consecutive 'no' , group id. counter function triggers when sees "no". once 3 consecutive rows of "no" occur, counter = counter + 1. no double count allowed. for instance: id = 001, there 3 consecutive "no" row 2 row 4, counter value = 1. since "no" row 2 row 4 have been used, row 3 row 5 can't counted event because of no double count rule.

python - datetime.now() returns wrong day in Django application -

my django application (nginx, uwsgi stack) requests current day calling datetime.now(): def get_drinks(request, drink_type): current_day = datetime.today().strftime("%w") current_day_string = datetime.today().strftime("%a") and show current day on website. bizarre reason, returning friday, instead of thursday (today). server time is: server:~$ date thu apr 9 18:51:02 pdt 2015 and when run datetime.now() in python shell, thursday well: >>> import datetime >>> datetime.datetime.today().strftime("%a") 'thursday' what's issue here? datetime.datetime.now() not aware of timezone gets current time in system's local timezone. should set time_zone america/los_angeles (pst/pdt) , use_tz true in settings.py file date values created within application timezone aware long import django.utils.timezone . please see timezone documentation more information. time_zone = "america/los_angeles&q

backbone.js - Make the URL for a Backbone Collection Dynamic -

i backbonejs newbie. i have scenario want make url of collection dynamic. essentially following 2 urls want load collection from: http://localhost:3001/employees http://localhost:3001/employees/searchbyname/john both url return same collection, difference being first url returns results while 2nd 1 based on search criteria. i have search field in form , based on whether search field empty or contains search value, want toggle between these urls. examples have seen either records filter in view or dynamic url have seen id added existing url single record instead of records. so first question : how can achieve dynamic url fetching collection? my 2nd question : how call collection differently based on search field value collection picks appropriate value. somecollection = backbone.collection.extend({ url: function() { if(this.searchname!=null) return baseurl + "/" + "searchbyname" + "/" + this.searchname;

javascript - Testing Angular Service resolve promise in error callback -

i trying figure out how test 403 response in following code. code works expected. realized using 403 not best option here out of control right , cant change it. new js testing feel missing , have reached end of knowledge. appreciated. this.joinitem = function(item, joinoption) { var deferred = $q.defer(), joinurl = ('http://testurl.com/company/items/abc456/join', joindata), joindata = { match: { minid: joinoption['id'] } }; $http.post(joinurl, joindata, { headers: headers }) .success(handlejoinsuccess) .error(handlejoinerror); function handlejoinsuccess() { deferred.resolve({status: 204}); }; function handlejoinerror(joinedresponse, status) { var joineditems = joinedresponse['joined_items']; if (status === 403) { deferred.resolve({ joineditems: joineditems, status: status }); } else { deferred.reject({ status: status });

javascript - Replacing underscores with spaces PHP -

i want search in array , replace occurrences of underscores spaces , implode array string new line character. however, i'm facing difficulties in replacing underscores array. here's code: $array = array('this_that','is','an','array'); function fixarraykey(&$arr) { $arr=array_combine(array_map(function($str){return str_replace("_"," ",$str);},array_keys($arr)),array_values($arr)); foreach($arr $key=>$val) { if(is_array($val)) fixarraykey($arr[$key]); } } fixarraykey($array); print_r($array); edit 1: i want search entries of true , replace yes in same array, optimal solution goal. i recommend using array_walk_recursive $array = array('this_that','is','an','array'); array_walk_recursive($array,function(&$v){ $v = str_replace('_',' ',$v); }); print_r($array);

c# - Playing sounds in WPF as a resource -

this question has answer here: how play wpf sound file resource 2 answers first of all, i've searched site , looked @ this unfortunately did not me much. whenever click frog image made, want play .wav file resource. here's code: void newfrog_mouseup(object sender, mousebuttoneventargs e) { system.media.soundplayer player = new system.media.soundplayer(@"g:\cosr3s\frogsandlilypads\frogsandlilypads\sounds\frogcroak.wav"); player.play(); } of course worked problem directory changes computer computer, thought i'd have play resource. don't know how that. new programmer, keep in mind. i tried few variations based on aforementioned link , played around it. examples: void newfrog_mouseup(object sender, mousebuttoneventargs e) { uri uri = new uri(@"pack://application:,,,/sounds/frogcroak.wav"); var player = new m

framelayout - how to change android : layout_centerHorizontal = "true" to "false" at runtime -

i know how change layout_centerhorizontal of framelayout dynamically . <framelayout android:id="@+id/myframelayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerhorizontal="true" > </framelayout> use following sample code change attribute for view in relativelayout , relativelayout.layoutparams params = (layoutparams) myframelayout.getlayoutparams();//get old parameters params.addrule(relativelayout.center_horizontal, 0);//change parameter myframelayout.setlayoutparams(params);//set new parameters click learn more relativelayout.layoutparams

mysql - PHP mysqli_fetch_assoc stored into an array -

i having troubles pulling row sql query , storing array. here code. $sql = "select water, importdate customer_table customer_number = '" . $custnum . "';"; $result_of_login_check = $this->db_connection->query($sql); echo $sql . "<br>"; $result = mysqli_query($this->db_connection,$sql); // set array $array = array(); // through query while($row = mysqli_fetch_assoc($result)){ // add each row returned array $array[] = $row; } print_r($array); this output looks when print array, array ( [0] => array ( [water] => 23 [importdate] => 2014-03-29 ) [1] => array ( [water] => 33 [importdate] => 2015-02-22 ) ) while storing, stuck @ trying figure out how copy each row array looks this, array ( [water] => 23 [importdate] => 2014-03-29 )

php - Format returning date format on Symfony2 FOSRestBundle -

is there way change returning date format on webservice built fosrestbundle in symfony2? for example, actual return: {"id":9,"nome":"guilherme","rg":"0000000000","cpf":"000.000.000-00", "nascimento":"1989-06-24t00:00:00+0200" ,"genero":"m"} i want change this: {"id":9,"nome":"guilherme","rg":"0000000000","cpf":"000.000.000-00", "nascimento":"1989-06-24" ,"genero":"m"} thanks. it's add annotation property: @type("datetime<'y-m-d'>") see more: http://jmsyst.com/libs/serializer/master/reference/annotations#type

xpath - how to iterate dynamically over child elements using for in xquery -

i have xml file contains multiple xml documents. in large xml document each document has root node , common xml documents in file. child elements inside root name vary. have write loop iterate dynamically each , every child node , have show on table format. here have pasted xml format below. have multiple xml files in way root node common every file. want map each child element table row , data table column. child elements numbers vary <source> <empname>john </empname> <empid>25825 </empid> <salary> 20000 </salary> <dob> 12-08-1993</dob> </source> <source> <empname>joe</empname> <empid>25826</empid> <salary>20000</salary> <dob>12-07-1993</dob> <source> <source> <emptype>developer</emptype> <address>3155 </address> <mobile>58258365</mobile> </source> <source> <emptype>analyst&l

Implementing angularJs factory or service for bootstrap tabs -

how write service or factory bootstrap tabs using angularjs. placed in 1 controller need common function(repeated code) different controllers. <ul class="nav nav-tabs"> <li data-ng-class="{active:tab===0}"> <a href ng-click="changetab(0)"> <i class="fa fa-list"></i></a> </li> <li data-ng-class="{active:tab===1}"> <a href ng-click="changetab(1)"><i class="fa fa-user"></i></a> </li> </ul> <div data-ng-class="{activetab:tab===0}" ng-show="isactivetab(0)"> tab1 </div> <div data-ng-class="{activetab:tab===1}" ng-show="isactivetab(1)"> tab2 </div> controller $scope.tab = 0; $scope.changetab = function(newtab){ $scope.tab = newtab; }; $scope.isactivetab = function(tab){ return $scope.tab === tab;

Two nested vertical scroll views in android -

i using 2 vertical scroll views(say,parent , child).what issue not able scroll child view instead scrolls whole parent view,is there way can restrict parent view scroll when scroll child scroll view , vice versa? need help...thanks in advance..!! you need handle touch event effectively outerscrollview.setontouchlistener(new view.ontouchlistener() { public boolean ontouch(view v, motionevent event) { findviewbyid(r.id.inner_scroll).getparent() .requestdisallowintercepttouchevent(false); return false; } }); innerscrollview.setontouchlistener(new view.ontouchlistener() { public boolean ontouch(view v, motionevent event) { v.getparent().requestdisallowintercepttouchevent(true); return false; } });

django - Qt send QbyteArray data to python -

i have device produce large amount of data because of specific operation. these data sent through rs232 serial port pc. want use library qserialport of qt receive these data , send these data python program display (such web page of django). the question how send data ( qbytearray or char) python program? using sip extend qt program python? or through network socket? or other solution situation? in addition, gave library pyserial because library unstable in project.

C object code file shows string values in plain text -

i use gcc (on ubuntu) compile c program had few string values don't want end user know. strings used in authentication , passcode file path / passcode etc. when compile program object file has these string values in readable (text) format. there other machine readable characters these strings present in file. expected ? there way tell compiler not print values plain text. thought of having strings encrypted within program, looks on engineering. ...but these strings present in file. expected ? yes, expected. string literals saved in executable. , can see tham all. example, gnu strings prints printable character sequences @ least 4 characters long... see how hide strings in exe or dll?

java - Issue with if statment -

im trying make if statement when r1 , num equal prints r1 wont print. asks product number , when enter nothing prints. main way @ end. please show me im doing wrong? import java.io.*; import java.util.*; import java.lang.*; import java.text.*; public class producttype implements comparable<producttype> { private string partnum; private double price; private int stock; public producttype (string partnum, double price , int stock ){ this.partnum = partnum; this.price = price ; this.stock = stock ; } public producttype(){ partnum = "" ; price = 0; stock = 0; } public void setnum(string partnum) {this.partnum = partnum;} public void setprice(double price) {this.price = price ;} public void setstock(int stock) {this.stock = stock ;} public string getnum() {return partnum;} public double getprice() {return price;} public int getstock() {return stock;} public int compareto(producttype othertype) { int temp = (this.getnum().comp

Android Facebook API and ShareLinkContent -

Image
for android app game have implemented button allows user share result of game. i have integrated facebook sdk, classes known project. manifest contains following tags: <meta-data android:name="com.facebook.sdk.applicationid" android:value="@string/app_id" /> <provider android:authorities="com.facebook.app.facebookcontentprovider16..." android:name="com.facebook.facebookcontentprovider" android:exported="true"/> when run app can share result of game code below. public void onshareresult(view view){ facebooksdk.sdkinitialize(getapplicationcontext()); callbackmanager = callbackmanager.factory.create(); final sharedialog sharedialog = new sharedialog(this); sharedialog.registercallback(callbackmanager, new facebookcallback<sharer.result>() { @override public void onsuccess(sharer.result result) { log.d(log_tag, "success");

go - Finding functions that return a specific type -

perhaps silly question, there way find functions (in standard library or gopath) return specific type? for example there many functions take io.writer argument. want know how create io.writer , there many ways so. how can find ways without guessing @ packages , looking through methods find return io.writer (or whatever other type i'm after)? edit: should extend question find types implement specific interface. sticking io.writer example (which admittedly bad example original question) have way find types implement writer interface, since types valid arguments function takes takes io.writer , answer original question when type interface. in days coding i'm rare in need find functions returning int16 , error (func can return few values in go, know) for second part of question there exists wonderful cmd implements written dominik honnef go honnef.co/go/implements after discover type satisfy conditions can assume constructor type (something func newthetype()