Posts

Showing posts from September, 2014

exception - Where does Java language define if a Throwable is checked or not? -

both exception , runtimeexception inherits throwable , not implement interface tell whether checkd or not. where specified exception checked , runtimeexception unchecked? hardwired in language or jvm? it's defined in java language specification section 11.1.1 . throwable , subclasses are, collectively, exception classes. exception superclass of exceptions ordinary programs may wish recover. error superclass of exceptions ordinary programs not ordinarily expected recover. error , subclasses are, collectively, error classes . [...] the class runtimeexception direct subclass of exception . runtimeexception superclass of exceptions may thrown many reasons during expression evaluation, recovery may still possible. runtimeexception , subclasses are, collectively, run-time exception classes . the unchecked exception classes run-time exception classes , error classes. the checked exception classes exception classes

ajax - onclick calling object working ONLY in Firefox -

as stated in title, can onclick calling object in firefox: not in chrome, not in ie, not in safari. i pretty new ajax , javascript in general, built code around answers guys gave here . i have html page number of 'products': each 1 of them, have form hidden fields contain information product. every form has 2 (submit) buttons: 1 'add' product shopping cart, other take 'off' of it. want identify button gets clicked in order identify product refers , add or cancel cart list. here html code page: <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> test </title> <meta charset="utf-8"> <script src="form_submit.js" type="text/javascript"> </script> </head> <body> <form id="ajax_1" name="ajax_form" method="post" action="test.php"> <fieldset>

c# - How can I specify an unordered Execution Block using the TPL Dataflow Library? -

i want set transformblock processes item in parallel. thus, i'm setting executiondataflowblockoptions.maxdegreeofparallelism > 1. don't care order of messages documentation says: when specify maximum degree of parallelism larger 1, multiple messages processed simultaneously, , therefore, messages might not processed in order in received. order in messages output block will, however, correctly ordered. does "correctly ordered" mean if there 1 message in queue needs long processing time, further messages not output until 1 message processed? and if so, how can specify execution block (for example transformblock ) not care ordering? or have specify @ consumption end don't care ordering? there no such block in library, can create 1 combining actionblock , bufferblock . like: public static ipropagatorblock<tinput, toutput> createunorderedtransformblock<tinput, toutput>( func<tinput, toutput> func, executiondataf

How to rename all files and folder containing underscore to hyphen in Linux -

