Posts

Showing posts from January, 2013

Android setBackgroundResource doesn't use image depend on dpi -

Image
i wan't use setbackgroundresource method set image button. i have different folders same button in different dpi's when set button code uses drawable folder instead of correct folder resume.setbackgroundresource(r.drawable.resumegrey); the resumegrey copied in right folders diffrent dpi's displaymetrics metrics = new displaymetrics(); getwindowmanager().getdefaultdisplay().getmetrics(metrics); float density = metrics.density; density float , value changed per screen size... so,if have 240*320 density 0.5 320*480 density 1.0 480*800 density 1.5 and set size using density , img.setmaxheight(density*100); and put multiple screen supports in manifest file. multiple screen support

How to host .NET website on amazon web service? -

i want host .net website on amazon web service. did bit research on google , found aws ec2 provides such facility cannot understand , other components(services) needing. found link on aws website gave me estimated monthly expense of hosting. problem quoted various services in quotation ( simple monthly calculator ) cannot understand. please me understand it.

android - Reference library project -

Image
i'm working on android 4.1.2 project, i'm trying add reference this github project following this guide , i've imported project same workspace, , i'm able select , add library , green checkmark. when press "apply" or "ok" dialog closes, , nothing happens (no rebuild). then, when again try see if it's added, it's not there - not red cross. i've tried running project anyway, gives me java.lang.classnotfoundexception: com.handmark.pulltorefresh.library.pulltorefreshgridview first choose library, green checkmark then press "apply" , "ok", , dialog closes , don't build. when trying see if library added, it's not there: suggestions what's wrong? did or did not check "is library" option?

objective c - Make app not open on push notification clicking -

i developing app enables pushnotification.when app in inactive mode receives push notification.when user click push notification app opening.i not want open app on push notification clicking.is possible so?thanks in advance there no way this. why want anyway? should use sound notification instead of banner/alert if don't want user interaction.

javascript - Regular Expression for Alphabetical text with some exceptions -

