Posts

Showing posts from April, 2015

python - whitespace is not allowed between stringprefix and bytesprefix? -

i not able understand statement in python documentation. "whitespace not allowed between stringprefix or bytesprefix , rest of literal." documentation link a string or bytes prefix u or b precedes literal specify 1 want. sentence saying cannot have whitespace in between prefix , literal itself. in other words: u "not allowed" b 'still not allowed' and u'good' b"also good"

django - How to mock an object's function which writes to the same object in python? -

class employee: address = models.foreignkey(address) def setzipcode(self, zipcode): setattr(self, 'zipcode', zipcode) def set_address_property(self, target_property, value): try: setattr(self.address, target_property, value) self.address.save() except objectdoesnotexist: # todo. figure out here print 'cannot save' return def get_address_property(self, target_property, default): try: return getattr(self.address, target_property) except objectdoesnotexist: return default @property def zipcode(self): return self.get_address_property('zipcode', none) @zipcode.setter def zipcode(self, value): self.set_address_property('zipcode', value) def functiontotest(employee): # blah blah blah... employee.setzipcode(123) def testfunctiontotest(self): employee = magicmock() employee.address.zipcode...

android - openfl - audio doesn't work on cpp target -

i've added <assets path="assets/audio" rename="audio" /> application.xml file. and load "mp3" files in audio folder calling assets.getsound("2_3_1.mp3"); , , use .play(); method on (sound) object play file. the sounds play in flash target. don't play on cpp targets. i'm targeting android (cpp) , ios (c#) targets app. when debugging windows (cpp) target, shows these errors in console: sound.hx:99: error: not load "audio/2_3_1.mp3" error opening sound file, unsupported type. error opening sound data done(0) i believe mp3 isn't supported on windows , other targets due decision related licensing costs format. the flash target exception since adobe has agreement allows developers use format without paying royalties. discussed more here: http://www.openfl.org/blog/2013/09/18/to-mp3-or-not-to-mp3/ a workaround use .ogg format non-flash platforms audio, , include audio files each platform spe...

c++ - error: invalid types for array subscripts -

i trying print matrix on screen.my code: #include <vector> #include <algorithm> #include <cmath> #include <eigen2/eigen/core> int main() { std::vector<int> items = {1,2,3,4,5,6,7,8,9,10,11,12,18}; // generate similarity matrix unsigned int size = items.size(); eigen::matrixxd m = eigen::matrixxd::zero(size,size); (unsigned int i=0; < size; i++) { (unsigned int j=0; j < size; j++) { // generate similarity int d = items[i] - items[j]; int similarity = exp(-d*d / 100); m(i,j) = similarity; m(j,i) = similarity; } } (unsigned int i=0; < size; i++) { (unsigned int j=0; j < size; j++) { std::cout << m[i][j]; } std::cout << std::endl; } return 0; } when compile got this: pex.cpp: in function ‘int main()’: pex.cpp:25:31: error: invalid types ‘eigen::ei_traits<eigen::matrix<double...

Picasso on custom ListView appear out of memory -

i'm using picasso load pictures assets floder have 900 pictures. when slided listview,the logcat appear out of memory. my custom listrow places_layout.xml: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <imageview android:id="@+id/iv_test" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true"/> </relativelayout> my custom adapter getview code public view getview(int position, view convertview, viewgroup parent) { viewholder holder=null; if(convertview==null){ holder=new viewholder(); convertview= layoutinflater.from(mcontext).inflate(r.layout.list_item,null); holder.mimageview=(imageview)convertview.findviewbyid(r...

printing - Setting Zebra Printer Installation To Vertical -

im printing receipts zebra 2030 printer , need vertical printing. im using rawprinterhelper class microsoft print, question is, how send the, u1 setvar "device.orientation" "value" , command printer. thanks advance help. the ttp 2030 not zpl or cpcl printer , doesn't have u1 commands. if want print text in vertical can use esc o n1 n1=0 portrait, n1=1 landscape. may better off using windows driver , creating bitmap of receipt , print printer instead of relying on text capabilities of printer.

