Posts

Showing posts from January, 2011

sql server - Rails 4 - MS SQL select * statement returning total count -

i'm trying run select statement on table in ms sql server 2008 database within rails application related gem acts-as-taggable-on if helps any. there no model/controller/activerecord table, doing tags.all (or of normal methods) won't anything. i'm on arch linux, ruby 2.1.6 rails 4.1.11. i want "name" field returned, i'll settle on returning of fields select * statement. from rails console, these commands i'm running. sql = "select * tags" activerecord::base.connection.execute(sql) which returns: select * tags => 191 what expected 191 rows of fields (id:integer 4, name:string 255, taggings_count:integer 4) running similar select statement within ms sql server manager software returns expected output. the database.yml connected ms sql database. its sql statement trying run count(*) query instead of * query. but, if run count(*) query, returns 1 instead of 191. i'm lost, co-workers, on causing this. , int

javascript - Testing with protractor using ui-select -

i trying test ui-select protractor. in ui-select have list of countries. html looks like: <ui-select ng-model="datianagrafici.countryofbirth" name="countryofbirth" theme="bootstrap" reset-search-input="true" append-to-body="true" required blur> <ui-select-match placeholder="paese di nascita">{{$select.selected.name}}</ui-select-match> <ui-select-choices repeat="country.code country in countries | filter: {name:$select.search}"> <span ng-bind-html="country.name"></span> </ui-select-choices> </ui-select> my page object looks like: this.country = element(by.model('datianagrafici.countryofbirth')); this.fillform = function(){ this.country.sendkeys('it'); } in spec file have: it('should fill form', function() { form.fillform(); }) but when run test ng-mo

c++ - std::is_copy/move_constructible fails even though copy/move constructors are defaulted -

i have class input, has default move/copy constructors. input(const input &) = default; input(input &&) = default; the following assertions fail however. static_assert(std::is_copy_constructible<input>(), "input not copy-constructible"); static_assert(std::is_move_constructible<input>(), "input not move-constructible"); why that? here full example: #include <type_traits> class { public: a(const &) = default; static_assert(std::is_copy_constructible<a>(), ""); }; int main() { // code goes here return 0; } your problem static_assert in class declaration. compiler can't know sure when reaches static_assert whether class copy- or move-constructible, because class hasn't been defined yet.

Why can primitives not be stored in Java collections, but primitive arrays can? -

list<int> list; //compile-time error list<int[]> list1; //works fine is there reason behavior? know primitives need boxed why not primitive arrays? because java arrays objects, not primitives. , can store references objects in java collections implemented generic types. from java language specification, chapter 10: arrays : in java programming language, arrays objects (§4.3.1), dynamically created, , may assigned variables of type object (§4.3.2). methods of class object may invoked on array. note arrays , generics don't play together. although can create collection of arrays, can't create array of collections. type-checking of array contents performed @ run time. parameterized types of collections not known @ run time, because of type erasure. joshua bloch's "effective java," 2nd ed., "item 25: prefer lists arrays" : for example, illegal create array of generic type, parameterized type, or type parameter. none

tomcat - grails resource tags creating duplicate app context in link -

at times, our code has need create links resources. when happens, looks following: <link rel="stylesheet" type="text/css" href="${resource(dir: '/css/', file: 'uxdashboard-pdf.css') }" media="all"/> however, creates link looks following (note duplicate app context) <link href="/ici/ici/css/uxdashboard-pdf.css" media="all" we not have grails.serverurl or grails.app.context defined. have app.name='ici' set in application.properties. we deploy using tomcat set autodeploy="true" should create application context of 'ici' based on war file name. i not sure second app-context coming from. should not setting app.name in application.properties? specify 'base' parameter, prefer understand duplicate context coming before try work around it. we use apache our front end document server, , apache seems able handle these links see 200 codes returned them. have

javascript - AngularJS : Two-Way Binding an Unknown Property Inside a Directive -

i've built directive creates markdown-friendly text editor. used @ various places throughout site, anywhere end user wants use markdown basic content styling (product descriptions, sort of thing). challenge directive deployed in multiple places, won't editing same property on every model. example, in 1 spot may edit longdescription of product, whereas in spot may edit shortdescription of ad campaign, or bio of user. i need able pass in property want edit directive using scope '=' method permits two-way data binding, property changed both in directive , on original controller, allowing user save changes. problem i'm having if pass property directive: <markdown-editor model="product.description"></markdown-editor> two-way data binding doesn't work, since passes value of description property. know '=' method two-way bind in directive, have pass object attribute value html. can pass entire object: <markdown-editor model=&

javascript - Can people modify/create cookies on my websites domain? -

i have website , making login system using cookies user can stay logged in, believe can't sessions. wanted know if malicious user create or modify existing cookies on domain. know can delete them, that's fine, can create or modify them? anyone can control browser, like. can create, edit , delete cookies. for reason, cookies should long , random (or @ least random-looking point of being indistinguishable random). they should meaningful server, should able relate them user, not meaningful outside server. should long enough , complex enough guessing 1 statistically impossible. your server should careful not make assumptions cookie values receives. instance, submit cookie 2,000 characters in - mustn't cause crash.

