Posts

Showing posts from July, 2014

opencv - How to store cv::Scalar objects in a Map in c++ -

i want store randomly generated scalar values in map. following attempt gives me compile error. rng rng(0xffffffff); std::map<scalar, int> segmentcolors; scalar randomcolortemp1 = randomcolor(rng); scalar randomcolortemp2 = randomcolor(rng); segmentcolors.insert(pair<scalar, int>(randomcolortemp1, 1)); segmentcolors.insert(pair<scalar, int>(randomcolortemp1, 1)); error report follows. 1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\xstddef(193): error c2678: binary '<' : no operator found takes left-hand operand of type 'const cv::scalar' (or there no acceptable conversion) 1> e:\opencv\build\include\opencv2\core\operations.hpp(3193): 'bool cv::operator <(const cv::filenodeiterator &,const cv::filenodeiterator &)' [found using argument-dependent lookup] 1> e:\opencv\build\include\opencv2\core\mat.hpp(1303): or 'cv::matexpr cv::operator <(const cv::mat &

jquery - Select2 Display Different Value after selection -

i trying find updated answer question here seems formatselection option select2 no longer work, or not working me. basically, have multi-select select2 menu , have option's value displayed after being selected rather being text description. instance, have list of provinces each 1 has shorthand value on option (ab alberta, bc british columbia, etc.) those ones have displayed after being selected. there simple way of doing in select2 4.0.0? markup: <select id="provselect" multiple data-role="none" > </select> for js: $("#provselect").select2({ width:"100%", formatselection: formatselection}); with appropriate function: function formatselection(item){ return item.id; } select2 still has formatting api, it's called templating now. example: function formatstate (state) { if (!state.id) { return state.text; } var $state = $( '<span><img src=&

c# - MS Word Interop, Keeping Paragraphs and tables with headers together keeping them from splitting to the next page -

i'm using code below working merge queued list of html files , saving them in either pdf or docx using ms word interop. i've run issues page breaks. cannot figure out how keep both paragraphs , tables page breaking in middle of them. goal keep text in paragraphs , tables together. tables have heading text direct above them. nice keep if possible. there way programatically keep these items together? document being used done not have static verbiage or format. dynamically created , can different depending on circumstances. code being developed in .net 2.0 environment. public static void mergea(string[] filestomerge, string outputfilename, bool insertpagebreaks, bool pdf) { //object defaulttemplate = documenttemplate; object missing = system.type.missing; object pagebreak = microsoft.office.interop.word.wdbreaktype.wdpagebreak; object outputfile = outputfilename; object ofileformat = microsoft.office.interop.word.wdsavefor

android - How to add an item to a scrollview from another activity? -

i want add item scrollview present in different activity second activity. have button in second activity , when button clicked want add item scrollview present in different activity. scrollview row consists of 2 textviews , button. problem each button in scrollview used different url. how can add these urls these buttons @ runtime. can suggest work around this? thank you. the scrollview activity created after click additem button few times. save "added data" class both activities can access. when scrollview activity launches, load current data. if you're keeping scrollview open in background, onresume still called, , can load current data there.

javascript - Undefined Returns on JSON Strings -

i wondering if able explain why of json returning undefined.. json question this {"273746":[{"name":"darius's wizards","tier":"gold","queue":"ranked_solo_5x5","entries":[{"playerorteamid":"273746","playerorteamname":"magnanimous","division":"v","leaguepoints":0,"wins":19,"losses":15,"ishotstreak":false,"isveteran":false,"isfreshblood":false,"isinactive":false}]}]} and javascript i've got run through is: note: in code provided /sumid 273746 , s 'oce' due riot api guidelines can't give direct link api had paste in above. function statslookup(i,s) { $.ajax({ url: 'https://oce.api.pvp.net/api/lol/' + s + '/v2.5/league/by-summoner/' + + '/entry?api_key=', type: 'get', datatype: 'json',

R: split data based on a factor, add a ranking column and extract -

i still haven't been able know how can access different elements of split data. here problem: have data set, want split based on column (state). want have ranking column added data each subset. part of function i'm writing. data set has 2 columns, hospital, state, outcome. each state, want add 'rank' column ranks data based on outcome; lowest outcome ranked 1 , highest outcome ranked last. how can use split, sapply/lapply this? there better way, using "arrange"? main problem when use either of these methods, not know how access each element of split or arranged data. here's how data set looks like: hospital state outcome. row lines not important here. hospital state outcome 1 southeast alabama medical center al 14.3 2 marshall medical center south al 18.5 3 eliza coffee memorial hospital tx 18.1 7 st vincent's east tx 17.7 8 dekalb regional medical center al

php - cannot install sample data with the installation of opensis -

currently i'm trying install opensis installation failed in step 3 after choosing **install sample data** the installation continue if choose not install sample data "other configuration" should done. working on xampp, mysql, php 5.5.24, windows 7 thanks

winapi - Get Application Name from .exe file in python -

i getting both active window title , exe filepath code below hwnd = win32gui.getforegroundwindow() _, pid = win32process.getwindowthreadprocessid(hwnd) if hwnd != 0 or pid != 0: try: hndl = win32api.openprocess(win32con.process_query_information | win32con.process_vm_read, 0, pid) self.newexe = win32process.getmodulefilenameex(hndl, 0) self.newwindowtitle = win32gui.getwindowtext(hwnd) except: self.newexe = '' self.newwindowtitle = '' the issue although is, window title not application name (the name users understand main part of application) , need. example calc.exe calculator withiout relying on window title. the purpose create script log in xml comparative use of software on computer is possible? most windows applications store information such inside resource tables. there api calls can used extract this. the following extracts file description given applic

css - Why is this SVG image blurry when scaled down? -

i making responsive web page using bootstrap 3 framework. have image want use logo on page. i started off saving full size (788 x 1098) image png. custom css makes sure image has max-width of 280px , of course bootstrap's css scale down image appropriately device. when viewed responsive web page on desktop pc looked ok though had been scaled down 197 x 280. when viewed on mobile image looked blurry , wasn't @ all. so heard svg images , thought i'd give go. downloaded inkscape mac, opened full size png in inkscape , re-saved svg image. unexpectedly svg image looks when view web page on mobile phone looks blurry , bad when viewed on desktop pc. why this? thought whole point of svg images can scaled without loss or blurriness? i've made codepen demonstrate: http://codepen.io/theclarkofben/pen/wvdkgm <p>svg 20%</p> <img src="http://www.clarkben.com/img/cv.svg" alt="a" style="height: 20%; width: 20%;"/> <p>s

Displaying data from database in bootstrap modal form(PHP&MySQL) -

i new both bootstrap , php. have created registration modal form register users site , registers perfectly. however, retrieve users details database based on user id , display details in registration form them edit , update. don't know how display records in form fields... please providing simple syntax this. i using php , mysql this modal form <div class="modal fade" id="updatelecmodal" tabindex="-1" role="dialog" aria-labelledby="updatelecmodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button> </div> <div class="modal-body">

ios - Convert NSString to NSDate in Spanish Locale -

i have integrate rss feed parser ios application. 1 of field in received data published date. i'm able parse date if iphone locale english-united states. when change language of iphone spanish, not able convert string nsdate object. here's code wrote: nsstring* dt = @"fri, 26 jun 2015 00:00:00"; nsdateformatter* dtformatter = [[nsdateformatter alloc] init]; //set locale spanish [dtformatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"es"]]; [dtformatter setdateformat:@"eee, dd mmm yyyy hh:mm:ss"]; nsdate* condt = [dtformatter datefromstring:dt ]; nslog(@"%@", condt); //this value (null) even after setting locale "es" (which spanish), still not able parse properly. how can convert string date in ios? when set locale, don't want use locale of device, rather locale used when string created (because you're taking english string , want convert nsdate regardless of locale of device). in fact, it&

javascript - jQuery function works intermittently -

i'm pretty stuck here. i'm using live search lookup script (ajax) lookup customers in database using input field. upon selection click chosen customer. form filling out customer filled details database. problem of time once clicked fields populated data. intermittent, if repetitively click same customer populate, appears though works in bursts , fails appears though there no pattern. thanks in advance :) // ########## live search function ########## // $(function(){ $(".search").keyup(function() { var searchid = $(this).val(); var datastring = 'search='+ searchid; if(searchid!='') { $.ajax({ type: "post", url: "search.php", data: datastring, cache: false, success: function(html) { $("#result").html(html).show(); } }); }return false; }); jquery(document).live("click", function(e) { var $clicked = $(e.target); if (! $clicke

Is token normalization implemented in Stanford NLP? -

i trying normalize tokens (potentially merging them if needed) before running regexner annotator on them. is there implemented in stanford corenlp or in stanford nlp in general? if not, what's best way implement it? writing custom annotator in corenlp? there options token normalization. apply -options flag comma separated list containing options want. this described in more detail on link: http://nlp.stanford.edu/software/tokenizer.shtml near bottom there section options shows list of possibilities. are there other normalizations interested in not on list?

python 2.7 - wxPython: GridBagSizer - Growable List Object -

im using gridbagsizer ui layout. im facing following problem. the grid im using has 4 rows , 12 columns. on second row (row 1) ad ultimatelistctrl , want to grow if window resized vertically or horizontally. ulc_style = ulc.ulc_report | wx.lc_vrules | wx.lc_hrules | wx.lc_single_sel | ulc.ulc_has_variable_row_height self.list = ulc = ulc.ultimatelistctrl(self.panel, agwstyle=ulc_style) self.sizer_grid = grid = wx.gridbagsizer(5,5) grid.add(self.list, (1,0), (1,12), flag=wx.expand) i use following function make columns growable , set row 1 growable. for in range(13): grid.addgrowablecol(i) grid.addgrowablerow(1) i can resize window horzizontally fine , alle elements resize vertically list stays is. if add size parameters listctrl row expand size entered, , expand further horizontally vertically still fixed size , wont adjust window size. grid.addgrowablerow(1) doesnt seem anything, when remove it, ui still looks same. im new python , wxpython maybe im do

Edges of image curves on canvas get distorted on android -

Image
as shown in image, when create image out of curvy path(using porterduffxfermode) looks distorted. black outline drawn same path image peaks out of edges creating distorted look. have listed code below (android:hardwareaccelerated="true" has been set well). how can remove distortion , align image behind black outline. ********************* create image ****************************** // translatedfigure curvy figure // sourcepicture image drawn curvy figure canvas gfx = new canvas(image); gfx.drawpath(translatedfigure, fillstrokepaint); // use new porterduffxfermode(android.graphics.porterduff.mode.src_in) gfx.drawbitmap(sourcepicture, 100, 100, porterduffpaint); gfx.drawbitmap(image, 0, 0,embosspaint); // emboss gfx.drawpath(translatedfigure, outlinepen); // draw black outline ****************************draw image on canvas**************************** canvaspaint.setflags(paint.filter_bitmap_flag | paint.anti_alias_flag); canvas.scale(mscalefactor, msca

Remotely deploy war file to Tomcat using java code -

i'm trying deploy restful web service web server tomcat 8 eclipse . i tried using httpclient using code second answer of post: tomcat: remote programmatic deploy? exception java.net.socketexception: connection reset peer: socket write error. i tried httpurlconnection using code first answer of post: how upload, download file tomcat server username,password in swing error. what reason? there way? thank you. ... in different machine. can use tomcat manager deploy web service java code http put request. in order possible, deployment folder need accessible http server or web application. that's bad idea security reasons. you can still programmatically java (or other language) calling of many utilities file transfers: ftp, scp, networked file system, etc. note after have copied artifact (eg war file) tomcat host, can tell tomcat deploy remotely via deployment manager url. documentation : in example web application located in directory /pat

javascript - Find Index In An Array Range -

i have array of quantities , find in array number found. if user entered 16 function return between index 6 & 7 because 16 greater 15 less 20. in wider picture index used in lookup find price band desired quantity. edit html markup <table cellpadding="0" cellspacing="0" border="0"> <tbody><tr> <th scope="row">quantity</th> <th id="js-quantityid-0" scope="col">0</th> <th id="js-quantityid-1" scope="col">1</th> <th id="js-quantityid-2" scope="col">2</th> <th id="js-quantityid-3" scope="col">3</th> <th id="js-quantityid-4" scope="col">4</th> <th id="js-quantityid-5" scope="col">5</th> <th id="js-quantityid-6" scope="col">10

xcode - How to drag a View Controller on top of a View Controller? -

i have view controller presented when first open app, , have controller can shown on screen if tap button @ top of screen. however, instead of doing way wondering if can either drag view down or tap button , have animation take care of that. i have tried doing pageview controller, doesn't show effect wanted translates on next view , doesn't keep initial view fixed in place while second view slides on it. also, instead of view controller view placed out of bounds in main view controller work? in advance! you use side menu mmdrawercontroller has 4 type of animations presenting viewcontroller. or can create custom uiview (not viewcontroller) using interface builder , animate screen yourself. animation can started using uiscreenedgepangesturerecognizer .

java - Migrating the SQL and application server from Windows 2003 to Windows server 2012 R2 -

we facing issue migrating application deployed on windows servers 2003. use tomcat 5.5 in app server , sql server in sql box both run on separate windows server2003. we able deploy application using tomcat 5.5 , jdk 1.6 on windows server 2012 rs2 , sql server migrated 1 other instance runs on windows 2012 rs2. but when application launched , when trying insert data db encountering "java.sql.sqlexception: [microsoft][odbc driver manager] data source name not found , no default driver specified" the same application running fine without issues on windows 2003 server runs on 32 bit new server 64bit. please let me know if have install tomcat 7.0 windows2012 or can still run application without issues. regards, nitin.

c# - XML Errors using EPPlus to download Excel file in MVC -

Image
here important part, called ajax call in view: using (excelpackage pck = new excelpackage()) { excelworksheet ws = pck.workbook.worksheets.add(filename); ws.cells["a1"].loadfromdatatable(dt, true); response.contenttype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; response.addheader("content-disposition", "attachment; filename=" + filename + ".xlsx"); byte[] bytes = pck.getasbytearray(); response.binarywrite(bytes); response.end(); } but creates error: any idea wrong?

android Sliding tabs error -

i followed this tutorial making sliding tab application , after have encountered error: unable start activity componentinfo{com.cap2.macsanity.droidgency/com.cap2.macsanity.droidgency.mainactivity}: android.view.inflateexception: binary xml file line #2: error inflating class this activity main.xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".mainactivity"> <include android:id="@+id/tool_bar" layout="@layout/tool_bar" android:layout_height="wrap_content" android:layout_width="match_parent" /> <com.cap2.macsanity.droidgency. android:id="@+id/tabs" android:layout_width="

Is there a shorthand way of writing a range type in Swift? -

so knowledge of swift there convenience syntaxes/shorthand ways of defining types can shorten types parameters in functions. e.g. array, func example(anarray: array<int>) {} can more written func example(anarray: [int]) {} or dictionary, func example2(adictionary: dictionary<string, int>) {} can more written func example2(adictionary: [string: int]) {} i wondering if there shorthand way available range, or following way write it? not long write way, i'm more curious! func example3(arange: range<int>) {} edit: the range operators used creating ranges, not used define type. if write let arr = [0, 1, 2] let dict = [0:0, 1:1, 2:2] let range= 0...2 and inspect 3 variables' types, for: arr let arr: [int] dict let dict: [int : int] range let range: range<int> which leads me beleive there no shorthand defining range type in swift.

How to enable syntax errors/warnings highlighting in atom -

so using aptana studio before, , switched atom. and got used aptana's errors , warnings highlighting. example if forgot ; after declaration of varible, or wrong brackets , etc... in atom don't see errors/warnings highlighting @ all. possible enable in stock atom, or should download additional packages? p.s. i'm working js/jquery/node/php/html ok, looks linter job: https://atom.io/packages/linter

c++ - SFML 2.3 Codeblocks Crash -

i set sfml 2.3 on codeblocks 13.12 when try build&run code : #include <sfml/graphics.hpp> int main() { sf::renderwindow window(sf::videomode(800,600),"blabla"); while(window.isopen()){ sf::event e; while(window.pollevent(e)){ if(e.type==sf::event::closed){ window.close(); } } window.clear(); window.display(); } return 0; } it crashes. linked these "audio graphics main network system window" in linker setting. can me? i solve it, recompiled sfml using mingw32-make (i added .../codeblocks/mingw/bin path variables) placed dll generated compilation project folder. (here how build sfml : https://www.youtube.com/watch?v=u1zn_qrswxw&ab_channel=alexthorne hope helped people had same issue (sorry english)

sql - parent child table to xml -

i have following table. id name parentid ---------------- 1 root null 2 child 1 3 child b 2 4 child c 1 can point me in right direction export xml in either c# or sql server while supporting hierarchy? <node>root</node> <children> <node>child a</node> <children> <node>child b</node> </children> <node>child c</node> </children> i ended using approach in c#. http://w3facility.org/question/converting-datatable-into-json-tree-while-maintaining-parent-child-relationship/ basically take datatable, place hierarchical object, , serialize json. worked charm.

ios - Forcefully stop and close Active Session -

i'm using latest fbsdk v4.3 using login version v2.3. i need stop , close current active session couldn't able find out fbsession class , corresponding methods. can please me out rid of issue when user taps on facebook provided logout button can stop , close current active session. i tried below code throwing me error 'unknown type name 'fbsession'. fbsession *session = [session activesession]; [session closeandcleartokeninformation]; [session close]; [fbsession setactivesession:nil]; please hep me out. in advance. in v4.x of facebook sdk can use new fbsdkloginmanager class , call logout method have same effect. in background calls [fbsdkaccesstoken setcurrentaccesstoken:nil] remove access token , resets facebook profile cached in fbsdkprofile

c# - speed up through parallel.for -

need download lot of data (daily) oracle, delete data on sql server (in case of reruns) , paste data sql server sqlbulk copy. non parallel version : (int = 0; < curves.rows.count; i++) { //download data oracle var data = getcurve(connectstring, impdate, curves.rows[i]); //delete old data in sql server deletesql(datetime.now, curves.rows[i]); //write sql server sqlbulk.copy writecurve(data, "dbo.t_curves"); } i wanted speed using parallel for, these steps dependent on each other. came (i have never used task factory before): parallel.for(0, curves.rows.count, => { var taskload = task.factory.startnew(() => getcurve(connectstring, impdate, curves.rows[i])); var taskdelete = task.factory.startnew(() => deletesql(impdate, curves.rows[i])); taskdelete.wait(); taskload.wait();

vb.net - VB - Issues With Progress Bar -

i'm making simple progress bar used splash screen within application when code executed, loading bar not reach end of progress bar. i've used code: splashprogressbar.increment(1) if splashprogressbar.value = 100 main_menu.show() me.hide() end if to open form when progress bar reaches 100, has been set maximum value. the issue more related appearance rather functionality still understand why occurs , fix. to clarify, form main_menu, opens when bar 3/4 of way completed , can't head around why occurs. ideas? i couldn't imagine vb has such bug. running old or incompatible ".net framework" causes that. can try set progressbars maximum programatically while running program. use code in form1_load event: progressbar1.maximum = 100 it should work. if doesn't, maybe it's code related. try fill progressbar way (it must in timer): if splashprogressbar.value = splashprogressbar.maximum main_menu.show()

c++ - pointer to array from serperate .cpp -

trying point array separate .cpp getting null values array. main.cpp int main() { storage exp; cout << exp.pointer[0]; _getch(); return 0; } storage.h class storage { public: storage(); int* pointer = experience; int storage::experience[10]; ~storage(); }; storage.cpp storage::storage() { } int experience[10] = { 100, 200, 400, 600, 1000, 2500, 3000, 4000, 5000, 10000; storage::~storage() { } it's rpg thingy. need return array values can't , can't create array scratch because it's handmade values. has go somewhere. don't want put in main(done before in separate code) because i'm trying learn how pointers doing terribly wrong. i don't think storing pointers , having each object contain own best way this. if objects of storage class share same values experience[10] array, should declare static int , not int , in declaration of storage class in storage.h . don't specify it's inside

java - Using 2 Calendar class instances to get time difference -

i using calendar library within java try , figure out problem application: i have 2 calendar instances, depart , arrive . depart leaving @ 5:35 pm on 7/15/2015 chicago, while arrive landing @ 9:50 on 7/16/15 in berlin, germany. my current code display travel duration is: calendar depart = calendar.getinstance(); calendar arrive = calendar.getinstance(); depart.settimezone(timezone.gettimezone("america/chicago")); arrive.settimezone(timezone.gettimezone("europe/berlin")); depart.set(calendar.month, 6); depart.set(calendar.day_of_month, 15); depart.set(calendar.hour_of_day, 17); depart.set(calendar.minute, 35); arrive.set(calendar.month, 6); arrive.set(calendar.day_of_month, 16); arrive.set(calendar.hour_of_day, 9); arrive.set(calendar.minute, 50); system.out.println("depart: " + depart.gettime() + "\narrive: " + arrive.gettime()); long hours = (arrive.gettimeinmillis() -

MongoDB import/export indexes -

i need tool rapidly recreating proper "schema" (such is) of mongodb instances between environments pre-creates right db names, collections, sets collection caps, , creates indexes each collection. not want copy of data between instances, though. each env manage has different data db/collection/caps/indexes same. there easy way this, preferably tool exports json doc of names, caps , indexes can re-imported new instance? after didn't find appropriate tool, dumped database , restored without data, metadata restored (particularly collections created apropriate indexes), collections empty. can applied databases data well, indexes created on existing db if there no conflict. 1.make dump mongodump 2.empty data of collections find ./dump -name '*bson' -type f -exec cp /dev/null {} \; 3.restore data new db mongorestore

python - SciKit-learn--Gaussian Naive Bayes Implementantion -

i have started using scikit-learn , trying train , predict gaussian naive bayes classificator. don't know i'm doing , if me. problem : enter x quantity of items of type 1 , have response of type 0 how did it: in order generate data training make this: #this of type 1 ganado={ "hora": "16:43:35", "fecha": "19/06/2015", "tiempo": 10, "brazos": "der", "sentado": "no", "puntuacion final pasteles": 50, "nombre": "usuario1", "puntuacion final botellas": 33 } #this type 0 perdido={ "hora": "16:43:35", "fecha": "19/06/2015", "tiempo": 10, "brazos": "der", "sentado": "no",

Calabash Android Looping through a ListView to check -

i've started using calabash , have come across listview. for each listview row want check presence of text , image view. however i'm unsure how can loop through listview? something like foreach list_item in listview check text label id check image view id end any appreciated. i not sure using foreach in case, based on index number in list. count of item, in loop move through them using of of 2 options getlistview().setselection(21); for smooth scroll: getlistview().smoothscrolltoposition(21); from post https://stackoverflow.com/a/7561660/1165581 handlerexploit and each item check image , text.

cordova - How do I prevent InAppBrowser from auto running with AngularJS $route? -

my app running cordova angularjs routing. need inappbrowser plugin view pdfs. however, since ngroute calls html on route change inappbrowser called. i need run on button click not everytime. -- edit -- when have cordova inappbrowser plugin installed white screen , message regarding white list issue regarding inital route "index.html": $routeprovider .when('/', { //load home @ start controller: 'homecontroller homeslides', templateurl: 'content/home.html', resolve: { // cause 1 second delay delay: function ($q, $timeout) { var delay = $q.defer(); $timeout(delay.resolve, 1000); var dl = document.getelementbyid('door-left'); var dr = document.getelementbyid('door-right'); dl.classlist.remove('open'); dr.classlist.remove('open'); return delay.promise; } } }) if uninstall plugin issue resol

angularjs - Dynamic Top Bar Text Based on Current Page in Zurb Foundation for Apps App -

i building single page application using zurb's foundation applications , angular. what recommended way display different text in top bar (nav bar) based on current route? for example, have page title associated current route appear in top bar (a simple form of breadcrumbs). i following standard app structure provided zurb's cli tool . top bar defined in index.html. the foundation apps framework uses ui-router . therefore, access router state information, example, name of current route/page, use following in html template: {{$state.current.name}}

MySQLi Array in PHP sometimes coming up empty -

okay, i'm pretty @ end of rope trying discover issue here, because code works perfectly, , not, here is: $allitems = array(); $allitemsquery = mysqli_query($conn,"select * cart_items crt_id='".$row['crt_id']."' , quantity>0"); while($itemsarray = mysqli_fetch_assoc($allitemsquery)){ array_push($allitems,$itemsarray['item_id']); } $allitemsnames = array(); foreach($allitems $key => $value){ $itemnames = mysqli_fetch_assoc(mysqli_query($conn,"select * items id='$value'")); array_push($allitemsnames, $itemnames['item_name']); } $allitemsfinal = array_combine($allitems,$allitemsnames); $itemslist = 'items:<br>'; foreach($allitemsfinal $key => $value){ $itemslist .='<a href="http://www.exampleurl.org/product.php?id='.$key.'">'.$value.'</a><br><br>'; } the idea it's supposed of item id's user has in cart db

Node.JS know where program is launched from -

i'm asking myself if possible see user launching program ? example : script in /home/user1/test.js, , user inside /home/user1/a-dir/, when enters $ node ../test.js possible user launched program ? (in case, /home/user1/a-dir/ ) thanks. you can current directory of process process.cwd() .

c# - How to call public static methods in Unit Test -

hi have simple method following , need know how can call in unit test in visual studio public class myclass { public static bool test(string value, string regex) { if (regex.ismatch(value, regex, regexoptions.ignorecase)) return true; return false; } } here have sofar [testmethod] public void testmethod_test() { string value = "myvalue"; string regex = "&#@<>\s\\\$\(\)"; privatetype pt = new privatetype(typeof(myclass)); bool actualresult = (bool)pt.invokestatic("test", new object[] { value, regex }); bool expectedresult = false; assert.areequal(actualresult, expectedresult); } you not want using reflection. call method directly: [testmethod] public void testmethod_test() { string value = "myvalue"; string regex = "&#@<>\s\\\$\(\)"; var result = classcontainingtest.test(value, regex); assert.ar

how to generate 16 bytes random number in python and xor them -

im writing own version of ssl , in order create master key, need create 2 random numbers of 16 bytes , xor them. can me doing so? i hope scientific purposes... ssl huge . , - in crypto - lot can go wrong implementation... luck! import os print(os.urandom(16)) but effort study/improve e.g. openssl, welcome effort!

state - Converting Epsilon-NFA to NFA -

Image
i'm having trouble understanding process of converting epsilon-nfa nfa, wondered if me it: and answer says: the 0 in new nfa has going 1,2 , 2. figured because 0 in epsilon nfa leads 1 , 2 (combined epsilon). why doesn't 1,2 have a-step going 2, because in epsilon nfa 1 has a-step 1 , 2? whenever remove ε nfa, should careful @ time of conversion direction of ε transition. in case, ε transition node 1 node 2, accept state. so, need consider incoming transitions state 1. also, {1} moves {2} upon ε-transition, 1 can reduced {1,2} , it'll accept state. check this question know why happens. so, removal of ε-transition, check incoming transitions state 1, replace {1} accept state {1,2} , convert them :- state 0 transits state 1 when reads a , , state 1 automatically transit state 2 reads ε . so, should omit path 1 2(of ε-transition), , state 0 on reading transits both {1} , {2}. so, 1 transition added exisitng nfa {0} -> {2

javascript - Redirecting multiple values in URL with Greasemonkey -

i'm trying greasemonkey automatically redirect page when hits url, , redirect page 2 of same values. instance: http://www.google.com/page=438985&view=49834 into: http://www.google.com/document/page=438985/field&view=49834&done i've tried following: var links,thislink; links = document.evaluate("//a[@href]", document, null, xpathresult.unordered_node_snapshot_type, null); (var i=0;i<links.snapshotlength;i++) { var thislink = links.snapshotitem(i); thislink.href = thislink.href.replace(regexp('http://www.google.com/page=($1)&view=($2)'), 'http://www.google.com/document/page=$1/field&view=$2&done'); } var links = document.getelementsbytagname('a'); for(var = links.length - 1; >= 0; i--) { if(links[i] && links[i].href) { links[i].href = links[i].href.replace(/http:\/\/www\.google\.com\/page=(\d+)&view=(\d+)/,