Posts

Showing posts from March, 2012

Count number of intersections of many random walks in a graph -

i want run k random walks each node of connected un-directed graph length lambda. when 2 or more walks visit 1 node @ same time, combine 1 walk , continue single random walk until lambda steps finish. want know how many walks merged @ end of lambda steps or @ least know bound it.

How to simplify javascript event listeners? -

what want achieve is, when hovering on li id="a", corresponding ul id="aa" appears. have html code: <ul> <li id="1">option1</li> <li id="2">option2</li> </ul> <ul id="11"> <li>option1.1</li> <li>option1.2</li> </ul> <ul id="22"> <li>option2.1</li> <li>option2.2</li> </ul> and javascript code: for (i=1; i<3; i++) { var fn = (function(i) { var li = document.getelementbyid(i); var ul = document.getelementbyid("" + + i); li.addeventlistener("mouseover", function() { ul.style.opacity = "1"; }, false); })(i); } and works expected, here user jordan gray stated possible rid of loop , instead create 1 event listener list items - achieve here. unfortunately not understand code , thankful if explain me or suggest solution. here how can use

node.js - Dropbox api V2, get access token in query param instead of url hash (#) (Nodejs) -

i'm using official dropbox api (v2) on nodejs app. sounds dumb question can't find out how given access token callback url . actually, supposed in the hash (#) part of url (according documentation , javascript client-side exemple ), not visible server side... i can't find exemple authentication nodejs app, using basic api. here authentication code: my express app: //entry point, dc dropboxconnector object app.get('/connect/dropbox', function(req, res) { console.log('/connect/dropbox called'); res.redirect(dc.getconnexionurl()); }); // callback authentication app.get('/authdropbox', function(req, res) { console.log("/authdropbox called"); console.log(url.format(req.protocol + '://' + req.get('host') + req.originalurl)); // above log is: 'http://localhost:8080/authdropbox' // here problem, access token unreachable express dc.gettoken(req.query.code, res); connectorlist.push(dc);

c# - Copy complete console output in a WPF TextBox? -

i' ve several places in c# code, output things console. using console.writeline, via tracelisteners system.diagnostics.consoletracelistener. now want display output in wpf textbox. possible bind console output 1:1 in way textbox? or have change every single call of tracelisteners or console.writeline add output textbox.text additionally? you can use console.openstandardoutput intercept console.writeline() - answer , link explain how implement textboxstreamwriter , inject in standard output stream. as consoletracelistener - should able write own textbox based tracelistener , assign appropriate tracesources (as support multiple trace listeners). answer highlights how implement same. more details regarding trace sources , listeners can found here .

go - write simple unit test for isolated function in golang, ethereum virtual machine -

in situation there isn't 1 correct answer, or expected result, can check for, i'm looking evaluate execution time of function under different conditions, still unit-test? there's function embedded in project i'm working on executes addition operation (opadd) on virtual machine (the ethereum vm), file can found on project github page . this specific function responsible task: func opadd(pc *uint64, evm *evm, contract *contract, memory *memory, stack *stack) ([]byte, error) { x, y := stack.pop(), stack.pop() stack.push(math.u256(x.add(x, y))) evm.interpreter.intpool.put(y) return nil, nil } what i'd create " unit-test " of sorts evaluate execution speed of operation. assess i've modified function accordingly: func opadd(pc *uint64, evm *evm, contract *contract, memory *memory, stack *stack) ([]byte, error) { // begin execution time tracking var starttime = time.now().unixnano(); x, y := stack.pop(), stack.p

javascript - React JS: Rendering object keys and its values -

i trying render objects key , value, doesn't seem work. i have managed display in console, not actual dom. iterating through object has multiple entries. what need print out values? {attributes.map(items => { {object.keys(items).map((key) => { console.log(key, items[key]); })} })} like this: {attributes.map((items, index) => { return ( <ul key={index}> {object.keys(items).map((key) => { return ( <li key={key + index}>{key}:{items[key]}</li> ) })} </ul> ) })}

Calculate invoice form with Javascript -

i trying create dynamic invoice form calculates sums once numbers entered. have combination of input fields , drop down (select). not know how combine these 2 types. know select should use "onchange" not sure how combine rest. and next step, have dynamic form, able add (and remove) rows. have no idea how add it. realize need unique names each item. $('input').keyup(function(){ var qty1 = number($('#qty1').val()); var price1 = number($('#price1').val()); var percentage1 = number($('#percentage1').val()); $('#sum1').html(qty1 * price1); $('#total1').html(qty1 * price1 * percentage1); /* var qty2 = number($('#qty2').val()); var price2 = number($('#price2').val()); var percentage2 = number($('#percentage2').val()); $('#sum2').html(qty2 * price2); $('#total2').html(qty2 * price2 * percentage2); $('#grand_total&#

javascript - Electron prevent main window from closing -

i writing application in electron if user has unsaved file open want prompt user before saving it. found example code online: window.onbeforeunload = (e) => { var answer = confirm('do want close application?'); e.returnvalue = answer; // *prevent* closing no matter value passed if(answer) { mainwindow.destroy(); } // close app }; this code strangely works if dialogs yes, cancel or x button pressed within few seconds of appearing if let dialog rest on screen little , click button application close no matter pressed. this code located in main script file called index.html really strange behavior! cannot explain why it's happening, can give workaround implemented in main process. you can use electron's dialog module , create same confirmation dialog electron. 1 works expected. main.js const { app, browserwindow, dialog } = require('electron') const path = require('path') app.once('ready', () =&g

ios - AVFoundation saving Photo in-app is 3-4 times larger than saving using the Photos app -

i using avfoundation capture photos , save photos locally. i data using avcapturephotooutput.jpegphotodatarepresentation, file size seems 3-4x compared size when saving using photos framework. how can be? photodata: photodata = avcapturephotooutput.jpegphotodatarepresentation(forjpegsamplebuffer: photosamplebuffer, previewphotosamplebuffer: previewphotosamplebuffer) code saving using photos framework: phphotolibrary.shared().performchanges({ [unowned self] in let creationrequest = phassetchangerequest.creationrequestforasset(from: uiimage(data: photodata)!) creationrequest.creationdate = date() if let assetcollection = assetcollection, let assetplaceholder = creationrequest.placeholderforcreatedasset { let albumchangerequest = phassetcollectionchangerequest(for: assetcollection) let enumeration: nsarray = [assetplaceholder] albumchangerequest?.addassets(enumeration) } }, completionhandler: { [unowned self] success, error in

java - Why doesn't activating the delegating classloader in tomcat change the apparent hierarchy of classloading at runtime? -

in tomcat, can reverse default ordering of classloading hierarchy setting <loader delegate="true"/> in context element. however, if try recursively dumping contents of classloaders, ordering same: static { classloader classloader = simpleservlet.class.getclassloader(); url[] urls; if (classloader != null) { urls = ((urlclassloader) classloader).geturls(); logger.info("simpleservlet.class: " + arrays.aslist(urls)); while(classloader.getparent() != null) { classloader = classloader.getparent(); urls = ((urlclassloader) classloader).geturls(); logger.info("parent: " + arrays.aslist(urls)); } } else { logger.info("simpleservlet.class classloader null"); } if (classloader != null) { classloader = classloader.getsystemclassloader(); urls = ((urlclassloader) classloader).geturls(); logger.info("system: "

android - RelativeLayout is always adding under one recyclerview item -

Image
please have on image below : this recyclerview in every item contains recyclerview (white space under "hp"). now problem no matter on arrow click adding recyclerview under "hp" only. need me added under item on click. first fragment (containing first recyclerview) public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { final view intent = inflater.inflate(r.layout.fragment_brand, container, false); //bundle object send data fragment bundle = new bundle(); brandfragmentgrid = intent.findviewbyid(r.id.fragment_grid); progressbar = intent.findviewbyid(r.id.brand_progressbar); progressbar.setvisibility(view.visible); final string selectedproductid = getarguments().getstring(appconstants.selected_product); if (selectedproductid != null) { //server api call brand fragment getproductdetailsbyproductid(selectedproductid);

osx - Installing Timescaledb on Mac OS X, PostgreSQL 9.6 not found -

i trying install timescaledb on mac, http://docs.timescale.com/getting-started/installation?os=mac&method=source . requirement postgresql 9.6 downloaded postgres.app. however, when try build , install timescaledb - following error: z-mbp:~ user$ cd timescaledb z-mbp:timescaledb user$ make /bin/sh: pg_config: command not found makefile:6: *** "timescaledb requires postgresql 9.6". stop. but postgres.app installed , server running fine. going wrong , how can fix it? makefile telling can't find pg_config . as postgres.app supposed include cli utility in install , first guess don't have utility in $path. i think asked same question on timescaledb's github issues page, , given ongoing q&a there, thought point readers that: https://github.com/postgresapp/postgresapp#command-line-utilities

c++ - Unable to connect to Cloudfront from MacOSX client -

my multi-platform client, written in c++ , built on curl , should download file cloudfront. on windows, download works fine libcurl 7.40.0 , openssl 1.0.2c . on macosx: the file served via "direct" amazon aws link correctly downloaded; the file served via cloudfront link cannot downloaded: curl error after call set curle_ssl_connect_error , , debug informations show protocol breaks during ssl handshake. the file correctly downloaded via curl command macosx bash (version 7.54.0). i linking against curl version installed on imac (version 7.54.0 security layer provided zlib version 1.2.8 ). version supports ssl , tlsv1.2 (as can seen when performing aws download). i @ wit's end: tlsv1.2 supported , should enabled during communication cloudfront. there else forgot? thank in advance help. mwe , responses both servers follow. minimum working example (urls faked): #include "curl/curl.h" #define urldownload "https://x.cloudfront.net/

wordpress - Point one domain to another domain's subfolder -

i have external domain (let's mygreatsite.com) , domain subfolder (let's myhostingsite.com/mygreatsite). i'm wondering if possible point mygreatsite.com myhostingsite.com/mygreatsite when users visit mygreatsite.com content of subfolder, behaves if on mygreatsite.com, not myhostingsite.com/mygreatsite. basically have clients have new web site , we're wondering if makes sense hijack subfolder of new site. wordpress based, if makes difference. both sites hosted/managed on separate hosts. this should you're hoping: rewritecond %{http_host} ^mygreatsite.com rewriterule ^(.*) http://myhostingsite.com/mygreatsite [p]

Access Javascript object values -

i'm having hard time getting role(here admin) in javascript object construct. i thought access value data.roles.data.role doesn't seem case? knows i'm doing wrong? "data": { "gender": "male", "suffix": "dr." "roles": { "data": { "role": "admin" } } assuming have inside object, , add missing , , } : var obj = { // <== added { wrapper "data": { "gender": "male", "suffix": "dr.", // <== comma missing here "roles": { "data": { "role": "admin" } } // === } missing here } }; // <== added } wrapper then yes, you're correct, it's data.roles.data.role on obj

javascript - Best way to add null checker to querySelector in jquery -

i have parsed xml , i'm using queryselector for example: this.queryselector("type").textcontent sometimes value of this.queryselector("type") null previous line returns error. what beautiful way avoid errors? i'm doing following: example = this.queryselector("type") != null ? this.queryselector("type").textcontent : "" //ugly! but long , looks bad. other way: own function findinxml(this, "type"), when want deeper it's looks that: findinxml(findinxml(this, "type"), "sth") // ugly! i prefer use way example: this.findxml("type").findxml("sth") //looks nice one call queryselector : var typeel; var example = (typeel = this.queryselector("type")) ? typeel.textcontent : ''; jsperf agrees: https://jsperf.com/nullqueryselector/1

angularjs - Avoiding pre-render page for Google crawl bot -

my web server returns pre-rendered page using angularjs. according final faq on google's official docs can affect performance of crawl bot. i can confirm crawl bot not picking complete webpage because of issue. when use google's search console > "fetch google" tool http response not complete webpage due pre rendering. the portion not being rendered produced angularjs. is there way can tell angularjs not send pre rendered response web server or there other method google crawl bot read pre rendered page?

c# 4.0 - How to list all the domains in India under one website based on categories -

i need list website links (domains) in india under 1 website based on categories. you cannot list 100% of indian websites. if understand want, want web crawler indian domains. "google". big spiders google's, yahoo's, bing's spiders can't build database of websites. algorithms (with partly published algorithms), think need more, because need 100% accurate database, need have ask them domain registrars, can't that. even if possible not client, created company that. that's practically impossible. can can search few thousands of sites , categorize them manually or build small "spider".

Pass parameters to python plumbum command from a list -

i'm using plumbum run command line utilities in foreground on python. if had command foo x y z , run plumbum so: from plumbum import cmd, fg cmd.foo['x', 'y', 'z'] & fg in code i'm writing however, parameters ['x', 'y', 'z'] generated list. not figure out how unpack list send parameters plumbum. suggestions? turns out have used __getitem__ this. had was: from plumbum import cmd, fg params = ['x', 'y', 'z'] cmd.foo.__getitem__(params) & fg

info.plist - OSX bundle and administrative rights -

is there way enable obtaining administrative rights osx bundle through info.plist file? making installer silently run several installations .pkg files , i'd obtain behavior, when bundle launched native dialog asks admin permissions pops , asks elevation. can done setting key in info.plist (i tried google came nothing) or there other means achieve this?

vba - Passing a parameter to an event handler procedure -

i generating scripting dictionary using 1 button on userform, using populate listbox, , need use same dictionary using second button on form. have declared dictionary either using binding so: dim isindict new scripting.dictionary or late binding so dim isindict object ... set isindict = createobject("scripting.dictionary") when try pass dictionary other button so: private sub okbutton_click(isindict scripting.dictionary) 'if binding private sub okbutton_click(isindict object) 'if late binding i following error: "procedure declaration not match description of event or procedure having same name" on line. any ideas i'm doing wrong? an event handler has specific signature, owned specific interface: can't change signature, otherwise member won't match interface-defined signature , won't compile - you've observed. why that? say have commandbutton class, handles native win32 messages , dispatches them - might thi

sql server - C# SMO Database do not log creation -

Image
i have integration test creates database of type microsoft.sqlserver.management.smo.database : var defaultconnectionconnectionstring = configurationmanager.connectionstrings["defaultconnection"].tostring(); var sqlconnection = new sqlconnection(defaultconnectionconnectionstring); var serverconnection = new serverconnection(sqlconnection); _server = new server(serverconnection); _database = new database(_server, _integrationtestingdatabasename); _database.create(); when run integration test via cli nunit, when test finishes, sql creating database dumped console. clutters output , not want see when running integration test. how can stop happening? this goose chase , cannot reproduced. i'm guessing there maybe confusion, perhaps 1 of scripts sql print or red-herring that. because executing unit test create sql db via sql management objects not output sql creation script. even executing directly command line doesn't log sql creation script. her

xml - Ant: Consecutive xmlproperty returning values from the first file -

in ant build.xml file, reading 2 different xml files , accessing same property in file. getting first value read both. <target name="readport"> <xmlproperty file"${port.file}" collapseattribute="true"/> <property name="portversion" value="${xs:schema.version}"/> </target> <target name="readname"> <xmlproperty file"${name.file}" collapseattribute="true"/> <property name="nameversion" value="${xs:schema.version}"/> </target> in other words, after running second target, getting value first xml file. there way clear first xml read? thank you!

url - Check what parameters are set in a concise way - PHP -

i need many parameters url different names , check if set. (their value doesn't matter). https://example.com?one=true&two=true&three=true etc. the problem in want do, of them set or not. so need of way grab of them in url , set in clean way, , preferably stored in different variables matching name of parameters, instead of having multiple $_get , isset() lines if statements on place. edit: submit being parameter in url: thinking done using foreach loop. if (isset($_get['submit'])) { foreach ($_get $key => $value) { $key = $value; echo $key; } } this echo out value of $key, (which need because know set), need actual name of $key set to. thanks edit 2: have found out how - needed parameters in url , know name of them. sorry if had worded wierdly. if (isset($_get['submit'])) { foreach ($_get $key => $value) { $$value = $key; echo $key; } } i found out using variable variables needed (hence 2 $$) gives me, in end,

python - Issue calling functions with argparse -

i'm having issues calling functions command line argparse. want execute 1 of functions defined in script. import os import shutil import getpass import argparse user = getpass.getuser() copyfolders = ['favorites'] parser = argparse.argumentparser() parser.add_argument('e', action='store') parser.add_argument('i', action='store') args = parser.parse_args() def exp(args): folder in copyfolders: c_path = os.path.join("c:", "/", "users", user, folder) l_path = os.path.join("l:", "/", "backup", folder) shutil.copytree(c_path, l_path) def imp(args): folder in copyfolders: l_path = os.path.join("l:", "/", "backup", folder) c_path = os.path.join("c:", "/", "users", user, folder) shutil.copytree(l_path, c_path) when try call argument get: error follow argument

php - Performant way to get large list of files with modified date and size -

i using php 5.6 on linux. getting list of files , directories in directory $directory_listing = scandir($path); i know similar following array of filenames plus modified date , size. $listings_final = array(); foreach ($directory_listing $listing) { $listings_final[]['listing_name'] = $listing; $listings_final[]['listing_modified'] = filemtime($listing); $listings_final[]['listing_size'] = filesize($listing); } this slow when number of files extremely large. there more performant way archive this? not likely. in accessing filesystem, metadata each file grabbed per file, not in bulk. relatively low-level tools ls way. if have 10,000 files in directory, there's not going way around making 10,000 separate calls grab metadata of files. there may tool purports in 1 go, it's going abstracting fact it's looping through files in directory information, , isn't going faster. the way know of create accesses filesystem

mysql - Crossfilter dimension of joined table without repeating values -

i preface both relatively unfamiliar sql , dc.js. feel solution pretty simple. i drawing group of charts based on join of 2 tables results in form similar following: subject | gender | testname ------- | ------ | -------- 1 | m | test 1 2 | m | test 1 1 | m | test 2 2 | m | test 2 essentially, lot of unique data repeated on join due testname changing per subject. join on subject . i have 1 bar chart gender , can either m or f . have bar graph of count of each test ( testname ) , how many subjects present in test. can tell join, single subject can , member of more 1 test. my issue when crossfilter data, counts each test correct (here, 2 each), gender information inflated (4, instead of 2) since counts should each unique subject every time appears in joined data set. want charts display n subjects gender, instead displays n * 'number of tests' . is there way chart correct count per test case keep other charts displayi

android - Run code when application is installed -

i need know if possible execute code when application installed. i've seen there way run when starts first time. need run code when installs. i have application develop , go store (ibm store), when application downloaded play store creates icon in "desktop" of phone. ibm store not happen, had code intent shortcutintent = new intent(getapplicationcontext(), mainactivity.class); shortcutintent.addflags(intent.flag_activity_new_task); shortcutintent.addflags(intent.flag_activity_clear_top); intent addintent = new intent(); addintent.putextra(intent.extra_shortcut_intent, shortcutintent); addintent.putextra(intent.extra_shortcut_name, "movistar click"); addintent.setaction("com.android.launcher.action.uninstall_shortcut"); getapplicationcontext().sendbroadcast(addintent); addintent.putextra(intent.extra_shortcut_icon_resource, intent.shortcuticonresource.fromcontext(getapplicationcontext(), r.mipmap.icon)); addintent.setaction("com.android.l

java - Cannot cast from JsonElement to String while parsing from the JSON file -

this first code reading json file keep getting error message: can not cast jasonelement string import java.io.filereader; import com.google.gson.jsonobject; import com.google.gson.jsonparser; public class json { public static void main(string args[]) { jsonparser parser = new jsonparser(); try { object obj = parser.parse(new filereader("c:\\users\\dell\\eclipse- workspace\\assignment\\data.json")); jsonobject jsonobject = (jsonobject) obj; string name = (string) jsonobject.get("name"); string author = (string) jsonobject.get("author"); system.out.println("name: " + name); system.out.println("author: " + author); } catch (exception e) { e.printstacktrace(); } } } excuse me silly mistakes. still beginner it depends on want. if name needs actual json string value (as in, must { "name": "str" } , not { "name": [] } ), should jsonobject.get("name&qu

excel - Check Multiple Columns for the highest value -

Image
so had table has score of 3 different teams week. day team1 team2 team3 mon 5 2 2 tue 0 7 7 wed 6 3 2 thu 0 0 1 fri 13 6 5 i want formula can find highest score day , mark on identical table value of 1 , mark other teams 0. if there 2 values highest want them both marked 1. there never day 0's using data table above other table this. day team1 team2 team3 mon 1 0 0 tue 0 1 1 wed 1 0 0 thu 0 0 1 fri 1 0 0 i have working formula =if(and(b2>=$c2,b2>=$d2,b2>=$e2),1,0) i hoping there better way write formula, can drag across teams , have still work. if try drag formula now. have update formula each column. might have 20 + teams. any advice appreciated. use max(): =if(b2=max($b2:$d2),1,0) then copy/drag on , down.

amazon web services - Is it possible to use aws sdk for upload data to s3 from file path -

i using aws sdk upload file s3 like: let params = { body: fileinbase64format... }; s3.upload(params); what trying avoid loading file in memory want make this: let params = { body: 'file:///...path-to-file.mov' }; s3.upload(params); i using react native v0.44 possible upload file avoid base64? yes can add file path filestream , run s3.putobject method upload s3. var fstream = fs.createreadstream("file:///...path-to-file.mov"); var parameters = { bucket: s3bucket, key: newkey, body: fstream }; s3.putobject(parameters, function(error, data){ if(error){ console.error(error); } else { console.log(data); } }); hope help!

parsing - PHP Parse/Syntax Errors; and How to solve them? -

Image
everyone runs syntax errors. experienced programmers make typos. newcomers it's part of learning process. however, it's easy interpret error messages such as: php parse error: syntax error, unexpected '{' in index.php on line 20 the unexpected symbol isn't real culprit. line number gives rough idea start looking. always @ code context . syntax mistake hides in mentioned or in previous code lines . compare code against syntax examples manual. while not every case matches other. yet there general steps solve syntax mistakes . references summarized common pitfalls: unexpected t_string unexpected t_variable unexpected '$varname' (t_variable) unexpected t_constant_encapsed_string unexpected t_encapsed_and_whitespace unexpected $end unexpected t_function … unexpected { unexpected } unexpected ( unexpected ) unexpected [ unexpected ] unexpected t_if unexpected t_foreach unexpected t_for unexpected t_while unexpected t_do

java - war deployed to webapp but directory created has no content -

appl.war deployed webapp folder of tomcat. when server started can see below line in server log : ...deployment of web application archive appl.war has finished in 181 ms. also appl directory created not see content in it. hence when browse giving context root /appl error message "page cant displayed". what going wrong idea ? you problem sounds similar stackoverflow link below, tomcat creates web-inf/lib doesnt explode war files (gwt)

Declare a class as an atribute of another class in Java -

how define class attribute of class? can have multiple classes of classes, class an attribute of class users ? class community{ class users(); static string x; static int y; community(){} } class users{ static string name; static int reputation; } in java there nested classes , mean can create class inside class , : class x{ class y{ } y newy=new y(); } and here newy object or member inside class x

Kafka in scenario with many devices/data consumers -

currently evaluating apache kafka use case have (up to) several thousand devices produce transactions - each 1 generating response in back-end. response, must go originating device. for subscriptions, then, seems have choice of either having topic per device (awkward management standpoint), or single topic transaction responses, , have each device pull down data topic - including meant else (sub-optimal performance-standpoint). is there way have brokers somehow filter data in polling process (on kafka side)? seems me common requirement, far haven't seen along lines.

Reverse Installation of Tomcat on Ubuntu -

i've installed tomcat on ubuntu using this tutorial . works, i'm able see default page @ localhost:8080 . for reason need remove machine now. how can reverse installation? try these steps: sudo systemctl stop tomcat sudo rm -r /opt/tomcat sudo rm /etc/init/tomcat.conf sudo systemctl reload-configuration this remove tomcat , not jdk (java) installed. might want keep if you're going install version of tomcat, or other programs need jdk run. also, user tomcat created still remain.

javascript - Getting the timezone a simplified ISO 8601 date string -

i have 2 date strings, each in different time zone. these strings in believe referred "simplified" iso 8601 format. 2 example dates listed below. 2017-08-14t18:41:52.793z 2017-08-14t23:41:52.000z the first date in cdt while second date in utc. believe last 4 digits of each of these strings indicates time zone. what's weird when set new date() each of these, i'm getting incorrect dates reported via console.log() . example: const local_date = new date("2017-08-14t18:41:52.793z"); const remote_date = new date("2017-08-14t23:41:52.000z"); console.log("local_date = " + local_date); console.log("remote_date = " + remote_date); outputs: local_date = mon aug 14 2017 13:41:52 gmt-0500 (central daylight time) remote_date = mon aug 14 2017 18:41:52 gmt-0500 (central daylight time) it appears though first date getting 5 hours subtracted though source date provided in cdt; it's it's assuming both date

sql delete - How to remove duplicate rows in CockroachDB -

i have table in cockroachdb, have populated data table before applying constraints set primary key, , because of insert statement failed through data-loading phase, of rows loaded table more 1 time mistake. the constraint want apply is: create unique index on "mydb"."mytable" ("row_id"); but duplicate data loaded table, following error: pq: multiple primary keys table "mytable" not allowed i have check see if there duplicated rows following query: select row_id, count(row_id) id mytable group row_id having count(row_id) > 1; and query showed there duplicate rows. what best way remove duplicate rows in cockroachdb? if don't care which duplicated row keep, run: delete mytable rowid in ( select min(rowid) mytable group row_id having count(*) > 1 ); for duplicates, query delete row created first.† note rowid not same row_id column. rowid internal cockroachdb column mag

java - AutoFit Row Height in Excel with POI -

i'm trying produce excel workbook 1 worksheet content in cells wraps , row height autofit when columns resized. word wrapping seems work ok, can't row auto height work. have looked @ several posts , many of different methods available in poi api, none of them seem work. the post @ auto size height rows in apache poi not seem work. using methods row.setstyle(style) row.setheight((short)-1) do not work either. has succeeded in creating workbook/sheet columns wrap text , row height set auto , row height adjusts when columns shrunk down?

java - Resultset getString throw ArrayIndexOutOfBoundsException -

i got exception when trying retrieve string value resultset. happens after added 2 new columns image_url , icon_url table (default null) , trying retrieve new added columns. table create statement below: create table `examples` ( `id` int(11) not null auto_increment, `name` varchar(255) collate utf8_unicode_ci default null, `description` text collate utf8_unicode_ci, `event_id` int(11) default null, `created_at` datetime not null, `updated_at` datetime not null, `session_id` varchar(255) collate utf8_unicode_ci default null, `location` varchar(255) collate utf8_unicode_ci default null, `start_date` datetime default null, `end_date` datetime default null, `url` varchar(255) collate utf8_unicode_ci default null, `button_label` varchar(255) collate utf8_unicode_ci default null, `hidden` tinyint(1) default null, `image_url` varchar(255) collate utf8_unicode_ci default null, `icon_url` varchar(255) collate utf8_unicode_ci default null, primary key (`id`) ) engine=innodb auto_increment