i want rename files , folder containing underscore in name , replace underscore hyphen. currently using following code, rename '_' '-' */*/* it working showing me "argument list long" you can try this: $ tree foo foo ├── dir_1 │   └── foo_file_2 └── file_1 1 directory, 2 files $ ft in d f; find foo -type $ft -execdir sh -c 'mv "$0" "${0//_/-}"' {} \; ; done 2>/dev/null $ tree foo foo ├── dir-1 │   └── foo-file-2 └── file-1 1 directory, 2 files this renames directories , files (the for loop on d f ) because haven't been able make renaming in 1 iteration.

algorithm - Computing the square root of 1000+ bit word in C -

imagine have e.g. 1000 bit word in our memory. i'm wondering if there way calcuate square root of (not accurate, lets without floating point part). or we've got memory location , later specified various size. i assume our large number 1 array (most significant bits @ beginning?). square root more or less half of original number. when trying use digit-by-digit algorithm there point when usnigned long long not enough remember partial result (subtraction 01 extended number). how solve it? getting single digit of large number? bitmask? while thinking pseudocode stucked @ questions. ideas? how hand? how divide 1000 digit number 500 digit hand? (just think method, quite time consuming). square root, method similar division "guess" first digit, second digit , on , subtract things. it's square root, subtract different things (but not that different, calculating square root can done in way similar division except each digit added, divisor changes). i w

IE 11 Javascript Object doesnt support property or method 'match' -

its javascript countdown working on firefox & chrome not working on ie 11. here code return this.each(function() { // convert if(!(todate instanceof date)) { if(string(todate).match(/^[0-9]*$/)) { todate = new date(todate); } else if( todate.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})\s([0-9]{1,2})\:([0-9]{2})\:([0-9]{2})/) || todate.match(/([0-9]{2,4})\/([0-9]{1,2})\/([0-9]{1,2})\s([0-9]{1,2})\:([0-9]{2})\:([0-9]{2})/) ) { todate = new date(todate); } else if(todate.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})/) || todate.match(/([0-9]{2,4})\/([0-9]{1,2})\/([0-9]{1,2})/) ) { todate = new date(todate) } else { throw new error("doesn't seen valid date object or string") } }

audio - How to extract a Sound envelope from a .wav file using Python? -

Image
i have sound file comprise of instrumental sound. want examine each note of instrument extracting audio file. can use python doing or other open source software can recommend this. got waveform using audacity. have attached image of sound file , red mark indicate portion extracted. starting , ending of envelope. (only single instrument played in audio file). the thing want called envelope detector or envelope follower . maybe try out pyo project this. analysis module has few envelope followers available. edit: appear have misunderstood question title. want split notes? extract envelope, split based on threshold.

dom - creating circles with svg and javascript -

(updated) i'm having issues regarding svg , javascript. want create series of circles on top of 1 another, radius (r) values increasing 1 each time loop goes round, creates sort of pattern. here have far(for loop values forum post, rather while loop execute 10 times) - <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>dynamic svg!</title> </head> <defs> <svg height="10000" width="10000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <circle id="cir1" cx="300" cy="300" r="40" stroke="yellow" stroke-width="" fill="none"/> </svg> </defs> <script> var svgns = "http://www.w3.org/2000/svg"; (var x = 0; x < 5000; x += 50) { (var y = 0; y < 3000; y += 50) { var circle = docum

inheritance - C++ How to initilize abstract base class reference element? -

my problem based on typical diamond hierarchy, not typical diamond problem. class interface { public: int value; // somebigdata &data; interface(int _value = 0) : value(_value) {}; virtual void function1() = 0; virtual void function2() = 0; }; class impone : public virtual interface { public: void function1() { ++value; } }; class imptwo : public virtual interface { public: void function2() { --value; } }; class device : public impone, public imptwo { public: device() : interface(7) {}; }; there abstract interface defining many function (the example above simplified). there implementation classes implement few of these functions @ time. , finally, there non-abstract classes, class device above, implementing whole interface combining several implementation classes together. now, problem this: there integer element in interface class gets initialized class device , shared among implementation classes, far good. if remove = 0 int

html - How do I set a custom viewport for an iframe? -

okay. actually, maybe title makes no sense. please read: i want create iframe custom width. okay. please try understand. i don't want iframe responsive (the site embedded in iframe responsive) , want appear shrunk picture. i can give examples if wish. idea how this? if have tried width attribute , didn't work, try using css' max-width property. example, index.html <iframe src="http://www.google.com/" class="if"></iframe> style.css .if { max-width: 100px; } find here live demo

button - Android onClickListener without xml -

here code: ... setcontentview(r.layout.activity_main); mygrid= (gridlayout) findviewbyid(r.id.gridlayout); mygrid.setcolumncount(3); mygrid.setrowcount(5); imagebutton a1 = new imagebutton(this); imagebutton a2 = new imagebutton(this); mygrid.addview(a1); mygrid.addview(a2); a1.setonclicklistener(this); a2.setonclicklistener(this); ... what need write in onclick method? want if press button "a1" , if press button "a2" another. public void onclick(view a) { can't use "if (a.getid == buttonid)" , because buttons haven't id. } in simple java if((a.getsource() == button1)), don't know how looks in android. in android, need override onclick method in listener: a1.setonclicklistener(new onclicklistener(){ @override public void onclick(view view){ // } }); or create custom listener 1 both buttons, check view clicked: myonclicklistener = new onclick

winapi - Having issues getting the module base address C++ -

Image
i trying make program store value 500 calculator's memory address mr (memory restore) button on calculator application. know address integer "calc.exe"+00073320 + 0 + c if use program cheat engine, can current address instance of calculator.exe i'm running, , write fine way. however, since not static address, need way module base address. i tried using getmodulebase function (see code below) base address of calc.exe, issue cannot base address. function returns 0 instead of correct address. i debugged , found in getmodulebase function, not cycling once through while loop because bmodule returning 0 module32first function. #include <tchar.h> #include <windows.h> #include <tlhelp32.h> #include <iostream> #include <psapi.h> #include <wchar.h> #pragma comment( lib, "psapi" ) using namespace std; dword getmodulebase(lpstr lpmodulename, dword dwprocessid) { moduleentr

php - URL rewrite with .htaccess for login and profile system -

i have website url localhost/project/profile.php?user=username and trying url this: localhost/project/username the able rid of .php using following code: options +followsymlinks -multiviews rewriteengine on rewritebase / rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r,l,nc] rewritecond %{request_filename}.php -f rewriterule ^ %{request_uri}.php [l] but not need right now. here code meant changing url - got off of thread. options followsymlinks rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /index.php?user=$1 [l,qsa] but doesn't work. i need able go url: localhost/project/username , registers original url localhost/project/profile.php?user=username ** answer ** thanks howlin rewriteengine on rewritecond %{the_request} ^(get|post)\ /project/profile\.php\?user=(.*)\ http rewriterule ^ /project/%2\? [r=301,l] rewritecond %{query_string} !user= rewriterul

AngularJS + Protractor How to select Dropdown option based on its text not value -

i want click on item it's text , not it's value dropdown box. i found great post : https://coderwall.com/p/tjx5zg doesn't work expected, search continue forever after match found , not clicking item, if have better example (a working one) or can fix code , make work, i apperciate. this code dan haller post used (all rights reserved him) function selectoption(selector, item){ var selectlist, desiredoption; selectlist = this.findelement(selector); selectlist.click(); selectlist.findelements(protractor.by.tagname('option')) .then(function findmatchingoption(options){ options.some(function(option){ option.gettext().then(function doesoptionmatch(text){ if (item === text){ desiredoption = option; return true; } }); }); }) .then(function clickoption(){ if (desired

CSS Styling not working in external file using backgound-image -

i'm using media queries passing image html page external css file styling works if call image directly html file not external css file. html code: <img id="photo" class="photo-frame"> external css code: #photo { background: url('/images/example-photo.jpg') no-repeat; width: 200px; height: 200px; } .photo-frame { float: left; padding: 10px 10px 30px 10px; background-color: #fff !important; box-shadow: 2px 2px 3px #aaa; transform: rotate(7deg); -moz-transform: rotate(7deg); -webkit-transform: rotate(7deg); -o-transform: rotate(7deg); -ms-transform: rotate(7deg); } so make photo polaroid photo tilted 1 side, problem border not showing white line showing border starts. works okay when reference photo html page , call photo-frame class not when apply id , pass on image externally - extremely appreciated. thanks use <div id="photo" class="photo-frame"> whats happening in <img id="phot

Ruby on Rails - redirect_to -

i'm having trouble understanding redirect_to statement. have model "book" (with boolean attribute "read")and controller "books". created second controller "admins" having methods: index , change. index view renders list off books link change method: <% @books.each |d| %> <%= d.title %><br> <% if d.read==true %> <%= link_to "mark unread", change_path(:id=>d.id)%> <% else %> <%= link_to "mark read", change_path(:id=>d.id)%> <%end %> now change method changes "read" attribute: @book=book.find(params[:id]) if @book.read==true @book.update_attributes(:read => false) else @book.update_attributes(:read => true) end redirect_to action: "index" the problem is: rails tries redirect me show action using :id parameter...(perhaps because change_url /admins/change?id=3) want directed index view "/admins" is there way? seems rails trie

PHP - 2 variables in 1 string -

$title = get_the_title(); echo ($field["field_name"] == "subject" ? "value=\"" .$title. "\"" : "") ? this code sets field value text contents of $title variable. have variable $refcode sit next title read like: title [refcode] i not sure how place new variable next title? you might use sprintf better overview on string. $title = get_the_title(); $recode = 123; echo ($field['field_name'] == 'subject' ? sprintf( ' value="%s" refcode="%d" ', $title, $recode ) : ''); you can add many placeholder ( %s, %d ) want – order of given parameters matter. further description see: http://php.net/function.sprintf.php

php - Database error when accessing $_SERVER variable in Codeigniter -

i'm using codeigniter , i'm trying echo $_server['http_referer'] . whenever tried access $_server variable i'm getting database error. a database error occurred unable select specified database: my_db_name filename: core/loader.php line number: 346 is codeigniter restriction or bug. so, can use : $this->load->library('user_agent'); echo $this->agent->referrer(); read also: http://ellislab.com/codeigniter/user-guide/libraries/user_agent.html

recursion - Recursive mergeSort to Iterative in c++ using deque -

i'm trying iterative version of multiple recursive mergesort: i need make iterable sort function: template<class t> deque<t> mergesort<t>::sort(deque<t> &right){ int size = right.size(); if (size <= 1){ return right; } int middle = size/2; deque<t> left; for(int = 0; < middle; i++){ left.push_back(right.front()); right.pop_front(); } left = sort(left); right = sort(right); return merge(left, right); } the merge function can same: template<class t> deque<t> mergesort<t>::merge(deque<t> &left, deque<t> &right){ deque<t> result; while(left.size() > 0 || right.size() > 0){ if (left.size() > 0 && right.size() > 0){ if (getorder(left.front(),right.front())){ result.push_back(left.front()); left.pop_front(); } else{ result.push_back(right.front()); right.pop_front(); }

java - running jar file from my class file in the IDE netbeans -

i use jar file called korat.jar. executed command line: java -cp $classpath korat.korat --visualize --class test.add --args 3 the classpath contains path of jar , add.class file. i want execute jar in own program java in netbeans ide. think use: string []s={test.add.class.getname(),"--visualize","--class","test.add","--args","3"}; korat.main(s); i exception: java.lang.noclassdeffounderror what mean "to execute jar in own program"? jar contains classes, if in class path, can instantiate classes , invoke methods. in case, should use test.add class. seems class not in classpath - java.lang.noclassdeffounderror.

ios - UIImage+ImageEffects doesn't work on device -

i have modal view want present results of calculation. in order make ios7 look, want tinted background popup view blured background. i managed got thing work using files "uiimage+imageeffects .h/m" apple. this viewdidload of modal view: - (void)viewdidload { [super viewdidload]; /* how works self.image screenshot of vc presenting modal view 1- set background screenshot of previous viewcontroler 2- hide popup view 3- set background of popup blured snapshot of container view (self.view) 4- unhide popup view , set radius 5- create tinted version of background image (what got previous view controller 6- set background of self.view tinted version */ // *** 1 *** self.view.backgroundcolor=[uicolor colorwithpatternimage:self.image]; // *** 2 *** self.containerview.hidden=yes; // *** 3 *** uiimage *pepe=[self bluredimagefromview:self.containerview withbackground:self.view withbac

