Posts

Showing posts from May, 2010

java - How to get remote access to a MySQL database on my computer? -

i've read around lot , tried suggestions nothing seems working. i want java program able remotely access database on computer. tried using ip address host name doesn't work. thing allows program connect database using localhost host name. would work use localhost host name? (jdbc url - jdbc:mysql://hostname/dbname) if java program running on different computer 1 mysql running on, may need set user privileges in mysql allow remote connections it. mysql> grant privileges on . 'username'@'%' identified 'password'

c - MPI reverse probe -

is there way check if processes waiting on mpi_recv? i have root proc, , slave processes. slave psedo-code: while (1) { do_some_stuff; // calls mpi_test , clear unused buffers mpi_recv(buf, ...); do_something_with_buf; mpi_isend(buf2, ...); // possibly many sends depending on in buf } if slave processes hang on mpi_recv, job done , need brake loop. need way notify slave processes job done. there way this? thought there might reverse probe check if waits message instead of checking if there message recieve. haven't found useful tho. edit: more explanation. i have 1 root proc, reads huge file , sends read data workers(rest of processes). each worker recieves portion of data, distributed(each worker has same amount of data stored). workers start communicate each other sending partial computations. when worker recieves partial computation may produce lot of new partial results, of need sent other workes. work done when workers have nothing , there no mor...

xcode6 - C++ compiler error in CodeBlocks & Xcode -

i'm learning become programmer , while learning came across bit of problem. program doesn't run , gives me error clang: error: linker command failed exit code 1 (use -v see invocation) why , how fix , prevent happening again? #include <iostream> using namespace std; void fav(); int main() { fav(); return 0; } void fav(int x) { cout<<"troy's favorite number \n"<<x; } the declared function , defined function different. therefore different functions, former of never defined, though called in main void fav(); // declared void fav(int x) // defined you need change signature of declared function matche declared , called function void fav(int x); int main() { int x; cin >> x; fav(x); return 0; } void fav(int x) { cout<<"troy's favorite number \n" << x; }

listviewitem - Load Images In a ListView stored in local App folder windows 8 app -

i have button on click of have populate multiple images in listview. have seen stackoverflow posts same did not help. want populate images app local folder, , set source of listview. sample of how select multiple image files folder , adding listview. e.g. var uri = new windows.foundation.uri('ms-appx:///images/logo.png'); var file = windows.storage.storagefile.getfilefromapplicationuriasync(uri);` this select 1 image stored in app folder, how loop through multiple images , add in listview. also in addition have grid added. when select image listview should load in grid. on select event changed how should grab file path of image or load selected image in grid. thanks in advance. you need reference proper storagefolder , can loop through storagefiles. can create object storagefile. since doesn't sound you're using mvvm, i'll show quick code behind example. //helper class store uri of image , file name public class myimage { public myimag...

python - Cartridge Python2.7 on OPenshift -

i try install django 1.5 on host openshift. use cartridge python 2.7. read https://developers.openshift.com/en/python-getting-started.html . did not understand code should be. virtenv = os.environ['openshift_python_dir'] + '/virtenv/' virtualenv = os.path.join(virtenv, 'bin/activate_this.py') try: # see: http://stackoverflow.com/questions/23418735/using-python-3-3-in-openshifts-book-example?noredirect=1#comment35908657_23418735 #execfile(virtualenv, dict(__file__=virtualenv)) # python v2.7 #exec(compile(open(virtualenv, 'rb').read(), virtualenv, 'exec'), dict(__file__=virtualenv)) # python v3.3 # multi-line python v3.3: exec_namespace = dict(__file__=virtualenv) open(virtualenv, 'rb') exec_file: file_contents = exec_file.read() compiled_code = compile(file_contents, virtualenv, 'exec') exec(compiled_code, exec_namespace) except ioerror: pass this code should in file wsgi.py ? appeal, give me sample worki...

variables - Precedence of arithmetic operators in Java -

i reading "programming in java deitel & deitel 7th edition" , watched precedence of operators trepidation. the author says when there mathematical typical expression in there operators of equal precedence operation runs left right. example: system.out.println (a + b + c - d); in sense operation executed left right, research on internet , find "=" operator runs right left. example: int x; x = 4 * 4 * 4% 2; all taxes fine until ponogo investigate further , write code , occurs me this, wrote exeption: system.out.println ((4 * 4) + (8 * 8) * (4 * 4) - 16/4); and question this, if book says addition , subtraction have lower priority compared other operators, if add value of typical expression multiplied ?. let me explain: when put (4 * 4) + (8 * 8) * (4 * 4) adding value of multiplication, lower precedence of operator? another question: if have example follows: system.out.println (a * b * c + d + e + f * g / h); as higher precedence opera...

Rails draper gem with Ajax/JS -

i'm using draper , want use 1 of decorators in view. with html works, decorators don't work in ajax version - undefined method error. in commentdecorator: delegate_all def comment_author "#{user.firstname} #{user.lastname}" end in view: comment.comment_author i'm using exposure, don't need instance variables in views. you can use comment.decorate.comment_author

netbeans - Sound problems in Java -

i have questions playing sound in java , hope can me out. 1. how can stop playing sound "stop" button? 2. how can slow down (or cooldown time) sound? 3. want create option frame can adjust volume , have mute option, how can that? code: private void bgm() { try { file file = new file(apppath + "\\src\\bgm.wav"); clip clip = audiosystem.getclip(); clip.open(audiosystem.getaudioinputstream(file)); clip.start(); } catch (exception e) { system.err.println(e.getmessage()); } } any appreciated, and, have nice day! you're working in object oriented programming lanuage, let's take advantage of , encapsulate management of clip/audio simple class... public class audioplayer { private clip clip; public audioplayer(url url) throws ioexception, lineunavailableexception, unsupportedaudiofileexception { clip = audiosystem.getclip(); ...

unit testing - How to test Dart Polymer elements using the new Test library? -

how test polymer elements using new test library? using new test library test dart polymer element, build my_element_test.html as prescribed . please see repo: polymer-dart-testing . no polymer initiation passes my_element_test.html , my_element_test.dart (commenting out polymer initiation) passes tests expected: my_element_test.html <!doctype html> <html> <head> <title>my element test</title> <link rel="import" href="packages/polymer_dart_testing/my_element.html"> <link rel="x-dart-test" href="my_element_test.dart"> <script src="packages/test/dart.js"></script> </head> <body> <div>custom html test custom.</div> <my-element></my-element> </body> </html> my_element_test.dart import 'package:test/test.dart'; import 'package:polymer_dart_testing/my_element.dart'; impo...

r - multidimensional arrays of data frames -

i define 3d-array of data.frame(a,b,c,...) can for (x in 1:4) (y in 1:5) (z in 1:5) { m[x,y,z]$a <- dnorm(1) m[x,y,z]$b <- dnorm(1) m[x,y,z]$c <- dnorm(1) } it ok too, if data.frame(x,y,z,a,b,c) x,y,z ids , short , effizient way manipulate , read line "x,y,z". perhaps there better ideas? rid of ma[x,y,z] <- ... mb[x,y,z] <- ... mc[x,y,z] <- ... i'm guessing meant rnorm since populating entire array dnorm(1) wouldn't seem interesting. lot faster make arrays in 1 pass with: m <- array( rnorm(4*5*5*3), dims= c(4,5,5, 3) , dimnames=list(x=null, y=null, z=null, lets=c("a","b","c") ) ) so access 4d array, be: > m[ 1,1,1,"a"] 0.6773062520076687 > m[ 1,1,1,"b"] b 0.6229924684213618 > m[ 1,1,1,"c"] c 0.6899440670029088 or if wanted 3 of them vec...

multithreading - TMVar, but without the buffer? -

i'm trying communication between haskell lightweight threads. threads want send each other messages communication , synchronisation. i using tmvar this, i've realised semantics wrong: tmvar store 1 message in internally, positing message empty tmvar won't block. it'll block if post message full tmvar . can suggest similar stm ipc construct which: will cause writes block until message consumed; will cause reads block until message provided? i.e. zero-length pipe ideal; don't think boundedchan happy if gave capacity of 0. (also, it's not stm .) if understand problem correctly, don't think can, since transactional guarantees mean transaction can't read transaction b's write until transaction b committed, @ point can no longer block. tmvar closest you're going if you're using stm. io, may able build structure completes write when reader available (this structure may exist, i'm not aware of it).

http - Is caching in browser automatic? -

i have javascript app sends requests rest api, responses server have cache headers (like etag, cache-control, expires). caching of responses in browser automatic, or app must implement sort of mechanism save data? an ajax request no different normal request - it's get/post/head/whatever request being sent browser, , handled such. confirmed here : the http , cache sub-systems of modern browsers @ lower level ajax’s xmlhttprequest object. @ level, browser doesn’t know or care ajax requests. obeys normal http caching rules based on response headers returned server. as per the jquery documentation , caches can invalidated in @ least 1 usual way (appending query string): cache (default: true, false datatype 'script' , 'jsonp') type: boolean if set false, force requested pages not cached browser. note: setting cache false work correctly head , requests. works appending "_={timestamp}" parameters. parameter not needed other ...

Meteor Iron Router not working on certain links -

i have route this: router.route('/box', function () { this.render('boxcanvastpl'); },{ name: 'box', layouttemplate: 'appwrapperloggedintpl', waiton: function() { console.log("box route ran ok."); return [ meteor.subscribe('item_ownership_pub', function() { console.log("subscription 'item_ownership_pub' ready."); }), meteor.subscribe('my_items', function() { console.log("subscription 'my_items' ready."); }) ]; } }); ... , clicking link in template this: <a href="/box?box=123" class="box-num-items">my link</a> i receive 'box route ran ok.' message, reason page not navigate given url. have added console.log code in funciton run when 'boxcanvastpl' rendered, these aren't showing in browser console. seems inbetwee...

Kotlin - IntelliJ Project Setup -

i want start new project kotlin jvm using intellij ide, can't configuration work. attempting follow this tutorial , , after didn't work (the "run '_defaultpackage'" option never showed up), started trying intuit supposed done without success. has happened far (repeatedly): i created new project, selected "kotlin - jvm" project type. i clicked "create..." button kotlin runtime on second page , selected "copy to: lib". i click "finish" , project created has 1 module same name project. there no default source file or configuration. i create kotlin file named "app.kt" (i've tried other names too, "main.kt"), , put following source code in: fun main(args: array<string>){ println("hello world!") } i right clicked on code editor , file in left pane find "run '_defaultpackage'" option mentioned in tutorial, failed find in either. i create new kotlin...

ms access - Moving into earlier cell of DataGridView VB.Net -

i writing application using datagridview in vb.net on datagridview, cell(column(0),row(0)) used searching database item code. want when item code not found in database, cursor should on cell(column(0),row(0)), cell used searching item code. below code have : private sub dgv1_cellendedit(byval sender object, byval e system.windows.forms.datagridviewcelleventargs) handles dgv1.cellendedit dim flag_cell_edited boolean dim currentrow integer dim currentcolumn integer if e.columnindex = 0 flag_cell_edited = true currentrow = e.rowindex currentcolumn = e.columnindex call koneksi() cmd = new oledbcommand("select nama_matakuliah, sks tbmatakuliah kode_mk = '" & dgv1.rows(e.rowindex).cells(0).value & "' , program_studi = '" & txt_ps.text & "'", conn) dr = cmd.executereader dr.read() if dr.hasrows dgv1.rows(e.rowindex).cells(1).value...

windows - How to identify user input help (/?) in batch file -

usually in of batch command, uses /? description or hel of particular command. there way identify user asking entering /? argument ( mybatchfilename /? ) i have tried if %1==/? goto help . seems ? has special meaning in batch command. any help? to fix problem, can put quotes (") around if parameters. so: if "%1" == "/?" goto this works , fixes problem. working example? here go: @echo off if "%1" == "/?" goto :main echo no here. echo doing stuff exit /b 1 :help echo file helping you... timeout 1 >nul echo kidding. exit /b 0

cocos2d-x physics nodes slide along other -

i developing game using cocos2d-x built-in physics engine. in game, user try put object stack , keep them balance. however, got problem when try put object on other one, makes 2 objects slide along each other i tried set friction value nothing changes. noticed when put dynamic object on non-dynamic object it's fine when put dynamic object on other dynamic object, problem (sliding along) happened. i create gif demonstrate problem because of bad english. http://makeagif.com/i/0lsvdw sorry don't have enough reputation post images. appreciate help!

silverlight - do you have any solution to reduce the build time? -

i'm working on big solution, includes 20 projects(in silverlight, , use 10 wcf sevices), each tim test presentation layer, have build solution, , take more time. have solution reduce build time? go build/configuration manager... , uncheck projects not working on. way build relevant project. create solution include project wish modify. copy dlls other projects folder. go build, your_project properties... reference path, , add folder. switch parallel msbuild (by adding external tool), can utilize cpu cores. set arguments multiproc , verbosity - minimal: /m /v:m get rid of unused styles use ssd if you're on laptop, make sure machine set in high performance mode. also refer old blog post

How to not receive the accumulated pushes from Pusher after returning online? -

how can 1 prevent pusher automatically pushing piled messages client after client goes online after being offline, i.e. after client re-establishes connection? pusher doesn't presently buffer messages delivered upon reconnection. functionality described in questions isn't application needs consider right now. future releases may contains called event buffer offer functionality. documentation released around time detail how avoid receiving buffered events.

c# - Many entries with OnItemsChanged(), how to delete old entries -

i new xaml. entries added scrolling view , event change. there many entries being logged causing memory consumption. how delete entries entered earlier. , entries on deletion should not appear in scroll view too. in advance. here xaml <local:scrollinglv x:name="logview" width="300" height="100" margin="10,0,10,10" itemssource="{binding logmsg}"> here code adds scroll view public partial class scrollinglv : listview { protected override void onitemschanged(system.collections.specialized.notifycollectionchangedeventargs e) { if (e.newitems != null) { int icount = e.newitems.count; if (icount > 0) { this.scrollintoview(e.newitems[icount - 1]); } } base.onitemschanged(e); } } if using observablecollection, simple removing item listview for example can refer msdn entry https://msdn.microsoft.com/en-us/...

multithreading - Create Semaphore in PHP linux (Centos) -

i'm using centos 6.5 php 5.3.3. i have 2 processes want prevent working together. thought creating semaphore after browsing online found this . this object doesn't work on server. when call function sem_get() , error: "call undefined function sem_get()" read , turns out need change compilations on server work. i made these changes , server collapsed, it caused huge mess , after restoring server i'm not going again. is there way above error fixed standard include or other solution? if not, can me find way implement semaphore in way or other solution prevent 2 process running @ same time? i need flag set true , other process check flag , out if true.

How do I take Someone's name in Python and create a file to write to with that name? -

i bit new python, , trying simple i'm sure. want ask name initial raw_input , want name used create file. additional raw_input taken user gets recorded file. raw_input("what name?") file = open("newfile.txt", "w") i have above code create file called newfile.txt, how can make requested name used file name? thank you! file = open("user.txt", "w") save name in variable , use : name = raw_input("what name?") file = open(name+".txt", "w") ... file.close()

php - how to rewrite url for this query string url in htaccess -

i have tried many rewrite rules following url didn't success.i researched lot , wasted 2 days. i need url need rewrite url from http://localhost/tour/tour.php?page=golden-triangle-tour to http://localhost/tour/tour/golden-triangle-tour please guide me fix in htaccess. you can use code in /tour/.htaccess file: rewriteengine on rewritebase /tour/ # external redirect actual url pretty 1 rewritecond %{the_request} /tour\.php\?page=([^\s&]+) [nc] rewriterule ^ tour/%1? [r=302,l,ne] rewritecond %{the_request} /tour/(.+?)\.php[\s?] [nc] rewriterule ^ %1 [r=302,l,ne] # internal forward pretty url actual 1 rewriterule ^tour/([^/.]+)/?$ tour.php?page=$1 [l,qsa,nc] # internally forward /dir/file /dir/file.php rewritecond %{request_filename} !-d rewritecond %{document_root}/toure/$1\.php -f [nc] rewriterule ^(.+?)/?$ $1.php [l]

ASP.NET Forms Authentication. Determine if another user is online or not -

in asp.net mvc 5 web app, using formsauthentication, want determine if user still logged-in. doing users sign out clicking on log out button pretty straightforward - can handle event , set flag in database indicate user has signed out. but not sure how handle users close browser without signing them off voluntarily (by clicking button). i did research don't think can rely on session_end event handler. or can i?

Parsing CSV files to arrays from very large sources in java -

i have parser works fine on smaller files of approx. 60000 lines or less have parse csv file on 10 million lines , method isn't working hangs every 100 thousand lines 10 seconds , assume split method, there faster way parse data csv string array? code in question: string[][] events = new string[rows][columns]; scanner sc = new scanner(csvfilename); int j = 0; while (sc.hasnext()){ events[j] = sc.nextline().split(","); j++; } your code won't parse csv files reliably. if had ',' or line separator in value? slow. get univocity-parsers parse files. 3 times faster apache commons csv, has many more features , use process files billions of rows. to parse rows list of strings: csvparsersettings settings = new csvparsersettings(); //lots of options here, check documentation csvparser parser = new csvparser(settings); list<string[]> allrows = parser.parseall(new filereader(new file("path/to/input....

datagridview - How to prevent adding a new row after using RowValidating -

i got issue , know can assist. my form contains datagridview , using key down add new row datagridview. issue datagridview still adds new row although validation fail when check data entered in row. following code private void dtdetail_keydown(object sender, keyeventargs e) { //if (allow_add_row) if (dtdetail.currentcell.rowindex == dtdetail.rows.count - 1) if (e.keycode == keys.down) dtdetail.rows.add(); } private void dtdetail_rowvalidating(object sender, datagridviewcellcanceleventargs e) { // checking , set e.cancel=true; } please advise if can check error before adding new row or workaround in issue. you on right way. try set e.cancel = true without checking, , @ dtdetail.rows.add() exception. check "some checking" code.

IPv6 address representation in Python -

i converting ipv6 addresses textual representation , noticed behavior not explain: in[38]: socket.inet_ntop(socket.af_inet6, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x7f\x00\x00\x01') out[38]: '::ffff:127.0.0.1' in[39]: socket.inet_ntop(socket.af_inet6, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x7f\x00\x00\x00') out[39]: '::ff:ffff:7f00:0' i surprised see ::ffff:127.0.0.1 , i'd expect ::ffff:7f00:0 . standard or @ least common? ipv6 addresses represented way? wikipedia article doesn't mention @ all. confused. the posix page inet_ntop specifies format 1 of options (slightly paraphrased): a third form more convenient when dealing mixed environment of ipv4 , ipv6 nodes x:x:x:x:x:x:d.d.d.d , x characters hexadecimal values of 6 high-order 16-bit pieces of address, , d characters decimal values of 4 low-order 8-bit pieces of address (standard ipv4 representation).

ios - From where geocode server Apple API get its information -

i'm working on backend of ios app. need list of countries corelocation might return. i.e if in u.s returned county u.s or united state. searched , find corelocation used geocode api: link didn't find gets information. knows form can information? thanks. clplacemark has isocountrycode property returns country code conforming iso 3166-1 alpha 2 standard .

java - Trying to calculate the average in an ArrayList -

i'm trying write code takes in number of entries , stores in arraylist given specific condition. i'm not able find average of values stored in arraylist . here's code written far: import java.util.arraylist; import java.util.scanner; public class app { private arraylist<integer> temp; private int t; private int count = 0; public void main() { scanner input = new scanner(system.in); temp = new arraylist<>(); system.out.println("enter temperatures: "); { t = input.nextint(); if (t == -99) { system.out.println("program terminating.."); break; } else { temp.add(t); } } while (t != -99); (int = 0; < temp.size(); i++) { if (temp.get(i) > 40) { count++; } } system.out.println(count); } } you have funky condi...

meanjs - Easiest way to create MEAN app -

i trying create mean app & ran following commands: npm install -g generator-meanjs yo meanjs after able setup application. problem can see lot of dependency being added (faceboom/twitter etc) & structure little difficult follow. is there easy setup mean app?

c# - How to fix 'System.OutOfMemoryException' occurred in mscorlib.dll after unison scrolling -

i have 2 datagriviews, requirements both datagriviews need scroll in unison allow user able see ‘input’. clarify: i create new file browsing original file, when loads (grid1) loads 1 grid being empty (grid2) i'm able input grid2. all menotined above working fine can save , edit file. created unison scrolling scrolls 1 row , throws error below, error: unhandled exception of type 'system.outofmemoryexception' occurred in mscorlib.dll scrolling code, private void gridview1_scroll(object sender, scrolleventargs e) { foreach (datagridviewrow _row in gridview1.rows) { (int n = 0; n < gridview1.columns.count; n++) { gridview1.scroll += new system.windows.forms.scrolleventhandler(gridview1_scroll); //it throws error here. } } foreach (datagridviewrow _roww in gridview2.rows) { (int nn = 0; nn < gridview2.columns.count; nn++) { gridview2.firstdisplayedscrollingrowindex = ...

c++ - How to create rotated rectangular or polygonal ROI/mask? -

Image
let's have following image: and region of interest looks this: and want have following result: how can achieve knowing roi denoted 4 points: point pt1(129,9); point pt2(284,108); point pt3(223,205); point pt4(67,106); the idea use fillpoly() fill pixels inside rotated-rectangle/polygon 0, 255 otherwise: mat mask = cv::mat(img.size(), cv_8uc1, scalar(255)); // suppose img image mat vector<vector<point>> pts = { { pt1, pt2, pt3, pt4 } }; fillpoly(mask, pts, scalar(0)); // <- here

html - I dont know why but i cant use multiple @media screens -

this question has answer here: media query canceling other media queries 2 answers i trying make site responsive , though problem media screen doesnt save found out. reason cant use more 1 media screens. have posted similer issue before know problem is, dont know solution. previous post : why doesn't @media screen save css @media screen , (max-width: 480px) { header img{ margin-left: auto; margin-right: auto; display: block; } footer img{ position:fixed; margin-left: auto; margin-right: auto; display: block; bottom: 5%; left: 40%; right: 40%; } .logo img{ position:fixed; margin-left: auto; margin-right: auto; display: block; bottom: 2%; left: 38%; right: 40%; } .home img{ position:fixed; margin-left: auto; margin-right: auto; display: block; bottom: 5%; left: 35%; right: 40%; width: 120px; } .socialmedia-twitter img { position:fixed; margin-left: auto...

java - set a parameter to request object -

i'm using else's code, has method can call logout site. inside method have following condition: if (request.getparameter("logout") != null) { //the rest of code } the problem is: how set parameter of "request" object logout value can different "null"? condition expressed in code returns "null" value, rest of code never executed. there way change "logout" parameter can still use method, or there approach should use? if want add parameter request need append url.depending on api use above servlet api ,it might different idea same: requestdispatcher dispatcher = request.getrequestdispatcher("/servlet/some.thirdpartyservlet" + "?" + "param_name=" + "somevalue")

openstreetmap - POIs with description and photos -

i know question asked, have problems different api/dump tested: open street map : free , dump can parse , store in elasticsearch database, there no description nor photos pois. foursquare : important number of pois descriptions, information , photos. many photos selfies, or bad photos can't see place. plus, must call api information rate limits. i'm looking way similar can find on tripomatic . maybe there way getting pois on openstreetmap , description on wikipedia , photos on wikimedia ? i'm interested if have works on this. thanks several pois in osm have wikipedia or wikidata tag, example frauenkirche in dresden . have image tag referring wikimedia commons / osm wiki filename or external url, example zwinger in dresden . these tags doen't exist pois. yet have possibility search poi's name on wikipedia or wikimedia commons.

vb.net - Visual Basic path asterisk -

i'm trying figure out how replace char (random) char in path example, don't need check multiple times (exemple : *:/program files/abc/*.cfg). in exemple, delete .cfg files in folder on every disk drives. what i've tried : if my.computer.filesystem.fileexists(dir & "\abc\?\?.cfg") my.computer.filesystem.deletefile(dir & "\abc\?\?.cfg") end if i don't think it's possible use wildcard disk drive (at least couldn't find way it), can quite drives on computer , run loop, using driveinfo.getdrives method: for each drive driveinfo in driveinfo.getdrives() dim filepath string = string.format("{0}test1.txt", drive.name) if file.exists(filepath) console.writeline(convert.tostring("exists: ") & filepath) end if next update in order use wildcards, must use directory.getdirectories , directory.getfiles instead of file.exists : dim wildcardpath string = "abc\*" ...

C/C++ Vector and reference parameter -

i want receive vector in main function. code this. int myfunction(void); int main(){ int p = myfunction(void); std::cout << p[2] << std::endl; }; int myfunction(void){ int new array[4]={0,1111,2222,3333}; int *p; p = array; return p; }; in c++ do: std::vector<int> myfunction(); int main(){ std::vector<int> p = myfunction(); std::cout << p[2] << std::endl; } std::vector<int> myfunction(){ return std::vector<int>{0,1111,2222,3333}; } and in c do: int* myfunction(void); int main(void){ int* p = myfunction(); printf("%d\n", p[2]); free(p); } int* myfunction(void){ int tmp[] = {0,1111,2222,3333}; int* array = (int*)malloc(sizeof(tmp)); memcpy(array, &tmp, sizeof(tmp)); return array; } now if have trouble code, i'd recommend go pick c or c++ book (whichever you're interested in) , read on basics of language, because se...

eclipse - Encountering issue in SimpleDateFormat parse method in Java -

i trying use simpledateformat.parse method parse date string date object, omitting "t" in final date returned. passing date string 2015-04-15t12:55:07.365 , getting 2015-04-15 12:55:07.365 in output. however, desired output 2015-04-15t12:55:07.365 . why "t" in final output omitted line parseddate = sdf.parse(transdate); public static void main(string[] args) { try { final string pattern = "yyyy-mm-dd't'hh:mm:ss.sss"; // example 2015-04-15t12:55:07.365 final simpledateformat sdf = new simpledateformat(pattern); string transdate = "2015-04-15t12:55:07.365"; date parseddate = sdf.parse(transdate); system.out.println("transdate:"+transdate+", parseddate: "+parseddate); } you never desired output 2015-04-15t12:55:07.365 why? because printing date object parseddate .date class has it's own tostring() method implementation.when printing date...

c# - Splitting a string based on specific characters -

Image
i try describe problem can. trying write program handle equations like: f = (x∨a) ↔ (x∨b) ( (x or a) equivalent (x or b) )! i have solve 'x', or better say, write disjunctive and/or conjunctive normal form. so, theoretically, goes this: when truth table written, have see when f equal 1 (tautology), , write conjunctive/disjunctive normal form. for example (disjunctive normal form given table): a=0,b=0 , a=1,b=1, value of x not matter, , a=0,b=1 , a=1,b=0, x must 1. in end, x=a∨b. since i'm writing in c#, equations written in textbox. bothers me,is how should separate string can solve part part? what first trying "split()" method (or other methods) of class string in c#? in first place, you'd better push users insert blank (as separator of split()) between each pair of tokens (e.g. , b) , can concentrate on main logic of solver.

asp classic - Merge Multiple FDF docs FDFEmbedAndClose -

i have legacy application uses acrobat pdf tk create fdf template pdf. the application works fine creating single fdf @ time, issue need batch process multiple fdf @ once, tried no luck using fdfembedandclose based on documentation should embed fdf container fdf. how should this?

javascript - After copy the website to a local server, "buy", "buy in one click" buttons don't work -

i have store on opencart cms, ive ceo, learn how works:). copy local webserver (macos 10.10.3, apache/2.4.10, mysql, php5.5). on local webserver site opens, can click on links - works. have problems "buy" buttons , others links open popup windows (buy in credit, buy in 1 click) - doesnt work. can make works? when open product page, in chrome console there errors: caroufredsel: no element found ".tabs-holder .product-holder:visible". xmlhttprequest cannot load 'http://localhost/index.php?route=product/product/review&product_id=209'. request redirected 'http://localhost/index.php?route=product/product/review&product_id=209', disallowed cross-origin requests require preflight. xmlhttprequest cannot load 'http://localhost/index.php?route=record/record/captcham'. request redirected 'http://localhost/index.php?route=record/record/captcham', disallowed cross-origin requests require preflight. consider using 'dppx...

css - Resource interpreted as Stylesheet but transferred with MIME type text/html dont know whats wrong -

im having problem trying website work on apache server after uploading when check see if website working error chrome resource interpreted stylesheet transferred mime type text/html firefox gives me error css not loaded because mime type, "text/html", not "text/css i have no idea going wrong, have done searching nothing seems have worked. made sure file privileges accessible users have added addtype text/css .css .htaccess still nothing here preview page of site http://preview2.sitepreviewservice.net/~star-gaming.co.uk page not loading css files @ post image of website should need 10 reputation post images. im still new webdesign please excuse ignorance, appreciated , in advance. to serve css-file text/css mime-type, have check following: your css file should static file (not script) your apache should have mime_module there should typesconfig conf/mime.types directive in httpd.conf there should corresponding line uncommented in mime.types ...

javascript - fire external script background with js? -

is possible fire execution of script in background via click? within cms/crm , want trigger external file load when clicking on link within cms/crm. e.g. activate php.mailer send email. it seems security issue when using (cross domain vulnerability?) foobar.onload() and if weren't, not execute file in background. have seen solved in python using subprocessor() . the external script on domain though , not touch cms / crm. ideas? in javascript can't access filesystem, can use ajax request url differents methods (get, post...). the script called url can execute function send email if want. if know jquery, can in javascript $.get("myscript.php"); and in myscript.php file : mail('you@mailhost.com', 'hello', 'cool !'); and if php script not on same domain, should check access-control-allow-origin header allow client (the browser execute ajax script) call remote php script

java - Compare users input -

i have text.file questions , text.file correct answers questions. program contains jbutton-s , when user clicks on button shows new pane question multiple choice answers, user asked write letter of correct answer. have done things , works. want compare entered answer correct answer , store number of correct answers in text.file if can give advice or example code appreciate it. thank in advance , here code, need add things. jtextfield xfield = new jtextfield(5); jpanel mypanel = new jpanel(); mypanel.add(new jlabel("answer: ")); mypanel.add(xfield); mypanel.add(box.createhorizontalstrut(20)); int result = joptionpane.showconfirmdialog(null, mypanel, "please enter answer", joptionpane.ok_cancel_option); return; } } } i have made similar application years ago. did putting questions answers in text file. ...

Java Cookie auto manager -

i'm new java. , have troubles java's cookies. let me put it. i want post json(paras username , password) server using api. if have login, can request other datas using api, have provide information using cookies. want methods python's cookiejar can manager cookies automatically. so,i can post username , password http server using tools cookiejar firstly.then can other data using cookies requesting http api. could me?

javascript - HTML <video> function if videoEnded go to other section of the page -

i have page here shows video @ load. trying achieve is; if video has ended, go other section of page (like button does). http://i333180.iris.fhict.nl/p2_vc/#section1 already collected code internet couldn't make functional. didn't found problem tho. html <!-- video --> <video id="moodvideo" autoplay controls onended="videoended()"> <source src="moodvideo.mp4" type='video/mp4'> </video> js function videoended() { //go hreff="#section" } html <video id="moodvideo" autoplay controls onended="videoended()" src="moodvideo.mp4"></video> script: <script type="text/javascript"> function videoended() { window.location.href="http://i333180.iris.fhict.nl/p2_vc/#section"; } </script> since it's referring section on same page simplify thing passing section name argument method. <script...

c - Array of constant pointers to functions -

i want make array of constant pointers functions. this: #include <stdio.h> #include <stdlib.h> int f( int x); int g( int x ); const int ( *pf[ ] )( int x ) = { f, g }; int main(void) { int i, x = 4, nf = 2; for( = 0; < nf; i++ ) printf( "pf[ %d ]( %d ) = %d \n", i, x, pf[ ]( x ) ); return exit_success; } int f( int x ) { return x; } int g( int x ) { return 2*x; } it works "fine" when compiled without -werror flag, otherwise get: building file: ../src/probando.c invoking: gcc c compiler gcc -o0 -g3 -pedantic -pedantic-errors -wall -wextra -werror -wconversion -c -fmessage-length=0 -mmd -mp -mf"src/probando.d" -mt"src/probando.d" -o "src/probando.o" "../src/probando.c" ../src/probando.c:17:14: error: type qualifiers ignored on function return type [-werror=ignored-qualifiers] ../src/probando.c:17:1: error: initialization incompatible pointer type ../src/probando.c:17:1: er...

javascript - How to get and append most recent messages from server using jQuery and AJAX? -

i'm working on first simple chat application , issue has me stuck. know i'm trying do, end overthinking it. basically, have heroku server going: http://tiy-fee-rest.herokuapp.com/collections/blabbertalk whenever sends message, added array. my issue: i have on set interval every 2 seconds, runs getnewestmessages function. when setinterval working , sends message, keep appending last message sent every 2 seconds. if disable setinterval , call getnewestmessages function myself in separate browser tab, doesn't seem happen. i want make sent message isn't re-appended dom when setinterval active. this function i'm using check recent messages. it's pretty bloated, sorry that: getnewestmessages: function() { $.ajax({ url: http://tiy-fee-rest.herokuapp.com/collections/blabbertalk, method: 'get', success: function (data) { // finds id of recent message displayed in dom var recentid = $('.message').last().data('id');...

arrays - Error: Not found: Value S (Scala) -

val array(k,s) = readline.split(" ").map(_.toint) this code works fine. not this: val array(k,s) = readline.split(" ").map(_.toint) capitalizing "s" here gives me error: error: not found: value s what going on? when creating k , s identifiers val array(k,s) = ... , using pattern matching define them. from scala specifications ( 1.1 identifiers): the rules pattern matching further distinguish between variable identifiers, start lower case letter, , constant identifiers, not. that is, when val array(k,s) = ... , you're matching s against constant. since have no s defined, scala reports error: not found: value s . note scala throw matcherror if constant defined still cannot find match : scala> val s = 3 s: int = 3 scala> val array(k, s) = array(1, 3) k: int = 1 scala> val array(k, s) = array(1, 4) scala.matcherror: [i@813ab53 (of class [i) ... 33 elided

node.js - Send a POST when the user hits the bottom? -

there loads of questions have same problem, ones i've found tell how actual javascript works, not routing kind of thing. so i'm bit lost @ moment trying implement html , routing side of infinite scroll system using node.js, express, , mongodb. i know how checks when user hits bottom, , know need have kind of listener in app.post route tell database append data. don't know doing 'posting', , how should route it. is onclick listener watching "submit" value true? , when user hits bottom, becomes true, express gets post, loads ten more entries. i literally don't understand actual concept of waiting event value in routing file, thought whole point of separating front , end meant not wait value "true" in javascript , return that. this pretty general question think, , code not needed. so if give decently broad explanation of how should looking @ whole event listening thing , routing it, lot. seems impossible. "what d...

html - Bordered element with display:table extends out of parent -

Image
this code seems have different effect in each browser. .container { display: inline-block; border: 1px solid black; padding-top: 5px; padding-bottom: 5px; } .box { display: table; width: 10px; height: 10px; background-color: red; border: 5px solid blue; } <div class="container"> <div class="box"></div> </div> in chrome 43.0, table not confined container: in safari 5.1, border overlaps table because seems interpret width inclusive of border width: in firefox 38.0 , internet explorer 11.0, table renders correctly: the ideal browsers behave similar firefox/internet explorer. using box-sizing: border-box , increasing width of .box include width of border makes browsers show firefox/internet explorer version, assuming width of border unknown, there way make major browsers render model according firefox/internet explorer (without using javascript)? the follo...

How to change all component values of parent panel on change of child panel in wicket -

in wicket have created dynamic panels (parent panel) using list view in have display slider have created panel(child panel) display slider. slider created each panel. on change of slider in child panel should calculation , change values in parent panel moved slider without refresh page. there way achieve in wicket without using javascript the "wicket way" use wicket events broadcast.bubble. see example of wicket events @ http://www.wicket-library.com/wicket-examples-6.0.x/events/ , documentation @ http://ci.apache.org/projects/wicket/guide/6.x/guide/advanced.html#advanced_2 . send event parent. event payload may bring ajaxrequesttarget parent can repaint if needed.

Revit API 2015 Python: GetAllViewports() takes exactly 1 argument (0 given) -

data = unwrapelement(in[0]) outlist = [] in data: vs = viewsheet.getallviewports() outlist.append(vs) out = vs this kind of problem: revit api 2015 python: getallviewports() takes 1 argument (0 given) what arg need place in getallviewports()? the error "... takes 1 argument (0 given)" hint calling unbound instance method: instead, hold of viewsheet interested in , call getallviewports method there, opposed using method on class name ( viewsheet ).

mapreduce - How can I query by document attribute when the attribute is an array? -

in couchbase server 3.0, documents in bucket of form: { "id":"xyz", "categories":["news", "articles", "etc.etc.."]} i want write view such when specify key="news", documents include "news" in "categories" array attribute returned. i went far writing map function emits same article many times have elements in "categories" array. function (doc, meta) { for(var = 0; < doc.categories.length ; i++) emit(doc.categories[i], doc); } but i'm stuck reduce. turns out map function sufficient, needed query key="cateogoryname" in url. i confused because if don't wrap key in quotes in query mysterious error, see: https://issues.couchbase.com/browse/mb-7555 not sure if reduce function more efficient though..

swing - How to get this Java Layout? -

Image
in java borderlayout north part this: so want have is, north , south part have same width center . east , west part should have height of center . means corners should empty. don't want use gridlayout this, because don't want north have same height center . how layout? simply nest 2 borderlayout using jpanels. in inner one, add north , south panels. place inner 1 in outer one's borderlayout.center position. done. import java.awt.borderlayout; import java.awt.color; import javax.swing.*; public class simplelayout extends jpanel { public simplelayout() { jpanel innerpanel = new jpanel(new borderlayout()); innerpanel.add(createlabeledpanel("center"), borderlayout.center); innerpanel.add(createlabeledpanel("north"), borderlayout.page_start); innerpanel.add(createlabeledpanel("south"), borderlayout.page_end); setlayout(new borderlayout()); add(innerpanel, borderlayout.center); ...

android - Lots of checkboxes to add to my RealmObject -

i use checkboxes lot in app , there screen have 3 different logical categories user might choose ( check ) 1 or more checkboxes. right have realmobject more 20 fields each 1 having value of 0 if not checked , value of 1 if is. is there way make more cohesive database's table schema?

jquery - Hide div for set period after clicking on button -

i got float button can close. here code of button : <div class="primary"><button id="ferme" class="popup-button" data-modal="popup">deviens un lhibou</button><div class="alert-close"></div></div> here jquery code makes close button deleting whole div : (function($) { $(document).ready(function(c) { $('#alert-close').on('click', function(c){ $(this).parent().fadeout('slow', function(c){ }); }); }); })(jquery); my question : how set cookies hide div set period after clicking on button ? thanks lot

python - AttributeError: '_Screen' object has no attribute 'mainloop' -

i'm designing simple python program uses turtle graphics module draw lines on screen arrow keys. import turtle turtle.setup(400,500) # determine window size wn = turtle.screen() # reference window wn.title("handling keypresses!") # change window title wn.bgcolor("lightgreen") # set background color tess = turtle.turtle() # create our favorite turtle # next 4 functions our "event handlers". def h1(): tess.forward(30) def h2(): tess.left(45) def h3(): tess.right(45) def h4(): wn.bye() # close down turtle window # these lines "wire up" keypresses handlers we've defined. wn.onkey(h1, "up") wn.onkey(h2, "left") wn.onkey(h3, "right") wn.onkey(h4, "q") # need tell window start listening events, # if of keys we're monitoring pressed, # handler called. wn.listen() wn.mainloop() when try execute...

XML to Word using custom paragraph styles and XSLT -

Image
i've got xml file contains textual information (list of questions in moodle xml format ). i'd convert document can opened ms word, i'd maintain context (using paragraph styles) can convert moodle xml. here's tried far: i excited find several tutorials (e.g., a ) how use xml in word, many of them moot given result of i4i patent dispute . i made prototype rtf xslt, rtf styling , unicode support complex. i've seen way use <p class="mycustomstyle"> html documents can opened in word. html style sheets , mapping them word styles seems limited. need styles "based on" (inherit from) other styles , it's not clear how works using html classes , css. i've looked @ openxml office. <w:blah> tags pretty easy use, don't whole zip archive solution. means styles go in 1 xml file, content in another, etc. i'm guessing i'll need step beyond xslt (some kind of script multiple transforms). i'm trying keep simple: i...

Java reflection - enum generate -

i make program can generate source code of class,enum , interfaces using reflection have problem enum generating. my eumtest class public enum enumtest{ a,b; private string r; private enumtest(){ } private void some(){ } public int[] some2(int[] b){ return b; } } method generate enum file private void generateenum(class<?> cls,printwriter writer) { this.writepackage(cls, writer); this.writeannotations(writer, cls.getdeclaredannotations()); writer.write(modifier.tostring(cls.getmodifiers())+ " enum " + cls.getsimplename()); this.writeimplementation(cls, writer); writer.write("{"); this.writenewline(writer); object[] cons = cls.getenumconstants(); (int = 0; < cons.length; i++) { writer.write(cons[i].tostring()); if(i != cons.length - 1) writer.write(","); } writer.write(";"); this.writenewline(writer); this.writefields(cls, writer); this....