Remap Lookup keys in C# using LINQ -

i have lookup looking this: lookup<string, datamodel> lookup; besides have dictionary containing key mappings: dictionary<string, keymodel> keymappings; what want re-map string keys in lookup keymodel entities in following way: lookup <string, datamodel> lookup; || || dictionary<string, keymodel> keymappings; ___________| v lookup<keymodel, datamodel> result; given: dictionary<string, keymodel> keymappings = ...; ilookup<string, datamodel> lookup = ...; the response is: ilookup<keymodel, datamodel> lookup2 = lookup .selectmany(x => x, (grouping, element) => new { key = keymappings[grouping.key], element = element }) .tolookup(x => x.key, x => x.element); so first re-linearize ilookup<,> using selectmany , , recreate ilookup<,> . clearly need keymodel define gethashcode() , equals() , or need iequalitycomparer<keymod

android - Eclipse ADT has stopped working -

few hours , used eclipse working it's not opening ![1][1] i had 2 different versions of eclipse , tried run both none of them working :( even faced same few days back problem workspace go workspace eclipse , remove metadata.log. text file should include information starting up, , stack trace, if java failed.

web services - How to handle SOAP response with omitted/optional/missing nodes -

i using wsdl import wizard embarcadero cpp builder (xe6), , checking returned nodes if null or not , before pass them further, otherwise if node missing (e.g. optional , not returned) i've got av. there more elegant way checking each node ? with large services i've got 50 values check. code generated wsdl import wizard quite messy, it's kinda hard sorted. trying "global" solution, creating default empty values in case they're not returned soap call, without success. appreciated. regards

Override die in Perl and still return correct exit code on Windows -

on windows, want execute when script dies. below block didn't help; think it's because windows don't support signals. $sig{__die__} = sub { qx(taskkill /f /im telnet.exe); core::die @_; } then tried this: end { qx(taskkill /f /im telnet.exe); exit $exit_code; } it performed taskkill , exited exit code 0. need propagate exit_code further processing based on it. end blocks can set $? control exit value. end { qx(taskkill /f /im telnet.exe); $? = $exit_code; }

vb.net - .net - service reference - assigning request values produces nullreferenceexception -

vb.net - vs2010 app. adding service reference & trying provide values request properties. in debug, nullreferenceexception on civicnum line below. have called other web services on same environment way no problem. difference - plain java web services - composite service created using bpel. can call service in soapui , ajax code. anyone able help? (valadd service reference - properties defined right off request object - here - find them under called process in object browser) dim valclient valadd.validateaddressmulticlient = new valadd.validateaddressmulticlient valclient.open() dim myresults new valadd.processresponse1 dim myrequest new valadd.processrequest myrequest.process.civicnum = "212" myrequest.process.place = "boise" myrequest.process.postalcode = "89567" myrequest.process.streetdir = "" myrequest.process.streetname =

ios - Calling method from different class sometimes works and sometimes doesn't -

i trying call set of methods 1 class reside in class. the methods reside in viewcontroller.m class , trying call them other class called myclass.m . sometimes works , doesn't. the errors are unrecognized selector sent class 0x1071c0050 terminating app due uncaught exception 'nsinvalidargumentexception', reason: '+[viewcontroller setprogressvalue:]: unrecognized selector sent class 0x1071c0050' when error suggests went wrong @ [viewcontroller setprogressvalue:] exclusively called within viewcontroller.m resides there. the flow looks this: viewcontroller.methoda -> myclass.methodb -> viewcontroller.methodb this not work, following works viewcontroller.methoda -> myclass.methodb -> viewcontroller.methodc how come first flow doesn't works second does? the error very descriptive. calling method not exist. you're calling setprogressvalue: class method, instance method. please note '+' in error description.

SQL: Count values higher than average for a group -

how can 1 use sql count values higher group average? for example: i have table a with: q t 1 5 1 6 1 2 1 8 2 6 2 4 2 3 2 1 the average group 1 5.25. there 2 values higher 5.25 in group, 8 , 6; count of values higher average group 2. the average group 2 3.5. there 2 values higher 3.5 in group, 5 , 6; count of values higher average group 2. try : select count (*) counthigher,a.q yourtable join (select avg(t) avgt,q yourtable group q) b on a.q=b.q a.t > b.avgt group a.q in subquery count average value both groups, join on table, , select count of values table value bigger average

python - virtualenvwrapper hooks aren't loading automatically -