css - Horizontal scrolling of divs inside a table PHP -

how make horizontal scrolling lot of divs inside table? i'm trying bar of friends... echo '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td style="">'; foreach($friends $fr){ $friend = $ots->createobject('account'); $friend->load($fr); $profile_img = $friend->getcustomfield("profile_img"); foreach (array("/", "\\", "..") $chan) { $profile_img = str_replace($chan, "", $profile_img); } if (empty($profile_img) || !file_exists("account/profiles/".$profile_img)) { $profile_img = "default.png"; } echo '<div style="border-right:1px solid #faf0d7;width:82px;height:82px;position:relative;float:left;background-image:url(account/profiles/'.$profile_img.');background-repeat:repeat-y;background-size:82px 82px;">'.$fr.'</div>'; } echo '</td></tr&

How to make SVN trunk head the git master? -

i'm creating git repository svn repository, , after running necessary commands fetch svn repo, have svn trunk branch checked out master in git. however, don't want entire trunk directory, head directory master in git. how can set master branch in git point trunk/head directory in svn? do mean in svn have <repo-base>/trunk/head , want master of git point it? instead of using -s/--stdlayout explicitly want master be: git svn clone <repo-base> --trunk=trunk/head --branches=...

python - Why does SQLAlchemy/mysql keep timing out on me? -

