Posts

Showing posts from June, 2012

java - Highlighter addHighlight not changing text color -

Image
i have jtextarea in highlight text using addhighlight method of highlighter jtextarea. highlights text not change text color of highlighted text selectedtextcolor have set. here example: import java.awt.color; import javax.swing.jframe; import javax.swing.jscrollpane; import javax.swing.jtextarea; import javax.swing.swingutilities; import javax.swing.text.badlocationexception; import javax.swing.text.defaulthighlighter; import javax.swing.text.highlighter; import javax.swing.text.highlighter.highlightpainter; public class sscce { private jframe frame; private jtextarea textarea; public sscce() { frame = new jframe(); frame.settitle("huge text"); frame.setdefaultcloseoperation(jframe.exit_on_close); textarea = new jtextarea("abcd abcd abcd"); textarea.setbackground(color.dark_gray); textarea.setforeground(color.light_gray); textarea.setselectioncolor(color.light_gray); textarea.s

c# - Unable to connect to the remote server using ClientWebSocket -

i'm trying connect web socket server on localhost:9222 using c# code: var ws = new clientwebsocket(); var uri = new uri("ws://localhost:9222/x/y/z", urikind.absolute); await ws.connectasync(uri, cancellationtoken.none); on last line, i'm getting unable connect remote server , inner exception the remote server returned error: (404) not found. . however, have javascript connects same websocket: var ws = new websocket("ws://localhost:9222/x/y/z"); and works great in both ie , chrome. i'm not using proxies. is there i've missed configure in c# code? how can debug this? update: using websocket4net instead of .net 4.5 clientwebsocket, i'm getting http 1.1 500: internal server error . however, i'm not sure how can debug either.

ruby - Error when creating new app with rails -

i installed rails on windows railsinstaller , when try create new application command e.g. rails new blog it creates lot of files after using turbolinks 2.2.2 returns error me: bundler::gemspecerror: not read gem @ c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/cache/tzinfo-data-1.2014.3.gem. may corrupted. how can solve problem? it looks have corrupted gem file (maybe due network download issue). go c:\railsinstaller\ruby1.9.3\lib\ruby\gems\1.9.1\cache\ , delete file called tzinfo-data-1.2014.3.gem . then run rails new blog command again , should work.

java - Java8 reducing a stream -

i have following methods: static intstream streameddivisors(final int n) { return intstream.range(2, n).parallel().filter(input -> n % input == 0); } static int streamedphi(final int n) { return streameddivisors(n).reduce(0, x -> x * x); } and i'm getting compilation error in streamedphi indicating have incompatible parameter types in lambda expression. can me make sense of this? i'm trying take divisors of given number n, , aggregate number on function defined (in case, squaring number). your compilation issue due fact intbinaryoperator#applyasint(int, int) takes 2 arguments. declaring/providing one. as stated in comments , after looking @ javadoc of intstream#reduce(int, intbinaryoperator) , aren't applying valid reduction. it's not clear me mean and aggregate number on function defined brian has suggestions .

Windows Firewall, Tinywall and GIT -

just updated win7 xp. using windows firewall added tinywall (gives more control) but when use git bash, firewall blocks commands. if disable firewall works ok i cannot figure proper exceptions add tinywall whitelist. i added shell window git.exe application exceptions still no go. these exceptions program paths added: c:\program files (x86)\git\git-cheetah\..\bin\sh.exe c:\program files (x86)\git\bin\git.exe example of error: $ git pull ssh: connect host xxx.xxx.xxx port 22: bad file number fatal: not read remote repository. please make sure have correct access rights , repository exists. to tinywall work git on ssh, must white-list: sh.exe git.exe ssh.exe to work git on https, need whitelist: c:\program files (x86)\git\libexec\git-core\git-remote-https.exe or c:\program files\git\mingw64\libexec\git-core\git-remote-https.exe

ruby on rails - How to configure Devise to re-authenticate user? -

i'm trying re-authenticate user when session old , he/she checking out order. when use: redirect_to "/users/sign_in" i get: filter chain halted :require_no_authentication rendered or redirected in console. is there way configure devise enable re-authentiction of users before critical actions? thanks help! in case you're considering re-authenticate user, session timeout. can configure devise use :timeoutable option. add :timeoutable devise attribute in user model. modify initialisers/devise.rb: uncomment config.timeout_in = 30.minutes you can set session time prefer. restart server. cheers!!

javascript - String validation with regex in JS -

i need frame regex validate string format in javascript, total length of string should between 3 , 30 characters length. first character must strictly alphabet. subsequent characters can either alphabet or dot or space. please help. the following work you. var re = /^[a-z][a-z. ]{2,29}$/i regular expression: ^ # beginning of string [a-z] # character of: 'a' 'z' [a-z. ]{2,29} # character of: 'a' 'z', '.', ' ' (between 2 , 29 times) $ # before optional \n, , end of string

java.io.FileNotFoundException: <my path> (The system cannot find the file specified). Please guide -

following code throws exception: java.io.filenotfoundexception: c:\cloud project\resource freeing attacks in cloud performance code , db\ftp\ftp\src\public.key (the system cannot find file specified) i not able figure out why key file not found. doubt key files not getting written why system not find them. package com.util; import java.net.*; import java.io.*; import java.security.keyfactory; import java.security.keypair; import java.security.keypairgenerator; import java.security.nosuchalgorithmexception; import java.security.privatekey; import java.security.publickey; import java.security.spec.invalidkeyspecexception; import java.security.spec.pkcs8encodedkeyspec; import java.security.spec.x509encodedkeyspec; import javax.crypto.cipher; import javax.crypto.cipherinputstream; import javax.crypto.cipheroutputstream; import javax.crypto.spec.secretkeyspec; public class simpleftpclient { public static string path = "c:/cloud project/resource freeing attacks in cloud

c++ - Gtkmm program compiles fine but crashes - windows XP -

i have installed gtkmm (gtkmm-2.4) when compile g++ use following information pkg-config headerfiles pkg-config gtkmm-2.4 --cflags objectfiles pkg-config gtkmm-2.4 --libs so compile simple helloworld problam show window on screen ... g++ gtkmm_app2.cpp -o gtkmm_app2 `pkg-config gtkmm-2.4 --cflags --libs` it compiles fine when execute program chrashes. following information: an unhandled win32 exception occurred in gtkmm_app2.exe[5364] i not exert on debugging when redirected visual studio problems seems point dll-file: libglibmm-2.4-1.dll information versions , platforms compiler: gnu c++ compiler: 3.4.5-20060117-3 gnu c++ compiler runtime library: 4.7.2-1 os: windows xp home edition 2002 (sevice pack 3) so question: have no idea problems depends on? version of mingw? or operating system causing problem? can compile , execute without problems using gtk3 on c-apps, not gtkmm c++. ideas how solve problem(s)? extremely helpful this!!! =======

javascript - selecting specific element within one parent -

this html form structure: edit: each section generated php script, , section id change depending on user input. not able use whole selector because of this <section id="janedoe"> <div class="gcolumn1">jane doe</div> <div class="gcolumn2">color: <input type="radio" name="chk_clr[]" id="chk_clr[]" value="y">yellow <input type="radio" name="chk_clr[]" id="chk_clr[]" value="r">rose <br>food: <input type="radio" name="janedoe-chk_food[]" id="chk_food[]" value="y">yes <input type="radio" name="janedoe-chk_food[]" id="chk_food[]" value="n">no</div> <div class="gcolumn3"> <select id="meal[]" disabled> <option value=""></option> <option value=&qu

sql server - Calculate sum in SQL and display it as another column? -

i used following query calculating credit of customers problem want calculate sum of credit column in sum credit , display in column .is there way of doing modifying following query? highly appreciable. select customer_name ,todays_total ,amount_recieved ,date_sale ,item_model ,quantity ,credit = (case when amount_recieved=0 , todays_total>0 , credit =0 todays_total when amount_recieved>0 , todays_total>0 , credit>=0 (credit+todays_total)-amount_recieved when amount_recieved>0 , todays_total=0 , credit >0 (credit-amount_recieved) end) customer_credit_records customer_name='saad ned' first, here query more understandably formatted: select customer_name, todays_total, amount_recieved, date_sale, item_model, quantity, credit = (case when amount_recieved=0 , todays_total>0 , credit=0 todays_total when amount_recieved>0 , todays_total>0

c# - DataGridViewComboBoxCell value is not valid -

can explain me how add datagridviewcomboboxcell datagridview? code this: foreach(....){ datagridviewcomboboxcell cmb = new datagridviewcomboboxcell(); //cmb.item.add(.... datagridview.rows.add(new object[] {cmb,name,surname}); } first cell in grid type of datagridviewcomboboxcolumn, tried changing cmb datagridviewcomboboxcolumn , still nothing. i handeld dataerror dont "value not valid" error, comboboxes in datagridview empty. ok, solved problem. seems have add values cells step step. i'm going give general explanation because seems loot of people have problem this. let's have datagridview 3 columns, datagridviewtextboxcell, datagridviewcomboboxcolumn, datagridviewcheckboxcell in order. now, have make make 3 columns using desinger or otherwise wont work. so want add specific values grid, each row representing lets person. in designer looks like name phonenumbers married ..*.. |.....|..............|.........|.... so

r - ggplot2: legends for different aesthetics -

Image
i first plot histogram group of simulated data , fill bars 1 colour. add line of density function data simulated , make line different colour. want use legends show 1 colour (the fill colour of histogram) samples whereas other (the colour of line) theoretical density. how can achieve this? the code follows require(ggplot2) df <- data.frame(x=rnorm(10^4)) p <- ggplot(df, aes(x=x)) + geom_histogram(aes(y=..density..), fill='steelblue', colour='black', alpha=0.8, width=0.2) x <- seq(-4, 4, 0.01) df <- data.frame(x=x, y=dnorm(x)) p <- p + geom_line(data=df, aes(x=x, y=y), colour='red', size=1.5) p without changing data @ all, can specify literal aes() values can define later via manual scales. df <- data.frame(x=rnorm(10^4)) p <- ggplot(df, aes(x=x)) + geom_histogram(aes(y=..density.., fill="samples"), alpha=0.8, colour="black", width=0.2) p <- p+scale_fill_manual("",breaks="sample

php - How to use call_user_func() instead of eval()? -

i needed automatically parameters $_get['url'] variable. thought i'll make using eval() function. as i've heard how not-secure is, began search solution , i've found function called call_user_func() , don't know how use it. this code, worked correctly, don't want use anymore. can tell me how make working call_user_func() ? $execute = '$controller->' . "$url[1]("; for($i=2; $i<count($url); $i++){ $execute .= "'" . $url[$i] . "'"; if($i<count($url)-1){ $execute .= ", "; } } $execute .= ');'; eval($execute); you might want use call_user_func_array instead: if (method_exists($controller, $url[1])) { call_user_func_array(array($controller, $url[1]), array_splice($url, -2)); } basically check if method exists, if call list of arguments. doing: $controller->{$url[1]}($url[2], $url[3], $url[4], ..); call_user_func ideal if have no

jsf - How to avoid exception, <c:if> and <c:catch> -

i'm trying render page, there possibility el expressions generate exceptions. tryed first of all, sorround block < c:if> in such way shows code checking critical condition. saw in case of "error" page redirected again "http 500 - internal server error". tought maybe el expression inside block computed in case, if < c:if> block not shown. sorrounded block < c:catch> read block catch exceptions. added on methods declaration "throws exception". but, again, when critical condition not respected, page redirect 500 error page. i post xhtml code: <c:if test="#{!partybean.emptyset}"> <c:catch> <p:panel id="panel" style="margin-bottom:10px;"> <f:facet name="header" > <h:outputlabel value="#{partybean.currentparty.name}" /> </f:facet> <f:facet name="actions">

Solving codingBat Post4 with one loop in Java -

the question solving this problem codingbat in java. problem statement: given non-empty array of ints, return new array containing elements original array come after last 4 in original array. original array contain @ least 1 4. note valid in java create array of length 0. post4({2, 4, 1, 2}) → {1, 2} post4({4, 1, 4, 2}) → {2} post4({4, 4, 1, 2, 3}) → {1, 2, 3} here solution: public int[] post4(int[] nums) { int lastfour=-1; int[] post4={}; for(int i=nums.length-1;i>=0;i--) { if((nums[i]==4)) { lastfour=i; //find index of last 4 in array break; } } int newlen=(nums.length-lastfour)-1; post4=new int[newlen]; //reassign post4 array required length for(int j=0;j<newlen;j++) { post4[j]=nums[lastfour+1]; //assign values orig. array after last 4 lastfour++; } return post4; } but have used 2 loops. should solved using @ max 1 loop. not use collections or wrappers classes. before it

c# - Design-pattern: different types of objects to one -

i want convert different types of objects one. for example have: object1:class1 object2:class2 object3:class3 all objects different, not make them inherit 1 interface. before transferring part of application, want convert them objectdto:classdto. what design pattern used in situation? you can use implicit type conversion operator in c#: public class object1dto { public int property {get; set;} } public class object1 { public int property {get; set;} public static implicit operator object1dto(object1 object1) { return new object1dto { property = object1.property }; } } or can use extensions: public static class extensions { public static object1dto todto(this object1 object1) { return new object1dto { property = object1.property }; } } you can @ libraries automapper handle such object-object mapping scenarios.

Symfony error with form entity class -

i'm trying add validation rules form using callbacks few choice fields. callback saw in documentation should in entity class form. in case i'm having time problem: "contexterrorexception: notice: array string conversion in /applications/mamp/htdocs/bbc/vendor/symfony/symfony/src/symfony/component/form/extension/core/choicelist/choicelist.php line 462" my code in entity looks this: namespace cgboard\appbundle\forms; use cgboard\appbundle\classes\iplayer; class searchentity { public $category; public $coming_soon_within; public $local_radio; public $masterbrand; public $max_tleos; public $media_set; public $page; public $perpage; public $q; public $search_availibity; public $service_type; public $signed; public static function getcategories() // getters firing error, why? { return ['undef', 'arts', 'cbcc', 'comedy'

php - Deschifer this bit of code please -

what following bit of code mean in "english"? just started learning php & codeigniter , cant seem make sense of it. <meta name="description" content="<?if (isset($contentdata) && isset($contentdata->description)):?><?=$data->description?><?=$contentdata->description?><?endif;?>" /> as far understand, gets info database, i'm not sure how, or why 2 conditions must true (&&). //if there's variable $contentdata , has property ->description <?if (isset($contentdata) && isset($contentdata->description)):?> //shorthand syntax <?php echo $data->description ?> <?=$data->description?> //shorthand syntax <?php echo $contentdata->description ?> <?=$contentdata->description?>

Google Drive Android Api reset Play Services Authorization -

when debugging gdaa app, need re-test "brand new account" situation. i.e. getting dialog asks user allow drive access: "[yourapp] to: view , manage google drive files have opened or created app" is there re-set method me ground zero? you can reset via drive "manage apps" page on web. disconnect app drive.

Validate number field with int values in Symfony -

im tryint validate field should contain int value (1, 2, 3....), not decimals. for i've set in form code: ->add('page', 'number', ['data'=>1]) in validation.yml have configured this: page: - type: type: digit i tried digit, int, integer , on, none of them allowed me introduce natural number , pass validation. use http://symfony.com/doc/current/reference/forms/types/integer.html , http://symfony.com/doc/current/reference/constraints/range.html . set min range 1 , precision 0 integer validator.

sql - VBScript - Syntax Error in FROM Clause -

so i'd preface saying have little experience vbs. anyway, i'm trying write script want calculate year number of project (but leave blank under circumstances) database storing several projects. there error i'm receiving is: error 800a0c3b – syntax error in clause. line 26 char 1 source: dao.database , can't quite figure out how fix it. option explicit 'line 1 'declare variables dim rs1 dim rs2 dim year '5 dim yearno dim oaccess dim oshell dim dblocation dim currentdb '10 dim sql dim program_year dim construction_year dim ofso set ofso = createobject("scripting.filesystemobject") '15 set oshell = wscript.createobject("wscript.shell") dblocation = "[drive]\folder\folder\file.accdb" set oaccess = createobject("access.application") '20 oaccess.opencurrentdatabase(dblocation) 'sql = "select * [expenditures] in '" & dblocation & "' " '25 oaccess.currentdb.exe

c# - Why I can't convert a byte[2] array to int with BitConverter? -

the main problem recive binary number 10 bits in use serialport use receive complete data: byte[] buf = new byte[2]; serialport.read(buf, 0, buf.length); bitarray bits = new bitarray(buf); the original idea convert binary int this: foreach (bool b in bits) { if(b){ binary += "1"; } else{ binary+= "0"; } } decimal = convert.toint32(binary, 2); decimal = decimal >> 6; binary string, works need know if exists solution, instead of previuos code try this: decimal = bitconverter.toint16(buf, 0); but read first 8 bits, need other 2 bits missing! if change toint16 toint32 decimal = bitconverter.toint32(buf, 0); the program stops system.argumentexception: destination array not long enough... what can do? you can shift values in bytes match, , put them together. if got use of bits right, be: int value = (buf[0] << 2) | (buf[1] >> 6);

c# - Visual Studio 2010 editor unexpected autocorrection -

i installed vs2010 32b spanish, , found strange issue while editing code. when write "s (in #include "st..." example), automatically converted s accent mark. similar issue happens when write aa, ii or uu, in these cases aa converted a+hypen (same behaviour other vowels less o , e). if write ""s ok, if delete 1 ", remaining "s again transformed in s accent. i noticed looks more visual effect, because if copy "wrong" code , paste in editor, looks perfect: "s "s. furthermore, vs compiles code these issue, points it's visual.. if write #include "stdafx.h" aa ii oo uu vs shows: #include ´stdafx.h" <=== 's s accent, can't write here! â î oo û <===== aa ii , uu converted in while editing. i'm unable find happening or why, , how remove annoying effect. tried different settings related (or so), nothing worked, reverted changes. notice os language , vs spanish, tried vs in english

ember.js - model returns null on controller -

i'm working a router , controller, , need complete operations on controller, model code acornstest.stockroute = ember.route.extend({ model: function(params) { "use strict"; var url_params = params.slug.split('|'), url = acornstest.config.quandl.url + '/' + url_params[0] + '/' + url_params[1] + '.json', stockinstore = this.store.getbyid('stock', url_params[1]), today = new date(), yearago = new date(), self = this; yearago.setfullyear(today.getfullyear() - 1); today = today.getfullyear()+'-'+today.getmonth()+'-'+today.getdate(); yearago = yearago.getfullyear()+'-'+yearago.getmonth()+'-'+yearago.getdate(); if(stockinstore && stockinstore.get('data').length) { return stockinstore; } return ember.$.getjson(url,{ trim_start: yearago, trim_end: today, auth_token: acornstest.config.quandl.apikey }) .then(fun

CustomListViewAddapter in Fragment Android -

i have problem customlistviewaddapter in fragment. have main activity has slide menu , try show customlistview in it. , error when tried use try-catch here part of main activity call fragment slide menu @suppresslint("newapi")public class mainactivity extends activity { .......some code..... @targetapi(build.version_codes.honeycomb) @suppresslint("newapi") private void displayview(int position) { log.i("position***", position + ""); // update main content replacing fragments fragment fragment = null; fragment fragment1 = null; switch (position) { case 0: fragment = new homefragment(); fragment1 = fragment; log.i("fragment1", fragment1 + ""); break; case 1: fragment = new findpeoplefragment(); break; case 2: fragment = new photosfragment(); break; case 3: fragment = new communityfragment(); break; c

Ruby on Rails : How to have conditional sender email address -

i using rails4, need change email address of action mailer based on condition. still takes default email address. how working? class mailercontroller < actionmailer::base before_filter :get_tenant default from: "#{env['tenant_email']}" if $tenant == 'mytenant' def get_tenant $tenant = 'mytenant' end end i have mailerclass inherits mailercontroller.... error: smtp address required send message. set message smtp_envelope_from, return_path, sender, or address. my recommendation, change 'from' inside mail method. def tenant? is_it_my_tenant_logic end def tenant? ? mailercontroller.default[:from] : "hiro@metaverse.com" end def a_mailer_method mail(:from => from, :to => "yt@realworld.com" , :subject => "i have logged in") end

spring - Do I have to try-catch JpaRepository -

i using jparepository spring data jpa framework. have snippet of code below: @repository public interface presetfolderrepository extends jparepository<presetfolder, integer>{ @modifying @transactional @query("update presetfolder pf set pf.parentid = :parentid pf.id = :id") int updateparentid(@param("id") int id, @param("parentid") int parentid); } when invoke method: @autowired presetfolderrepository repo; repo.updateparentid(1,2); public void test(){ do have surround try-catch? how can know if self-defined method 'updateparentid' has try-catch implementation in it? thanks! edit: concern is, if database went down, method catch exception. repositories tell if problem happens (i.e. never swallow exceptions). you'll runtime exception if that's case. and should not catch such exception either, except @ top of call stack, have possibility display error message end user.

Customise the Tumblr 'Submit' Form -

i'd restyle default submission block on tumblr theme here on tumblr themes: name.tumblr.com/submit but i'm struggling find if possible. you try using css filters or positioned overlays; being iframe restricts of usual options. the other method i've got work applying background image , messing iframe's opacity.

php - How add user data to an already registered user -

i new database world. in registration process user has give values, required (e-mail , password). when registered , logged in, want give user opportunity add not required info row in database. edit2: here updated version of relevant part of code. not working, beyond happy, if point me right direction once again! thank you!! <?php require_once 'config.php'; require_once 'database_connection.php'; $first_name = trim($_request['first_name']); $last_name = trim($_request['last_name']); $url= trim($_request['url']); //get logged in user's id $user_id = $_request['user_id']; //select logged in user $select_query = "select * users user_id = " . $user_id; //update user's row $update_sql = sprintf("update users (first_name, last_name, url) " . "values ('%s', '%s','%s');", mysql_real_escape_string($first_name),

html - Javascript: How to tell if a span is the first thing in a paragraph? -

i objective c programmer, , need javascript in latest project. 1 week ago had never worked on javascript. have spent few hours on particular problem , can't figure out. know virtually nothing javascript, apologise in advance if make basic errors (very likely). basically have html page. there number of custom span tags in page. need function tells me if particular span tag first thing (not first span) in paragraph. e.g. if html looks this: <p><span class="myclass">the</span> quick brown fox jumps on lazy <span class="myclass">dog.</span></p> and use var spanlist = document.getelementsbyclassname("myclass"); i need function return true isfirstinparagraph(spanlist[0]); //ie. word "the" and false for isfirstinparagraph(spanlist[1]); // ie. word "dog." and in following case, both spans return false, since neither first thing in paragraph.: <p>the <span class="myc

How to execute shell script and save in text file command through java in linux -

i m using linux. i want call small executable application java command line called "wmic". needs input query. output stored in text file in specific directory. when use command in linux terminal echo "hello world" >> /home/kannan/hello.txt the output stored in hello.txt file. but when call command java process p = runtime.getruntime().exec("echo \"hello world\" >> /home/kannan/hello1.txt"); the output not created hello1.txt file please 1 me. thanks in advance. use processbuilder . makes easy redirect output of command file shown below: new processbuilder("echo", "hello").redirectoutput(new file("output.txt")).start(); if want append output file: new processbuilder("echo", "hello").redirectoutput(redirect.appendto(new file("output.txt"))).start();

vb.net - ASP.NET Snowman in Validation Error -

we've been experiencing problem on our site in internet explorer 8. we have form, when submitted in ie8 displays validation exception, claiming character "☃" potentially dangerous. system.web.httprequestvalidationexception (0x80004005): potentially dangerous request.form value detected client (_utf8="☃"). the funny thing character not typed in, , not part of our vb .net project. if set page validaterequest = "false", error goes away, fear opening ourselves xss attacks. sanitise our own inputs, rather got source of problem, rather creating work around. this thread regarding ruby seems interesting, we're unsure how applies our situation: what _snowman param in ruby on rails 3 forms for? also worth considering form works in other browsers have tested (ie11, chrome, fire fox, opera). you can override specific case in request validator (excuse c#, you'll able translate it): public class enhancedrequestvalidator : reque

java - Disable log output from libraries -

in java program, using log4j2 (debug) output. when using third party libary, disable log output these libraries. how can that? actually seems quite simple me not find solution it. can't 1 looking this? an example of turning off logging in log4j 1.x add following xml tag log4j.xml. category name package path root of library want ignore logging from. example ignore log4j logging apache tiles library use following: <category name="org.apache.tiles"> <priority value = "off" /> </category>

sql - PLS-00382: expression is of wrong type in Oracle cursor -

i have written cursor in oracle 11g follows: declare cursor qna_cursor select activity_id, question, answer table1 question != 'surveytext' order activity_id, question; cur_count int := 1; que nvarchar2(10); ans nvarchar2(10); sqlcommand nvarchar2(500); rowcountvar int; begin queans in qna_cursor loop if cur_count = 4 cur_count := 1; end if; /* have 3 questions each activity_id */ que := 'question' || cur_count; /* question1, question2, question3 */ ans := 'answer' || cur_count; /* answer1, answer2, answer3 */ sqlcommand := 'update table2 set '||que||' = :1, '||ans||' = :2 activity_id = :3'; execute immediate sqlcommand using queans.question, queans.answer, queans.activity_id; cur_count := cur_count + 1;

c# - Why is the Console pausing my code when I click on the scrollbar -

run code in c# console application: long last = 0; long curr = stopwatch.gettimestamp(); while (true) { last = curr; curr = stopwatch.gettimestamp(); var delta = ((curr - last) / (float)stopwatch.frequency) * 1000; console.writeline(delta); thread.sleep(50); } this source should print out steady numbers like ... 62.234235 62.123134 62.589342 62.423423 ... and while running hold scroll button seconds. while holding button outputs should stop cause thread sleeping.... the next output when u release smt. this: ... 62.234235 62.123134 <--- holding scroll button 2540.342112 <--- release 62.589342 62.423423 ... now question: there way stop console telling thread goodnight story when scrolling? no, there no way. console.writeline blocking operation . when scroll, preventing call complete, stopwatch continues run. the number seeing when release scroll 50 + how long keep holding scrolling button.

MVVMCross programmatically change start ViewModel -

the portable class library defines start view model. scenario sounds great considering this. have written ios universal application or android needs change start screen / view model. if application phone, default view model login if tablet, want different view model start. there override or way take control of this? see wiki section - https://github.com/mvvmcross/mvvmcross/wiki/customising-using-app-and-setup#custom-imvxappstart - has example of programmatic switching: if more advanced startup logic needed, custom app start can used - e.g. public class customappstart : mvxnavigatingobject , imvxappstart { public void start(object hint = null) { var auth = mvx.resolve<iauth>(); if (auth.check()) { showviewmodel<homeviewmodel>(); } else { showviewmodel<loginviewmodel>(); } } } this can registered in app using: registerappstart(new customappstart

multithreading - How to populate two dataGridViews continously using different threads in C#? -

Image
i have created 2 datagridviews , start button shown in figrue. when press start button 2 threads t1 , t2 created using delegate mydel. actually, want both datagridview1 , datagridview2 populated continuously. datagridview2 getting updated continuously. after completion of datagridview2, datagridview1 starts updating. can please give me suggestion how fix this? using system; using system.windows.forms; using system.threading; namespace multithreadeddatagridviewdemo { public partial class form1 : form { private delegate void mydel(); int count=0; int count_1 = 0; public form1() { initializecomponent(); //cells created in datagridview1 , datagridview2 (int p = 0; p < 37; p++) { datagridview1.columns.add("", "");// dynamic cloumn adding datagridview1.rows.add();//dynamic row adding datagridview1.colum