Posts

Showing posts from March, 2010

maven - IntelliJ Project Structure full of "... and modules" and duplicates -

i have following folder structure: main - server -- server-module-1 --- --- b --- c -- server-module-2 --- d --- e --- f - client -- modules --- client-module-1 --- client-module-2 --- client-module-3 - war-module maven structure similar - main pom.xml: <modules> <module>server</module> <module>client</module> <module>war-module</module> </modules> the problem begins if move 1 module separate profile since don't need war-module (on jenkins). <modules> <module>server</module> <module>client</module> </modules> <profiles> <profile> <id>createmodule</id> <modules> <module>war-module</module> </modules> </profile> </profiles> after change, intellij project structure looks this: main , modules - client , modules -- client-modules , modules --- client-module-1 ---

Highlight specific points on line charts in Dygraphs for R -

is possible highlight specific points on line chart using dygraphs in r without pointer being located @ point? this can achieved in other graphing options plotting line chart , scatter plot together. since in dygraphs scatter plot not available there work around?

View JWT Token on jwt.io -

i came across badge section on jwt.io , 'view on jwt.io' caught eye. there way link jwt.io, shows users jwt token (from application) , verification key? skimming through code of page couldn't find clue on how that. did miss on page? i'm still trying find answer on how preload secret own, users see happening. however did manage link work correctly though: https://jwt.io/#id_token=your-token-here found on blog post: https://auth0.com/blog/2015/07/21/jwt-json-webtoken-logo/ not sure how supposed find before linked post on jwt.io . also linking here, because found it. had been trying find nicely formatted documentation our users ages (before linked them jwt.io ): https://auth0.com/learn/json-web-tokens/

asp.net - Is there any possibility to add master page for more then one existing .aspx page? -

i made update.aspx page , view.aspx page want assign master page these pages...can me out ? create new master page names site.master, move want update.aspx master, head section html content, , in body put placeholder: <asp:contentplaceholder runat="server" id="maincontent" /> now when "shared" master content moved update.aspx/view.aspx, need wrap that's left in pages this: <asp:content runat="server" id="bodycontent" contentplaceholderid="maincontent"> update.aspx page content </asp:content> in first line of page should have <%@ page ... attributes ... %>, add new attribute points master page: masterpagefile="~/site.master" for reference, create new webforms project , you'll few sample pages. see how should html content in master page like, , how wrap page content of aspx page. end result should this: site.master <html><head>...</head>

Bluemix: MQA : how to make phone shake harder in android to report bug and feedback -

i trying integrate bluemix mqa mobile app. using mqa-android-2.7.4.arr file in project. have 1 query related phone-shake below. how make phone shake harder in android report bug slight shaking popping screen multiple times? android devices have different accelerometers , same algorithm appears have different effects on each. i’m creating request enhancement add shake threshold slider shake gesture.

ruby on rails - sidekiq returns Net::SMTPSyntaxError: 501 -

i using rails , sidekiq sending out mails through background, when trigger emails returns error_message"=>"501 5.0.0 helo requires domain address\n", "error_class"=>"net::smtpsyntaxerror", "failed_at"=>1453973913.4580712, "retry_count"=>3, although works fine when shoot mails directly without sending sidekiq, appreciated. found it, because smtp authentication wrong. but got require domain address error fixed adding o allowbogushelo=bool in sendmail configuration, again got error 'smtp authentication failed' whence have got clue.

imap - How to get all mails with flagged use php -

i setting webmail. there fold 'flagged' meaning mail flagged. ,these mails mybe in sent folder or in inbox folder or in draft folder. there anyway them quickly?because imap_open function use 1 folder each time. imap_open("{localhost:993/imap/ssl/novalidate-cert}sent", "username", "password") imap_open("{localhost:993/imap/ssl/novalidate-cert}draft", "username", "password") imap_open("{localhost:993/imap/ssl/novalidate-cert}inbox", "username", "password") if not , need user loop,then merge 3 part of them together! use paging !oh, that's crazy! can me!

computational geometry - Reliable test for intersection of two Bezier curves -