i have 2 functions need executed , first takes 4 hours execute. both use sqlalchemy: def first(): session = dbsession rows = session.query(mytable).order_by(mytable.col1.desc())[:150] i,row in enumerate(rows): time.sleep(100) print i, row.accession def second(): print "going onto second function" session = dbsession new_row = session.query(anothertable).order_by(anothertable.col1.desc()).first() print 'new row: ', new_row.accession first() second() and here how define dbsession: from sqlalchemy.ext.declarative import declarative_base sqlalchemy.orm import scoped_session, sessionmaker sqlalchemy import create_engine engine = create_engine('mysql://blah:blah@blah/blahblah',echo=false,pool_recycle=3600*12) dbsession = scoped_session(sessionmaker(autocommit=false, autoflush=false, bind=engine)) base = declarative_base() base.metadata.bind = engine first() finishes fine (takes 4 hrs) , see "going

php - How to update .htaccess file for another folder along side wordpress -

i have wordpress site complete url as: mydomain.com/wp_myfolder/index.php but after wordpress rewriting access site mydomain.com want place project in folder on same domain facing issues i want access new project not working mydomain.com/project/mypage.php instead opening as mydomain.com/wp_myfolder/project/mypage.php it want remove wp_myfolder url try add rewrite rule in .htaccess. rewriterule ^project/(.*)$ /wp_myfolder/project/$1 [l]

javascript - How can I redirect to a page after sending a JQuery get request in rails -

i trying post simple request search page , redirect page (a product page). however, when send request, nothing happens , page not change. my code below: javascript $('.imagebox').click(function () { $.get("/s/product/ref", { se: search, pr: price, crr: current, bs: best, bt: better, gd: }) }) } main_controller.rb def product respond_to |format| format.js { render :json => @json_data } end @search = params[:se] end i don't see code direct user different page. try using window.location

javascript - Create a new sheet in a Google Spreadsheet with Google Apps Script -