App crashes with 'NoClassDefFoundError' only on Android 4.x -

i getting series of type or error while running project: https://github.com/evercam/evercam-play-android on lower android versions (tested on htc 1 x - 4.1.1 && galaxy s3 - 4.3 simulators , both crashes). works on android 5. seems of crashes happening when creating runnable object, couldn't figure out reason. i've resolved few other similar crashes removing runnables new error come up. any idea going wrong here? lot! i using android studio 1.3 , here logs latest error: 08-05 05:28:51.071 3080-3080/? e/dalvikvm﹕ not find class 'io.evercam.androidapp.custom.cameralayout$3', referenced method io.evercam.androidapp.custom.cameralayout.<init> 08-05 05:28:51.071 3080-3080/? w/dalvikvm﹕ vfy: unable resolve new-instance 6631 (lio/evercam/androidapp/custom/cameralayout$3;) in lio/evercam/androidapp/custom/cameralayout; 08-05 05:28:51.071 3080-3080/? d/dalvikvm﹕ vfy: replacing opcode 0x22 @ 0x0019 08-05 05:28:51.071 3080-3080/? w/dalvikvm﹕ v...

Java Swing moving java.awt.Shape -

we have application displays kind of map. swing application draw set of java.awt.shape s java.awt.graphics2d#draw(shape) , fine. and now, have extend app allow our users editing (moving shapes on) map. there no translate or move methods on java.awt.shape s. can't change position ( java.awt.point ) of shape. i have tried override java.awt.shape#getpathiterator in order apply translation matches shape position. it's tricky because method accept transformation have merge , because correct pathiterator should start @ (0, 0) because relative shape position. and anyway, won't work because seems graphics2d don't use method draw java.awt.shape . so now, i'm feeling bit lost. solution let shapes drawn themselves, have rewrite part of application. that's not problem have know best solution : find trick move java.awt.shape seems best solution can't figure how that. change app have self drawing shapes nice have compute myslef contains , other ...

angularjs - javascript does not accept 0 before any number -

Image
this question has answer here: leading 0 in javascript 3 answers var value = 05000; var addvalue = 1; if calculate value + addvalue , it's calculating wrong value var result = value + addvalue;// it's return value 20481 see below image quick watch result but if give value 5000( without 0 before value), it's calculate correct . why? putting 0 before number makes octal number literal. interpreted in base 8. for reason - not put leading zeros before numbers. doesn't intend . if ran code in strict mode , you'd have gotten error instead: uncaught syntaxerror: octal literals not allowed in strict mode.

java - How can i move in string array item to the end of the array? -

ipaddresses = ipaddresses.generateips(); the array contain 56 items. want item in index 2 remove end of array. content in index 2 in index 56. array size not change order of items. item 2 in place 56. think index 3 index 2. you can use system.arraycopy . similar happens when remove element arraylist , in case moving removed element end : e element = elementdata[index]; // element removed int nummoved = elementdata.length - index - 1; // move elements follow moved element if (nummoved > 0) system.arraycopy(elementdata, index+1, elementdata, index, nummoved); // put moved element @ end elementdata[elementdata.length - 1] = element; here elementdata array , move element @ index position end.

resize - JavaFX- scaling the inner elements of a Pane -

when increase window, inner elements stay @ same size. i want when increase window, elements larger/scale main.fxml: <?xml version="1.0" encoding="utf-8"?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <anchorpane cachehint="scale_and_rotate" focustraversable="true" prefheight="600.0" prefwidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.controller"> <children> <tableview fx:id="finaltable" layoutx="27.0" layouty="358.0" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" prefheight="190.0" prefwidth="766.0" /> <label layoutx="27.0" layouty="21.0" prefheight="25.0" prefwidth="149.0" text=" quell-datei" /> <tabl...

java - Spring declaration for interfaces with the same implementation -

