Posts

Showing posts from February, 2010

java - Printing JPanel into PDF with itext without displaying it -

i have number of sheets contains numbers of jpanel. jpanels parents jtextpane, once panel visible can print pdf itext, if page not itext doesnt print panel. @ time of printing ducument created , contents added jtextpane , size of panel known too. hier print code public static void printcomponent(final jcomponent component, final rectangle bounds) throws documentexception, saxexception, ioexception, parserconfigurationexception { if (pdfcanvas == null) { return; } final rectangle alloc = new rectangle(component.getbounds().width, component.getbounds().height); pdfcanvas.savestate(); pdfcanvas.setleading(0); pdfcanvas.setcharacterspacing(0); final pdftemplate canvas = pdfcanvas.createtemplate(alloc.width, alloc.height); final fontmapper arialuni = new fontmapper() { @override public basefont awttopdf(final java.awt.font font) { //return basefont.... } @override public java.awt.

JAVA JDBC ODBC DRIVER SQLMX -

i have application connect mxsql(hp non stop db) using odbc driver. below code : string driver = "sun.jdbc.odbc.jdbcodbcdriver"; string dburl = "jdbc:odbc:smartvista"; string dbuname = "*****"; string dbpwd = "******"; class.forname(driver); connection conn = drivermanager.getconnection(dburl, dbuname, dbpwd); string getquery = "some query here"; system.out.println(getquery); statement stmt = conn.createstatement(); the code working fine time ago stop working throwing below error java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) i suspect error related java version. post has suggest using ucanacess , unable implement same. please advise anyone

python - How to get the state of checkbox which is the listview_item -

here code: list_view = ruleset_form.tsettingslistview ctrl = list_view.wrapperobject() list_view = listviewwrapper(ctrl) i can't checkbox http://take.ms/plezr variants presented below don't work: 1) ctrl = list_view.items()[2].wrapperobject() checkbox = buttonwrapper(ctrl) output is: attributeerror: '_listview_item' object has no attribute 'wrapperobject' 2) ctrl = list_view.getitem(i,3).wrapperobject() checkbox = buttonwrapper(ctrl) output is: attributeerror: '_listview_item' object has no attribute 'wrapperobject' 3) ctrl = list_view.getitem(i,3).item().wrapperobject() checkbox = buttonwrapper(ctrl) output is: attributeerror: 'lvitemw' object has no attribute 'wrapperobject' 4) checkbox = buttonwrapper(list_view.getitem(i,3).listview_ctrl) output always: 0

Embedded Tomcat logging over logback / sl4j -

how can make embedded tomcat write logs on logback? found info using standalone tomcat log4j. how setup embedded tomcat , logback? these maven dependencies: <dependency> <groupid>ch.qos.logback</groupid> <artifactid>logback-core</artifactid> <version>${logback.version}</version> </dependency> <dependency> <groupid>org.apache.tomcat.embed</groupid> <artifactid>tomcat-embed-core</artifactid> <version>${tomcat.version}</version> </dependency> <dependency> <groupid>org.apache.tomcat.embed</groupid> <artifactid>tomcat-embed-logging-juli</artifactid> <version>${tomcat.version}</version> </dependency> <dependency> <groupid>org.apache.tomcat.embed</groupid> <artifactid>tomcat-embed-logging-log4j</artifactid> <version>${tomcat.version}</version> </depend

ios - Application builded using Dynamic framework not submitted to app store -

i have created dynamic framework , while importing dynamic framework application needs add in embedded binaries. it working both device , simulator when archive , make .ipa file submit , got below error while submitting app app store. 1) error itms-90087: "unsupported architectures. executable sample.app/frameworks/customframework.framework contains unsupported architectures '[x86_64, i386]'." 2) error itms-90209: "invalid segment alignment. app binary @ 'sample.app/frameworks/customframework.framework/customframework' not have proper segment alignment. try rebuilding app latest xcode version.” 3) error itms-90125: "the binary invalid. encryption info in lc_encryption_info load command either missing or invalid, or binary encrypted. binary not seem have been built apple's linker.” 4) warning itms-90080: "the executable 'payload/sample.app/frameworks/customframework.framework' not position independent executable. please