how reliably find out whether 2 bezier curves intersect? "reliably" mean test answer "yes" when curves intersect, , "no" when don't intersect. don't need know parameters intersection found at. use floating-point numbers in implementation. i found several answers here use curves' bounding-boxes test: not i'm after such test may report intersection if curves don't intersect. the closest thing found far "bounding wedge" sederberg , meyers "only" distinguishes between at-most-one , two-or-more intersection, whereas want know if there at-most-zero , one-or-more intersections. i assuming cubic bezier curves. the reliable method reporting intersections, using floating point computation, find them, combined error analysis . the main problem, when floating point computations involved, inconsistency in computed results w.r.t. topology. unfortunately unavoidable, if need compute in computational geometry

ios - Is there a way to check if 3x assets are the correct resolution without using simulator? -

i want check if 3x assets have in correct resolution. don't have knowledge objective-c or swift, there way check without using xcode? i have basic knowledge of swift , xcode (navigating , such) if can give me steps think can it. i want check because have low resolution file maximum output of 2x, i'm trying find way 3x without losing quality migrating psd file ai.

sql - LISTAGG in ORACLE -

i trying use listagg() fetch more 2 columns. select deptname, deptno, listagg(ename, ',') within group (order ename) employees emp group deptno; but throwing error: : keyword not found expected 00000 - "from keyword not found expected" *cause: *action: error @ line: 3 column: 12 can please explain why is? the listagg analytic function introduced in oracle 11g release 2 . so, if on older version, won't able use it. the error seems strange. should ora-00904: "deptname": invalid identifier standard emp table in scott schema doesn't have deptname column. also, should ora-00979: not group expression did not mention select ed columns in group by expression. using standard emp table in scott schema: sql> select deptno, 2 job, 3 listagg(ename, ',') within group ( 4 order ename) employees 5 emp 6 group deptno, 7 job; deptno job employees ---------- --------- -------------

node.js - Grunt CSS min - Issue with minifying different CSS files -