how create new sheet in google spreadsheet google apps script? i know seems obvious want create new sheet specific name. surprisingly didn't find clear , quick answer. so here code: function onopen() { var activespreadsheet = spreadsheetapp.getactivespreadsheet(); var yournewsheet = activespreadsheet.getsheetbyname("name of new sheet"); if (yournewsheet != null) { activespreadsheet.deletesheet(yournewsheet); } yournewsheet = activespreadsheet.insertsheet(); yournewsheet.setname("name of new sheet"); } finally, note new sheet automatically active one.

encryption - who to work AES_DECRYPT in mysql? -

Image
i use aes_encrypt(...) in mysql encrypte column of table when use aes_decrypt decrypte, result null. please me. thanks. code encrypt: update tbl_users set password = aes_encrypt(password , '123456'); code decrypte: select cast(aes_decrypt(password,'123456') char) tbl_users password must string 'password'. password without quotes field name. update tbl_users set password = aes_encrypt('password' , '123456'); try aes_decrypt witout cast function: select aes_decrypt(password,'123456') tbl_users

d3.js - Change dataset on d3 Tree drag n drop -

im trying use d3 library build tree. far ive used example ( http://bl.ocks.org/robschmuecker/7880033 ) , works fine. once node dragged , assigned 1 id liek new dataset/ change , wondering advise how ?any help, leads appreciated. ive located ondragend event dont know how refer 'changed dataset'. ideally id love call webapi method , record changes in database.. thank you, neil

C++ getting integer instead of a float value -

my problem when dividing 2 integers can't float value. here's code { cout << "kokie skaiciai?" << endl; cin >> x; cin >> y; cout << "atsakymas: " << dalyba(x, y) << endl; } and function use int dalyba (int x, int y) { float z; z = (float) x / y; return z; } so if x = 5 , y = 2 answer 2 instead of 2.5. apreciated. the problem function returns int instead of float , float result cast integer, , truncated. may want change return value type of function int float . moreover, in modern c++, may want use c++-style casts static_cast<> . the following snippet prints 2.5 expected: #include <iostream> using namespace std; float f(int x, int y) { return static_cast<float>(x) / y; } int main() { cout << f(5, 2) << endl; }

multithreading - C# Console Application - How do I always read input from the console? -

i writing console application uses lot of multithreading. want able allow user enter console however, there regular output console threads want users able enter things console , me handle input. how achieve this? i've found nothing online it? thanks in advanced! this c# btw! class program { static void main(string[] args) { // cancellation keyboard string cancellationtokensource cts = new cancellationtokensource(); // thread listens keyboard input var kbtask = task.run(() => { while(true) { string userinput = console.readline(); if(userinput == "c") { cts.cancel(); break; } else { // handle input console.writeline("executing user command {0}...", userinput); } } }); // thread performs main work task.run(() => dowork(), cts.token); console.writeline("type commands followed 'e

python - django product of annotate -

django 1.3 python 2.7 i have following models (irrelevant fields omitted): class encounter(models.model): subject = models.foreignkey('subject', to_field='uuid') uuid = models.slugfield(max_length=36, unique=true, default=make_uuid, editable=false) class subject(models.model): uuid = models.slugfield(max_length=36, unique=true, default=make_uuid, editable=false) location = models.foreignkey('location', blank=true, to_field='uuid') class location(models.model): uuid = models.slugfield(max_length=36, unique=true, default=make_uuid, editable=false) i want know how many encounters occurred @ each location. if encounter contained location field, use annotate() , doesn't , can't add one. know number of encounters per subject , number of subjects per location via annotate() . open combining these multiplicatively wondering a) if works , b) if there better way. thanks in advance! seems should work: location.objects.a

2D Array Pointer Syntax - C -

i'm new c , our professor has given performance assignment have manipulate 2d arrays. i'm trying figure out how correctly move value between 2 arrays. believe using *(array*i+j) might speed things cannot compile. aware array[i][j] acceptable need fast possible. problem line like out[x] = *( *(in+i) + j); the error i'm getting "incompatible types when assigning type int[10000] type int. should making pointers out , in? not allowed change implementation is define n 10000 /* input matrix */ long in[n][n]; /* output matrix */ long out[n][n]; i answer depressingly obvious none of changes have worked. want change value @ out[x] or out+x. try this out[column][row] = *( *(in+i) + j); you forgetting index 2nd dismension of array assgining to.

c# - Where/how to store cost for multiple objects without copy/clone? -