(following marina mele's taskbuster django tutorial) the virtualenv called tb_test. in $virtual_env/bin/ (~/.virtualenvs/tb_test) pasted postactivate file general hooks folder in $workon_home , added 2 lines looks this: $virtual_env/bin/postactivate #!/bin/zsh # hook sourced after every virtualenv activated. echo "helo" export django_settings_module="taskbuster.settings.testing" however, upon running workon tb_test virtualenv gets activated , postactivate hook not being loaded. no "helo" echo :-( works me. double check using workon activate virtualenv (not source bin/activate ), , activating right virtualenv. if still not work, please provide more information environment (os, versions of involved packages, etc.). did modify of other virtualenv-wrapper hooks? update: maybe created hook in wrong path? if create virtualenv mkvirtualenv , should create postactivate file in right place, have edit it. should in location:

[Solved]Scala/Spark save texts in program without save to files -

my code save val: s result.txt , read file again want know there method code can run directly without save file , read back. i user val textfile = sc.parallelize(s) but next part have error: value contains not member of char import java.io._ val s = (r.capture("lines")) resultpath = /home/user val pw = new printwriter(new file(f"$resultpath%s/result.txt")) pw.write(s) pw.close //val textfile = sc.textfile(f"$resultpath%s/result.txt") old method:save file , read val textfile = sc.parallelize(s) val rows = textfile.map { line => !(line contains "[, 1]") val fields = line.split("[^\\d.]+") ((fields(0), fields(1).todouble)) } i have problem having variable s string data type , doing parallelize on string instead of collection. when run map function iterating on each character in string.

node.js - NodeJs + OracleDB + load sql file -

the problem simple, cant load sql file using oracledb connector. seems doesn´t supoport more 1 sentence. any idea how load sql file? var oracledb = require('oracledb'); var fs = require('fs'); fs.readfile("test.sql", function(err, data) { if (err) { throw err; } connect(data.tostring()); }); function connect(sql) { oracledb.getconnection({ user: "****", password: "***", connectstring: "****" }, function(err, connection) { if (err) { console.error(err.message); return; } connection.execute( sql, [], function(err, result) { if (err) { console.error(err.message); dorelease(connection); return; } console.log(result.metada

wso2esb - update local entry in WSO2 ESB -

how can update local entry in wso2 esb through xml configuration or javascript? when update using set-property() not updating in local entry whole, updating instance. thanks. yes thats right. when u create property instance property saved somewhere in registry , try set property, change value in instance only. save in original local instance first use custom mediator , load desired part in property instance , create output stream , store below props.setproperty("key", "value"); props.store(out, null); where out outputstream instance.

vb.net - Filtering only on DataGridView items -

dv.rowfilter = string.format("name '%{0}%'", txtsearch.text) gridunpaid.datasource = dv i used code above filter , working fine. here want. in data grid view item filter not on database possible? you can filter datagridview without changing datasource using code: ctype(gridunpaid.datasource, datatable).defaultview.rowfilter = string.format("name '%{0}%'", txtsearch.text)

python - exception in sqlalchemy with gevent -

at first. project use sqlalchemy==0.9.3 gunicorn==19.3.0 . runs perfect. recently, upgrade sqlalchemy 1.0.4. then, there exist exception. error sqlalchemy.pool.queuepool[101946]:[myproj]pool => _finalize_fairy exception during reset or similar traceback (most recent call last): file "/srv/virtualenvs/myprojenv/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 631, in _finalize_fairy fairy._reset(pool) file "/srv/virtualenvs/myprojenv/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 765, in _reset pool._dialect.do_rollback(self) file "/srv/virtualenvs/myprojenv/local/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 2519, in do_rollback dbapi_connection.rollback() file "/srv/virtualenvs/myprojenv/local/lib/python2.7/site-packages/pymysql/connections.py", line 711, in rollback self._read_ok_packet() file "/srv/virtualenvs/myprojenv/local/lib/python2.7/site-packages/

sql - How to group and concatenate query results -

say have query this: select dept, person_id form depts which returns following result dept person_id ----- --------- 'sales' 2 'management' 2 'sales' 3 'administrative' 4 'management' 4 how can make query returns following result ? depts person_id ----- --------- 'sales, management' 2 'sales' 3 'administrative, management' 4 not postgresql work ms sql server : select person_id, (select stuff((select ', ' + dept tablename t2 t2.person_id = t1.person_id xml path('')), 1, 2, '')) depts tablename t1 group person_id edit: ;with cte as(your super big query here) select person_id, (select stuff((select ', ' + dept cte t2 t2.person_id = t1.person_id x

c# - Web API parameter is always null -

i have following method in web api: [acceptverbs("post")] public bool movefile([frombody] fileusermodel model) { if (model.domain == "abc") { return true; } return false; } the fileusermodel defined as: public class fileusermodel { public string domain { get; set; } public string username { get; set; } public string password { get; set; } public string filename { get; set; } } i'm trying call through fiddler whenever model set null. in fiddler i've sent composer use post , url there , correct debugger in visual studio breaks when called. request i've setup as: user-agent: fiddler host: localhost:46992 content-length: 127 content-type: application/json the request body as: "{ "domain": "dcas" "username": "sample string 2", "password": "sample string 3", "filename": "sample string 4" }" but whenev

signals - Ruby prevent default CTRL+C output ^C -

i catching signal with rescue interrupt => e but prints: ^cshutting down! is there way prevent default ctrl+c output: ^c any ideas? some terminals support stty -echoctl disable echoing of control characters: `stty -echoctl` begin loop # ... end rescue interrupt => e puts 'shutting down' end if above doesn't work, can disable echoing setting io#echo= false : require 'io/console' stdin.echo = false begin loop # ... end rescue interrupt => e puts 'shutting down' end

android - Why my date comparison not working? -

i have compare user entered date current date & time. using below code. datetimestring = ondate.concat(" ").concat(ontime); simpledateformat = new simpledateformat("yyyy-mm-dd hh:mm"); try { dateobject = simpledateformat.parse(datetimestring); if (new date().after(dateobject)) { dateobject.setyear(new date().getyear()); datetimestring = simpledateformat.format(dateobject); dateobject = simpledateformat.parse(datetimestring); if (new date().after(dateobject)) { dateobject.setyear(new date().getyear() + 1); dateobjectstring = simpledateformat.format(dateobject); } else { dateobjectstring = simpledateformat.for

html - How to target only numbers in a list containing both numbers and alphabets? -

here list items: <ul class="col2"> <li>from $400</li> <li>from $1000</li> <li>sold out</li> <li>from $1400</li> </ul> now want want format numbers ($200,$1000 , $1400) following: droid serif, bold, 36px, #1c1819 and words(from , sold out) following: open sans, bold, 22px, #726850 is there way can it? with html , css need element, in case recommend use <span> : .col2 li { font: bold 22px"open sans"; color: #726850; } .col2 li span { font: bold 36px"droid serif"; color: #1c1819 } <ul class="col2"> <li>from <span>$400</span></li> <li>from <span>$1000</span></li> <li>sold out</li> <li>from <span>$1400</span></li> </ul>

logging - How to redirect python flask werkzeug logs to a log file when using TimedRotatingHandler? -

i've created timedrotatinghandler flask server. logs generated werkzeug still thrown on console. how can redirect these logs log file(test.log) log rotating functionality. code snippet: log = logging.getlogger(__name__) log.setlevel(logging.debug) # add file handler fh = logging.handlers.timedrotatingfilehandler("test.log",when='m',interval=1,backupcount=0) fh.setlevel(logging.debug) # create formatter , set formatter handler. frmt = logging.formatter('%(asctime)s - %(levelname)s - %(message)s') fh.setformatter(frmt) # add handler logger log.addhandler(fh) app.run(host='0.0.0.0', debug=true) the below logs still thrown on console. * running on http://0.0.0.0:5000/ (press ctrl+c quit) * restarting stat 192.168.1.6 - - [25/jun/2015 07:11:13] "get / http/1.1" 200 - 192.168.1.6 - - [25/jun/2015 07:11:13] "get /static/js/jquery-1.11.2/jquery-1.11.2.min.js http/1.1" 304 - 192.168.1.6 - - [25/jun/2015 07:11:13] "get

C# Chart space between series -

i tried create bar chart represent data more series data. seem good,but when run application bar in each data series closed, want modified chart space bar each data series, can not solve problem. and code add 3 data series chart , chart1.series["s1"].points.addxy(1, 5); chart1.series["s1"].points.addxy(2, 6); chart1.series["s1"].points.addxy(3, 7); chart1.series["s1"].points.addxy(4, 2); chart1.series["s1"].points.addxy(5, 8); chart1.series["s2"].points.addxy(1, 5); chart1.series["s2"].points.addxy(2, 6); chart1.series["s2"].points.addxy(3, 7); chart1.series["s2"].points.addxy(4, 2); chart1.series["s2"].points.addxy(5, 8); chart1.series["s3"].points.addxy(1, 5); chart1.series["s3"].points.addxy(2, 6); chart1.series["s3"].points.addxy(3, 7); chart1.series["s3"].points.addxy(4, 2); chart1.series["s3"].points.addxy(5, 8); and cha

python - Substitution happens here, as the completely-expanded BINDIR is not available in configure -

just now, have set linux on cloud platform. i'm trying install python3.4 on centos 6.4. i cannot go out situation. i don't understand what's mean of message below. how can resolve this? $yum install gcc ... $./configure ... ... configure: creating ./config.status config.status: creating makefile.pre config.status: creating modules/setup.config config.status: creating misc/python.pc config.status: creating misc/python-config.sh config.status: creating modules/ld_so_aix config.status: creating pyconfig.h config.status: pyconfig.h unchanged creating modules/setup creating modules/setup.local creating makefile $make ... # substitution happens here, completely-expanded bindir # not available in configure sed -e "s,@exename@,/usr/local/bin/python3.4m," < ./misc/python- config.in >python-config.py # replace makefile compat. variable references shell script compat. ones; -> sed -e 's,\$(\([a-za-z0-9_]*\)),\$\{\1\},g' < misc/pyt

css - IE8 Overflow hidden in table -

http://jsfiddle.net/zwfac/ can't make code work ie8, trully apreciated. (the intention if text exceeds max width shall hidden , shown in tooltip @ hover) td, th { width: 65px; max-width: 65px; white-space: nowrap; overflow: hidden; } placing position: relative stated in many other post doesn't anything. placing position: absolute in parent , position: relative in child stated in other post doesn't anything. also, expected max-width: 65px; never works.

c# - Generating fingerprint of virtual machines -

i'm trying create fingerprint of servers using c#. important logic works virtual servers fingerprint not change when vm migrated host. i found sample on codeplex: http://www.codeproject.com/articles/28678/generating-unique-key-finger-print-for-a-computer using following components create fingerprint: cpu, bios, motherboard, disk, video card , mac address. use computer name. now question is: components not changing after migrate vm host? think cpu , mac address not changing.

c# - SetAllProperties method missing in structuremap Registry -

i have old project needs work doing on it, have run update-package in nuget , following in typeregistry the name 'setallproperties' not exist in current scope the typeregistry follows public class typeregistry : registry { public typeregistry() { for<ilogger>().singleton().use<log4netlogger>(); this.setallproperties(p => p.oftype<ilogger>()); } } can explain why case , point me me resolve problem please. i ran problem well. think method might have been deprecated in newer versions. able accomplish setter injection using policies property of registry class. public class typeregistry : registry { public typeregistry() { for<ilogger>().singleton().use<log4netlogger>(); policies.fillallpropertiesoftype<ilogger>().use<log4netlogger>(); } } edit: just found setallproperties method on policies well. believe either 1 inject property.

sql - PHP PDO sqlsrv executing multiple SELECT COUNT -

i'm @ beginning of pdo learning curve , soaking can learn. please can advise if code below best approach. want find if user has entry in more 1 sql server table try { $conn = new pdo("sqlsrv:server=$pdoserver;database=$pdodatabase;", $pdouid, $pdopwd); $conn->setattribute( pdo::attr_errmode, pdo::errmode_warning ); } catch (pdoexception $e) { die(error_log(print_r("could not connect sql server".$e->getmessage(), true), 0)); } if (isvalidusername($username)) { $res_sites = $res_pr = $res_ta = array(); try { $stmt_pr = $conn->prepare("select count(*) prcounter tbl1 usr_username=:username"); $stmt_ta = $conn->prepare("select count(*) tacounter tbl2 usr_username=:username"); $stmt_pr->bindparam(':username',$username,pdo::param_str); $stmt_ta->bindparam(':username',$username,pdo::param_str); $stmt_pr->execute(); $stmt_ta->execut

css - Can't keep footer down on mobile -

Image
i'm having problems keeping footer @ bottom of page when viewing on mobile. looks - i followed this site (code below) on how keep footer down, worked on desktop not on mobile - html, body { margin:0; padding:0; height:100%; } #wrapper { min-height:100%; position:relative; } #header { background:#ededed; padding:10px; } #content { padding-bottom: 100px; padding-left: 100px; padding-right: 100px; padding-top: 50px; } #footer { width:100%; height:100px; position:absolute; bottom:0; left:0; } here jsfiddle . what doing wrong? try following keep footer @ bottom of page. html { position: relative; min-height: 100%; } body { /* use margin-bottom footer height */ margin: 0 0 100px 0; } .footer { position: absolute; bottom: 0; width: 100%; /* set footer height corresponding body margin-bottom */ height: 100px; background-color: #f5f5f5; } <div class="footer"> footer </div>

java - Paho MQTT cleanSession set to false yet not receiving messages -

i testing mqtt project. able receive messages on topic client had subscribed when client connected. have set qos 1 , cleansession set false. unable receive messages sent subscribed topic when client connects again. in application work done helper service. here code androidmanifest.xml <?xml version="1.0" encoding="utf-8"?> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.access_network_state" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".mainactivity" android:label=

web - Switching between a Vps/Dedi to a Cloud service (Like AWS/Google) -

im planning host app on vps or dedi @ same time want security if there downtime vps. there way can host app on dedi , whenever there outage of sort dedi cloud takes on , there no outage. it looks want call "cloud vps" - virtual machine backed high-availability system, making them more resilient hardware outages. vms backed not openvz/kvm/xen (sadly, many of falsely advertized "cloud"), backed system of shared storage in case physical machine vm running on crashes, worst case reboots afterwards on physical machine, , best case don't notice because gets migrated live. example, i've used such service based on cloudstack.

javascript - jquery to existing php page -

im working on having search result list of bugs im trying use jquery m new jquery . im not able produce search result . can me or guide me how produce table based on name entered here code <?php ini_set('display_errors','on'); include('connection.php'); $result=mysql_query("select * bug"); echo"bug list"; echo "\n"; echo "<table border=1>"; echo"<tr><td>bugid</td><td>name</td><td>description</td><td>priority</td><td>assigned to</td></tr>"; while($row=mysql_fetch_array($result)) { echo "</td><td>" .$row['bugid']. "</td><td>" . $row['name'] . "</td><td>" .$row['description']. "</td><td>" .$row['priority']. "</td><td>" .$row['assign']. "</td></tr>"; } echo &qu

Android Date Picker not working properly -

i trying implement date picker in android. datepicker should appear after tapping on button. yeah,i know it's pretty straightforward being beginner, bit stuck in this. here parts of code relevant task. public class needfragment extends fragment { private datepicker datepicker; private calendar calendar; private textview dateview; private int year, month, day; fragment fragment; string selecteddate=null; public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_need_blood, container, false); button button1 = (button)rootview.findviewbyid(r.id.dialog_btn1); button1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { getactivity().showdialog(999); if(selecteddate != null) {

SQL Query - Add condition in WHERE only IF another condition -

i want in clause where ( i.accountid = @accountid , case when @istest not null b.istest = @istest else 1 = 1 but solution not work. there solution this. want add verification based on @istest value. you want use simple boolean logic: where i.accountid = @accountid , (@istest null or b.istest = @istest) if want make case solution work (just illustrative purposes - it's not idea), you'd need have case return value you'd compare - t-sql doesn't have "bool type" ( bit incredibly-small-integer, doesn't have special syntax): ... , (case when @istest not null @istest else 1 end) = 1

javascript - AngularJS if ng-repeat item is out of parent div - set class -

if item partially or not visible in parent div, need set class "novisible" invisible items (when user scrolling dynamic). how detect, items beyond of border parent div? .item { height:30px; border: 1px solid #ff0000; } <div style="height: 300px; border: 1px solid; overflow: auto;"> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div> <div class="item">item</div>

what is "Right click" keyboard shortcut in Chrome -

what "right click" keyboard shortcut in chrome i want use macro save picture on webpage , need use "right click" keyboard shortcut in position mouse cursor open menu, shift+f10 in chrome not work the menu button right below r. shift

python - What is the most pythonic way to iterate over OrderedDict -

i have ordereddict , in loop want index, key , value. it's sure can done in multiple ways, i.e. a = collections.ordereddict({…}) i,b,c in zip(range(len(a)), a.iterkeys(), a.itervalues()): … but avoid range(len(a)) , shorten a.iterkeys(), a.itervalues() a.iteritems(). enumerate , iteritems it's possible rephrase as for i,d in enumerate(a.iteritems()): b,c = d but requires unpack inside loop body. there way unpack in statement or maybe more elegant way iterate? you can use tuple unpacking in for statement : for i, (key, value) in enumerate(a.iteritems()): # i, key, value >>> d = {'a': 'b'} >>> i, (key, value) in enumerate(d.iteritems()): ... print i, key, value ... 0 b side note: in python 3.x, use dict.items() returns iterable dictionary view. >>> i, (key, value) in enumerate(d.items()): ... print(i, key, value)

ios - Cannot run latest version of xamarin on MAC having OS 10.7.5 -

i have mac mini mac os x lion 10.7.5 , trying install latest version of xamarin studio on mac have windows machine (having latest xamarin studio installed) , want connect mac developing ios app. but cannot run latest version of xamarin on mac machine, can tell me how can create ios app on 10.7.5. what minimum system requirements? xamarin requires platform sdks apple , google target ios or android, , our system requirements match theirs . build ios, you'll need latest ios sdk (currently ios 8.1), ships xcode 6.1 , requires mac osx 10.9.4+ (mavericks) or 10.10 (yosemite) . our visual studio extensions ios , android support non-express editions of visual studio 2010, visual studio 2012 , visual studio 2013. http://xamarin.com/faq

requirejs - Hammer.js events with Marionette.js doesn't work -

i'm trying use hammer.js backbone , marionette , require.js when initialize events , event not fired . i use hammer.js , jquery.hammer extension i : edit : events: { "tap .menu ": " handletap " }, handletape: function(){ console.log("hammer time!"); }, onrender: function () { // instantiate hammer $ el.hammer(). } to reach goal , include hammer.js first , jquery.hammer before backbone , marionette.js. there no error in debug console, event not detected there way bind hammer's events without doing : onrender: function () { // instantiate hammer , bind tap event this.$el.hammer().bind('tap .menu', function () { console.log('hammer time!' }). }

rest - HTTP Redirect to a Partial Response (206) -

i'm building api, , trying make restful possible. to end i've build search 'controller', allows query searchable params, , posting redirect (302) controller/resource result of search. this other controller supports "range:" header allow client request how , in list of items wants. reading http spec, says server should respond 206 partial content if request contains range header. valid http send range header along post request?. it bad me respond first 10 items, 206 if range header wasn't supplied?. 206 give client knowledge can ask more items if needs it. a literal reading of http://www.w3.org/protocols/rfc2616/rfc2616-sec10.html & http://svn.tools.ietf.org/svn/wg/httpbis/specs/rfc7233.html indicates range applicable requests. i wonder why don't use request search, i'm guessing idempotent more appropriate. also note registered range unit bytes, wouldn't useful (see http://www.iana.org/assignments/http-parameters/h

php - Symfony2 - base64_decode in twig -

i need display picture in twig template. picture in controller string encoded in base64, created personal function in service decode base64 : public function base64toimg($base64) { $img_str = 'image/png;base64,'.$base64; $img_data = explode(";",$img_str); $type_img = $img_data[0]; $final_img = explode(",",$img_data[1]); header("content-type:".$type_img); return base64_decode($final_img[1]); } and in controller : $logo = $this->container->get('services.utils')->base64toimg($mydata); echo $logo; die(); it works, when send $logo template render , picture isn't displayed {{ logo }} . tried create own twig function doesn't works also... there solution ? thanks how trying display image inside template? if use base64encoded string you'd need data:image/png;base64,encoded string in image tag. <img alt="embedded image" src="data:image/png;base64,ivborw0kggoa

c# - 2d sprite did not rendered as original image after put in unity -

Image
image size = 2048 x 512px as shown on image uploaded don't know happened 2d sprite many people compress problem still can't fix , tried use unity asset store 2d pack in unity, ever got same? used photo shop make these 2d sprite, used brushes, burn , dodge tools. public gameobject background;

javascript - ^How to parse multiple JSON arrays received from server? -

here json data received server: [ {"name":"a"}, {"name":"b"}, {"name":"c"}, {"name":null} ] [ {"name":null}, {"name":"d"}, {"name":null} ] [ {...}, {...} ] how parse using using jquery in ajax success attribute? here ajax code: $.ajax({ url: '#.php', type: 'post', async: false, data: {}, datatype: 'json', success: function(data){ var str = json.stringify(data); var obj = json.parse(str); for(var i=0; i< data.length;i++) { alert(data[i].name); } }, complete: function(xhr,status){ alert(status); }, error: function(xhr){ alert("an error occured: " + xhr.status + " " + xhr.statustext ); alert("an error occured. please try again"); } }) this co

c# - XMS.NET hanging indefinitely on factory.CreateConnection("username", null); -

i trying connect existing jms queue .net client. know queue working, browsed using ibm mq explorer. in following code, call factory.createconnection keeps hanging - not jump next line, in not show error message. doesnt consume cpu. are there options should try working (or @ least make show me error message of kind)? private static iconnectionfactory getconnectionfactory() { var factoryfactory = xmsfactoryfactory.getinstance(xmsc.ct_wmq); var cf = factoryfactory.createconnectionfactory(); cf.setstringproperty(xmsc.wmq_host_name, "server address"); cf.setintproperty(xmsc.wmq_port, portnumber); cf.setstringproperty(xmsc.wmq_channel, "channelname"); cf.setintproperty(xmsc.wmq_connection_mode, xmsc.wmq_cm_client); cf.setstringproperty(xmsc.wmq_queue_manager, "queuemanager"); cf.setintproperty(xmsc.wmq_broker_version, xmsc.wmq_broker_unspecified); return (cf); } the mai

d3.js - Forced directed D3 Graph setting specific image for each node -

hi have gone through few questions , possible solutions of putting image node in forced directed. of them either putting randomly or 1 image all. there way can assign particular image particular node? creating dynamically , fetching data database. highly appreciated. try shown in fiddle: http://jsfiddle.net/cyril123/n28k7oqo/3/ you can specify data , pass image shown below var graph = { "nodes": [ {"x": 469, "y": 410, 'img': "https://cdn1.iconfinder.com/data/icons/industry-2/96/mine-512.png"}, {"x": 493, "y": 364, 'img': "https://cdn0.iconfinder.com/data/icons/ikooni-outline-free-basic/128/free-09-128.png"}, {"x": 442, "y": 365, 'img': "https://cdn0.iconfinder.com/data/icons/ikooni-outline-free-basic/128/free-17-128.png"}, {"x": 467, "y": 314, 'img': "https://cdn0.iconfinder.com/data/icons/ikooni-

jquery - Pass an argument to callback function -

i want pass argument directly function in jquery. i used $(this).prev() to access previous argument. want access previous argument anytime want, without prev method. current code below $(".a").click(function(){ $(this).next().slidetoggle(1000,function(){ $(this).prev().css("background-color","green"); }); }); use closure merge event object , element single argument list: $(".a").click(function(eve){ (function ( e, p ) { $(e.target).next().slidetoggle(1000,function(){ $(p).css("background-color","green"); }); })( eve, $(this).prev() ); }); you may opt not deliver event object @ all: $(".a").click(function(eve){ (function ( n, p ) { $(n).slidetoggle(1000,function(){ $(p).css("background-color","green"); }); })( $(this).next(), $(this).prev() ); }); of course, actual callback function can

single page application - Angulartics Piwik - Which line(s) should I comment in tracking code? -

i'm using angulartics track single web app. angulartics documentation says in order work need comment automatic tracking lines , quote: "make sure delete automatic tracking line vendor snippet code!" // google analytics example ga('send', 'pageview'); // <---- delete line! since i'm using piwik i'll attach snipet of code provide: <!-- piwik --> <script type="text/javascript"> var _paq = _paq || []; (function(){ var u=(("https:" == document.location.protocol) ? "https://{$piwik_url}/" : "http://{$piwik_url}/"); _paq.push(['setsiteid', {$idsite}]); _paq.push(['settrackerurl', u+'piwik.php']); _paq.push(['trackpageview']); _paq.push(['enablelinktracking']); var d=document, g=d.createelement('script'), s=d.getelementsbytagname('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.

ios - Media queries not working for iPhone series -

i wrote media queries iphone 4/4s , iphone 5/5s , iphone 6 , iphone 6plus . here code: /*for iphone 4/4s*/ @media screen , (min-device-width : 320px) , (max-device-width : 480px) , (orientation: portrait){ /*my styles here */ } @media screen , (min-device-width : 320px) , (max-device-width : 480px) , (orientation: landscape){ /*my styles here */ } /*for iphone 6*/ @media screen , (min-device-width : 375px) , (max-device-width : 667px) , (orientation : portrait) { /*my styles here */ } @media screen , (min-device-width : 375px) , (max-device-width : 667px) , (orientation : landscape) { /*my styles here */ } /*for iphone 6plus*/ @media screen , (min-device-width : 414px) , (max-device-width : 736px) , (orientation : portrait) { /*my styles here */ } @media screen , (min-device-width : 414px) , (max-device-width : 736px) , (orientation : landscape) { /*my styles here */ } for portrait mode , each device's portrait css gets applied successfully. landscape mode of

php - Scheduling App/Commands in Laravel 5 -

here sendbirthdayemailcommand command created under /app/commands/ directory class sendbirthdayemailcommand extends command implements shouldbequeued { use interactswithqueue, serializesmodels; public function __construct() { } } with handler class sendbirthdayemailcommandhandler in /app/handlers/ diretory class sendbirthdayemailcommandhandler { public function __construct() { // } public function handle(sendbirthdayemailcommand $command) { // $reminders = \app\reminder::all()->where('reminder_status','=','scheduled') ->where('reminder_set','=','birthday') ->where('reminder_type','=','email') ->where('reminder_time','<=', \carbon\carbon::now('asia/kolkata')); foreach ($reminders $reminder) { $this->sendemailnow($reminder); } } publi

python programming for multiple path copy and read from default path -

i coping file in default path reading verification. if read fails need copy copy in default path again , read. present logic follows, can 1 suggest syntax copy in path copy bakcup default in failed case? #copying dump cpdump = "cp -rf "+dumpconst.hmc_default_dump_offload_path + i_dump_name + \ " "+destpath self.testlog("copying dump file "+i_dump_name+" path==>"+destpath) try: l_fw_con.su_command(suid, destname, supasswd,cpdump,suidpasswd) except lcbcommandserror,e: raise dumphelpererror(fwerrors.sysdump_setup_error,\ "unable copy dump file.reason:"+e.reason) except sshconnectionerror,e: raise dumphelpererror(fwerrors.sysdump_setup_error,e.reason) self.testlog("dump file copy mount path==>[completed]") dump_verify_tool = dumpconst.dump_verification_tool_dir + \

android - Image display small in lollipop 5.0 -

i showing bitmap image in code through url . image appears correct size in other devices appears too small in lollipop version. how can solve issue? here code: try { string imageurl=params[0]; url = new url(appconstants.base_url+"images/"+imageurl); bm = imagethreadloader.readbitmapfromnetwork(url); bitmap_new = bitmap.createbitmap(bm.getwidth(),bm.getheight(), config.argb_8888); canvas canvas = new canvas(bitmap_new); final int color = 0xff424242; final paint paint = new paint(); final rect rect = new rect(0, 0, bm.getwidth(),bm.getheight()); final rectf rectf = new rectf(rect); final float roundpx = 17.0f; paint.setantialias(true); canvas.drawargb(0, 0, 0, 0); paint.setcolor(color); canvas.drawroundrect(rectf, roundpx, roundpx, paint); paint.setxfermode(new porterduffxfermode(m

How to assign each post to an unique id in Wordpress? -

Image
i trying structure website in format there 2 tables. table 1 used store ids, names , logo each university. table 2 used store degrees each university (1 university have 30 degrees). the goal here create multiple unique posts can reference data table 1 , table 2. ideas? assuming schools post type , degrees post type connecting factor school id. either using custom meta data , add field (school id etc) each post type. or create taxonomy shared both post types refers school id. you able use custom queries degrees school id equals value need. for custom meta: https://codex.wordpress.org/function_reference/add_meta_box for taxonomies: https://codex.wordpress.org/function_reference/register_taxonomy

c# - XML Parsing - Parsing 2 identical named XMLArrays -

i've searched arround did not find solution fit requiremnts. i’m trying parse information of the .csproj file c# object. i'm using function this. method gives posibilbity parse xmlfile long have representation of file c# object cast it. public static object deserializexml(string xmlpath) { if (file.exists(xmlpath)) { object returnobject; xmlserializer serializer = new xmlserializer(typeof (projectconfiguration)); using (filestream fs = new filestream(xmlpath, filemode.open)) { xmlreader reader = xmlreader.create(fs); returnobject = serializer.deserialize(reader); fs.close(); } return returnobject; } return null; } here problem. csproj file shows similar xmlarrays. <itemgroup> <reference include="system" /> <reference include="system.core" /> </itemgroup&g