i have problem spring. i have 2 separate interfaces, findunconditionaldiscountvaluesstrategy , findconditionaldiscountvaluesstrategy. these interfaces implemented in same class mmfgfindpricingwithcurrentpricefactorystrategy. this declared in spring configuration file this: <alias name="mmfgfindpricingwithcurrentpricefactorystrategy" alias="currentfactoryfindpricingstrategy"/> <bean id="mmfgfindpricingwithcurrentpricefactorystrategy" class="com.mmfg.mmfgacceleratorcore.order.strategies.calculation.impl.mmfgfindpricingwithcurrentpricefactorystrategy" parent="abstractbusinessservice"> <property name="findpricingwithcurrentpricefactorystrategy" ref="original-currentfactoryfindpricingstrategy"/> <property name="configurationservice" ref="configurationservice"/> <property name="mmfgsessionservice" ref="mmfgsessionservice"/> <...

android - Google Play APK upload failure with uses-permission maxSdkVersion -

Image
we have app following manifest settings: <uses-permission android:name="android.permission.get_accounts" android:maxsdkversion="15" /> <uses-sdk android:minsdkversion="14" android:targetsdkversion="20"/> the get_accounts permission used required push notifications, no longer required since api 16 (at least our understanding), used maxsdkversion option this. we've uploaded apps these settings awhile, , may 2015, today (7/23/2015) we're getting error developer console: we use google play services, , have guess change culprit. any advice? the problem android:maxsdkversion attribute not added <uses-permission> element until api 19. this means if set android:maxsdkversion below 18 aren't going behavior desire- first version of android can interpret value 19.

migrating a Rails 3.2 app to strong parameters and getting this error -