i have a* implemented in c# pointa , pointb being tile objects with. x, y, walkable, neighbours (size 8 list), cost. my issue on backend online game server, , tile maps shared between monsters. don't want copy grid each monster trying move. for example map looks like: tile[] tiles; public this[int x, int y] { {return tiles[x + y * sizey];} } before cloning tiles copy before each monster wanted calculate move. noticed using crap-load of memory. should store cost in a-star calculation assigned each tile (without copying grid)? if array going sparse , i.e. a* looks in small region of map, represent map (e.g. dictionary in c#) of index value. you consider priority queue of potential candidate objects, each of contains location, cost, heuristic value , reference previous candidate, , forget array completely. although array of primitives should quite bit smaller array of objects of same length. make sure didn't make few copies (assuming you're

laravel - Sentry versus OAuth2 server -

i used oauth2 code api server githhub: https://github.com/lucadegasperi/oauth2-server-laravel instead using standard laravel auth, want use sentry, because sentry have lot of features sending mail, ban, approve registration, ... i created connection client (laravel guzzle plugin) on api server, cannot keep sentry session. ok, or not? how can know permission, groups or whatever of user on api server. each call api send access_token, enough oauth2. not have idea how keep sentry session, example: i logged in moderator permission user, , send new request api getting moderator information, not know moderator or administrator or what, because not have sentry session. maybe oauth:scope1,scope2 enough, , maybe not need sentry, not have sentry features (look on beginning of post). i believe problem trivial, not know how resolve issue. not have idea :( your issue understanding of oauth2 flawed. oauth2 authentication not authorization . generally oauth2 have 3 servers:

c++ - Copy a vector to an array? -

i copied 2dim array 2dim vector , did modifications on it, want know how can copy 2dim vector 2dim array?(i did below:) copy 2dim array 2dim vector: vector< vector<int>> path2; vector<int> temp; // simplicity (int x = 0; x <= 1; x++) {temp.clear(); (int y = 0; y < 4; y++) { temp.push_back(path1[x][y]); } path2.push_back(temp); } out put: path2[0][6,0,2,6] path2[1][6,1,3,6] copy 2dim vector 2dim array int arr [4][10] ; copy(path3.begin(), path3.end(), arr); print arr (int i=0;i< ???? ;i++)// how define size of vector first dimention 2 ( aware size() 1 dim vector, 2dim vector ...... ?????????? for(int j=0;j<?????; j++) //same prolem above cout<<endl<<arr[i][j]; the problem not sure copy part , and dont know how define size of each size of vector? you of these iterate on vector of vector: //works c++11 std::vector<std::vector<int>> vec; for(auto &i : vec)

openflow - In band Controller with Mininet -

please want test in band controller mininet, found code (there http://windysdn.blogspot.fr/2013/10/in-band-controller.html ) don't know how integrate (or write) in mininet. can me please ? thanks install mininet (mininet.org) copy/paste code found (which script creating mininet topology , starting mininet topology) python script (.py) run python script, , see mininet start-up. take mininet tutorial on mininet.org, , learn hard, , efficient, way else ps: should #4 first.

How do I sort a multi-dimensional array by time values in PHP? -

i'm doing school project , have multi-dimensional array having start_time , end_time of courses. i sorted array day, want sort array time. such lowest start_time first element of array. this how array @ moment: array ( [0] => array ( [courseid] => comp345 [lectureid] => ss [day] => monday [stime] => 18:20 [etime] => 20:30 [term] => winter [year] => 2014 ) [1] => array ( [courseid] => comp275 [lectureid] => gg [day] => monday [stime] => 12:15 [etime] => 15:16 [term] => winter [year] => 2014 ) ) i wondering if there pre-defined functions or if need create new specific function tas

java - Android SQLite Concurrency (trying to reopen an already closed connection) -

this type of question has been asked lot, not find answer satisfies me. question how should maintain multiple open sqlite connections on multiple threads? possible check how many connections open , call close() if none are? edit accepted answer below sqlite fast , synchronizing sql api methods (only 1 run @ time) may not hurting. being said, i'll still happy hear solution synchronize read()s , write()s, multiple read() can done @ once... background i'm building android app , in places use few internet connections (get requests). when requests finish, threads access sqlite, writing. when threads try connect simultaneously, error mentioned in title. i know why happens: way it, each "sqlite api" method (api wrote) starting opening connection , finishes closing it. write/read open() used whenever needed. so when 1 thread closes connection (the api method finishes) , other still using cursor or whatever, error occurs , exception thrown. here co

sql - How can I recover the users with whom a user chatted recently from a MySQL db? -

i ask in query came across. basically, have 3 tables: 'users', stores data of user in db, fields are: usr_id -> id of user, primary key; usr_profile_photo_id, foreign key references profile photo filename in 'files' table names of files of user stored (in case foreign key references profile photo filename); usr_name -> name of user; usr_surname -> surname; 'files', stores files of user, fields are: fil_usr_id -> foreign key references user in 'users' table; fil_uid -> referenced file id (this field referenced 'usr_profile_photo_id'); fil_name -> name of file (e.g. user154241profile.png, user163451profile.png, etc.); 'chat', stores chat messages of users, fields are: id -> primary key, identifies in univocal way chat message; chat_from -> foreign key references id of user wrote chat message; chat_fromname -> name surname (e.g. "john smith", "mary smith", etc.) of u

Consecutive subset product -

i got interview question , thinking on how solve it. lets number array ={7,6,3} , consequtive substring ares {7},{6},{3},{7,6},{6,3},{7,6,3}({7,3} not valid) check if product of 2 subsets equal). so {6,2,3} fails {6}={2*3} can give me nudge in right direction. if there n numbers in array. there n * (n - 1) / 2 consequtive subsets. can pre-process thess subsets' product, , insert map . enum subsets find if product have more twice in map . can solve question.

