Posts

Showing posts from June, 2014

go - Using new and assigning variable at the same time -

wd := new(time.weekday) fmt.println(wd.string()) the above 2 lines return sunday (weekdays start 0) is possible me assign value along new ? other method tried var wd time.weekday wd = 3 this 1 returns wednesday time.weekday int can assign such (or use defined constants adam suggested). can ask why need use new in situation? package main import ( "fmt" "time" ) func main() { var wd time.weekday = 3 fmt.println(wd) }

asp.net mvc 4 - itextsharp advance pdf generation by configuration xml -

i generating pdf using itextsharp.i got many sample code in google how can configure pdf setting required generate pdf like var doc = new document(pagesize.a5); var doc = new document(new rectangle(100f, 300f)); these setting wanted set config xml file , read xml , generate pdf on fly. professional sample example code available?plz help..

java - Prevent RecyclerView showing previous content when scrolling -

i have recyclerview gridlinearlayout , custom adapter. content of each item picture downloaded using json , parsing it. basically grid of pictures. everything works fine, however, when scrolling down content, , going again, shows previous views in each item less second, , show proper picture again. what prevent or fix this? in advance and/or guidance provide. this adapter code: package jahirfiquitiva.project.adapters; import android.content.context; import android.graphics.bitmap; import android.support.v7.graphics.palette; import android.support.v7.widget.recyclerview; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.view.animation.animation; import android.view.animation.animationutils; import android.widget.imageview; import android.widget.linearlayout; import android.widget.progressbar; import android.widget.textview; import jahirfiquitiva.project.activities.wallpapersactivity; import com.koushikdutta.async.

javascript - How can I keep this table header fixed? -

i'd keep table header fixed, problem when set thead position fixed loses size. basically, want keep thead moving rest of table original shape , size . thanks in advance. table { margin: 100 0 100 0; width: 100%; } th, td, table { /*word-wrap: break-word;*/ border: 1px solid black; border-radius: 3px; } body { overflow: hidden; } .scrollable { height: 100%; display: flex; flex-direction: column; overflow-y: scroll; } thead { position: fixed; width: 100%; } .myhead { width: auto; border: 11px solid blue; } <!doctype html> <html> <head> <title>mytable</title> </head> <body> <div class="scrollable"> <table> <thead> <tr class="myhead"> <th class="header" align="center">title</th> <th class="header" align="center">t

angularjs - The correct definition of data -