i have rails 3.2. app , getting error on following scope: class location < activerecord::base include activemodel::forbiddenattributesprotection scope :active, -> { where(is_deleted: false) } with view fragment: <% @location.order('updated_at desc').active.where('menu_event_category_id ?',nil).each_with_index |x, idx| %> the error is: actionview::template::error (undefined method `active' #<class:0x0000011da42c20>): why getting error , how fix it?. this has nothing strong_parameters. need use scope: <% location.active.order('updated_at desc').where('menu_event_category_id ?',nil).each_with_index |x, idx| %> or.. <% @location.active.order('updated_at desc').where('menu_event_category_id ?',nil).each_with_index |x, idx| %> further, should set @locations in controller: @location = location.active.where('menu_event_category_id ?',nil)

ruby - add child screen to parent screen with rmq -

Image
in on_load method of homescreen class want rmq.append(loginscreen, :login_form). loginscreen inherits pm::formscreen. since not implementing initwithframe in loginscreen app crashes. this has been done in http://jamonholmgren.com/getting-started-with-motionkit-and-promotion/ motion kit. how can achieve same rmq? you're going need create instance of screen , add view. def on_load @login_screen = loginscreen.new addchildviewcontroller @login_screen rmq.append(uiimageview, :logo) rmq.append(@login_screen.view, :login_form) end the addchildviewcontroller ensures lifecycle events called on loginscreen .

reference - ROS Arduino Bridge not compiling -

i downloaded package rosarduinobridge , examples come packages don't work in arduino. the error keep getting is: rosarduinobridge.cpp.o: in function 'runcommand()': /usr/share/arduino/rosarduinobridge.ino:150: undefined reference 'readencoder(int)' /usr/share/arduino/rosarduinobridge.ino:179: undefined reference 'readencoder(int)' /usr/share/arduino/rosarduinobridge.ino:234: undefined reference 'initmotorcontroller()' collect2: error: ld returned 1 exit status i'm confused on why error showing since haven't changed code @ all.

cakephp - cakephp3 iterate hasMany associated entities -

we using new cakephp orm , have issues understanding way new orm works when dealing hasmany associations. e.g. have table called "users" has hasmany relation table "usersabsences". definition , handling works fine. have defined table-objects , entities. $this->addassociations([ 'hasmany' => [ 'usersabsences' => [ 'classname' => 'usersabsences', 'propertyname' => 'absences', 'foreignkey' => 'user_id' ] ]); within our userstable we've created custom method retrieves details 1 user, using querybuilders ->contain method fetch hasmany-associated "usersabsences" defined property "absence". we're setting view-variable $user work entity in template: works fine. ... $users->contain(['usersabsences',...]); ... now part puzzles me: object-type of $user "userentity". when iterate through $user->abs...

.net 4.0 - Write a "partial" XAML TypeConverter that can convert to/from only a specific sub-type in a hierarchy -

given base class color @ least 2 sub-types, rgbcolor , cmykcolor : abstract partial class color { } sealed class rgbcolor : color { public byte r { get; set; } public byte g { get; set; } public byte b { get; set; } } sealed class cmykcolor : color { public byte c { get; set; } public byte m { get; set; } public byte y { get; set; } public byte k { get; set; } } and type going (de-) serialize to/from xaml .net 4's system.xaml.xamlservices : class { public color color { get; set; } } i able abbreviate rgb colors on xaml side this: <something color="#010203" /> instead of having type out: <something> <something.color> <rgbcolor r="1" g="2" b="3" /> </something.color> </something> this done typeconverter . (find current implementation @ end of question.) problem don't need, nor want, special abbreviation syntax other sub-types of color , such ...

javascript - Detect if page is scrolled on document load -

i'm using scrolltop detect if users scrolls fadein element: $(document).ready(function() { // scroll top $(window).scroll(function() { if ($(this).scrolltop() >= 700) { // if page scrolled more 700px $('#return-to-top').fadein(200); } else { $('#return-to-top').fadeout(200); } }); }); it works if user loads page , scroll, if user below 700px , reload or goes same page element doesn't fadein automatically on document load. seems not detecting page scrolled. any idea problem code? just test when document ready it's better create function function checkscroll(){ if ($(window).scrolltop() >= 700) { $('#return-to-top').fadein(200); } else { $('#return-to-top').fadeout(200); } } $(document).ready(function() { checkscroll(); $(window).scroll(checkscroll); });

android - Error message when starting App -

i have done updates code , went run on phone testing when error message pops stating "unfortunately,campfire songbook has stopped working". below logcat menus if can tell me problem great. 07-23 21:18:26.782 2787-2787/com.songbook.noo.sttrfsongbook e/androidruntime﹕ fatal exception: main process: com.songbook.noo.sttrfsongbook, pid: 2787 java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.searchview.setsearchableinfo(android.app.searchableinfo)' on null object reference @ com.songbook.noo.sttrfsongbook.mainactivity.oncreateoptionsmenu(mainactivity.java:39) @ android.app.activity.oncreatepanelmenu(activity.java:2820) @ android.support.v4.app.fragmentactivity.oncreatepanelmenu(fragmentactivity.java:277) @ android.support.v7.internal.view.windowcallbackwrapper.oncreatepanelmenu(windowcallbackwrapper.java:84) @ android.support.v7.app.appcomp...

Way for moving stored procedure from Firebird to SQL Server -

i have working sp on firebird , can'not find way translate code ms sql server sp here code: i have 1 table data from. 1 fields called "iznos" data summary , 1 field recognite diference summary category create or alter procedure some_procedure ( b_date date, e_date date) returns( dat date, value1 decimal(18,2), value2 decimal(18,2), value3 (18,2)) begin select gk.date gk gk.date between :b_date , :e_date group 1 :dat begin /* value 1 */ select sum(iznos) gk gk.category=1 , gk.datum=:dat :value1; /* value 2 */ select sum(iznos) gk gk.category=2 , gk.datum=:dat :value2; /* value 3 */ select sum(iznos) gk gk.category=3 , gk.datum=:dat :value3; suspend; end end you can solve using pivot : select datum, [1] value1, [2] value2, [3] ...

swing - Java progress bar not progressing, though the file gets downloaded? -

i have visited this , , several other pages on forum , went through swing on oracle docs. of code doesn't work progressbar, if emulate codes line line , few adjustment in code. don't know why not working! feeling pity on myself can't make work. i know there issue edt, but, on myself can't figure out. think code working on worker threads updating progress bar. also, once when code downloads, again if reset fields , selected items, subsequent calls download blocked. file created,but not downloaded. size remains 0. please explain why? i created swingworker instance , called updation of fileprogressbar doinbackground() method, , calling done(). but, didn't work. file gets downloaded successfully, but, progress bar doesn't move inch!!! public class client{ public static void main(string[] args) { swingutilities.invokelater(new runnable() { @override public void run() { new makegui().setvisible(true); } }); ...

Android app fetching Joomla website with DB -

my client has joomla website plugins (mosets tree , jse events) lists business events. wants android app developed fetch these info. immidiately came mind, create php scripts query database , call scripts app. in app, display information collected. another idea occurred me, enable rss feed , read rss feed. is approach above right approach? there different way or standard way when developing apps fetch information joomla website backend? please note website mobile friendly requirement create app part of website. pointers helpful building 1 or more php scripts query db , returns data faster , simpler solution. if want build more robust / compatible solution, may extend set of php scripts full blown rest api application. in case take frameworks slim or silex @ this. there more complete , elegant solutions overkill needs. edit: why query directly database in theory, seems better not access directly database, , interact mosets tree component instead; because ...

c# - Eager Loading with Entity Framework, LINQ -

i working on asp.net mvc project. using ef code-first approach. have 3 classes, are: public class { public int aid {get;set;} public string a1 {get;set} public string a2 {get;set} public virtual list<b> bs {get;set;} } public class b { public int bid {get;set;} public string b1 {get;set} public string b2 {get;set} public aid {get;set} public virtual a {get;set} public virtual list<c> cs {get;set;} } public class c { public int cid {get;set;} public string c1 {get;set} public string c2 {get;set} public bid {get;set} public virtual b b {get;set} } i want select c1 properties of class c based on class b a1 = 4 . tried using: var result = db.c.select(x=>x.c1).include(x=>b).where(x=>x.a.equals(4)) i confused , don't know how execute linq query. not sure whether continue using eager loading or fall on else. please can guru me out please? try this: var result = db.c .where(...

javascript - How to find if message is already printed to the console -

assume run javascript project in browser , i'm inside specific module, can check whether already message printed console ? i.e. read message console... for example i'm inside js.file inside function want check if printed hello world in console. jthanto's answer gave me idea. don't think it's practice, if must, can define own console class: var myconsole = function(oldconsole) { // store messages ever logged this.log = []; // keep pointer oldconsole this.oldconsole = oldconsole; } myconsole.prototype.log = function(args) { // push message log this.log.push(array.prototype.join.call(args)); // call oldconsole.log display message on console if (this.oldconsole) this.oldconsole.log.apply(this.oldconsole, args); } // todo: implement other console methods in fashion (apply console api methods) myconsole.prototype.<method> = function(args) { if (this.oldconsole) this.oldconsole.<method>.app...

javascript - how to read a text file and display it in html (angularjs) -

i using angularjs , have terms of use document in text file render html. recommendations on how read text file , display using html or display user? thanks simplest way using ng-include . if need use line breaks in text file within view wrap in <pre> tag <h3>terms</h3> <ng-include src="'terms.txt'"></ng-include> or <pre ng-include src="'terms.txt'"></pre> demo

ios - Swift 2.0 'unexpected trailing closure' error with lazy var assignment -

i'm converting project swift 2.0 , keep coming across error everywhere i'm using lazy var. code works in 1.2 breaks in 2.0: lazy private var placeholderimage = uiimage(named: "theimage") but, code generates 'unexpected trailing closure' error in 2.0. following xcode's suggestions fix error, come out with: lazy private var placeholderimage: uiimage = uiimage(named: "theimage")! this compiles , seems work, don't understand why change necessary in first place. in apple developer forum apple staff ( chrislattner ) said: yep, known bug (and reported) type inference isn't working lazy properties. adding explicit type annotation best way work around now. the issue discussed in this google group

Is there a way to get the system configuration files folder within a Perl script? -

tried searching number of ways , have not yet found answer ... background i working on legacy perl application has lot of hard-coded values in should configurable depending on app installed. so, obviously, looking externalize these values configuration file may located in 1 of few "expected" locations. is, using traditional approach of checking configuration file in: the current working directory, the user's home directory (or sub-folder therein), and the system configuration directory (or sub-folder therein) where first 1 found wins. where at perused cpan site bit , found config::any package, looks promising. can give list of files use: use config::any; $config = config::any->load_files( { files => [qw(sample.conf /home/william/.config/sample.conf /etc/sample.conf)], use_ext => 0, }); this check existence of each of these files, and, if found, load contents array reference of hash references. not bad, still have h...

java - Resource leak: workbook is never closed warning when using Apache.POI XSSFWorkbook -

so, using apache poi in order parse excel file database. initializing xssfworkbook follows: xssfworkbook workbook = new xssfworkbook(fip); then proceed method. workbook.close() not available method close workbook afterwards. ideas of how can let garbage collection take workbook after task finished? i had issue, , making little sense. in end tracked issue down ide (netbeans) picking earlier version of poi libraries (v3.8) didn't have "close" method. check class path , duplicate imports of different versions of poi libraries.

escaping - How to write a escape sequence for "(" and ")" in java -

i have query using select concat(jo.title, "(" ,ccp.name,")"), for result .my expected result java developer(morgan stanley) way .so how can write in java file .for using +" concat(jo.title ," + "\"(\""+",ccp.name )"+"\")\""+"\") ," i doing right bracket ,but not coming ,please you can try " concat(jo.title ," + "\"(\""+",ccp.name) ,"

javascript - How does a Node.js server process requests? -

let's assume have following code. i'm using expressjs, don't think server part different vanilla node.js. var express=require('express'); var settings=json.parse(fs.readfilesync('settings.json','utf8')); // run once (when server starts)? app.get('*',function(req,res){ res.write(fs.readfilesync('index.html')); // block other requests? settimeout(function(){ someslowsynctask(); // block other requests? },1000); res.end(); }); in example above, first readfilesync run once when server starts, or run each time server receives request? for second readfilesync , prevent node processing other requests? in other words, other requests have wait until readfilesync finishes before node processes them? edit: added settimeout , someslowsynctask . block other requests? you should avoid synchronous methods on server. available convenience single user utility scripts. the first 1 runs once since synchronous ...

cmd - Using a batch file to find text in a file, then cleaning it up, saving to a file and a variable -

ok have searched , searched days , cant find works. if missed sorry. my problem: have text file source code web page. goal search text file , find. "below lines around want" <b>public</b> </a> </td> <td></td> <td class="b"> 705330 </td> <tr> <tr> <td> (there lot more source code other numbers kind of same way public unique. below unique(not numbers) right thought more matched better) <td class="b"> 705330 </td> i trying numbers(so have remove numbers), number change rest doesn't. want save numbers file .txt(just numbers) (first line , on writes previous save) , assigns variable can compare previous run commands. like comparing new(variable) old .txt , doing something. i got rest of down, cant figure out. ive tried find, findstr , every forum trying fine work me. couldn't searched string variable echoed 30 lines or did nothing. i appreciate help, in ad...

How to fill page width of tables with css -

Image
i have table separated , formated using css. trying whole table align same width. black 2 out of 5 in row fill width each of 3 table same width. i recommend use the <table width="100%"></table> attribute table tag.

javascript - Angular.js: change internal view of a template -

i have html pages: dashboard.html <div class="wrapper"> <div class="box"> <div class="row row-offcanvas row-offcanvas-left"> <dashboard-sidebar></dashboard-sidebar> <div class="column col-sm-10 col-xs-11" id="main"> <div class="padding" ui-view="main-view"></div> </div> </div> </div> </div> with change template on "main-view" element: angular.module("gecodashboard", ["gecodashboardgui", "gecodashboardhome", "gecodashboardblog", "ui.router"]) .config(function ($stateprovider, $urlrouterprovider) { $urlrouterprovider.otherwise('/'); $stateprovider .state('home', { url: '/', views: { 'm...

java - Spring boot application in netbeans -

i installed netbeans 8.0.2, installed gradle plugin, , created new gradle empty project. copied *.java , *.gradle files https://github.com/spring-guides/gs-spring-boot.git . when call gradle build - ok, jar created , works. build netbeans menu works fine too. but in java editor of netbeans lines contains gradle dependencies marked incorrect. example imports this import org.springframework.boot.springapplication; are marked not exists. , dependencies empty (in projects tab). how fix this? update. don't know wrong time, works fine. if there such problem try reload netbeans, check environment variables $gradle_home, reboot computer.

java - Spring-Security : Optimizing get currently authenticated user… -

i working on spring-mvc application in using spring-security authentication. due excessive usage of getting authenticated user mechanism, profiler shows 'allocation hotspot' , 9.5kb memory consumed single user. there way optimize infrastructure. personserviceimpl : @override public person getcurrentlyauthenticateduser() { authentication authentication = securitycontextholder.getcontext().getauthentication(); if (authentication == null) { return null; } else { return persondao.findpersonbyusername(authentication.getname()); } } if somehow can push user in cache retrieved after first retrieving, atleast should improve performance, have no idea how that. suggestions welcome. thanks. you can use variants. can try ue spring: 1. extends org.springframework.security.core.userdetails.user , add userentity (person) public class user extends org.springframework.security.core.userdetails.user { priva...

c++ - Declaration of Vectors -

vectors size dynamically, why giving seg fault: #include <iostream> #include <string> #include <vector> using namespace std; int main(){ vector<int> vectorofints; vectorofints[0] = 3; } what i'm trying declare vector in class. #include <iostream> #include <string> #include <vector> using namespace std; class directory{ public: string name; int maxindex; vector<directory> subdirectories; void addsubdirectory(string x){ directory newsubdirectory(x); subdirectories[maxindex++] = newsubdirectory; } directory(string x){ name = x; maxindex = 0; } }; int main(){ directory root("root"); root.addsubdirectory("games"); } but gives seg fault. vectors don't resize entirely automatically. use push_back or resize change size of vector @ run-time, vector not automatically ...

ios - Notification center today widget flashes and then "unable to load" Swift -

i developing simple reminders app , i've run trouble today extension. extension works on ipad , in simulator, on iphone flashes twice before displaying "unable load" message. believe caused sort of memory problem, didrecievememorywarning called in 1 of debug sessions, console output receive "program ended exit code: 0." appreciated. here code today extension: import uikit import notificationcenter class todayviewcontroller: uitableviewcontroller, ncwidgetproviding { let repeattitles = ["no repeat", "repeat every minute", "repeat hourly", "repeat daily", "repeat weekly", "repeat monthly", "repeat annually", "repeat monthly week number", "repeat annual week number"] var maincolor = uicolor(colorliteralred: 57/255, green: 181/255, blue: 74/255, alpha: 1.0) var secondcolor = uicolor(colorliteralred: 95/255, green: 147/255, blue: 196/255, alpha: 1.0) var objects = [nsarr...

javascript - Chrome inline installation does not display popup -

i'm trying make extension of chrome webstore installed on site through chrome.webstore.install function, not appear when click installation popup on button below .. source: <head> <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/nlmdaeedalndkbecknjlofncilhlemph"> </head> <body> <button onclick="chrome.webstore.install()" id="install-button">add chrome</button> </body> you need allow inline installation work through app individually in chrome store. go developer dashboard here: developer dashboard then go chrome extension , select "edit". allow "inline installation" , click publish. more information on here: chrome inline-installation

php - Most efficient way of sending very large base64 data over ajax -

i looking send giant string on ajax server php handle it. there no point in pasting base64 data talking high quality images 2000 * 2000 px in size. the way im doing @ moment doesnt work unless im on fast internet connection, takes long times out. im wondering there better way it? convertimgtobase64(imageurl, function(base64img){ console.log(base64img); //alert(base64img); $.ajax({ url: 'index.php?route=product/product/image_upload', type: 'post', datatype: 'json', data: { img : base64img, }, success: function(json) { //stuff } }); });

Variable doesn't get updated in the function of Batch file -

i have simple batch script read value in file version.property , perform job code below title starteodmaintenance echo off cls set "build=0" call:findstring "mainalgo" if /i "%build%" == "mainalgo" ( echo "start job on mainalgo" ) else ( call:findstring "drsitealgo" echo build value %build% if /i "%build%" == "drsitealgo" ( echo "start job on secondalgo" ) else ( echo "sth wrong" ) ) :findstring echo funtioninput %~1 find /i /c "%~1" version.property if %errorlevel%==1 ( echo "errorlevel 1" set "build=0" ) if %errorlevel%==0 ( echo "errorlevel 0" set "build=%~1" echo build value in function %build% ) :end the content in version.property below drsitealgo the problem found when program executed looks below line work incorrectly. variable build not set value in "%~1" set ...

ajax - passing a PHP variable to pages loading in a div -

i trying pass php variable series of pages loading in div within admin page . once click link link page refreshes , directed login page. tried start session in admin.php , put variable in $_session, didn't make sense.i still directed login.php. <?php $_session['user_id']=$_get['msg']; if(!isset($_session['user_id'])){ # redirect login page header('location: login.php?msg=' . urlencode('login first.')); exit(); } ?> <li><a href='admin.php?url=addnews.php'><span> news</span></a></li> <li><a href='admin.php?url=addarticles.php'><span>articles</span></a></li> you haven't called session_start before setting session variables, , result session data not being saved between page refreshes or redirects. <?php session_start(); $_session['user_id'] = $_get['msg'];

c# - System.Web.HttpContext.Current.User.Identity.Name not consistent -

in our project using system.web.httpcontext.current.user.identity.name userid domain. few pages say, login or home page or many of them returning username expected domainname domainname\userid when want trying upload file using usercontrol on 1 of pages, throws exception returning directly username like harry,burlington instead of dom\hburlingt . we using windows authentication mode in our web,config , sample code thats throwing exception public static string getcurrusersloginidentity() { string name = ""; if (system.web.httpcontext.current != null) name = system.web.httpcontext.current.user.identity.name; else { windowsidentity id = windowsidentity.getcurrent(); if (id != null) name = id.name; } //if still don't have name wrong if (string.isnullorempty(name)) throw new system.security.authentication.invalidcredentialexception("c...

python - Error running *requests* -

installed python/pip on osx 10.10 using instructions here http://docs.python-guide.org/en/latest/starting/install/osx/ only installed gain access pip installed requests using pip install requests ran script import requests feed_url = 'http://www.mylocation.com/the_data' #grab xml url r = requests.get(feed_url) r.text print r error is traceback (most recent call last): file "get_all_listings.py", line 1, in <module> import requests file "/usr/local/lib/python2.7/site-packages/requests/__init__.py", line 58, in <module> . import utils file "/usr/local/lib/python2.7/site-packages/requests/utils.py", line 12, in <module> import cgi file "/usr/local/cellar/python/2.7.10_2/frameworks/python.framework/versions/2.7/lib/python2.7/cgi.py", line 50, in <module> import mimetools file "/usr/local/cellar/python/2.7.10_2/frameworks/python.framework/versions/2.7/lib/python2.7/mimet...

image - Android BlurMaskFilter -

can confirm android blurmaskfilter method based on gaussian blur (and not e.g. mean blur)? i'm surprised documentation not explicit here. in referencing code here , can assume based off of gaussian blur method. i agree documentation point, crazy have dig through source info.

c# - How to inject DbContext implementation into Prism ViewModel constructor? -

i'm working on wpf prism application using unity , entity framework. i'm looking inject custom dbcontext while constructing viewmodels, can use through life of viewmodel. module dbcontext class in gets registered in bootstrapper, , dbcontext type gets registered during module.initialize(). with said, runtime error getting thrown when trying construct viewmodels inject dbcontext. it's saying idbconnection needs registered. when register module says dbconnection abstract class , can't constructed. there must i'm not aware of concerning how dbcontext supposed registered. here's type being registered in module: public class sharedresourcesmodule : imodule { iunitycontainer container; public sharedresourcesmodule(iunitycontainer container) { this.container = container; } public void initialize() { container.registertype<iauthenticationservice, authenticationservice>(); container.registertype<idata...