i looking regular expression text field accepts alphabets, dots(.), brackets, -, & a.b.c abc (new), & co. a-abc. i have regular expression: /^[a-z.&() ]+$/ code: var regex = /^[a-z][a-z.()&-]+$/; var sel = document.getelementbyid("textboxid").value; if (sel != "-- select --") { if (!regex.test(sel.tostring())) { alert("please use proper name."); } } return false; i want string mandatory start alphabet. seems not working when add - same, may syntax wrong. first, note [a-z] not same [a-za-z] , meant. if @ an ascii table , can see range a z includes several special characters may not intend include. second, since dash - denotes range in character class (as above), must included last (or first, more commonly last) in order interpreted literal dash. so, want this: /^[a-za-z.()&-]+$/ and assert starts alphabet: /^[a-za-z][a-za-z.()&-]*$/ ^^^^^^^^ ^ (notice i've changed + quant

windows store apps - WinRT MVVM Search Contract -

i'm using caliburn-micro build windows store app, can't seem find example on how implement search contract using library. how can this? any appreciated. thanks. nigel compileexperience.com pointed out me caliburn micro has sample search implemented. searching here's solution: on app.xaml.cs file, add following method: protected override void onsearchactivated(searchactivatedeventargs args) { displayrootview<searchview>(args.querytext); } where searchview xaml created view displaying results. also, on configure method (still on app.xaml.cs) don't forget register searchviewmodel on container. create searchviewmodel parameter property. have query string when search. , voilá. it's done. implement or call proper search method on viewmodel. you can see sample on caliburn micro code, here.

php - Call model function inside view joomla -

how can call different models , functions in joomla 2.5 view ? model: settings.php // import joomla modelitem library jimport('joomla.application.component.modelitem'); class urcmodelsettings extends jmodelitem { public function getsettings($user_id = '') { $user = jfactory::getuser(); $user_id=$user->id; $db =& jfactory::getdbo(); $query = $db->getquery(true); $query->select('*'); $query->from('#__settings_urc'); $query->where('user_id = '. (int) $user_id); $db->setquery($query); return $db->loadobjectlist(); } } view: view.html.php // import joomla view library jimport('joomla.application.component.view'); /** * html view class helloworld component */ class urcviewurc extends jview { // overwriting jview display method function display($tpl = null) { $model = $

apache - ".htaccess" doesn't work for cache-control at sub directories -

i made own cache-control rule in httpd.conf . , need apply different rules on each different sub directories. i made no-cache .do extension default( httpd.conf ). # use .htaccess files overriding, accessfilename .htaccess ... <ifmodule mod_headers.c> <locationmatch "\.(do)$"> header append cache-control "max-age=0, no-cache, no-store, must-revalidate" </locationmatch> </ifmodule> and need cache directories( .htaccess ). example url : xxx.com/en/product.do so made .htaccess on <webroot>/en . <ifmodule mod_headers.c> <locationmatch "\.(do)$"> header set cache-control "max-age=216000, public, must-revalidate" </locationmatch> </ifmodule> am going wrong? there other way rule different on different directories? nothing <locationmatch> can used in .htaccess ; generate runtime error. also, *.do proxied, in case no filesys

sql - top 1 case in select statement on TSQL -

i having problem on query. how can fix this: select (select case top 1 status when 'inprocess' 'processing' when 'inworkbin' 'waiting in draft' end ics_email_connections_trx a.sessionid = b.sessionid , status <> 'completed' order a.create_date desc) last_status i getting error: incorrect syntax near keyword 'top'. any suggestions? try: select top 1 case status instead of select case top 1 status

graphics - How can I modify how bars are displayed on a R barplot -

Image
i plot 2 graphs of same time serie, first 1 represent value, second frequency of same variable. date 1 2 3 4 5 6 7 ... value v1 v2 v3 v4 v5 v6 v7 ... freq f1 f2 f3 ... the first graph usual plot , second graphics::barplot , problem want x-ticks on same vertical line (after same date). seems barplot centering bars vertical line representing date shifted (zoom on graph bellow see mean) how can arrange ? you without using barplot() , rather plot() different plot "type" argument. , make sure x-axis values same. an old example of mine bollinger bands plotting @ r graph gallery. uses segments() volume bars.

winforms - c# Animation via sequence of pictures -

i made animation in windows forms via c#. have bitmap inside code updates frequently. after each update picturebox draws bitmap. if work big bitmap (e.g 1000 height), draws slow , animation moves slow too. how can avoid lag? ofc can reduce frames animation, dont want that. may use 2d rendering libraries draw image? i'm looking possible solutions. thanks.

wix - upgrade multi instace web application installer -

can upgrade multi instance web application installer? i achieve multiinstance web application deployment, when changed productversion since productcode (guid) remains same in other instances getting following error in log: msinewinstance requires new instance not installed. followed below link multi instance: http://ysdevlog.blogspot.in/2011/08/revisited-multiple-instance.html <instancetransforms property="instanceid"> <instance id="i00" productcode="{guid-here-4e6d-b26b-aa7eafaf526b}" productname="telstrat"/> <instance id="i01" productcode="{guid-here-45a9-a703-5f01fe83380f}" productname="telstrat1"/> <instance id="i02" productcode="{guid-here-471e-9a00-8756c12f358f}" productname="telstrat2"/> </instancetransforms> the productcode must updated able major upgrades. need update productcode in multi-instance transforms.

c# - merge sound file audio and record in Widows 8 Metro Windows Store application -

i have 2 sound files need merge. 1 audio file , other recording file. i using c# build metro style app. there libraries or functionality in .net can use complete this? take naudio , don't know if have version windows store apps. an option write .net web service uses naudio job of merging audio files , send app.

Retriving data from MySQL database in Java -

i have written method in java retrieves data mysql database , adds list. method returns null values few of ids although there data in database. here code: public static list getposttime(int id) { list<timestamp> time = new arraylist(); try { preparedstatement ps; resultset rs; connection con; con = dbconnection.getdbconnection(); string querytime = "select created tbl_posts_98 `makerid` = \'" + id + "\'"; ps = con.preparestatement(querytime); rs = ps.executequery(); while (rs.next()) { time.add(rs.gettimestamp(1)); } } catch (java.lang.throwable t) { //system.out.println(t.getclass().getname()); //this'll tell class has been thrown t.printstacktrace(); //get stack trace } return time; } thank in advance.

sql - Create a table + populate it using another table in One Query -

i'm using access 2000 , have 2 queries: the first 1 is: create table first_table_name (....) the second is: insert first_table_name [(column1, column2, ... columnn)] select column1, column2, ...columnn second_table_name [where condition]; is possible same thing (create table , fill using table) 1 query? thank ! try select column1, column2, ...columnn first_table_name second_table_name [where condition]; first_table_name have same table column second table name

URL parameters stripped on Google Sites? -

using google apps script gadget, can use parameters of url ( http://sites.google.com/.../my-page?urlparameter=value&otherurlparameter=value ) added google sites webpage generate dynamic content. but if try add link page of google site parameters, , save page, parameters deleted : http://sites.google.com/.../my-page?urlparameter=value&otherurlparameter=value becomes http://sites.google.com/.../my-page . same thing when trying publish webpage using apps script service sitesapp.page.sethtmlcontent(yourhmtl) . it doesn't happen when using external urls. how can bypass limitation ? it's possible include relative links pages including parameters. example : in http://sites.google.com/.../home/page-1 , link http://sites.google.com/.../home/page-2?urlparameters overwritten without parameters ../page-2?urlparameters won't be.

python - Plugin in Nagios does not work when using paramiko? -

we're experiencing strange issues nagios. wrote script in python uses paramiko, httplib , re. when comment out code written use paramiko script returns ok in nagios. when uncomment script status returns (null). this our code ssh = paramiko.sshclient() ssh.set_missing_host_key_policy(paramiko.autoaddpolicy()) #ssh.connect(self.get('hostname'),int(self.get('port')),self.get('username'),allow_agent=true) ssh.connect('192.168.56.102' , 22 , 'oracle' ,allow_agent=true) link = '127.0.0.1:4848' stdin,stdout,stderr = ssh.exec_command('wget --no-proxy ' + link + ' 2>&1 | grep -i "failed\|error"') result = stdout.readlines() result = " ".join(result) if result == "": return monitoringresult(monitoringresult.ok,'webservice up') else: return monitoringresult(monitoringresult.critical,'webservice down %s' % result) so when comment out part above if result ==&

c++ - Why is the CPU time different with every execution of this program? -

i have hard time understanding processor time. result of program: #include <iostream> #include <chrono> // function f() time-consuming work void f() { volatile long double d; int size = 10000; for(int n=0; n<size; ++n) for(int m=0; m<size; ++m) d = n*m; } int main() { std::clock_t start = std::clock(); f(); std::clock_t end = std::clock(); std::cout << "cpu time used: " << (end - start) << "\n"; } seems randomly fluctuate between 210 000, 220 000 , 230 000. @ first amazed, why these discrete values. found out std::clock() returns approximate processor time . value returned std::clock() rounded multiple of 10 000. explain why maximum difference between cpu times 20 000 (10 000 == rounding error first call std::clock() , 10 000 second). but if change int size = 40000; in body of f() , fluctuations in ranges of 3 400 000 3 500 000 cannot explai

matlab - How to statistically plot and show the difference between two fluctuations -

this kind of tricky question.so if cannot understand kindly post comments. this data between anchor , source dbm values. if see first set of data between a=30,s=50 , can see fluctuation in dbm values in different channels. taking average of these 4 channel combinations give -72.75 **a = 30 s = 50** , a-s distance = 18.00 rssi value a-chan 0 , s-chan 0 -69 rssi value a-chan 0 , s-chan 1 -73 rssi value a-chan 1 , s-chan 0 -73 rssi value a-chan 1 , s-chan 1 -76 now next case follows in case reverse of above (i.e.) a=50,s=30. can see fluctuations between channels , average dbm value -74.75 **a = 50 s = 30** , a-s distance = 18.00 rssi value a-chan 0 , s-chan 0 -74 rssi value a-chan 0 , s-chan 1 -77 rssi value a-chan 1 , s-chan 0 -73 rssi value a-chan 1 , s-chan 1 -75 now,if see in "a=30,s=50"the dbm value "-72.75" , in "a=50,s=30" dbm value of "-74.75". there fluctuation or difference between the

c++ - Is there any library that provides containers for non-copyable types that are not default-contructible? -

i looking library provides containers std::array (compile-time fixed size, without support aggregate initialization) , std::vector (variable size, continuous memory) work types non-copyable , not default-constructible. specifically, want able pass set of functions constructor used obtain arguments constructors of contained objects. emplace_back , constructor , using lazily evaluated arguments. here (naturally not working) example: class stubborn_type : boost::noncopyable { public: explicit stubborn_type(int value) : value(value) {} private: const int value; }; struct generate_values { generate_values(int initial_value = 0) : current_value(initial_value) {} int operator()() { return current_value++; } private: int current_value; }; /* should create vector containing 10 elements initialized values [0..9] in order. */ magic::vector<stubborn_type> data(10, generate_values()); i need solution compatible c++03 (since

Xcode: Send SMS programmatically -

i want send sms programmatically without showing message controller (for jailbroken iphone). you can not send silent sms app in ios if these things apple reject application not in apple guideline. if want have send webserver using webservices.

defining an initial variable in a new object in php -

i new oop forgive me if question flawed. i writing class fetch , populate data set, performed within loop, return series of index id's populate data of object. within app, need both in loop, , individually. question when (inside or outside loop) initiate class, how define id particular object's item id, used class's methods? $object = new item($itemid); // or $object = new item->4; // ? i not sure how this, or if proper way handle kind of logic. sidenote i writing class under assumption first object collection of commonly used functions exist such, trying clean things up. you need initialize class, , set item id. $object = new item(); $object->item_id = 1;

php - how to fix CConsoleApplication.user undefined in a command class in yii framework? -

i having error , whenever ran simple cron script in shell , idea how fix thing ?, error itself, says .user undefiend, when placed 'user' => array( // enable cookie-based authentication 'allowautologin' => true, 'loginurl' => array('myaccount/blah/login'), in console config, looking "class" ,, class supposed include in array? , user login url using ldap stuff in loggin in , authentication, should ? a cconsoleapplication handling offline tasks. example, application starts cronjob within linux system. application checks each day if registered user of website should change password, because must changed every 3 month. if password expired send email. preselecting users have set scope condition check status of user, scope restricted signed in users on own data: public function scopes(){ return array(..., 'user' => array(

jquery - Drag and drop item to trigger event -

i'm creating website contains section downloading ebook after payment. in order make nice user interface use icon of ebook , icon of shopping cart , allow visitor drag icon of ebook shopping cart in order trigger action leads purchase of ebook. heard function draggable , droppable in jquery ui , draggabilly javascript library. can suggest me other ways achieve or provide proof of concept code? you use jquery ui draggable/droppable/sortable functionalities here: {this jquery ui shopping-cart basic demo plus ability of drop out item shopping cart} http://jsfiddle.net/rr6z5/1/embedded/result/

mysql - Change default collation/character set -

i know has been answered before solutions found not apply system (i've tested them). i want change default collation in mysql. seems setted latin1_swedish_ci , want change utf8_general_ci. the returning solution on net putting default_character_set directive in my.ini default value of utf8, reason gives error. this error. hope can me. 130502 15:45:17 [note] plugin 'federated' disabled. 130502 15:45:17 innodb: innodb memory heap disabled 130502 15:45:17 innodb: mutexes , rw_locks use windows interlocked functions 130502 15:45:17 innodb: compressed tables use zlib 1.2.3 130502 15:45:17 innodb: initializing buffer pool, size = 128.0m 130502 15:45:17 innodb: completed initialization of buffer pool 130502 15:45:17 innodb: highest supported file format barracuda. 130502 15:45:17 innodb: waiting background threads start 130502 15:45:18 innodb: 1.1.8 started; log sequence number 2472751 130502 15:45:18 [error] wampmysqld: unknown variable 'default-character-set=utf

c# - How do I call a method on a static class if I've only got the classes string name? -

for example have list of strings happen names of static classes , depending on string name selected want use static class. know method called on static class, , same on each class. if strings "x", "y", "z" , selected string "z" , method called process() , in code call x.process() in way, x being name of actual static class. remember these static classes. you use reflection include namespace class name. type type = type.gettype("namespace.x"); methodinfo process = type.getmethod("process"); process.invoke(null, null);

jsf 2 - Spring Security:redirection to a specific page based on roles in JSF -

i work jsf , spring security. use custom login page. have 2 roles : administrator , user. question how redirect different pages different roles. example if user administrator, redirected "dashboard_admin.jsf" , if simple user, redirected "dashboard_user.jsf". this spring security file : <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> <security:http auto-config="true" use-expressions="true"> <security:intercept-url pattern="/pages/**" access

objective c - NSDateformatter Converting date to string -

i having following date , time 2013-04-25 10:42:44 +0000. when convert above date string, getting output 2013-04-25 16:12:44. following code using convert date string nsdateformatter *dateformatter = [[nsdateformatter alloc]init]; dateformatter.timezone = [nstimezone systemtimezone]; [dateformatter setdateformat:@"yyyy-mm-dd hh:mm:ss"]; nsstring *datestr= [dateformatter stringfromdate:date]]; nslog(@"datestr--%@",datestr); this gets asked on , on (but difficult find via search). when log nsdate object, date in utc format. how description method of nsdate implemented. as long difference seeing can accounted based on local timezone relative utc, seeing correct , expected behavior. btw - there no reason set date formatter's timezone "system" timezone. done default. same locale. set timezone or locale if want different current values.

java - Coloring dates in a CalendarView -

i have been searching through stackoverflow , numerous other sites more week find way color days in calendarview containing events, no luck. color change described in documentation of focused date, , of focused week. i got calendarview setondatechangelistener opens dialog fragment user can add information , save database. pull dates information database , show days colored. can me find way color days registered events in calendarview? best regards appdroid that because there no such feature in calendarview, have either find 3rd party library can display events on days or write own calendar

unit testing - Symfony2 Custom form type using entity trying to test it -

i trying test form type have creating uses field class entity here creation of form $builder ->add('name', 'text') ->add('description', 'textarea') ->add('services', 'entity', array('class' => 'mybundle:service', 'group_by' => 'category.name', 'property' => 'name', 'multiple' => true, 'required' => false)); this works nice when build form, trying unit test type following this example on how test custom form types i getting error symfony\component\form\exception\exception: not load type "entity" the error caused @ beginning of unit test @ command: $type = new mytype(); $form = $this->factory->create($type); any ideas on how fix error in order test custom form type using entities? thanks in advance i guess can't unit test form entity types, because it's

java - How many threads being created? -

in 1 of interview came across query on threads.question in below code snippet, how many threads being created? know it's seems basic query. couldn't find answer proof. could provide me answer concept(any links)? in anticipation. class mainapp { public static void main(string[] args) { system.out.println("welcome java"); } } since simple program not create threads explicitly 1 application thread created here. "correct" short answer @ interview. however can continue , jvm creates other threads needs itself. example garbage collector (gc) thread. number of gc threads depends on configuration. default 1.

json - NodeJS: saving renamed uploaded image to the database -

im using jqgrid insert data. data includes images. uploading has no problem im having hard time combining data , renamed file in able save database. tried check using console , seems system try call insert model twice. output: console.log (content.record); { id: '_empty', logo: undefined, name: 'foo' } { id: 'undefined', logo: 'public/foo.jpeg', name: 'undefined' } //it trying insert twice. maybe because of for(...); this code rename uploaded file , save database data included.. exports.upload = function(req,res){ for(var in req.files) var tmp_path = req.files[i].path; for(var in req.files) var target_path = newpath + req.files[i].name; fs.rename(tmp_path, target_path, function(err) { fs.unlink(tmp_path, function() { var content = {}; content.table = "teams"; content.record = {id:r

java - Can I inject proxies in front of Blueprint services published by other bundles? -

we using karaf , number of osgi blueprint services implement system. is possible make "bundlelistener" type of bundle that, when present in osgi container, decorates our blueprint services proxy bundles referring these services call proxy instead? (i guess accomplished either somehow adding proxy in front of service in service registry, or changing reference obtained referring bundle - servicetracker.addingservice style) the standard way these hacks use service hooks in osgi core framework. hooks allow remove service view of 1 or more bundles. can register service proxies first service , not removed bundle's view. existing: +----------+ +----------+ | register |------<|------| using | +----------+ +----------+ proxied +----------+ hide +----------+ | register |------<|-+--x-| using |---|>---+ proxied +----------+ | +----------+ | |

javafx 2 - How to send events from one Node to another Node -

i have pane listens wheel mouse scroll; have scroll bar automatically listens wheel mouse scroll. know how send scroll event captured pane scrollbar. i can’t use scroll pane because need custom implementation of pane, tried use scroll pane , did not cover needs. i tried fire event , other method can event passed/propagated/sent scrollbar. thanks in advance sample application: package com.test; import javafx.application.application; import javafx.beans.value.changelistener; import javafx.beans.value.observablevalue; import javafx.event.event; import javafx.event.eventhandler; import javafx.geometry.orientation; import javafx.scene.scene; import javafx.scene.control.scrollbar; import javafx.scene.input.scrollevent; import javafx.scene.layout.borderpane; import javafx.scene.layout.pane; import javafx.stage.stage; public class scrolltest extends application{ @override public void start(stage primarystage) throws exception { final borderpane root = new borderp

c# - UserPrincipals.GetAuthorizationGroups An error (1301) occurred while enumerating the groups. The group's SID could not be resolved -

this question has answer here: userprincipals.getauthorizationgroups error (1301) occurred while enumerating groups. after upgrading server 2012 domain controller 9 answers background: i've been using userprincipal.getauthorizationgroups while check permissions in 2 different applications. have been working fine several years. users have been getting error mentioned in title ( system.directoryservices.accountmanagement.principaloperationexception ) while others have not. have suspicion might related new domain controller added running on windows server 2012 because problems started day after added. full error listed below: exception: system.directoryservices.accountmanagement.principaloperationexception: error (1301) occurred while enumerating groups. group's sid not resolved. at system.directoryservices.accountmanagement.sidlist.tran

python - numpy indexing with multiple arrays -

given 2 sequences of data (of equal length) , quality values each data point, want calculate similarity score based upon given scoring matrix. what efficient way vectorize following loop: score = 0 in xrange(len(seq1)): score += similarity[seq1[i], seq2[i], qual1[i], qual2[i]] similarity 4-dimensional float array, shape=(32, 32, 100, 100); seq1 , seq2 , qual1 , qual2 1-dimensional int arrays of equal length (of order 1000 - 40000). shouldn't work(tm)? >>> score = 0 >>> in xrange(len(seq1)): score += similarity[seq1[i], seq2[i], qual1[i], qual2[i]] ... >>> score 498.71792400493433 >>> similarity[seq1,seq2, qual1, qual2].sum() 498.71792400493433 code: import numpy np similarity = np.random.random((32, 32, 100, 100)) n = 1000 seq1, seq2, qual1, qual2 = [np.random.randint(0, s, n) s in similarity.shape] def slow(): score = 0 in xrange(len(seq1)): score += similarity[seq1[i], seq2[i], qual

java - Passing date input when invoking via cxf jaxrs:client -

maybe trivial, somehow have not been able around finding why doesn't work! i have service exposed via cxf's jaxrs:server directive <jaxrs:server id="specialservicers" address="http://localhost:8080/specialservicers"> <jaxrs:servicebeans> <ref bean="specialservice" /> </jaxrs:servicebeans> <jaxrs:providers> <bean id="jaxbprovider" class="org.apache.cxf.jaxrs.provider.jaxbelementprovider"> <property name="marshallasjaxbelement" value="true" /> <property name="unmarshallasjaxbelement" value="true" /> </bean> <bean class="org.codehaus.jackson.jaxrs.jacksonjsonprovider"> <property name="mapper" ref="jacksonmapper" /> </bean> <bean class="com.kilo.progressivedatehandler

jquery - How to prevent form submission from firing continuously? -

i have text field user enters message, clicks enter , submits database. problem is, submits multiple times depend on how many milliseconds enter key pressed. i'm not doing field validation, it's more of proof of concept while learning. know can disable submit form entirely after single submission want able continue entering messages. <input type="text" placeholder="enter message" id="entermsg"> $(document).ready(function() { $("#entermsg").submit(function(){ var uid = $("#entermsg").val(); messages.insert({text: uid}); }) should using different html tags or jquery functions? since admit purely acedemic, because no 1 in right mind deploy insecure... you have global variable determine if submission should accepted or rejected. before submission accepted check global variable. if set true, accept submission , set global variable false. create timeout of, say, 1 second reset global variable t

php - fwrite() function erase .txt file but do not write in it -

i'm stuck problem fwrite() in php. i'm using raspberry pi running server on apache2. code works on windows. problem cannot write file. code erase in file , didn't write it. can see file updated, still 0 bytes written. permissions file, folder , user set should be. logging root account , executing php code make sense. googled 3 days , has same problem me, mentioning selinux. appreciated. this php code: <?php error_reporting(e_all); ini_set('display_errors', '1'); if (isset($_post['temp'])) { $name = $_post['temp']; $fp = fopen("/var/www/smarthome/webcompare6.txt", "a"); $data = "$name"; echo ("$name"); fwrite ($fp, ($data)); sleep (1); fclose ($fp); } ?> this html form, write user input .txt file: <form name="form" method="post" action="room6.php"> temperature: <input type="text" name="temp"> <input

sql - Force query to deliver duplicate results based off WHERE values -

i have been asked add few columns report based on account number. the problem several accounts listed more once in report. the report has on 500 rows, 450 account numbers. is there way force results give me duplicate data? example: select a.accountnumber, a.programflag, a.applicationstatus accountinfo a.accountnumber in ('100','101','101','101','102','102','103') order a.accountnumber asc results: accountnumber | program flag | applicationstatus ------------------------------------------------ 100 | 1 | installed 101 | 0 | closed 102 | 1 | installed 103 | 0 | installed desired results: accountnumber | program flag | applicationstatus ------------------------------------------------ 100 | 1 | installed 101 | 0 | closed 101 | 0 | closed

python - Index of row where maximum value is located -

i have list: dcf3v=[[(1.90689635276794, -44704.76171875)], [(1.90689635276794, -44705.76171875)], [(1.90689635276794, -44706.76171875)], [(1.90689635276794, -44707.76171875)] ] i'd know index of row maximum value is. in example above: row index 3. i have code finding maximum value: cf3a = (abs(x[0][1]) x in dcf3v) cf3 = max(cf3a) if possible i'd adapt code , not have classic for , if loops . you can use enumerate keep indices , key argument max right value: dcf3v=[[(1.90689635276794, -44704.76171875)], [(1.90689635276794, -44705.76171875)], [(1.90689635276794, -44706.76171875)], [(1.90689635276794, -44707.76171875)] ] cf3a = (abs(x[0][1]) x in dcf3v) index, value = max(enumerate(cf3a), key=lambda (index, value): value) print index,value

c# - Lambda compilation throws "variable '' of type '' referenced from scope '', but it is not defined" -

when attempt compile lambda shown below, throws: variable 'model' of type 'system.collections.generic.ienumerable`1[wheelendcatalogkendo.models.sapbasicdata]' referenced scope '', not defined public static gridboundcolumnbuilder<tmodel> buildcolumnstring<tmodel>(this gridboundcolumnbuilder<tmodel> column, webviewpage<ienumerable<tmodel>> webviewpage, int width) tmodel : class { var modelparameter = expression.parameter(typeof(ienumerable<tmodel>), "model"); expression<func<ienumerable<tmodel>, tmodel>> firstitem = (model) => model.firstordefault(); var member = memberexpression.property(firstitem.body, column.column.member); var lambda = expression.lambda<func<ienumerable<tmodel>, string>>(member, modelparameter); var title = webviewpage.html.displaynamefor(lambda).tohtmlstring(); var header = webviewpage.html.shortlabelfor(lambda).tohtmlstring().

javascript - How to implement a generic click event for anchors -

currently have php script throws out bunch of buttons(format in case needed is <a class="classinfo" id="id">name</a> the file retrieved dynamically , there can many buttons possible, maybe none , maybe million(unlikely though). anyways javascript. need use javascript , cant redirect user website(mostly because operation repeated heavily , gets extremely tedious..). is possible me use combination of javascript + jquery detect button pressed , operation appropriately? example of hoping this: user clicks 1 of buttons(which has unique id number). javascript detects button clicked(i cant use fixed code number of buttons , ids can change whenever feel it). javascript send out ajax request , fancy operations(i got part covered). now possible me detect button clicked? struggling this. the target property of event object tell element clicked on. document.addeventlistener('click', function (e) { var target = e.target; if (targ

java - How do I get the original text that an antlr4 rule matched? -

using java 7 grammar https://github.com/antlr/grammars-v4/blob/master/java7/java7.g4 want find methods specific name , print out method. see can use methoddeclaration rule when match. subclass java7baselistener , override listener method: @override public void entermethoddeclaration(java7parser.methoddeclarationcontext ctx) { } how original text out? ctx.gettext() gives me string whitespace stripped out. want comments , original formatting. antlr's charstream class has method gettext(interval interval) return original source in give range. context object has methods beginning , end. assuming have field in listener called input has charstream being parsed, can this: int = ctx.start.getstartindex(); int b = ctx.stop.getstopindex(); interval interval = new interval(a,b); input.gettext(interval);

javascript - Can One Check that Rafael JS Canvas.paper.set() is not empty -

under circumstances, pop() canvas.paper.set() if not empty. there way check how many elements contains or @ least number not zero? checked rafael reference , find info. that. set has length property tell how many elements contains. someset.length

Append to string in Fortran -

i have simple problem, yet find answer to. there way in can append character, in particular white space character has been initialized in fortran. apparently character(2000) :: result result = '' result = result//' ' does not work. thank time! what want achieve? of course works, has not use. try approach have been suggested in previous question. in particular, aware strings filled space after last non-space character, important! 'a'//' ' produces 'a ' but result = result//' ' produces 2001 character string, truncated on assignment, result ends being same. you may want result = trim(result)//' ' but useless, because string filled spaces anyway. if want make variable larger, have use: character(:),allocatable:: result result = '' !now contains ' ' , has length 1 result = result//' ' !now contains ' ' , has length 2 you have enable reallocation on assignment on

multithreading - Show progress text while logging user in - Android App -

i'm working on android app , having trouble updating gui. want achieve when user clicks sign in button, call setvisibility method on grouploginprogress defined below , set view.visibile. fire off method logs them in, , if returns success value, set grouploginprogress view.gone, , grouploginsuccess view.visible (displays "sign in successful!") pause few seconds , start main intent. if log in method returns false, have set grouploginprogress view.gone , grouploginerror view.visible. can't seem figure out how make these things happen without causing app hang while waits log in method complete. below have far, appreciated!! //hide sign in progress/success/error layouts oncreate grouploginprogress = (linearlayout) findviewbyid(r.id.grouploginprogress); grouploginsuccess = (linearlayout) findviewbyid(r.id.grouploginsuccess); grouploginerror = (linearlayout) findviewbyid(r.id.grouploginerror); hideallstatus(); //this simple method sets above groups view

service - WCF - Can i securely use the CallbackChannel to identify authenticated clients? -

i'm using nettcpbinding wpf client. want know if callbackchanel (operationcontext.current.getcallbackchannel) can spoofed 1 else ... meen, can sure, if store callback object in list, call can't use 1 else ... exemple : private class clientcallback { public iduplexservicecallback callback { get; set; } public long userid { get; set; } public bool isauthenticate { get; set; } public datetime lastping { get; set; } public datetime lastpong { get; set; } public bool fault { get; set; } public long ping { get; set; } } static list<clientcallback> clients; public void login(string username, string password) { var auth = new autentificationservice(); var user = auth.login(username, password, true, null); if (user != null) { clients.add(new clientcallback() { callback = operationcontext.current.getcallbackchannel<

java - Regexes for modifying beginning and end of line or string -

given string 1990january20hello.abc want apply regexes final string 1990january-20hello.abc i thought do: string text = "1990january20hello.abc"; pattern p = patter.compile("(.*)(january|jan)(.*)", pattern.case_insensitive | pattern.dotall); matcher m = p.matcher(text); while (m.find()){ string val1 = m.group(2); string val2 = val1.replace("$", "-"); text = text.replace(val1, val2); } when seems in while loop find "january" val2 , text stay january. doing wrong? if java doesn't recognize $ end of line/string. ideally want val1.replace("(^|$)","-") can 1990-january-20hello.abc final string. please help. suggestions in advance. use pattern: (\d+)([a-za-z]+)(\d+)(.*) the resulting groups , values are: group 1 = 1990, group 2 = january, group 3 = 20, group 4 = rest of string. and can append them , add whatever want.

PARTSIZE option for SAS SPD datasets -

i've noticed when specify partsize option when creating spd datasets in sas9.3 win7 64bit doesn't seem work intended. i'm using simple spde libname no additional parameters. when creating dataset specify option partsize=5g files created ~700mb. total size of combined partitions creates approximately 20g, instead of ending 4-5 partitions 20 30. anyone else experienced or have workaround? apparently option compress doesn't work spde expect. this works describe: libname mylib spde 'c:\temp' datapath=('c:\temp' 'd:\temp'); options compress=yes;; data mylib.test (partsize=5g); set sashelp.class; _t = 1 2.5e7; output; end; run; turning options compress no yields expected results. also, in brief test, options compress didn't save time (even though 40% reduction in size), suggesting spde doesn't work optimally compress.

ruby - How to compare data in two CSV files -

i have 2 csv files have same structure , ideally should have same data. i want compare data in them using ruby , wanted know if have ruby function same. as summea commented, @ csv class. then use: #will store each line of each file array of fields (so array of arrays). file1_lines = csv.read("file1.csv") file2_lines = csv.read("file2.csv") in 0..file1_lines.size if (file1_lines[i] == file2_lines[i] puts "same #{file1_lines[i]}" else puts "#{file1_lines[i]} != #{file2_lines[i]}" end end note using for in ruby quite rare. iterate using each on collections, there 2 of them here. also, pay attention 1 of list may longer other, should started.

c++ - Vector of a Vector troubles -

basic problem can please me understand how use vector of vector. take example vector< vector<int> > help . not understand if vector of ints each vector of ints or if vector of vector of ints? don't understand how utilize it. example code vector< vector<int> > test[500]; test[0].emplace_back(1); cout << test[0][0]; test[50].emplace_back(4); cout << " " <<test[50][0]; -console- 1 50 //this not happens btw, desired results disclaimer have spent better part of morning testing , googling this. please :) did hw. can't find documentation of vectors of vector. have correct libraries , using namespace std. noob , understand namespaces bad practice, convient me right now. basically want set size of vector filled each pt being vector of int. rather not go way of separate class. vector of vector of int, right thing looking into? thank :) this vector of int: std::vector<int> v; this vector of vectors of

apache - Auto reloading python Flask app upon code changes -

i'm investigating how develop decent web app python. since don't want high-order structures in way, choice fell on lightweight flask framework . time tell if right choice. so, i've set apache server mod_wsgi, , test site running fine. however, i'd speed development routine making site automatically reload upon changes in py or template files make. see changes in site's .wsgi file causes reloading (even without wsgiscriptreloading on in apache config file), still have prod manually (ie, insert linebreak, save). there way how cause reload when edit of app's py files? or, expected use ide refreshes .wsgi file me? the current recommended way (flask >= 0.11) flask command line utility. http://flask.pocoo.org/docs/0.11/server/ example: $ export flask_app=main.py $ export flask_debug=1 $ python -m flask run or in 1 command: $ flask_app=main.py flask_debug=1 python -m flask run i prefer python -m flask run rather flask run because former

map - python map_async, where is the overhead coming from? -

i using map_async intended - map iterable on multiple processing cores using: cores = mp.cpu_count() pool = mp.pool() r = pool.map_async(func, offsets,callback=mycallback) r.wait() func returns dict, callback 'merges' dicts using: ddict = defaultdict(set) def mycallback(w): l in w: key, value in l.items(): v in value: ddict[key].add(v) offsets iterable have tested 1,000 - 50,000 elements. if remove r.wait() not possible return of output map_async call. using r.wait() , seeing processing times both inferior serial implementation , not scale, i.e. parallel implementation increases in time exponentially, while serial version increases linearly. i know func sufficiently expensive in serial , parallel pegs processing cores. where have introduced overhead using map_async? not in callback function, removing , replacing result.append not impact time. edit comments: i moving large dicts around, anywhere 1,000 -

php - Codeigniter Auto Responder -

in main library has following: $ci-email-from(autoresponders_fromemail, autoresponders_fromname); i have noted throughout controllers uses following: /** send user course request phone call success email: - sends bcc staff **/ @$this-autoresponder-send(15, $booking['email_address'], $responder_array['%full_name'], $responder_array, true); i have noted in constants file - in config folder previous developer has set following: define('autoresponders_fromemail', "email@domain.org"); define('autoresponders_fromname', 'domain'); define('autoresponders', 'on'); // used debugging , development switch autoresponder emails on or off am able "email@domain.org", "email1@domain.org"?

iphone - Trying to display an image and label when making a selection from the UIPicker -

please bare me. new @ this. i have array geek names , array careers of each geek. geek names should appear in uipicker. when name selected, image , career of selected player should displayed @ bottom of picker. unable place images in array _imageview = @[@".... because every time attempt screen goes black. when delete it, runs crashes right after opens on device , following message: 2013-05-02 13:40:03.761 assignment5[2968:c07] -[uiview numberofcomponentsinpickerview:]: unrecognized selector sent instance 0x7549d30 2013-05-02 13:40:03.780 assignment5[2968:c07] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uiview numberofcomponentsinpickerview:]: unrecognized selector sent instance 0x7549d30' *** first throw call stack: (0x1c92012 0x10cfe7e 0x1d1d4bd 0x1c81bbc 0x1c8194e 0xc634 0xd25f 0x642dd 0x10e36b0 0x228efc0 0x228333c 0x228eeaf 0x1032bd 0x4bb56 0x4a66f 0x4a589 0x497e4 0x4961e 0x4a3d9 0x4d2d2 0xf799c 0x44574 0x4476f 0x

javascript - Setting Bootstrap Error Class via AngularJS on Form Submit? -

how can efficiently set error state of multiple form field after user submits form? i can set error state enough on constant basis. described in this thread use following html code: <div class="control-group" ng-class="{ error: groupform.textbox_group.$invalid }"> <label class="control-label" for="textbox_group"><i class="icon-home"></i> organization</label> <div class="controls controls-row"> <input type="text" class="span6" id="textbox_group" name="textbox_group" placeholder="organization" ng-model="org" required> </div> </div> my issue appear in error state on page loading. want appear normal before user hits submit , then, if $invalid flagged. i'm using individual flags, along lines of: <div class="control-group" ng-class="{ error: group.isinvalid }">

html - How to not clear input fields in php form? -

i have webpage uses php , has bunch of input fields in user enters data , turn input sql statement query database. parse input fields , put sql statement when click "submit" button, input fields cleared. how can make these input fields don't erase every time user clicks "submit"? store them in local variables <?php $name = ''; $last = ''; if(isset($_post['post_me'])) { $name = $_post['post_me']; $last = $_post['last']; //process further } ?> <form method="post"> <input type="text" name="name" value="<?php echo $name; ?>" /> <input type="text" name="last" value="<?php echo $last; ?>" /> <input type="submit" name="post_me" /> </form>

c++ - How to download files from QWebView? -

i created small web browser qt creator , qwebview. i's working , pages loading fast. how can make browser capable of downloading files? looked through signals , functions list, did't find me. how can found out if qurl contains link file other text/html can download it? qwebview has 'qwebpage' member can access it's pointer webview.page() . should look. qwebpage has 2 signals: downloadrequested(..) , unsupportedcontent(..) . believe dowloadrequest emitted when user right clicks link , selects 'save link' , unsupportedcontent emitted when target url cannot shown (not html/text). but unsupportedcontent emitted, should set forwardunsupportedcontent true function webpage.setforwardunsupportedcontent(true) . here minimal example have created: mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); ui->webview->page()->setforwardunsupportedcontent(true); connect