i have code, when run error of "referenceerror: data not defined" have defined data in several ways nothing seem correct. thing when think data declared in api (no?).. appreciate help.. app.service('statisticsservice', ['apiclient', '$q', '$rootscope', '$timeout', function (apiclient, $q, $rootscope, $timeout) { var self = this; self.getstatisticsfromserver = function (data) { var deferred = $q.defer(); //1 apiclient.getstatstopmeeters(data) .then(function (response) { //2 console.log('externalapiconnect', response); if (response.data.length === 0 || response.result !== "success") { // todo: show error deferred.reject(response);

regex - Regular Expression substring start and end with JavaScript -

i have string: "/upload/c_fill,w_960,h_640/v1430399111/" where want replace wherever "w_" other value, w_960 w_930 while 960 vary. i tried following not able find string end with: var imgpath = elempath.replace(/(\,w_)/, ",w_"+930); if understand correctly wanted replace ,w_ followed 3 digits ,w_930 . on right track. can use \d match digit , {3} 3 repetitions. don't need group () or escape comma: var imgpath = elempath.replace(/,w_\d{3}/, ",w_"+930); if number of digits can vary, use + (one or more repetitions): var imgpath = elempath.replace(/,w_\d+/, ",w_"+930);

Passing context to qweb report for managing table visibility - odoo -

how can pass context value qweb report can control visibility of tables. have qweb report lot of tables. depending on selection list, want control view of these tables in qweb report. option control using context. didn't find way pass context. if there other opinion, please share. create parser class first import time openerp.osv import osv openerp.report import report_sxw class sale_quotation_report(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(sale_quotation_report, self).__init__(cr, uid, name, context=context) self.localcontext.update({ ‘key’: value, ‘function_name’: self.function_name, }) def function_name(self): ### add code if required.. then define class class report_saleorderqweb(osv.abstractmodel): _name = ‘module_name.report_sale_order_qweb’ _inherit = ‘report.abstract_report’ _template = ‘module_name.report_sale_order_qweb

Regex: negative match on group of characters? -

i want create regular expression match strings starting 0205052i0 , next 2 characters not bb. so want match: 0205052i0aaaaaa 0205052i0acaaaa 0205052i0bcabaa but not match: 0205052i0bbaa how can pcre regular expressions? i've been trying $0205052i0^(bb) on https://regex101.com/ doesn't work. you can use negative ahead : "0205052i0(?!bb).*" see demo https://regex101.com/r/mo6uv4/1 also note have putted anchors @ wrong position. if want use anchor can use following regex : "^0205052i0(?!bb).*$"

AngularJS ui-select: option not added when typed fully -

i using angular ui-select , want allow user select option using auto-complete, allow them type in custom options. i've configured control tagging enabled , no tagging labels follows: <ui-select multiple tagging tagging-label="false" ng-model="colors" theme="bootstrap" style="width: 300px;" title="choose color"> <ui-select-match placeholder="select colors...">{{$item}}</ui-select-match> <ui-select-choices repeat="color in availablecolors | filter:$select.search"> {{color}} </ui-select-choices> </ui-select> here's example plunkr: http://plnkr.co/edit/yw7wlozcds1xios6usns?p=preview the problem when type in word exists in available colors , press enter, option not become selected. in plunkr, can see if type blue , press enter. where going wrong? this appears known bug related using tagging-label="false" . works correctly when re

image - base64 URI to PNG-Python -

Image
i trying generate pdf via python using "reportlab" , add image it. image have use png has format: data:image/png;base64,ivborw0kggoaaaansuheugaaa+gaaah0cayaaacukactaaagaef (and continues) i don't know do, first think need transform uri image don't know how , then, use like: import image im = image.open("infile.png") im.save("outfile.jpg") in order convert .png .jpg. can me? try ( edit : njzk2 pointing out cut header): import image, io, base64 data = "data:image/png;base64,ivborw0kggoaaaansuheugaaaauaaaafcayaaacnbyblaaaaheleqvqi12p4//8/w38giaxdibke0dhxgljnbaao9txl0y4ohwaaaabjru5erkjggg==" im = image.open(io.bytesio(base64.b64decode(data.split(',')[1]))) im.save("image.jpg") added real base64 string testing here , should result in image of little red dot:

selenium - how to write below xpath in java -

//div[@ng-if="subnav.state == 'active'"] i tried below getting "invalidselectorexception" : string active = "subnav.state == 'active'"; driver.findelement(by.xpath("//div[@ng-if='"+active+"']")) <li class="active" on="subnav.state != '' && subnav.state != 'active'" ng-switch="" ng-repeat="subnav in navigation[activenav].pages | filter:subnavfilter(navigation[activenav].pages)"> <div class="whereabouts ng-scope" ng-if="subnav.state == 'active'"></div> <span class="badge badge-active" aria-disabled="true" ng-if="subnav.state != 'complete'">6</span> <span class="ng-binding ng-scope" ng-switch-when="false">loan</span> </li> if there quotes used inside value should escape quotes.and sugge

c# - 2D Graphic in Windows Universal App -

i thinking upcoming school project focused on windows 10 universal apps , ran interesting experiment : https://www.chromeexperiments.com/experiment/stochasticity i want work on similiar or achieve similar level of animation in metro universal application writen in csharp. have never worked sort of animation or 2d graphics while writing wua. can direct me right way start ? recommendation, possible..any particular sample codes ? thank you. for 2d raster graphics take @ win2d . win2d windows runtime wrapper on direct2d , enables high performance 2d rendering similar experiment html canvas. canvasanimatedcontrol designed scenarios think you're looking for. see introduction , quick start on github started , more samples.

How to use serilog with latest asp.net 5? -

if have both "microsoft.framework.logging.console": "1.0.0-*, and "serilog.framework.logging": "1.0.0-*" in project.json , i'm getting following conflict: the type iloggerfactory exists in both microsoft.framework.logging.abstractions , microsoft.framework.logging.interfaces the type ilogger exists in both microsoft.framework.logging.abstractions , microsoft.framework.logging.interfaces looks have mixed old , new packages in project.json. take @ announcement , can see in aspnet 1.0.0-beta5 packages renamed. so,for example, microsoft.framework.logging.console depends on old microsoft.framework.logging.interfaces , serilog.framework.logging depends on new microsoft.framework.logging.abstractions, @ project.lock.json dependency details. try update packages beta6 version in project.json, not forget dnvm upgrade dnx. hope ) thanks

java - How to initialize initial context in JMS -

i create message queue in standalone application using jms queue. not using kind of container tomcat , jboss. should arguments passed initial context object.? s standalone application.. note: if wishes give down vote question, please give reason in comment , give down vote. thanks! initialcontext ctx = new initialcontext(?????); queue queue = (queue) ctx.lookup("queue/queue1"); queueconnectionfactory connfactory = (queueconnectionfactory) ctx.lookup("queue/connectionfactory"); queueconnection queueconn = connfactory.createqueueconnection(); queuesession queuesession = queueconn.createqueuesession(false,session.auto_acknowledge); queuesender queuesender = queuesession.createsender(queue); queuesender.setdeliverymode(deliverymode.non_persistent); textmessage message = queuesession.createtextmessage("hello"); queuesender.send(message); system.out.println("sent: " + messag

Junk character is not visible in Oracle SQL developer -

Image
i not able view junk character in oracle sql developer, visble in plsql developer. below screenshot plsql developer: below screenshot oracle sql developer: the junk character visible in notepad not visible here. please explain how can made visible in oracle sql developer tool allowed use officially. use locale command: $ jim> locale lang=c lc_collate="c" lc_ctype="c" lc_monetary="c" lc_numeric="c" lc_time="c" lc_messages="c" lc_all= usual locale setting on our db servers == utf-8 if use non-latin characters in in language different.

jquery - Javascript files clashing, please suggest changes -

i making view page out of html code , source files of 2 bootstrap templates. both templates using different java script files different features. using both js files in 1 html view page, features of 1 js file not working. two js files using are: jquery-2.1.1.min.js , jquery-2.1.4.min.js please suggest alternative or way out combine both these files in single features working. <!-- jquery 2.1.4 --> <script src="plugins/jquery/jquery-2.1.4.min.js"></script> <!-- jquery ui 1.11.2 --> <script src="http://code.jquery.com/ui/1.11.2/jquery-ui.min.js" type="text/javascript"></script> <!-- resolve conflict in jquery ui tooltip bootstrap tooltip --> <script> $.widget.bridge('uibutton', $.ui.button); </script> <!-- bootstrap 3.3.2 js --> <!-- morris.js charts --> <script src="http://cdnjs.cloudflare.com/ajax/libs/r

Retrieve data from facebook graph API 2.4 -

can me retrieve data using new graph api v2.4 of facebook, using url- https://graph.facebook.com/ {user-id}/feed?limit=1&locale=en_gb&access_token={access-token} previously provides data, (provide data view in json format) "id": "12345_67890", "from": { "name": "xyz", "id": "123456" }, "message": "hwregdsfdsf", "link": "http://example.com/wordpress/", "name": "example.com", "caption": "example.com", "icon": "https://www.facebook.com/images/icons/post.gif", "actions": [ { "name": "comment", "link": "https://www.facebook.com/12345/posts/67890" }, { "name": "like", "link": "https://www.facebook.com/12345/posts/67890"

.net - C# Serialize expression -

i serialize expression. (create iquery clientside -> send server -> execute -> return result client) but expressions not serializeable. gnupacket serialize.linq ( https://github.com/esskar/serialize.linq ) still have problem. following exception thrown: error converting type: der typ 'prog.db.query`1[[prog.database.user, prog.database, version=1.0.0.0, culture=neutral, publickeytoken=null]]' mit dem datenvertragsnamen 'arrayofuser: http://schemas.datacontract.org/2004/07/prog.database ' wird nicht erwartet. verwenden sie ggf. einen datacontractresolver, oder fügen sie alle unbekannten typen statisch der liste der bekannten typen hinzu, beispielsweise mithilfe des knowntypeattribute-attributs oder indem sie sie zur liste der bekannten typen hinzufügen, die datacontractserializer übergeben wird. i added known types jsonserializer js = new jsonserializer(); js.addknowntypes(assembly.getassembly(typeof(prog.database.

php - Show a Parse error: "@" on dbc connect. how i fix it? -

this question has answer here: php parse/syntax errors; , how solve them? 12 answers error - "parse error: syntax error, unexpected '@' in /home/vol2_8/byethost13.com/b13_16347614/digiquiz.my-style.in/htdocs/simplephpquiz-master/includes/db_conn.php on line 7" here code: <?php // set database access information constants define ('db_user', 'xxxxxxxxx'); define ('db_password', 'xxxxxxx'); define ('db_host', 'xxxxxxxxxxx'); define ('db_name', 'xxxxxxxxxxx'); @ $dbc = new mysqli(xxxxxxxxxx, xxxxxxxx, xxxxxxxxx, xxxxxxxx); // details added constants not define's if (mysqli_connect_error()){ echo "could not connect mysql. please try again"; exit(); } ?> why not using defines so: <?php //set database access information constants define

Spring Boot doesn't use CommonsMultipartResolver? -

i have problem rest web service running spring boot (jetty). 1 of rest method file upload , i'm guessing commonsmultipartresolver not using during multipart requests. signature of upload method : @responsebody @requestmapping(value = "/upload", method = requestmethod.post, produces = "application/json") public baseresponse upload(@requestparam("login") string login, @requestparam("passwd") string passwd, @requestparam("partner") string partner, @requestparam("filename") string fname, @requestparam("length") int flen, @requestparam("file") multipartfile file) throws ioexception i have root application class below : @springbootapplication public class bootapplication { private static final logger _logger = logger.getlogger(bootapplication.class.getname()); public static void main(string[] args) { springapplication app = new springapplication(bootapplication.c

asp.net mvc 4 - How to get select option value inside razor in mvc -

i have <select> tag in view. example: <html><head></head> <body> <div> <select> <option value="">select</option> <option value="alert1">alert1</option> <option value="alert2">alert2</option> </select> </div> <div id="preview"> `enter razor code here`@ { here have write condition based on <select option> tag value, need display respective viewbag. } </div> </body></html> from controller passing viewbag , e.g.: viewbag.alert1="some html template1". viewbag.alert2="some html template2". my requirement is: on selecting <option> , if select 'alert1', in <div id="preview"> need display viewbag.alert1 content. if user selects 'alert2' in <div id="preview"> need display viewbag.alert2 value. i know, c

jquery - Javascript cookie not saving when user input reaches a certain size -

i trying save user input textarea in javascript cookie on unload of page , read textarea when user returns. issue having cookie not saving when user input reaches length. seems working fine small strings. here html: <html> <head> <title>cookie test</title> <link rel="stylesheet" type="text/css" href="css/site.css"> </head> <body class="full" onload="getcookies()" onunload="writecookies()"> <div class="fullscreen-overlay" id="fullscreen_overlay"> <div class="fullscreen-container js-fullscreen-container"> <div class="textarea-wrap"> <textarea name="fullscreen-contents" id="fullscreen-contents"></textarea> </div> </div> </div> </body> </html> javascript: function writecookies() { var d = new date(); var n = document.getelementbyid(&

wix3.9 - How can I make the background of an checkbox transparent in wix? -

Image
how can make background of checkbox transparent or white? that quite common complaint. quick answer - no, there's no way nicely. let me quote wix toolset tutorial : and common complaint: no, checkbox can't have transparent background. if have bitmap in background, ugly, in our example above. workaround reduce width of checkbox actual box , place additional static text (these can made transparent) adjacent it. the downside of workaround described won't able click text in label check/uncheck checkbox. you'll have click directly control. there is, however, 1 more (even uglier?) workaround: design final dialog way have default grey area place checkbox on.

maven build android project: specify the location of aidl file -

my android project has aidl file, project structure below: myproject/ src/ main/ com.my.aidl/ imyservice.aidl pom.xml i building android project maven. pom uses dexguard-maven-plugin extension of android-maven-plugin . in plugin configuration, explicitly specified directory of source aidl file & directory of generated java file. <build> <plugins> <plugin> <groupid>com.saikoa.dexguard.maven</groupid> <artifactid>dexguard-maven-plugin</artifactid> <configuration> <aidlsourcedirectory> ${project.basedir}/src/main/com/my/aidl </aidlsourcedirectory> <gendirectoryaidl> ${project.build.directory}/generated-sources/aidl/main/com/my/aidl </gendirectoryaidl> </configuration> <extensions>true</

c# - How can I close a video with MediaElement? -

i have mediaelement, , click of button, open video <button x:name="videotour" click="videotour_click" grid.column="4" grid.columnspan="2" grid.row="0" borderbrush="{x:null}" style="{staticresource buttonstyle1}" verticalalignment="top" margin="0,14,0,0" foreground="#ff5acb2f" background="{x:null}"> <button.content> <image source="../assets/movie.png" width="40" height="40"/> </button.content> </button> <mediaelement x:name="playtour" visibility="collapsed" grid.row="1" grid.rowspan="2" grid.column="1" grid.columnspan="4" source="{binding urltour}" aretransportcontrolsenabled="true" width="260" height="250"/> when video has opened, submit button close mediaelement video,

javascript - Image manipulation in Meteor -

i uploading images in meteor collectionfs . it works interested in creating thumbnails images. i have followed https://github.com/collectionfs/meteor-collectionfs#image-manipulation cannot graphicsmagick work. if use var createthumb = function(fileobj, readstream, writestream) { readstream.pipe(writestream); }; the code works image not resized (the thumbnail equals orginal image should). when call gm(readstream, fileobj.name()).resize('10', '10').stream().pipe(writestream); to resize image 10x10 thumbnail, code works thumbnail not created correctly. thumbnail created size 0kb. suspect graphicsmagick not installed correctly. have downloaded , installed windows binary , added cfs:graphicsmagick packages . are there alternatives graphicsmagick ? rather avoid using third parties since graphicsmagick not installed on meteor's free development servers , want app portable. maybe image manipulation such advanced task cannot done directly in javasc

ios - Show alternative routes -

Image
i working apple map , want show more 1 route between given start , end directions don't want use nsurl class send request through url. want use apple provided classes.

How to dynamically draw bitmaps to a Canvas in Android? -

here scenario of issue . custom view canvas on need draw . 2 buttons beneath ,lets call them , b when clicked -> image drawn above canvas . when b clicked -> image b drawn above canvas . the issue demands drawn image on canvas must preserved . if click button followed button b canvas must contain 2 images . previous images need preserved. problem : how achieve ? possible solution 1 : create arraylist , keep adding images arraylist . pass updated arraylist canvas ondraw method , redraw every single image every button click . possible solution 2 : there has method preserve state of canvas on each button click draw on canvas's last preserved state , draw new image . further requirements : images drawn canvas dragged need keep track of updated positions . i @ impasse , couldn't find tutorial or book tackling such requirement , appreciated . you can create bitmap, , draw want on it. bitmap mbitmap; protected void onlayout(boolean changed, int left,

c++ - a write() to tun/tap interface returns "invalid argument" -

i have created , attached tap interface. can read interface no problem. trying write fails reporting "invalid argument". code follows : int tapinterface::write(char *buf, int n) { int nwrite; if((nwrite=::write(this->my_tap_fd, buf, n))<0) { qdebug("writing data") ; perror("error:"); exit(1); } return nwrite; } .... .... qbytearray txdata("hello"); write(txdata.data(), txdata.length()); any help?

php - echo all row of a mysql_num_rows -

i have following php $q=mysql_query("select smiles geoandenergies weight='".$data."' ") or die(mysql_error()); $n=mysql_num_rows($q); //not mysql_fetch_row, not return count array if($n>0) { $info=mysql_fetch_row($q); echo $info[0]; } else { echo "molecule not find"; } i echo not $info[0] $info[0]+"<"+ $info[1] + "<" .... + $info[n], correct syntax? thanks use while loop fetch rows $q=mysql_query("select smiles geoandenergies weight='".$data."' ") or die(mysql_error()); $n=mysql_num_rows($q); if($n>0) { $val=''; while($info=mysql_fetch_row($q)) { if($val!='') $val.=' < '; $val.= $info[0]; } } else { $val= "molecule not find"; } echo $val;

How to validate SMTP server's SSL/TLS certificate using java mail API? -

we adding functionality send email through smtp. basically, when user tries add , save smtp server details through ui, need validate server's certificate. "sending mail" code done; there enough number of examples :) however, i'm trying see if there way certificate details smtp server , validate @ client side using java mail api; can see transport.connect() method implicitly validates server certificate,but i'm trying understand if there explicit way of doing it. in short, these 2 things i'm trying achieve: 1) sll/tls certificate server , prompt user relevant details(like, whether certificate valid). 2) if certificate not valid, provide option add key store. any hints done through java mail api appreciated. you can use openssl server certificates ssl/tls or starttls. for ssl/tls: openssl s_client -connect smtp.gmail.com:465 -capath /etc/ssl/ </dev/null for starttls: openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587 -

javascript - How to animate this peak chart? -

i'm new css , javascript, struggeling trying animate peak (bar) chart found on codepen... : http://codepen.io/anna_123/pen/qbqqqb /* pie chart based on pen aaronlsilber (http://codepen.io/aaronlsilber/pen/iqrkl) based on article james litten (http://html5.litten.com/graphing-data-in-the-html5-canvas-element-part-iv-simple-pie-charts/) */ /* peak chart javascript =====================================================================*/ var peakcolors = ['rgb(236, 208, 120)', 'rgba(217, 91, 67, 0.7)', 'rgba(192, 41, 66, 0.7)', 'rgba(84, 36, 55, 0.7)', 'rgba(83, 119, 122, 0.7)', 'rgba(119, 146, 174, 0.7)']; function drawpeakchart( canvasid ) { var i, start, peakpoint, canvas = document.getelementbyid( canvasid ), peakdata = canvas.dataset.values.split(',').map( function(x){ return parseint( x, 10 )}), ctx = canvas.getcontext( '2d' ), max = math.max.apply( math,

javascript - Submit Form Issue in Search Bar -

no matter try cannot submit search form <div id="search_bar_container" style="z-index:99999"> <div class="container"> <form action="tour-list-search-results.php" method="post" name="search_2" id="search_2"> <div class="search_bar"> <div class="nav-searchfield-outer"> <input type="text" autocomplete="off" name="field-keywords" placeholder="type search terms ...." id="twotabsearchtextbox"> </div> <div class="nav-submit-button"> <input type="submit" onclick="this.form.submit();" name="button" id="button" class="nav-submit-input" value="submit"> </div> </div> <!-- end search bar--> </div> </div> &

javascript - Video height difference in chrome and mozilla -

i getting different height while using video: #myvideo{ position: absolute; z-index: 4; right: 0; bottom: 0; top:0; right:0; width: 100%; height: 100%; margin-bottom: -100px; background-color: black; background-image: /* our video */; background-position: center center; background-size: contain; object-fit: cover; } <video autoplay loop muted id="myvideo"> <source src="imgs/flowers.mp4" type="video/mp4"> <source src="imgs/flowers.webm" type="video/webm"> </video> how can solve different heights in chrome , mozilla.

angularjs - How to dynamically change template of popover in angular-strap -

i using angularstrap create popover using template. using attribute ng-attr-data-template provide link template. changing mentioned attribute value using function called on click of button. change not being reflected popover. please suggest possible solution problem. here link plunkr code follows index.html <!doctype html> <html ng-app="klk"> <head> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"></script> <script src="//mgcrea.github.io/angular-strap/dist/angular-strap.js" data-semver="v2.0.4"></script> <script src="//mgcrea.github.io/angular-strap/dist/angular-strap.tpl.js" data-semver="v2.0.4"></script> <link rel="stylesheet" href="style.css" /> <script src=&qu