java - android SQLite, can't view data anymore in my listView -

yesterday made nice listview see database, today tried add on line database , got error message saying "database leaked. blabla close database". after not add anymore line database. but restarted android studio , add new line (and no error anymore) ! can't see news lines add. see line added before error (or maybe can see 1 added caused me error). checked database chrome , see everything, added news lines ! i don't know up, checked history several class didn't make bad change (i think). how can see database again ? use contentprovider access database. here fragment class list view (i use 2 button inside elements list view , textview) : public class viewcardeditor extends fragment implements loadermanager.loadercallbacks<cursor> { public static final string authority = "com.example.jean.cartememoire.cardcontentprovider"; public string[] from; public final int[] = {r.id.idlist, r.id.themelist, r.id.questionlist, r.id.reponselis

spring boot - Where does MongoDB for PCF Development Services store all data values? -

my current application using mongodb running on localhost default port 27017. web application reflect data stored in database. when push application cloud foundry, , bind mongo service, uses database. , how can view/access data being inputted. on local machine able use db.collection.find() , queries of data. the data stored in cf mongo service. can check running inspecting values in vcap_services section of application environment: cf env <app name> in environment can see connection details, db should not accessible directly. connect db can use tunnel similar chisel or crowbar. there chisel fork contains instructions on how connect cf services.

automation - AppleScript "Can’t get every note of account" -

i'm trying out applescript first time today. wanted start logging name of every note in notes.app here's script: tell application "notes" activate set mainaccount name of account 1 tell account mainaccount repeat n in notes log name of n string end repeat end tell end tell i error message: tell application "notes" activate name of account 1 --> "icloud" exists folder "archive" of account "icloud" --> true count every note of account "icloud" --> error number -1728 every note of account "icloud" result: error "notes got error: can’t every note of account \"icloud\"." number -1728 every note of account "icloud" what's happening here? accounts don't have notes, have folders. so script can written this: tell application "notes" activate s

Android Studio image shown in Design screen but not in emulator -

an image use (.jpg) in android project shown in "design" when start emulator, not there. other images not loaded. i found possible solutions image showing in android studio not on phone none of solutions worked in case. sum up, tried: moving image drawable-xxhdpi or mipmap--xxhdpi using other image , different format (.png) adding android:adjustviewbounds="true" clean/rebuild project etc no success. work on os x code: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"

Recording video using ffmpeg in android -