delphi - Inserting text into new Word 2010 file not working (Delhi XE2) -

i've written test program in deplhi xe2 create new word document (using wort 2010 , twordapplication), insert text it, , save both .doc file , .pdf file. 2 word components on form. works except text insertion. when open documents after fact both created empty. it's frustrating work without docs regarding using vba equivalents word. if can point me twordapplication , tworddocument specs eternally grateful. but, immediate problem how insert text. here's have: procedure tform1.btngenerateclick(sender: tobject); var snewtext: widestring; begin snewtext := 'hello, world!' + #13; { create word document, set text , close it. } wordapplication1.visible := false; wordapplication1.newdocument; wordapplication1.selection.endof(wdstory, wdmove); wordapplication1.selection.insertafter(snewtext); wordapplication1.selection.endof(wdstory, wdmove); if fileexists('d:\temp\mynewdocdup.doc') deletefile('d:\temp\mynewdocdup.doc') else ;

jquery - DataTables + Bootstrap 3 enabling horizontal scrolling issue -

i'm having problem datatables integrated in bootstrap 3 , horizontal scrolling enabled here fiddle datatables initalization /* data table initialization */ var equipmentdatatable = $('#equipmenttable').datatable({ "aocolumndefs": [{ "sclass": "text-center", "atargets": [ 0,25 ] }, { 'bsortable': false, 'atargets': [ 25 ] }], "sscrollx": '100%' }); i don't know why header not aligned body of table. in advance i had similar issue, solved in different way. i modified sdom parameter wrap table in div: <i> sdom: 'r<"h"lf><"datatable-scroll"t><"f"ip>', applied following styles .datatable-scroll class: /** * makes table have horizontal scroll bar if wide conta

c# - Get Groups info for contact using Google's gdata -

i'm using google gdata driver account's contacts. 1 of things i'd able group membership info each contact. i've seen contact.groupmembership collection, far can tell things contains href property, url. there i'm missing have name, uri, etc contact's group? for list of group names , references (href atom id, cr instance of contactrequest) feed<group> fg = cr.getgroups(); foreach (group group in fg.entries) { console.writeline("atom id: " + group.id); console.writeline("group name: " + group.title); }

php - Cannot make outbound HTTP Requests from vagrant VM -

i unable connect internet within vagrant virtual machine have set up. for example, @ root, when type: curl http://google.com it fails message: curl: (6) couldn't resolve host 'google.com' i'm not sure if it's firewall setting, although far know have not created firewall rules port 80 or other port. here relevant section of vagrantfile. if there other information can provide please let me know in comments: vagrant.configure("2") |config| # vagrant configuration done here. common configuration # options documented , commented below. complete reference, # please see online documentation @ vagrantup.com. # let vagrant manage hostname @ boot config.vm.hostname = "devbox" # create forwarded port mapping allows access specific port # within machine port on host machine. in example below, # accessing "localhost:8080" access port 80 on guest machine. # config.vm.network :forwarded_port, guest: 80, host: 808

linux - Batch mode images on white background of A5 size -

i have 260 scanned images of text ‘tailored’ scantailor cropped contain text area (no margins on side). bit smaller size of a5 (the hard copy a5). now, want put of them (individually) on white background of a5 size, horizontally centred, vertically image should start 0.88 inches top of background. should done in terminal in batch mode. imagemagick should job, cannot imagine how. info: ubuntu gnome 13.10 i386 update #1 convert bg.tif fg.tif -gravity center -composite new.tif this command partially suficient, centres fg.tif horizontally and vertically. have no idea how put fg.tif 0.88 inches top while horizontally centred. btw, images 300 dpi. in update #1, bg.tif image created in gimp of a5 size , has white background , processed same settings in scantailor same image qualities other files. undate #2 i have manually found out the following command puts fg image approx .88 inches top: composite -geometry +0+264 fg.tif blnk_300.tif new.tif but combine -gravity

