Posts

Showing posts from July, 2012

c# - Not greedy quantification in regular expression -

Image
i have string m(2,n(3)) . i need retrieve matches (calls) regex: m(2,n(3)) n(3) my variant of regex - (m|n\((.*?)\)) it doesn't work. you can make use of balanced constructs in .net regex. positive look-ahead can match nested expressions this: (?=(\b\w+\b\((?>[^()]+|\((?<n>)|\)(?<-n>))*(?(n)(?!))\))) the values stored in group 1. see demo (go table tab see actual results). var rx = new regex(@"(?=(\b\w+\b\((?>[^()]+|\((?<n>)|\)(?<-n>))*(?(n)(?!))\)))"); var str = "m(2,n(3)), call(param,3)"; var matches = rx.matches(str).oftype<match>().select(p => p.groups[1].value).tolist();

Google PHP API Analytics gives strange userRateLimitExceeded -

since gapi stopped working 2 days ago had rewrite code google analytics dashboard. decided use google api php client ( https://github.com/google/google-api-php-client ) got working pretty nice @ local vagrant ubuntu server when deploy code remote webserver 500 php error. when checking logs discover error message creates (403) quota error: user rate limit exceeded. how can code working on vagrant not on remote webserver? domains both added correctly developers console. tried setting query/user/second-setting 10 or more not change anything. allright, fixed it: i added sleep(1); php foreach loop querying google analytics profiles have in account. apparently vps querying google's api faster local development environment , therefore not getting errors local.

Scala Function block as String to Function -

just wondering if there way convert/parse string, containg scala function body block, function object. you can check eval class twitter. previous answer might of use.

javascript - scan table data and replace certain string inside html table -

i have following table <table class="data"> <thead> <tr> <th>1</th> <th>2</th> <th>3</th> </tr> </thead> <tbody> <tr> <td> 1 data </td> <td> 2 data </td> <td> 123456789123 </td> </tr> </tbody> </table> how can dynamically scan table , replace values in third table body td values information 123456789123 stored. this information should placed character on string location so <td> 123456789123 </td> should <td> 12345678*12* </td> please find below code block need, have added 1 specific class td want modify value. $( document ).ready(function() { $('.value_td').each(function(key, ele){ // getting original value var original_val = $(...

Sorting vectors in c++ -

i need sort data structure vector<pair<unsigned, pair<vector<unsigned>, vector<unsigned> > > > sbp first sbp.second.second vector , equal values of sbp.second.second sbp.second.first -- both vectors compared (i) size of vectors; (ii) if size of vectors equal, vectors lexicographically sorted. doing so, wrote following code. dont know why code getting stuck in infinite loop. can please me going wrong. #include <vector> #include <iostream> #include <algorithm> using namespace std; typedef std::pair<std::vector<unsigned>, std::vector<unsigned> > vec_pair; bool sortingfunc(const pair<unsigned,vec_pair>& a, const pair<unsigned,vec_pair>& b) { if((a.second).second.size() == (b.second).second.size()) { if(std::lexicographical_compare((a.second).second.begin(), (a.second).second.end(), (b.second).second.begin(), (b.second).second.end()))//a<b { return true; ...

php - How to generate a secured query string link using Laravel? -

the html code is: <a href="room/info/{{$value->id}}">click show details</a> and code generating type of link: localhost:8000/room/info/2 the router is: router::get('room/info/{id}', 'roomcontroller@details'); where numeric '2' id of room. but think it's unsecured. because user can change id browser address bar. want know there secured way in laravel framework use query string? or there other way operation securely using laravel? you can prevent users entering rooms not allowed using middleware . each request passed registered middlewares route, before controller reached. can check if user authorized view room. in laravel 5 can create middleware easy: php artisan make:middleware roommiddleware a new file generated in app/http/middleware . can write logic there: <?php namespace app\http\middleware; use closure; class roommiddleware { /** * run request filter. * * @param \illum...

Not able to record HP Webtour app using Jmeter -

Image
i new jmeter , took hp loadrunner webtour application testing. not able record webtour app using jmeter. i have changed settings firefox browser proxy port record jmeter scripts. tried other web application , recording fine not webtour application. any suggestions!! thanks. my expectation is didn't change settings under "no proxy for" input. default firefox browser don't use proxy local requests , hp web tour application runs on local apache server. make sure "no proxy for" either empty or doesn't contain related computer hostname or ip address if reason doesn't can try out jmeter google chrome extension doesn't require configuration , don't need worry proxies , ssl certificates.

sql - Database Design for Order management for multiple sources -

i know what's best method building order management database there multiple shops, each own list of products , prices. my current design product ------ name image price_per_item shop ------ name product_list - manytomany field order ------ order_id primary key shop order content ------ order_id foreign key order product quantity the problem foresee each shop may have same item may sell item @ different price_per_item . how build db shops can manage have different price per items , yet have multiple items sell? you're worried relationships, , not worried enough tables. first, let's build shop table. shop ---- shop id shop number shop name shop address ... generally, tables have singular name , auto-incrementing integer primary key. called blind key. that's why have shop id , shop number. shop id primary key , shop number data. shop number can changed without changing of relationships we're going build. now, let's bu...

javascript - document.cookie is still accessible on IE11, even though cookies are disabled -

using ie11, can display content of cookies, write out cookie, find it, , delete using javascript, though have privacy set "block cookies". (and actually, no matter version set ie emulation to, document.cookie still works.) works should on chrome cookies disabled - i.e. document.cookie returns empty/nothing when try reference in same javascript. i'm trying detect whether user has cookies turned off in ie. (old asp app requires ie cookies. no jquery. no modernizr.) that, i'm attempting write out cookie, find it, , delete it. either works or doesn't - should tell me whether cookies turned on or off. ideas? thought safest way detect user's ie cookie setting. my code: <script language=javascript> cookieson = false; if ("cookie" in document ) { alert("1. document.cookie (before add): " + document.cookie); var datenow = new date(); document.cookie = "testcookie=" + new date() ...

Preallocate sparse matrix with max nonzeros in R -

i'm looking preallocate sparse matrix in r (using simple_triplet_matrix) providing dimensions of matrix, m x n, , number of non-zero elements expect have. matlab has function "spalloc" (see below), have not been able find equivalent in r. suggestions? s = spalloc(m,n,nzmax) creates 0 sparse matrix s of size m-by-n room hold nzmax nonzeros. whereas may make sense preallocate traditional dense matrix in r (in same way more efficient preallocate regular (atomic) vector rather increasing size 1 one, i'm pretty sure not pay preallocate sparse matrices in r, in situations. why? dense matrices, allocate , assign "piece piece", e.g., m[i,j] <- value sparse matrices, different: if s[i,j] <- value internal code has check if [i,j] existing entry (typically non-zero) or not. if is, can change value, otherwise, 1 way or other, triplet (i,j, value) needs stored and means extending current structure etc. if piece piece, inefficient... irr...

java - configuration of TabHost using getDrawable -

i have problem when calling getdrawable() in mainactivity , i'm done activity_main.xml , shows warning "the method getdrawable(int) type resources deprecated". can me? mainactivity.java : public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); resources res= getresources(); tabhost tabs = (tabhost) findviewbyid(android.r.id.tabhost); tabs.setup(); tabhost.tabspec spec = tabs.newtabspec("pestana 1"); spec.setcontent(r.id.tab1); spec.setindicator("1",res.getdrawable(android.r.drawable.bottom_bar)); tabs.addtab(spec); tabs.setup(); tabhost.tabspec spec1 =tabs.newtabspec("pestana 2"); spec1.setcontent(r.id.tab2); spec.setindicator("2",res.getdrawable(android.r.drawable.btn_minu...

svg text positioning, overlapping or two styles for same text element -

Image
i have 2 different svg text elements aligned horizontally 1 other: "title1", "20%" , "120.000" 3 independent svg objects.the 120.000 text element end anchored , 20% middle anchored. what trying place 20% text appears on image setting same space between , 120.000 text. position of percentage set this: canvas.append("text") .attr("transform", "translate(" + ((width/2) - width/4) + " ," + (height/2 - 10) + ")") .style("text-anchor", "end") .text(function(d) { return data.values[0].percent}); where "width" , "height" total width , height of svg element holds piechart the problem comes when right value text big: percentage text overlaps: i place 2 pieces of text in same text element 2 pieces of text have different styles. do have suggestions on how fix this? the 2 solutions i've thought of are to able set 2 diffe...

c# - Printing list of diverse objects -

i trying return combine list of 2 different list types. child class derived same base class doesn't have code. can see items in base class. but, supposed have. class baseclass { //empty no code } class childclassa : baseclass { public string name {get; set;} public datetime dateaccess {get; set;} public childclassa(string name, datetime dateaccess){ name = name; dateaccess = dateaccess; } public list<childclassa> getlistmethod() { //block of code return list<childclassa>; // each items have name , dateaccess } } class childclassb: baseclass { public string group {get; set;} public datetime sessionduration {get; set;} public string report{get; set;} public childclassb(string group, datetime sessionduration, string report) { group = group; sessionduration = sessionduration; report = report; } public list<childclassb> getli...

multithreading - Android App Hangs When Running While Not USB Connected -

my android application runs normal when connected computer. however, when run while usb disconnected, application hang indefinitely. this sounds dumb question, wondering if being plugged in gives kind of advantages may missing. threading act differently while connected computer?

mysql - How to insert multiple rows at once using INSERT INTO query -

Image
so here problem, want insert data table (webform_submitted_data) anather table (feedback_analysis) data want copy 1 nid=20 , cid= 3,4,5 table this, so here doing, insert feedback_analysis (service,type,feedback) values ((select data webform_submitted_data nid=20 , cid=5),(select data webform_submitted_data nid=20 , cid=3),(select data webform_submitted_data nid=20 , cid=4)); but i'm getting error error 1242 (21000): subquery returns more 1 row i got reason behind that, subquery returning 2 rows in result single insert into query can not handle. i want insert all rows in table, can process further so please me find solution this. i want apply trigger directly insert values feedback_analysis table once new value of nid=20 inserted table of weform_submitted_data thank you. you can use limit 1 insert feedback_analysis (service,type,feedback) values ((select data webform_submitted_da...

MGWT Forms vs pure GWT Form -

what real difference between in forms classes provided mgwt , pure gwt? i'm developing in gwt web application lots of forms, i'm preparing helper classes. in moment need mobile version. i've made steps in mgwt , think suits me best in general mobile layout. i'm wondering forms. should need prepare set of helper classes uses form widgets provided mgwt or can use pure gwt widgets? going further if can use pure gwt forms can mix mgwt form item widgets cases? thanks in advance!

backwards compatibility - QNX runtime error: unknown symbol __stack_chk_guard -

i'm trying test backward compatibility between qnx 6.6.0 , 6.5.0 (in concequence of earlier question i've got). compiled relatively simple program using sdp6.6.0 , executed on neutrino 6.5.0. when execute program follow runtime error pops up: unknown symbol: __stack_chk_guard ldd:fatal: not resolve symbols what causing this?.. (i've found solution wasn't working rightaway. when started writing question realized error made. future reference provide solution here q&a myself). since qnx using gcc (qcc): "buffer overflow detection enabled in current , newer gcc builds in (rare , complex) cases may result in run time complications such undefined symbol: __stack_chk_guard errors. in such cases possible solution disable feature adding -fno-stack-protector cflag list used gcc compilation options" (see [ 1 ] , what use of -fno-stack-protector? ). additionally: found forum thread ryan mansfield (qnx compiler lead maintainer, t...

ssl - Using custom certificates for Authorize.net AIM API in Rails on Heroku -

as of few days ago, authorize.net upgraded certificates signed using (sha-2) . our customers error returned authorize.net: ssl_connect returned=1 errno=0 state=sslv3 read server certificate b: certificate verify failed so need use them in our rails app on heroku. heroku's set of root certificates doesn't include these, have include them in activemerchant, having no luck finding clear instructions how properly. here's i've tried far: i've downloaded 5 root certificates authorize.net requires, , chained them "cacert.pem," replacing existing "cacert.pem" file in app's /vendor/plugins/active_merchant/lib/certs/ folder (i backed old cacert.pem file first, in case). did not solve problem -- still same error in development. looking @ new "cacert.pem" file created, saw last certificate in chain ( https://cacert.omniroot.com/bc2025.crt ) looked this: 0Çw0Ç_†��Ï€0 *Ühܘ �0z10 uie10u baltimore10u cybertrust1...

inheritance in C# "must declare a body because it is not marked abstract, extern, or partial" -

i trying use class account parent , class login child object. here account code looks class account { private string account; private string password; private string email; public account(); public account(string _account, string _password, string _email) { this.setacount(_account).setpassword(_password).setemail(_email); } ....... } and here class login class login : account { private bool login_status ; private static int try_count ; public login() { login_status = false; try_count = 0; } ...... } however pop error messages error1 'team2.account.account()' must declare body because not marked abstract, extern, or partial that's not valid declaration: public account(); constructor has have body: public account() { };

ios - Prevent Interface Builder from auto creating Constraints? -

i created demo project here . have view created scrollview in .xib file. in interface builder did not set constraints. in viewdidload method set constraints snapkit : scrollview.snp_makeconstraints { (make) -> void in make.edges.equalto(self.view) } when run code following console output: unable simultaneously satisfy constraints. @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. (note: if you're seeing nsautoresizingmasklayoutconstraints don't understand, refer documentation uiview property translatesautoresizingmaskintoconstraints) ( "<nsibprototypinglayoutconstraint:0x7b74e280 'ib auto generated @ build time view fixed frame' v:|-(1)-[uiscrollview:0x7b74c430] (names: '|':uiview:0x7b74dd10 )>", "<<deviceimagestest.layoutconstraint:0x7baa2760> <uiscrollview:0...

html - jade errors on codepen -

i'm trying make email template in jade, , i'd put in codepen other people can have access it. however, everytime error: codepen removed words below jade because used bad things. please remove them , try again. ->greensborohomevalue ->com <br> ->style <br> ->color <br> ->white <br> ->text <br> ->decoration <br> ->15 <br> ->span <br> ->style <br> ->color <br> every single piece of text... etc my codepen can found here, http://codepen.io/cutcopy/pen/qdrmor . any idea why it's doing this? compiled fine on desktop. i receiving similar error on codepen because jade contained string 'node'. codepen removed words below jade because used bad things. please remove them , try again. ->node my markup included element class called 'ordered-chart-nodes'. changing string 'node' else (in case, 'ordered-chart-items'), fixed error. inte...

ruby on rails - Proper Setup of Active Record Associations for a Doctor-Patient Survey Model -

i having trouble building active record associations doctor -> patient relationship. doctors can create assessments patients. before create assessment, must choose template (for type of injury). template has_many :questions, , question has_many :answers. so models are: user, patient, assessment, template, question, answer. the user --> patient relationship pretty straight forward, i'm having trouble the template, assessment, questions, , answers. i'm pretty confused 'has_many :through'. i'd able call template.questions list of questions given template, also able call assessment.questions (instead of assessment.template.questions). then can filter through assessment.questions answers. here current model associations. current setup isn't allowing me call assessment.questions (which thought taken care of has_many :questions, :through=> :templates). what need change in order call assessment.questions ? accepting other feedback on architectu...

php - Google Developer Console does not give password when creating Service Account -

overall goal trying access (my own) google sheets server-side php application (not sheets owned individual app visitors). i'm hoping use https://github.com/asimlqt/php-google-spreadsheet-client , mentions doesn't handle oauth2 stuff, can use https://github.com/google/google-api-php-client . so in trying follow https://developers.google.com/api-client-library/php/auth/service-accounts , says (step 5): the console shows private key's password @ initial moment of service account creation--the password not shown again however when steps, sends me .json (with private_key_id, private_key, client_email, client_id, type), @ no point show me kind of password. have tried both firefox , chromium, tried deleting old service account, making new service account. there else need enable on developers console? or else i'm missing? when create service account on google api console, usually, file randomname.p12 downloaded automatically, , password file notasecre...

javascript - Jquery animate - callback executing before animation is complete -

what i'd accomplish element expand in height, , apply background image once height change complete. i've noticed background image in callback applies before height animation complete resulting in laggy performance. can tell me why is? $(document).ready(function() { $('#hero').animate({ height: ($(window).height() - $("#hero").offset().top - 50) }, 100, function() { $('#hero').css('background-image', 'url(./img/hero.jpg)'); }); }); you have transition: 1s ease on #hero , cause animation play erratically since trying use css3 animations animate jquery animation (and throw kinds of timing problems). what suspect happening getting notified jquery animation completed, css3 animation doesn't complete additional 1s, why seeing are.

android - Reading from SQLite database causes stack overflow -

can't find problem why sqlite database cannot read, it's taken me long , still can't figure out why trying read giving me stack overflow, appreciate help, thank you. public class databasehandler extends sqliteopenhelper { private static context ctx; // static variables // database version private static final int database_version = 1; // database name private static final string database_name = "chirhogs_android_api"; // login table name private static final string table_login = "fusers"; // login table columns names private static final string key_id = "id"; public static final string key_name = "name"; public static final string key_email = "email"; private static final string key_uid = "uid"; private static final string key_created_at = "created_at"; public databasehandler(context ctx) { super(ctx, database_name, null, database_version); this.ctx = ctx; } databasehandler jhel...

reactive programming - RxJava: retrying map actions -

i have observable each item transformed in way may result in exception, can retried. don't want failures break stream, each item represents independent transaction. best solution can come this: final atomiclong errcount = new atomiclong(); observable.from(immutablelist.of(1l, 2l, 3l)).flatmap(new func1<long, observable<long>>() { @override public observable<long> call(long along) { return observable.from(immutablelist.of(along)).map(new func1<long, long>() { @override public long call(long along) { if (along == 2 && errcount.getandincrement() < 1) { throw new runtimeexception("retryable error"); } return along * 100; } }).retry(2); } }).foreach(new action1<long>() { @override public void call(long along) { sys...

python - PyQT + VTK : QVTKRenderWindowInteractor is invisible -

i've made little program visualize 3d data pyqt , vtk . qvtkrenderwindowinteractor embed in qmainwindow centralwidget . everything works fine if add : self.setwindowflags(qtcore.qt.framelesswindowhint) self.setattribute(qtcore.qt.wa_translucentbackground, true) i hole (the qvtkrenderwindowinteractor 100% transparent). other widgets displayed correctly (menubar, statusbar, etc..) i've tried several combinations , seems issue doesn't comes stylesheet. have absolutly no idea going on here. any welcome :) edit : here sample (python 2.7 , vtk. i'm using python(x,y)) : #!/usr/bin/env python import sys import vtk vtk.qt4.qvtkrenderwindowinteractor import qvtkrenderwindowinteractor pyqt4 import qt pyqt4 import qtgui, qtcore class test(qt.qmainwindow): """test class""" def __init__(self, parent=none): qt.qmainwindow.__init__(self, parent) self.setwindowflags(qtcore.qt.framelesswindowhint) self.s...

java - How to add app file to appium Desired Capabilities correctly? -

i used saucelabs example desiredcapabilities capabilities = new desiredcapabilities(); capabilities.setcapability("browser_name", "android"); capabilities.setcapability("version", "4.4.2"); capabilities.setcapability("devicename", "android emulator"); capabilities.setcapability("platformname", "android"); //zip file containing app tested capabilities.setcapability("app", "http://appium.s3.amazonaws.com/testapp6.0.app.zip"); driver = new remotewebdriver (new url(messageformat.format("http://{0}:{1}@ondemand.saucelabs.com:80/wd/hub", sauceusername, sauceaccesskey)), capabilities); and work fine. when downloaded zip app , switched local environment capabilities.setcapability("app", app.getabsolutepath()); driver = new remotewebdriver(new url("http://0.0.0.0:4723/wd/hub"), capabilities); i got error appium cons...

apache - htaccess rewrite condition not working in internet explorer -

we have mutiple websites same code. problem working correctly in firefox, chrome etc, not working in ie. my suggestion internet explorer sends different/incorrect http_host. can't figure out why. can me in right direction. have posted htaccess file below what code should do: 1. check if request sitemap 2. redirect www http 3. if website not website.nl use http 4. if website website.nl use https 5. use request request.php file rewriteengine on rewritebase / rewriterule ^sitemap\.xml/?$ generate_sitemap.php [nc,l] rewritecond %{http_host} ^www\.(.*)$ [nc] rewriterule ^(.*)$ http://%1/$1 [r=301,l] rewritecond %{http_host} !^(www\.)?website.nl$ [nc] rewritecond %{http_host} ^$ rewriterule ^(.*)$ http://%{http_host}%{request_uri} [r=301,l] rewritecond %{http_host} ^(www\.)?website.nl$ [nc] rewritecond %{https} !=on rewriterule ^(.*)$ https://%{http_host}%{request_uri} [r=301,l] rewritecond %{request_filename} !-f rewriterule ^((.|/)*)$ /request.php?path=$1 [qsa,...

Magento show empty grouped product -

i want tot display grouped products in magento(version 1.9.1.1) if don't have active simple product attached them. it's possible me view grouped product on frontend if visit product using direct url, when use search form or check category page don't see product. if activate simple product associated grouped product grouped product appears in category page , search form. thanks in advance! this due bug in magento's grouped product price indexer ( mage_catalog_model_resource_product_indexer_price_grouped ). the indexing process takes account grouped products have simple products associated, see mage_catalog_model_resource_product_indexer_price_grouped line 118: if (!is_null($entityids)) { $select->where('l.product_id in(?)', $entityids); } this needs changed if (!is_null($entityids)) { $select->where('e.entity_id in(?)', $entityids); } to make work. also, mass indexing of product prices (via admin interface or vi...

Firefox redirects to https -

i'm using firefox, , while setting server, have been fiddling around redirects. now, firefox has cached 301 redirect http:// example.com https:// example.com , http:// sub.example.com https:// sub.example.com. i've tried following things: history -> show history -> forget site. checked no bookmark https://example.com present. changing browser.urlbar.autofill false in about:config. changing browser.cache.check_doc_frequency 3 1. options -> advanced -> network -> chached web content -> clear now. none of above works, checked redirect wheregoes.com , doesn't show redirect http https. i've changed dns point ip served server, i've never set redirection - redirection still in effect. i've tried in private browsing in firefox, , there no redirect there. i've tried in google chrome, , there no redirect here. i've tried make redirect https http worked in google chrome, , yielded redirection error in firefox. my version of...

javascript - Selecting field from array based on a value filter -

very new angular (and whole mean stack). i have mongodb db collection so: db.users({ username: "test1", fname: "bob", lname: "saget", email: "test@test.com", password: "12345", status: [{ active: false, "non-active": false, suspended: true, "un-confirmed": false, banned: false }] }) i'm wishing print users screen. , have been doing success, so. <tr ng-repeat="user in users"> <td>{{user.username}}</td> <td>{{user.fname + ' ' + user.lname}}</td> <td>{{user.email}}</td> <td>{{user.password}}</td> <td></td> </tr> my problem comes trying display field (not value) of status array based on boolean value. in example read 'suspended' 1 page rather 'true...

javascript - Remove commas from the content -

i want change date format removing commas. i cannot access html content var d = "friday, 20 november, 2015, 2015, sunday, 22 november, 2015" var res = d.replace(/,(?=\s+\d+)/g, ""); document.write(res); when friday, 20 november, 2015 - sunday, 22 november, 2015 09:00 - 17:00 gmt time <ul class="icons"> <li> <a id="lnkaddcal" href="javascript:void(1);" style="text-decoration: none"> <img src="/g/images/details-calendar-large.png" title="add calendar" alt="add calendar"><span style="display:block">add calendar</span> </a> <p id="tdcal" style="...

linux - Shell script getting superuser privilege without being run as sudo -

here script: script.sh : sudo cat /etc/passwd- if in sudo session (e.g ran other command sudo few minutes ago), , run script.sh the script sudo access. if run cat /etc/passwd-/ , permission denied error. as user, wouldn't expect script.sh able super user privileges (e.g without me giving access superuser privileges sudo script.sh ). is expected behavior ? configurable ? i see behavior being similar sudo su , e,g potentially giving superuser access script run in session, worse, because might not aware of it, , don't know when ends (at least not without checking manually) is expected behaviour ? yes, indeed expected behavior. user's cached credentials sudo responsible it. is configurable ? yes configurable. and think security concern valid one. running script.sh in terminal sudo command run before (within timeout), give script superuser privilege if script written explicit sudo commands. you can avoid script not prompting p...

countif - adding up numbers after an if operation in R -

i have set of data consists of number of courses of medication patient has taken @ date. subject<-c(111,111,111,222,222,333,333,333,333) date<-as.date(c("2010-12-12","2011-12-01","2009-8-7","2010-5-7","2011-3-7","2011-8-5","2013-8-27","2016-9-3","2011-8-5")) medicationcourses<-c(1,0,na,3,4,2,4,5,6) data<-data.frame(subject,date,medicationcourses) data subject date medicationcourses 1 111 2010-12-12 1 2 111 2011-12-01 0 3 111 2009-08-07 na 4 222 2010-05-07 3 5 222 2011-03-07 4 6 333 2011-08-05 2 7 333 2013-08-27 4 8 333 2016-09-03 5 9 333 2011-08-05 6 i have hospital admission date. hospitalsubject<-c(111,222,333) admissiondate<-as.date(c("2011-12-31","2013-12-31",...

java - Invalid operation for read only resultset when using select for update nowait in multithreaded environment -

for oracle database, following program throw sql exceptions threads. why downgrading resultsetconcurrency concur_updatable concur_read_only ? in single thread environment not happening. import java.sql.connection; import java.sql.drivermanager; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; public class main extends thread { public static final string dburl = "jdbc:oracle:thin:@localhost:1521:db"; public static final string dbuser = "user"; public static final string dbpass = "pass"; public static void main(string[] args) { // todo auto-generated method stub for(int i=0; i<20; i++) new main().start(); } @override public void run() { try { drivermanager.registerdriver(new oracle.jdbc.driver.oracledriver()); connection con = drivermanager.getconnection(dburl, dbuser, dbpass); con.setautocommi...

finite automata - Can I use stack in Turing Machine? -

i trying design turing machine accepts language l = {w | a n b 2n } ∑ = {a, b}. for example machine accepts input : "aabbbb" not accept "aabb" my code below language ; #include <iostream> #include <string> using namespace std; char stack[30]; int top = -1; void push(char ch){ stack[++top] = ch; } char pop(){ return stack[top--]; } int main(){ string str; char flag = 0; cout<<"enter input string: "; cin>>str; for(int i=0; i<str.length(); i++){ if(str[i] == 'a') push(str[i]); else if(str[i] == 'b'){ if(top<0 || i>=str.length()-1 || str[++i] != 'b'){ flag = 1; break; } pop(); } else{ flag = 1; break; } } if(flag == 1 || top != -1) cout<<"input unacceptable turing machine.\n...

websphere - WAS 8.5.5.2 not able to connect to DB2 Datasource -

i trying test datasource connection created on cluster in websphere 8.5.5.2 nd db2. click on test connection button, flashes me following message: the test connection operation failed data source temp on server nodeagent @ node mynode001 following exception: java.sql.sqlinvalidauthorizationspecexception: [jcc][t4][2013][11249][4.16.53] connection authorization failure occurred. reason: user id or password invalid. errorcode=-4214, sqlstate=28000 dsra0010e: sql state = 28000, error code = -4,214. i checked everything, username , password correct , not expired. driver files verified. tried restarting deployment manager node agents still displays me same error

perl module - Net::Google::Spreadsheets login failing. need to use two-legged OAuth2 -

i have application uses net::google::spreadsheets. began fail authentication errors earlier week. understanding google has deprecated authentication methods, , use oauth2. my application runs on headless server, cannot use three-legged oauth2 solution shown in net::google::authsub login failed new google drive version i need use two-legged authentication service account. put code build jwt, , obtain access_token (as detailed in google developer documentation). what need assistance method need use net::google::spreadsheets make use of access_token, or method two-legged oauth2 works module. if have managed create access_token, should able right format net::google::spreadsheets using create new net::oauth2::accesstoken object, , proceeding more or less in example linked in other thread : use net::google::spreadsheets; use net::google::dataapi::auth::oauth2; use net::oauth2::accesstoken; $oauth2 = net::google::dataapi::auth::oauth2->new( client_id => ...

DataGrid with wpf in vb.net not working -

here vb code imports system.data imports system.data.sqlclient class mainwindow private sub button1_click(sender object, e routedeventargs) handles button1.click dim cmd sqlcommand = new sqlcommand("select qnumber tencmpc1", new sqlconnection(" server=(localdb)\projects;database=question;uid=sa;pwd=12345;")) try dim adp new sqldataadapter(cmd) cmd.connection.open() dim ds dataset = new dataset adp.fill(ds, "qnumber") grid.itemssource = ds.defaultviewmanager 'dim adp new sqldataadapter(cmd) 'cmd.connection.open() 'dim ds new dataset() 'adp.fill(ds) 'grid.itemssource = ds 'cmd.executereader() ''grid.databind() 'adp.dispose() 'ds.dispose() 'cmd.connection.dispose() catch ex exception txt1.text = ex.message end try end sub end class <w...

mysql - Any better alternative for getting last record without limit -

i have following query declare lv_duration int; set @lv_duration = 0; select @lv_duration := timestampdiff(second, changedon,now()) `transactionhistory` transaction_id = trim(_transaction) order tsh_id desc limit 1; in getting time since last entry of transaction_id fields.but taking .25 of second in relative mid size table.my primary auto-increment field tsh_id. have index on transaction_id field. think ordering , taking last record might have performance impact. alternative it? from order by optimisation link supplied mcadam331 believe query matches pattern: select * t1 key_part1 = constant order key_part2; a composite index on (transaction_id,tsh_id) should speed up. i don't think there quicker way limit latest record.

css - javascript - innerHTML with fade in -

with following line of code: document.getelementbyid("mydiv").innerhtml=txt; is possible add .fadein("slow" ) function? new text fade in. do js+css. css transition fade in. you need have font-color set background-color. first change content, change color normal font color. your js: document.getelementbyid("mydiv").innerhtml=txt; document.getelementbyid("mydiv").style.color = "#333333"; your css: #mydiv { color: #ffffff; transition: color 2s ease 0s; }

css selectors - :nth-child(3n):after cleafix not working in CSS -

hello there have tried following think should valid css , not work (tested google chrome). <ul> <li><a href="...">bla</a></li> <li><a href="...">bla</a></li> <li><a href="...">bla</a></li> <li><a href="...">bla</a></li> <li><a href="...">bla</a></li> </ul> the css: ul li { float:left; } ul li:nth-child(3):after { content:""; display:table; clear:both; } the floating list elements should start new row after each third element in list within responsive design. have solution suggestion? isnt supposed work? just apply below. ul li:nth-child(4n) {clear:both;} demo

Share a function between two passes inside CG Shader for unity3d -

i'm writing shader in cg language unity3d. if make shader transparent object need create 2 similar passes in subshader . first 1 render faces (with cull front ) , second 1 render front faces (with cull back ). code vertex , fragment function same 2 passes. is possible not double code , declare functions, shared between passes? want have in code example: shader "cool shader" { properties { ... } subshader { cgprogram // need declare vertexoutput somewhow here float4 sharedfragfoo(vertexoutput i) : color // how make smth this? { .... return float4(...); } endcg pass { cgprogram #pragma vertex vert #pragma fragment frag vertexoutput vert(vertexinput v) { vertexoutput o; ... return o; } float4 frag(vertexoutput i) : color { return sharedfragfoo(i); // call shared between passes function } ...