i'm having issue minifying multiple css files using grunt cssmin i'm not looking minify files single file. have files having same name min.css extension. my gruntfile.js follows. module.exports = function (grunt) { grunt.initconfig({ cssmin: { target: { files: [{ src: ['assets/css/*.css', '!assets/css/*.min.css'], // source files mask dest: 'assets/css/', // destination folder expand: true, // allow dynamic building flatten: true, // remove unnecessary nesting ext: '.min.css' // replace .css .min.css }], /* below trick used minify files skipped above */ /*files: [{ src: ['assets/css/home.css', 'assets/css/institutions.css', 'assets/css/form-elements.css'], // source files mask dest: 'assets/css/', // destination fol

python 2.7 - checking duplicate images with ORB -

currently working on checking duplicate images , using orb that, first part complete, have descriptor vector of both images, second part want know how calculate scores using hamming distance, , should threshold of saying these duplicates img1 = gray_image15 img2 = gray_image25 # initiate star detector orb = cv2.orb_create() # find keypoints orb kp1 = orb.detect(img1,none) kp2 = orb.detect(img2,none) # compute descriptors orb kp1, des1 = orb.compute(img1, kp1) kp2, des2 = orb.compute(img2, kp2) matcher = cv2.bfmatcher(cv2.norm_hamming, crosscheck=true) matches = matcher.match(des1, des2) # sort them in order of distance. matches = sorted(matches, key = lambda x:x.distance) i want know next step in process can print yes or no duplicates. using opencv3.0.0 python 2.7 once obtain descriptors, can use bag-of-words model cluster descriptors of reference image, is, build vocabulary (visual words). then project descri

c# - WPF WebBrowser - open links in default browser -

i using wpf system.windows.controls.webbrowser control show html content downloaded service. html contains urls ("a" elements) should clickable. by default, when such url clicked opens in internet explorer. want them open in default browser instead. note talking wpf webbrowser. there tons of solutions winforms browser, not work wpf browser. the common "solution" handle navigating event, cancel , own thing url. does not work because navigating event not called when click link in html. another solution found seem work, strange reason: https://stackoverflow.com/a/9111151/573249 i have following code, using method link above: private void webbrowser_onnavigating(object sender, navigatingcanceleventargs e) { // demonstration purposes // not called when link clicked debug.writeline("> navigating called."); if (e.uri == null) { debug.writeline(">> uri null."); return; } e.cancel =

VBA Word.Selection.Copy not working correctly -

i have problem can't seem wrap head around. i'm trying populate userform using shapes (images) word-document. use code so: ishapecount = wrddoc.shapes.count = 0 if ishapecount > 0 redim opic(ishapecount - 1) ipicturedisp each wrdshape in wrddoc.shapes wrdshape wrddoc.activate .select wrdappmain.activedocument.activewindow.selection.copy set opic(i) = pastepicture(lpictype) end = + 1 next wrdshape end if with opic being one-dimentional array of pictures , pastepicture being subroutine copied image off of clipboard , array image-file. so far good. this works should, there more 2 shapes (images) present in word-document, copy-command copies first 2 charm, other ones (although correctly selected) not copied copy-command copying literally nothing. another funny thing: if leave out wrdappmain.activedocument.activewindow.selection.copy -thingy , manual

upgrade - Errno::EMFILE: Too many open files when upgrading to ruby 2.3 -

i upgrade ruby 2.3 in order take benefits of frozen_string_literal option produce me error errno::emfile: many open files in production. when downgrade ruby 2.2.3, no more errors. here 1 of ruby 2.3 error calltrace have : errno::emfile: many open files - socket(2) "xx.xxx.xx.xxx" port 9200 (xx.xxx.xx.xxx:9200) /.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:597:in `initialize' /.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:597:in `new' /.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:597:in `create_socket' /.../production/shared/bundle/ruby/2.3.0/gems/httpclient-2.7.1/lib/httpclient/session.rb:742:in `block in connect' /.../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout' /.../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/timeout.rb:101:in `timeout' /.../production/shared/bundle/ruby/2.3.0/gems/httpclien

php - How to get input of Html editor in textarea using javascript -

please i'm working on project make html editor. downloaded program online trying modify need, i'm having difficulty inner html of edit using javascript or jquery output in textarea , input type can save database. shows output in html element not in textarea. more explanation of need 1 when key text in editor want return in hidden textarea. 2 want able save in database. 3 want editor have default text display [please start typing code here] please have been giving me trouble complete work appreciate if can me or suggest method or program use in archive this. thank guys here program html <link rel="stylesheet prefetch" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet prefetch" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/styles/monokai_sublime.min.css"> <style class="cp-pen-styles">.ace-md{ height: 300px; }</style> <div ng-app=

java - org.eclipse.ui can't be resolved? -

could please tell me how resolve package import, thought element of swt , i've have swt installed eclipse ide. why bothersome? guess have download *.jar or *.zip files add project external library. please give me solution. thank you! viphalong. no, org.eclipse.ui not part of swt (or vice versa, requires swt). if creating rcp plugin (if not, shouldn't using org.eclipse.ui ), need open plugin.xml file, "dependencies" tab, , add org.eclipse.ui "required plugins".

wpf - Instantiate object defined in other XAML file -

i have xaml file looks this: <!-- file1.xaml --> <m:somename xmlns:m="clr-namespace:somenamespace"> ... </m:somename> i have xaml file in instantiate object defined in file1.xaml , set property on object defined in file2.xaml : <m:someothername xmlns:m="clr-namespace:somenamespace"> <m:someothername.property> <!-- want file1.xaml object here --> </m:someothername.property> </m:someothername> any ideas? if want use xaml object, object needs extend dependencyobject . easiest way create usercontrol : <usercontrol x:class="somenamespace.somename" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorabl

ios - How to maintain two custom cells in one tableview with segment selection? -

Image
i new ios. have 1 uiviewcontroller in added 1 tableview , segmented control. if press segmented value = 0, want first custom cell loading images , title , segment value = 1, want display second custom cell uicollectionview loading of images , title, how can please me? here of code: menuviewcontroller.m -(void)callsegmentselected { value=(int)segment.selectedsegmentindex; if (segment.selectedsegmentindex == 0) { nsstring *urlstring = [nsstring stringwithformat:@"http://api"]; nsstring *jsonstring = @""; nsdata *myjsondata =[jsonstring datausingencoding:nsutf8stringencoding]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request seturl:[nsurl urlwithstring:urlstring]]; [request sethttpmethod:@"post"]; nsmutabledata *body = [nsmutabledata data]; [body appenddata:[nsdata datawithdata:myjsondata]]; [request sethttpbody:body]; nserror *error; nsurlresponse *response; nsdata *urldata=[nsurlconnection sendsynchronousrequest:request

css - HTML input element not taking 100% width -

Image
my angular code on github is using ngroute, page1.html gets loaded in ngview. i have input element in page1.html css set 100% expected fill width of view taking 70% or so. if main element width set 100%, footer buttons disappear, image 2. not sure why? * { margin: 0; padding: 0; } html { height: 100%; } body { height: 1%; } header > button { height: 1.5em; width: 1.5em; font-size: 1.5em; top: 0; } label.pagetitle { display: inline-block; width: calc(100% - 5em); text-align: center; } header { border-bottom: 1px solid black; width: 100%; position: fixed; top: 0; } main, .mainmenu { position: absolute; top: 2.5em; } main { z-index: -2; } footer { position: fixed; bottom: 0; width: 100%; } footer > button { font-size: 1em; padding: 0.5em 1em; } input { font-size: 1em; padding: 0.25em; margin: 0.25em;

sql - Understanding Raw Data -

Image
when going through tables in database, see table called measbinary , attribute attracted me rawdata . image type , allow null. have attached screenshot of table me understand that? , how understand how has been processed ? update : checked stored procedures , find image parameter passed sp_storebinary @rawspectra image , value inserted table mentioned above. this raw data of binary field. has "no meaning" except being way ssms (management studio) show binary field. remember - ssms (and database) have no clue in field (image, word document, whatever) , how show it. hex coded string "as gets" generic approach, allows programmer compare first bytes.

javascript - d3.js collapsible force diagram - assigning unique ID's to identical nodes -

i have nice collapsible force layout collapsed in beginning taken http://bl.ocks.org/mbostock/1093130 . here example: http://plnkr.co/edit/rqh8sd?p=preview it works when nodes have unique names ( http://plnkr.co/edit/e1n6asbm5vfx2vjgpkko?p=preview ), nodes have same name (unfortunately need that), collapsing not work properly. anyone able me assign unique ids identical names of nodes? believe piece of code make trick not know insert it. node.each(function(d,i){ // use iterate through d.uniqueid = uniquenode + i; } i tried issue solved @ previous thread d3.js collapsible force layout, collapsed default - not successful. any appreciated! doing make nodes unique should work. i'd recommend doing after flatten nodes, before insert them force directed graph: function update(d) { var nodes = flatten(root), links = d3.layout.tree().links(nodes); nodes.each(function(d, i) { d.uniqueid = i; }); // restart force layout. force .nodes(nodes) .links(

jsf - Clearing values of a composite component in a reusable form -

i have composite component: <ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:cc="http://java.sun.com/jsf/composite" xmlns:a="http://xmlns.jcp.org/jsf/passthrough"> <cc:interface componenttype="compositelocaldate"> <cc:attribute name="value" type="org.joda.time.localdate" shortdescription="the bean value" required="true" /> <cc:attribute name="days" type="java.lang.boolean" shortdescription="add days input question" required="true" /> <cc:attribute name="disabledby" type="java.lang.boolean" shortdescription="disable component" required="false" /> <cc:attribute name="limitfuture" type="java.lang.integer

php - find ip address in codeigniter -

i tried add geolocation on site customer current location want ip address did not get. <?php include('doctype.php');?> <header> <?php include('topheader.php');?> <?php include('searcharea.php');?> </header> <?php include('nav.php');?> <div class="container"> <section> <?php $b=get_client_ip(); echo $b; function get_client_ip() { $ipaddress = ''; if($_server['remote_addr']) $ipaddress = $_server['remote_addr']; else $ipaddress = 'unknown'; return $ipaddress; }?> </section> </div> <?php include('footer.php');?> this code tried ip address geolocation. did know geolaction example customer current city. best way of current location using geolocation use below client current location latitude & longitude <!doctype html> <html> <body onload="getlocation(

android - Google Places Api returns only single result -

Image
google places api renders single result if use in autocompletetextview. issue occurs second request., i.e., first time list loaded 5 results. used [ placesautocompleteadapter][1] adapter. googleapiclient mgoogleapiclient = new googleapiclient.builder(this) .addapi(places.geo_data_api) .addapi(places.place_detection_api) .addonconnectionfailedlistener(this) .build(); placeautocompleteadapter madapter = new placeautocompleteadapter(this, mgoogleapiclient, null, null); autocompletetextview eventlocation.setadapter(madapter);

jquery - Fullscreen spinning background image -

i've been looking everywhere how achieve effect of animated spinning image covering whole screen. like one . bassically, want make spin , fullscreen. this got far, http://losmosca.com.ar/reiki/ html: <img src="img/bg.jpg" id='test' class='rotating'> css3: #test { position:relative; margin:0 auto; width:1000px; height:1000px; } @-webkit-keyframes rotating { from{ -webkit-transform: rotate(0deg); } to{ -webkit-transform: rotate(360deg); } } .rotating { -webkit-animation: rotating 1000s linear infinite; } as can see, can make spin not fullscreen, possible? thank you! try using width:100%; rather width:1000px; and height:100% rather height:1000px; cool effect way, may have find excuse use trick.

gradle - How to share jacoco exec files between multilple Jenkins jobs -

i have several java projects runs on several jenkins jobs gradle , jacoco plugins. let's have 2 jobs: core app the core job, pulls svn workspace: /jenkins_workspace/core/ , builds , creates jacoco exec file. works fine , can see code coverage. the app job, pulls svn workspace: /jenkins_workspace/app/ , builds , creates jacoco exec file. works fine , can see code coverage however inside app job there tests actullay covered part of core project. code coverage of core job should updated. guess core project should have access jacoco exec file of app job, on 2 different workspaces. question : how can core job can access jacoco exec file of app job update core code coverage? you can try use both "destfile" , "append" configuration. if use maven: <plugin> <groupid>org.jacoco</groupid> <artifactid>jacoco-maven-plugin</artifactid> <executions> <execution> <id>jac

windows - Python(x,y): MinGW installation - MWE -

background i reinstalled python(x,y) on windows 7 machine. when finished installation wanted upgrade packages using pip. mingw compiler gives weird error messages. last question resolved issue: python: install sip therefore checked out an example online builds c code python using mingw. failed - might indication mingw not working intended. have details if helps anything: mingw32-make --version 3.82.90 gcc --version 4.8.1 python --version 2.7.10 i configured python ( c:\python27\lib\distutils\distutils.cfg ) according qutip installation guide , https://docs.python.org/2/install/#location-and-names-of-config-files . issue i want test mingw installation since cannot upgrade python packages pip. please give me tested code check if installation working python.

ruby on rails - Add dynamic password_expirable duration for devise_security_extension -

i using devise_security_extension gem expire user password. expires password after duration gave in config/initializers/devise.rb. want use duration present in user table. ideas? check out line: password_expirable.rb#l43 def expire_password_after self.class.expire_password_after end if override expire_password_after in model, should want. not tested

java - How to disable Wildfly 9.0.2 trying to serialize certain classes in a clustered application -

during set of cluster i'm having issue wildfly/infinispan attempting serialize number of classes fine recreated on each instance - although whatever reason seem determined distribute across cluster. initially thought @stateless annotation have effect wanted, although throws issue not having correct constructors, don't believe looking for. what proper way disable this, or overwrite method of serialization, on per-class basis? the non-answer be careful approach of disabling serialisation selected classes. application might not need 'clustered' , not needing replicated sesssions or stateful entities, when run locally or in limited development environment. once deployed test or production clustered. it's going broken, if have prevented serialization. therefore best cause of action ensure 'serializability' of classes, rather force-preventing it. serialization off answer if insist on disabling serialization, removing <distributable/>

xml - Button with background and scale on click - Android -

i've particular button make. need define button in xml, it's composed 2 part: icon or text , monocolor background setted alpha(only on background). icon should in middle(with adjustments) of background. when press button should scale(icon background together) , original size on relase. i've looked solution , found selector, replace image one. there way without replace image? i think best solution go selector. in 1 selector create button original size , in second selector create button smaller size, or whatever size need. now achieving effect icon , background together, can set button icon android:drawable="@drawable/icon.png" , setting background android:background="@drawable/background.png" .

asp.net web api - Azure Api Management import APIs from swagger -

i use swashbuckle nuget generate swagger.json api in asp.net web api project. generated json has fields called 'tags'. swagger ui uses these 'tags' group api methods. possible similar grouping in api management? or can use tags set web api url suffixes automatically somehow? currently it's not supported there no functionality tag apis no way import information swagger. feel free suggest feature @ https://feedback.azure.com/forums/248703-api-management , we'll supporting in future.

Rails undefined variable @assets -

i following tutorial error @asset variable using in _form.html.erb , index.html.erb not working .it saying first argument in form cannot contain nil or empty .but when replace :asset_path starts working [assets_controller] class assetscontroller < applicationcontroller before_filter :authenticate_user! #authenticate users before methods called def index @assets = current_user.assets end def new @asset = current_user.assets.new end def create @asset = current_user.assets.new(user_assets) end private def user_assets params.require(:asset).permit(:user_id, :uploaded_file) end end [assets/_form.html.erb] <%= form_for @assets, :html => {:multipart => true} |f| %> <%= f.error_messages %> <p> <%= f.label :uploaded_file, "file" %><br /> <%= f.file_field :uploaded_file %> </p> <p><%= f.submit "upload&q

android - how to show images in different row and columns? -

(int = 0; <10; i++) { int count = i; iv_album[i] = new imageview(this); iv_album[i].setimagedrawable(this.getresources().getdrawable(r.drawable.desimg)); iv_album[i].setpadding(0, 5, 5, 0); iv_album[i].setid(i); // below id 0 doesn't work iv_album[i].setscaletype(imageview.scaletype.fit_xy); params1 = new relativelayout.layoutparams( relativelayout.layoutparams.match_parent, 230); if((i>0)) { params1 = new relativelayout.layoutparams( 150, 200); if (imgtype[i].equalsignorecase("medium") ) { //iv_album[i] // picasso.with(getapplicationcontext()).load("http://aflaree.com/yoday/images/b.jpg").into(iv_album[i]); params1 = new relativelayout.layoutparams( 150, 200); //params1.addrule(relat

php - Getting Twitter data with new API -

as twitter has updated api recently, how can number of followers of person? i such data old api using following, if understand correctly, stop working @ time. http://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitter how can same data using new api? have checked documentation not understand. well straight new documentation seem biggest difference using 1.1 instead of 1 you still retreive data using json - https://api.twitter.com/1.1/statuses/user_timeline.json the docs requirements are: always specify either user_id or screen_name when requesting user timeline. and returned object contains "user" object, contains followers_count key:value pair. { { ...... user: { ..... "followers_count" : int } } }

Jquery functions with variable arrays -

i have function produces random number game. running function 8 times. instead of copying function 8 times , renaming variables, want streamline it. function card1nums() { card1array = []; var iteration1=0; while (iteration1 < 25) { num1=getcardnum(); //look see if number exists if($.inarray(num1,card1array) == -1){ //number not found add array card1array.push(num1); iteration1++; } }return card1array; } function card2nums() { card2array = []; var iteration2=0; while (iteration2 < 25) { num2=getcardnum(); //look see if number exists if($.inarray(num2,card2array) == -1){ //number not found add array card2array.push(num2); iteration2++;

Python list of ints in prepared sql statement -

my question same python list of string sql in parameter have list of integers. python code use is: ids = [1000032, 1000048] sql = 'select compno, compname, comptype component deptid in (?)' cursor.execute(sql, [','.join(ids)]) and sybase database engine responds with: pyodbc.error: ('07006', "[07006] [sybase][odbc driver][sql anywhere]cannot convert '1000032','1000048' numeric (-157) (sqlexecdirectw)") what correct way this? imo more readable way build dynamic query string placeholders using str.format ids = [1000032, 1000048] sql = 'select compno, compname, comptype component deptid in ({0})' sql = sql.format(','.join('?' * len(ids))) cursor.execute(sql, (ids,)) ...

utf 8 - How to detect Chinese Character in MySQL? -

i need calculate number of chinese in list of columns. example, if "北京实业" occur, 4 characters in chinese count once since occurs in column. is there specific code figure out? select count(*) tbl hex(col) regexp '^(..)*(e[2-9f]|f0a)' will count number of record chinese characters in column col . problems: i not sure ranges of hex represent chinese. the test may include korean , japanese. ("cjk") in mysql 4-byte chinese characters need utf8mb4 instead of utf8 . elaboration i assuming column in table character set utf8 . in utf8 encoding, chinese characters begin byte between hex e2 , e9, or ef, or f0. starting hex e 3 bytes long, not checking length; f0 ones 4 bytes. the regexp starts ^(..)* , meaning "from start of string ( ^ ), locate 0 or more ( * ) 2-character ( .. ) values. after should either e -something or f0a . after that, can occur. e-something is, more specifically, e followed of 2,3,4,5,6,7,8,9,

django building a get_page_url function in model to return list with pagination number -

i have scenario items paginated list of items in model , want create function return page contains item. for example class item(models.model): subject = models.charfield(max_length=200) assuming have 1000 items in table , return 10 per page. how can build method/function in model tell me in page item fall? please advise? you add classmethod takes order_by , paginate_by import itertools def grouper(n, iterable, fillvalue=none): args = [iter(iterable)] * n return itertools.izip_longest(fillvalue=fillvalue, *args) class item(models.model): # attrs @classmethod def get_pagination_index(cls, self, order_by, paginate_by): if order_by: qs = cls.objects.all().order_by(order_by) else: qs = cls.objects.all() pages = grouper(paginate_by, qs) = 0 page in pages: += 1 if self in page: return # return item_index = list(qs).index(self) # e

java - Getting error while changing to string-array from string in text field of activity xml file in android studio -

i want display random strings each time android app opened. using stackoverflow, able write java program getting random strings resource file. package com.example.krishna.quotes; import android.support.v7.app.appcompatactivity; import android.os.bundle; import java.util.random; import android.content.res.resources; import android.widget.textview; public class mainactivity extends appcompatactivity { private string[] mystring; private static final random rgenerator = new random(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); resources res = getresources(); mystring = res.getstringarray(r.array.quotes_array); string q = mystring[rgenerator.nextint(mystring.length)]; textview tv = (textview) findviewbyid(r.id.text); tv.settext(q); } } when used string type in text field of a

How do you import a file in python with spaces in the name? -

do have to take out spaces in file name import it, or there way of telling import there spaces? you should take spaces out of filename. because filename used identifier imported modules (i.e. foo.py imported foo ) , python identifiers can't have spaces, isn't supported import statement. if really need reason, can use __import__ function: foo_bar = __import__("foo bar") this import foo bar.py foo_bar . behaves little bit different import statement , should avoid it.

sql server - how to copy data from one table to another table based on they have some same data in 3rd column? -

as question, how achieve goal? example table 1 place_id place_name invoice_no 100 sydney null 101 melbourne null 102 adlaide null 103 gold coast null 104 perth null 105 hobart null table 2 invoice_id invoice_no place_id 1 nit1001 100 2 nit1002 101 3 nit1002 102 4 nit1003 103 target table place_id place_name invoice_no 100 sydney nit1001 101 melbourne nit1002 102 adlaide nit1002 103 gold coast nit1003 104 perth null 105 hobart null use join clause: insert targettable select a.place_id, a.place_name, b.invoice_no table1 left join table2 b on a.place_id = b.place_id