SQL query not executing in java -

im trying execute query through java program doesn't execute. here's method public list<usuario> darproveedores() throws exception{ preparedstatement st=null; arraylist<usuario> respuesta = new arraylist<usuario>(); string consulta ="select u.direccion_electronica dire, " + "u.login login, " + "u.palabra_clave clave, " + "u.rol rol, " + "u.tipo_persona tipoper, " + "u.documento_identificacion docid, " + "u.nombre nombre, " + "u.nacionalidad naci, " + "u.direccion_fisica dirf, " + "u.telefono tel, " + "u.ciudad ciudad, " + "u.departamento depto, " + "u.codigo_postal codpostal "

c# - Re-sizing border-less form with a custom border -

Image
the problem isn't don't know how make border-less form re-sizable, or how draw border. problem happens when re-size form custom border. here screenshot, because don't know how explain it: here how created border (currently): private void form1_paint(object sender, painteventargs e) { int width = 1; rectangle rec = this.clientrectangle; buttonborderstyle bbs = buttonborderstyle.solid; color clr = color.gray; controlpaint.drawborder(e.graphics, rec, clr, width, bbs, clr, width, bbs, clr, width, bbs, clr, width, bbs); } as re-sizing border-less form; created repository project. resize custom border - bitbucket i don't have idea why happens, wouldn't know begin. need draw border without doing this. have tried other ways of drawing one, results same. hopefully , repository becomes useful trying same. thank taking time read if did. try use graphics.drawrectangle instead of drawborder protected override void onpaint(painte

web services - Document/Encoded and RPC/Encoded combinations are not WS-I compliant -

can of network explain why document/encoded , rpc/encoded encoding style combinations not ws-i compliant soap-based web service? document/encoded , rpc/encoded released ws-i adheres bp1.0(basic profile 1.0) specification. later ws-i release bp1.1,2.0.. specifications.the rules specified in these specification not supported above message exchanging formats , not complaint. the exchanging formats complaint ws-i document/literal,rpc/literal,document/wrapped

c++ - How to finish Qt programm from any place? -

my example: main.cpp: qapplication a(argc, argv); mainwindow w; w.start(); return a.exec(); w.start(): if (cf.exec()){ this->show(); } else { qdebug()<<"need exit"; //here should exit } at comment place, tried do: qapp->exit() , qapp->quit() , this->close() (but 'this' not shown , of cource close() not working). how can finish app place of code? whole code: main.cpp #include "mainwindow.h" #include <qapplication> int main(int argc, char *argv[]) { qapplication a(argc, argv); mainwindow w; w.start(); return a.exec(); } mainwindow.h #ifndef mainwindow_h #define mainwindow_h #include <qmainwindow> #include "cadrform.h" #include "teacherform.h" #include "departmentform.h" #include "categoriesform.h" #include "postform.h" #include "ranksanddegreesform.h" #include "teachersranka

swing - Sliding Puzzle Java Shuffle issue -

i trying shuffle pieces 15 piece sliding puzzle when click shuffle button. unfortunately, don't know how "grab" jpanel buttons because dynamic , don't "passed" action listener: here's loop creates & adds buttons: pos = new int[][] { {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15} }; centerpanel = new jpanel(); centerpanel.setlayout(new gridlayout(4, 5, 0, 0)); add(box.createrigidarea(new dimension(0, 5)), borderlayout.north); add(centerpanel, borderlayout.center); int counter = 0; ( int = 0; < 4; i++) { ( int j = 0; j < 4; j++) { if ( j == 3 && == 3) { label = new jlabel(""); centerpanel.add(label); // empty label } else { counter++; button = new jbutton();

c++ - Is clearing a vector considered a proper way of managing memory -

i tried make question title descriptive possible won't have click on question figure out whether have answer question. i implementing chaining hash table class assignment, , have come conclusion vector best serve purpose of project. consider following snippet of code: struct node { public: node(string key, node * next = null) { this->key = key; this->next = next; } string key; node * next; }; class htable { private: static const int table_size = 100; vector <node*> table; public: htable() { table.resize(table_size); (int = 0; < table_size; i++) table[i] = null; } ~htable() { table.erase(table.begin(), table.begin() + table_size); } }; will erase function in htable class destructor perform proper memory management? will erase function in htable class destructor perform proper memory management? no. vector<node*> doesn