i studying ffmpeg android library,was unable understand part of code. public void onpreviewframe(byte[] data, camera camera) { if (audiorecord == null || audiorecord.getrecordingstate() != audiorecord.recordstate_recording) { starttime = system.currenttimemillis(); return; } if (record_length > 0) { int = imagesindex++ % images.length; yuvimage = images[i]; timestamps[i] = 1000 * (system.currenttimemillis() - starttime); } //till here able understand first statement purpose? /* video data */ if (yuvimage != null && recording) { ((bytebuffer)yuvimage.image[0].position(0)).put(data); } } onpreviewframe overridden method if provide cameracallbacks in mcamera.setpreviewcallbackwithbuffer(new previewcallback() { public void onpreviewframe(byte[] imagedata, camera arg1) { <<<your logic here>>> } } please refer link http://www.programcreek.com/j

php - Android laravel passport -

i trying retrieve token laravel passport no response, code.. login public void gettoken(){ final string url = "http://10.96.2.159/chat/public/oauth/token"; stringrequest str = new stringrequest(request.method.post, url, new response.listener<string>() { @override public void onresponse(string response) { msgresponse.settext("work!"); } } , new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { } }){ @override protected map<string, string> getparams() throws authfailureerror { map<string,string> params = new hashmap<string, string>(); params.put("client_id","2"); params.put("client_secret","token"); params.put("grant_type","password");

find - finding files with names in numeric text -

i trying find files in current directory names contains numeric digits 111 1101 3348 444. tried find . -name "[0-9]\+" -type f but not work when run find . -name "[0-9]*" -type f this works , can 1 explain why first command not finding numeric file names ? the -name argument accept unix glob . you can't use regex inside of it. use -regex if need more power, need match path.

Ruby: array is being passed by reference into function? -

this question has answer here: is ruby pass reference or value? 11 answers i have simple code below def testarray arr_tree = [1,2,3,4,5] (1..3).each |index| abcde(arr_tree) puts arr_tree[0] end end def abcde(node_tree) node_tree[0] += 100 end so inside testarray function, have array arr_tree being passed function abcde . change value of array inside abcde function , print array inside testarray changed value here. output is 101 201 301 but expecting 1 1 1 please explain why results this? how can achieve expected result? everything "passed object" in ruby. and arrays objects. if want avoid side-effects make copy of argument def abcde(node_tree) copy = node_tree.dup copy[0] += 100 copy end a note of caution though since named variable tree , dup method makes shall

swift3 - Protocol Property Allowed With Realm? -

i'm trying model data. i have class contains optional property of type excercisecontent. import realmswift class excercise: object { var content: excercisecontent? } the idea excercise contains content, duration, , 1 of two: audio or text. protocol excercisecontent { var duration: int { } } protocol audioexcercisecontent: excercisecontent { var audio: string { } } protocol textexcercisecontent: excercisecontent { var text: string { } } i found similar question , know if still applies, , response means "realm needs know concrete object type linked @ initialization time." i've declared protocol, shouldn't realm know object type? or object type different every time, , that's why can't done? realm needs know concrete object type linked @ initialization time. . your content property should either realm object or 1 of supported property types .

r - How do I deal with special characters like \^$.?*|+()[{ in my regex? -

i want match regular expression special character , \^$.?*|+()[{ . tried: x <- "a[b" grepl("[", x) ## error: invalid regular expression '[', reason 'missing ']'' (equivalently stringr::str_detect(x, "[") or stringi::stri_detect_regex(x, "[") .) doubling value escape doesn't work: grepl("[[", x) ## error: invalid regular expression '[[', reason 'missing ']'' neither using backslash: grepl("\[", x) ## error: '\[' unrecognized escape in character string starting ""\[" how match special characters? some special cases of in questions old , written enough cheeky close duplicates of this: escaped periods in r regular expressions how escape question mark in r? escaping pipe ("|") in regex escape double backslash r treats backslashes escape values character constants . (... , regular expressions. hence need 2

html - Space Between Heading and Canvas -

i wrote following code .bluecolor{background-color : skyblue;} canvas{width: 100pt;margin:0px;border: 5px solid;} h1{margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;} <html> <head> <title>hello world</title> </head> <body> <h1>hello</h1> <canvas id = "canvas1" class = "bluecolor"></canvas> </body> </html> why there still space between hello , canvas , when have made every padding , margin 0 each element?i confused thing. and have came know inline , block elements , used them no avail , deleted space between 2 canvas element when made them block , had not clue how working ? if see wrong in question please comment , , correct it, still learning ways of site. update people pointing line height , can include example in answer , explain mean? there isn't space between hello , canvas . it's line-height of font. https://css-t

.net - Git commit and push issue in Jenkins multibranch pipeline -

i'm working on multibranch pipeline in jenkins building .net application , creating ms test results using msbuild on windows server. i've written jenkinsfile same. now issue is, need commit , push mstest results file same branch on git. i've tried same using 'bat' in jenkinsfile, gives me detached head state . below jenkinsfile configuration:- node ('windows') { stage 'checkout' checkout scm stage 'build' bat '"path msbuild.exe" projectfile.proj' bat '"path git.exe" add mstest/output.trx' bat '"path git.exe" commit -am "adding test results"' bat '"path git.exe" push origin develop' } the call checkout scm checks out specific commit (latest commit on branch time jenkinsfile loaded) , results in detached head state. if want checkout specific branch , later commit changes it, use git directl

java - Differences between View create with xml - View create with code -

there difference when i'm trying add programmatically relativelayout , when use directly xml view. if copy paste several relativelayout in container_tabs works.. and when try inflate relativelayout file (exactly same container_tabs) result different , doesn't works. how fill view programmatically @bindview(r.id.container_tabs) protected linearlayout mlinearlayoutcontainertabs; private list<custombookingtab> mbookingtabslist = new arraylist<>(); private void initcustombuttonstabs() { mbookingtabslist.add(new custombookingtab(this, enumbookingtab.booking_tab_calendar, r.drawable.ic_calendar_white)); mbookingtabslist.add(new custombookingtab(this, enumbookingtab.booking_tab_time, r.drawable.ic_clock)); (int = 0; < mbookingtabslist.size(); i++) { mlinearlayoutcontainertabs.addview(mbookingtabslist.get(i).getrelativelayoutbookingtab(), i); } } how inflate view xml file (custombookingtab cons

javascript - Unit test on Angularjs with Jasmine and Webpack, error Unknown provider -

i ask how solve error won't let me write test. angularjs factory (service.es6) test: import rx 'rxjs/rx' var themiddlemodule = angular.module('themiddlemodule', []) themiddlemodule.factory('themiddleop', function ($http){ var api = 'someurl' var themiddleop = {} themiddleop.getssoidfromservice = () => { return rx.observable.frompromise( $http({ method: 'get', url: api }) ) } return themiddleop }) this test webpack configuration: var jasminewebpackplugin = require('jasmine-webpack-plugin'); module.exports = { entry: ['./app/scripts/test/service.js'], plugins: [new jasminewebpackplugin()], output: { path: __dirname, filename: 'test.js' }, module: { loaders: [ { test: /\.es6$/, exclude: /(node_modules|bower_components)/, loader: 'babel?presets[]=es2015!eslint-loader' },

c# - How to convert Icon into a base64 string? -

icon icon = icon.extractassociatedicon(_path); how convert above icon base64 string in c# ? first have raw bytes of icon: var icon = icon.extractassociatedicon(_path); byte[] bytes; using (var ms = new memorystream()) { icon.save(ms); return ms.toarray(); } then can convert bytes base64 string: var base64string = convert.tobase64string(bytes);

How to write HTML code in $rootScope variable using angularJS? -

i trying change value of label in html page on event,is possible insert html code variable? the html code like: <div ng-controller="welcomecon" ><label>{{ welcomemsg }}</label></div> and in controller in script: $rootscope.welcomemsg="you not logged in,please log in or register" is there way make words log in , register links? if no, happy if guide me in alternative. thanks you can other answers suggest using $sce service or ng-bind-html , object approach because links won't change, why defining html in code instead of in html. what want this: <ul class="my-menu"> <li ng-if="$root.loggedin"> <a href="url/to/logout">logout</a> </li> <li ng-if="!$root.loggedin"> not logged in, please <a href="login">login</a> or <a href="register">register</a> </li> &l

android - getExtras NullPointerException -

this question has answer here: what nullpointerexception, , how fix it? 12 answers app crash nullpointerexception in line int position = i.getextras().getint("id"); problem ? tell me please ! i build on tutorial http://seegatesite.com/android-tutorial-display-image-to-android-gridview-from-url-using-picasso @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final gridview gridview = (gridview) findviewbyid(r.id.gridview); gridview.setadapter(new imageadapter(this)); gridview.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> parent, view v, int position, long id) { intent = new intent(getapplicationcontext(), fullimageactivity.class);

java - XPosed: Hooking a function overridden in an enum -

say have enum class defined (adapted java documentation ) package com.example.planetexample; public enum planet { mercury (3.303e+23, 2.4397e6){ public double surfacegravity() { return 42; } }, venus (4.869e+24, 6.0518e6); private final double mass; // in kilograms private final double radius; // in meters planet(double mass, double radius) { this.mass = mass; this.radius = radius; } // universal gravitational constant (m3 kg-1 s-2) public static final double g = 6.67300e-11; double surfacegravity() { return g * mass / (radius * radius); } } now, want use xposed hook surfacegravity function has been overriden mercury (and not general 1 defined below). how can access function? i tried findandhookmethod("com.example.planetexample.planet", lpparam.classloader, "surfacegravity", [etc]) , 1 hooks general surfacegravity defined planet class, , not 1 defined

c++ - User-defined conversion operator to inaccessible base class -

why not allow user-defined conversion base class (or reference it) when base inacessible: protected or private ? when there class d , public base b , there implicit rule bind references b ( b& or b&& , possibly cv-qualified) objects of class d , user-defined conversion b& doesn't make sense. when base class protected or private , implicit rule not applicable anymore. why not allow use user-defined conversion b& (or const b& or b&& etc.)? it allowed, nothing in standard prohibits this. states such conversion operator never used. [class.conv.fct]/1 : a conversion function never used convert (possibly cv-qualified) object (possibly cv-qualified) same object type (or reference it), (possibly cv-qualified) base class of type (or reference it), or (possibly cv-qualified) void. overload resolution prefer base class constructor on conversion operator, , conversion operator never called, unnecessary implicit conversions. acces

php - Define Silex routes as it goes -

is possible define silex routes route definition goes. instance, define following routes depending on previous routes are: /a/{user}/{app_name}/list/ -> /a/{user}/{app_name}/list/{id}/ /a/{user}/{app_name}/add/ -> /a/{user}/{app_name}/add/success/ /a/{user}/{app_name}/help/ -> no sub route here 5th route should {id} when 4th list or success when 4th add or nothing when 4th help . don't know how in silex: $app -> get('/a/{user}/{app_name}/{action}/{sub}/', function (silex\application $app, $user, $app_name, $action, $sub) { ... }); which doesn't work of them. is there way this: $app -> get('/a/{user}/{app_name}/{action}/', function (silex\application $app, $user, $app_name, $action) { if ($action == 'list') { $app -> get('/a/{user}/{app_name}/{action}/{id}', function (silex\application $app, $user, $app_name, $action, $id) { ... }); } elseif ($action == 'add'

java - Can I use CDI to inject a resource into a JAX-RS Application/ResourceConfig? -

i'd resourceconfig have access database configuration. i've tried this: @applicationpath("/api") public class applicationconfig extends resourceconfig { @persistencecontext(unitname = "mypu") private entitymanager em; @inject private myejb myejb; @postconstruct public void init() { // em , myejb both null ... } but neither entitymanager, not ejb, injected (both null) is there special way in jax-rs? note: i'm able inject resources path-annotated class fine. i'm having trouble doing in actual applicationpath-annotated class.

c# - Retrieve Injection Members from Unity Container -

i doing dependency injection microsoft.practices.unity. for classes, using injection factories this: container.registertype<icar>(new injectionfactory(o => {return new car("toyota")})); later in code, want able find out if have used or not injection factory given interface. i see can regitrations in container.registrations, these objects not give me injection members. a possible way them implement wrapper around iunitycontainer, records injection members. but maybe there better way directly leverages unity api ? there way these injection members directly unity container ? as suggested in comment (but not unity). copied project. public void configureservices(iservicecollection services) { var lgr = logmanager.getcurrentclasslogger(); var logger = new nloglogger(lgr); services.addsingleton<ilogger>(provider => logger); services.addsingleton<imachineconfigfactory, machineconfigfactory>();

c# - PrintDocument just prints some part of my JPG file -

i created application allows users print multiple jpg files. send print request directly, this: if (existfile == true) { printersettings a=new printersettings(); printdocument pd = new printdocument(); ienumerable<papersize> size = a.papersizes.cast<papersize>(); papersize a4 = size.first<papersize>(i => i.kind == paperkind.a4); pd.defaultpagesettings.landscape = true; pd.defaultpagesettings.papersize = a4; pd.printpage += printpage; pd.print(); } and print function : private void printpage(object o, printpageeventargs e) { system.drawing.image img = system.drawing.image.fromfile(currentaddress); point loc = new point(100, 100); e.graphics.drawimage(img, loc); } but code prints part of image, not of .i want pr

javascript - Callback on recursive function -

the following code used fetch .zip file our web application. file generated closing application safely zipping, sending download. var dl = function() { request({ method: 'get', uri: 'some_url', headers: { 'user-agent': 'scripted-download' }, encoding: null, jar: true }, function(err, res, body) { if (err) throw(err) if (res.headers['content-type'] === 'application/zip;charset=utf-8') { process.stdout.write('\rdownloading file ..') var id = uuid.v4() , file = path.resolve(__dirname, '../../' + id + '.zip') fs.writefile(file, body, function(err) { if (err) throw(err) process.stdout.write('\rfile downloaded ' + id + '.zip') process.exit(0) }) } else { process.stdout.write('\rawaiting

javascript - AngularJS, stop the a href? -

i using angularjs. want realize type onediv button, hide `onediv.' then, google every time. don't want go google. how stop "a href"? the question named "how preventdefault on anchor tags?" question. in question, use angularjs, new question due use angularjs. <style> .content { width: 500px; height: 400px; background-color: green; } .one { width: 100px; height: 100px; background-color: black; } .two { width: 100px; height: 100px; background-color: yellow; } </style> <body ng-app="app" ng-controller="controller"> <div class="content"> <div ng-show="!onehide" class="one"> <a href="http://www.google.com"> <button ng-click="oneclickfu

javascript - Why Buffer copy prints me some garbage value? -

i new node.js, i reading on node.js buffers. i stumbled on buffer.copy method. wrote code follows, var bufferone = new buffer("this china"); var buffertwo = new buffer(20), starttarget = 0, sourcestart = 8, sourceend = 0; var bufferlength = bufferone.length; sourceend = bufferlength; console.log("buffer length "+bufferlength); bufferone.copy(buffertwo,starttarget,sourcestart,sourceend); console.log("buffer1 "+bufferone.tostring()); console.log("buffer2 "+buffertwo.tostring()); the output follows, buffer length 13 buffer1 china buffer2 china but prints garbage output after "china", follows, buffer length 13 buffer1 china buffer2 china���*� sometimes, buffer length 13 buffer1 china buffer2 china��� can please tell me whats going on ? the length of buffertwo 20, you're copying 13 bytes. remaining 7 bytes contain semi-random data. documented here : passing number first argument buf

c# - populate objectlistview using datatable list -

im work objectlistview , trouble populate data database list , here code static internal list<birthday> getbirthdays() { if (birthday.alldata.count == 0) birthday.alldata = birthday.initializedata(); return birthday.alldata; } static private list<birthday> alldata = new list<birthday>(); static private list<birthday> initializedata() { koneksi con = new koneksi(); var qcmd = "select nm, sex, replace(hp, ' ', '') hp, datediff(year, left(tgllhr, 4), '2016') umur, alamat " + "from mcif " + "where right(tgllhr, 4) = 20160615"; con.sqlquery(qcmd); list<birthday> birthdaylist = new list<birthday>(); using (datatable dt = con.queryex()) { birthdaylist = (from datarow dr in dt.rows select new birthday()

Two UserDetailsServices in Spring, Java config -

i trying configure 2 userdetailsservice s authentication of 2 different user groups , came across this post . however, using xml configuration, how accomplish same using java configuration? as far know, http element configured overriding configure(httpsecurity http) method, how configure multiple http elements? i know in many scenarios, sufficient have 1 userdetailsmanager manages 2 user database tables, curious how other solution in case decide it. i not see reason using 2 userdetails implementations, saying need authenticate 2 different user groups. suggest @ http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#authorization , think give lot of pointers should go there. in need upon authentication in system know logged in user role , define it. 2 ways indeed 1 via xml second annotation based in @configuration java class specifics laid out there. read above link posted , should able see spring offers , in need actually. would take lot of

osx - INSTALL_FAILED_INVALID_URI when launching app in android studio - Mac OS X -

Image
in android studio when launching app in either emulator or device,getting install_failed_invalid_uri , in mac os x. detail error message below: 10/26 15:18:56: launching froiosocial $ adb push /users/saad/documents/android-projects/fcrepo/fcchat/frenclubsocial/build/outputs/apk/frenclubsocial-debug.apk /data/local/tmp/com.frenclub.fcsocial $ adb shell pm install :app:assemblerelease -r "/data/local/tmp/com.frenclub.fcsocial" pkg: :app:assemblerelease ver: -r failure [install_failed_invalid_uri] $ adb shell pm uninstall com.frenclub.fcsocial delete_failed_internal_error error while installing apk any solution or workaround this?

tensorflow - Using height, width information stored in a TFRecords file to set shape of a Tensor -

i have converted directory of images , labels tfrecords file, feature maps include image_raw , label , height , width , depth . function follows: def convert_to_tfrecords(data_samples, filename): def _int64_feature(value): return tf.train.feature(int64_list=tf.train.int64list(value=[value])) def _bytes_feature(value): return tf.train.feature(bytes_list=tf.train.byteslist(value=[value])) writer = tf.python_io.tfrecordwriter(filename) fname, lb in data_samples: im = cv2.imread(fname, cv2.imread_unchanged) image_raw = im.tostring() feats = tf.train.features( feature = { 'image_raw': _bytes_feature(image_raw), 'label': _int64_feature(int(lb)), 'height': _int64_feature(im.shape[0]), 'width': _int64_feature(im.shape[1]), 'depth': _int64_feature(im.shape[2]) } )

haskell - Create hackage package that can be installed with stack -

when running stack sdist in project directory, stack.yaml file isn't included in tarball (this seems be expected ). consequently, when upload tarball hackage, stack install mypackage complains missing dependencies ( extra-deps ) specified in stack.yaml file. $ stack install pandoc-placetable run outside project, using implicit global project config using resolver: lts-5.17 implicit global project's config file: ~/.stack/global-project/stack.yaml while constructing buildplan following exceptions encountered: -- failure when adding dependencies: spreadsheet: needed (>=0.1.3 && <0.1.4), not present in build plan (latest applicable 0.1.3.4) needed package: pandoc-placetable-0.4 -- while attempting add dependency, not find package spreadsheet in known packages recommended action: try adding following extra-deps in /users/maurobieg/.stack/global-project/stack.yaml - spreadsheet-0.1.3.4 or what's recommended way make hackage pack

Construct Pandas Panel from 2D structured NumPy array -

Image
i have 2d numpy array of structs: arr = np.zeros((3,5), [('x',int), ('y',float)]) that is: array([[(0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0)], [(0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0)], [(0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0)]], dtype=[('x', '<i8'), ('y', '<f8')]) i want create pandas panel it. tried obvious: pd.panel(arr) valueerror: number of dimensions required 3, number of dimensions of ndarray given 2 then discovered hideous pile: pd.panel(dict(enumerate(pd.dataframe(a) in arr))) it produces: <class 'pandas.core.panel.panel'> dimensions: 3 (items) x 5 (major_axis) x 2 (minor_axis) items axis: 0 2 major_axis axis: 0 4 minor_axis axis: x y this "works" inefficient , eyesore. how such panels meant constructed? edit: submitted issue here: https://github.com/pandas-dev/pandas/issues/14511 you need provide 3-d array cor

reactjs - How to make simple mobx reaction work in sub component -

i miss in mobx observables , reactions. prepared 2 examples, 1 of them works, other not, don't understand why. example 1 (does not work): @observer class alert1 extends component { constructor(props) { super(props); this.r2 = reaction( () => this.props.v1, v => console.log("alert1 reaction trigger",v) ); } render() { return null; } } @observer class main extends component { @observable v1 = false; render() { return ( <div> <alert1 v1={this.v1} /> <button onclick={e=>this.v1=!this.v1}>switch</button> </div> ); } } in example 1 send observable variable in props , create reaction in alert1 component, not trigger. example 2 (works): @observer class alert2 extends component { constructor(props) { super(props); this.r2 = reaction( () => this.props.someobj.v1, v => console.log("alert2 reaction trigger",v) );