Posts

Showing posts from July, 2011

c# - Convert Base64 string to image and save it -

i want save base64 image folder in application, have problem in code. gives error below, message = "invalid length base-64 char array or string." in code; public static string updateuser(int refuser, string name, string surname,string base64) { string result = "failed"; var photo = ""; if (base64!=null && base64!="") { string mediapath = extend.getxmlconfigparameter("media", "path")+"user\\"; string medianame = guid.newguid().tostring(); base64 = base64.replace("data:image/png;base64,", ""); base64 = base64.replace("data:image/jpg;base64,", ""); base64 = base64.replace("data:image/gif;base64,", ""); base64 = base64.replace("data:image/jpeg;base64,", ""); ...

python fu - gimp preset "fixed: aspect ratio" property for a selection -

Image
i need script acts shortcut for: making selection setting selection property "fixed" value "aspect ratio" (that is: proportions of selection should fixed) the following line selection part: gimp.pdb.gimp_rect_select(img,20,20,80,80,2,0,0) but couldn't find way set selection properties , keep properties of last selection done. is there way accomplish this? no can't, because design scripts cannot interfere ui (and "fixed" setting humans, script can compute this). but, if want have quick way make specific selection, use diskette icon @ bottom save tool settings name (and, later, folder icon, restore it).

c# - BindingContext not working in Action call but does work outside of Action -

i trying change binding context of content page inside socket.io on call, , reason keeps halting action method. inside action can alter stuff inside content page, moment change bindingcontext stops method working anymore. here example: //this works app.notif_page.bindingcontext = new { count = "1234" }; socket.on("ping", (obj) => { //this not work app.notif_page.bindingcontext = new {count = "124"}; }); the action called above, reason bindingcontext not change. if called same page , changed data work, trying change bindingcontext halts method being able called. thanks, avery.

c++ - Access violation writing location with dynamic array -

i have member variable points wchar_t array hold input given user through console. wchar_t ** marray; then, in member function, ask input user , store in std::wstring. afterwards, use length of wstring dynamically allocate memory marray , , assign each character in loop. however, "access violation writing location" error. std::wstring givenwstring; std::cin.ignore(); std::getline(std::wcin, givenwstring); marray = new wchar_t*[givenwstring.length()]; (size_t = 0; < givenwstring.length(); i++) { *marray[i] = givenwstring.at(i); } i don't know why getting access violation error because assigning each character wstring each index in dynamic array. you must store data in dynamic array of appropriate objects, wchar_t in case. i.e. need pointer wchar_t manage array. std::unique_ptr<wchar_t[]> marray; // unique_ptr takes care of delete[] std::wstring givenwstring; std::cin.ignore(); std::getline(std::wcin, givenwstring); marray.reset(new w...

javascript - save data with a dynamic row script inside mysql -

i know how save data dynamic row script in multilanguage approach in mysql database. element below create new empty row every time click on input. input can deleted. don't know best approach , if ideas, cool thank you $content .= ' <div class="form-group form-group-options col-md-8"> '; ($i=0, $n=sizeof($languages); $i<$n; $i++) { $content .= ' <div class="col-md-12"> <div class="form-group row"> <div class="input-group input-group-option"> <label for="lang" class="col-1 col-form-label">' . $oscom_language->getimage($languages[$i]['code']) . '</label> ' . html::inputfield('user_question[][' . $languages[$i]['id'] . ']', null, 'placeholder="write question"') . ' <span class...

sql - Syntax for STUFF/FOR XML PATH -

can see doing wrong syntactically getting msg 156, level 15, state 1, line 33 incorrect syntax near keyword 'for'. i boiled down query readability , still getting error in various ways i've tried execute it: select stuff((select * (select n',' + n'first' union select n',' + n'second') xml path('')), 1, 1, '') also tried: select stuff((select * (select n',' + n'first' union select n',' + n'second')) xml path(''), 1, 1, '') for while getting the xml clause invalid in views, inline functions, derived tables, , subqueries when contain set operator. work around, wrap select containing set operator using derived table syntax , apply xml on top of it. but amended code per exacthelp's post . updat...

javascript - Resetting the navigation stack for the home screen (React Navigation and React Native) -

i've got problem navigation of react navigation , react native. resetting navigation , returning home screen. i've build stacknavigator inside of drawernavigator, , navigation between home screen , other screens working. problem is, navigation stack grows , grows. i'm not sure how remove screen stack. for example when going home screen settings screen, entry screen , lastly again home screen, home screen twice in stack. button not out of app, again entry screen. when selecting home button again reset of stack great, don't know how this. here tried other person similar problem, solution didn't work me. const stack = stacknavigator({ home: { screen: home }, entry: { screen: entry }, settings: { screen: settings } }) export const drawer = drawernavigator({ home: { screen: stack }}, { contentcomponent: hamburgermenu } ) and simple example of drawer screen export default class hamburgermenu extends component { ...

php - Use wildcards in Symfony routing configuration for subdomain and tld -

i tried setup symfony routing. i'm using symfony 2.7. have 2 bundles work under different subdomain. domainname can wild card , tld can multiple. here current config file: company_api: resource: "@apibundle/controller/" type: annotation prefix: / company_core: resource: "@corebundle/controller/" type: annotation prefix: / i want first bundle works under subdomain "api", domain can wildcard , tld want specify few (nl|eu). edited company_core: resource: "@apibundle/controller/" type: annotation prefix: / host: www.mydomainname.{tld} defaults: tld: nl requirements: tld: "nl|eu" i have nog upgarde config setup. , tld works correct. possible have wildcard domain name "mydomainname"? easy dev , producten server use different doamain names. here example of use on 3.1 app, use placeholder top-level domain varies environment — app: resource: "@appbundle/controller/...

r - Shiny: keep boxes checked on datatable after changing inputs -

i want implement checkboxes shiny app; however, i'm facing 2 problems: after reorder columns, checks on datatable disappear (e.g., try order table mpg ) after remove column, checks on datatable disappear (e.g., unchecking boxes columns show: ) here's dummy example (it's modified version of code this answer ): library(shiny) table = mtcars table$id = 1:nrow(mtcars) app <- list() app$ui <- pagewithsidebar( headerpanel(null), sidebarpanel( checkboxgroupinput("show_vars", "columns show:", names(table), selected = names(table)) ), mainpanel( datatableoutput("resulttable") ) ) app$server <- function(input, output, session) { output$resulttable = renderdatatable({ addcheckboxbuttons <- paste0('<input type="checkbox" name="row', table$id, '" value="', table$id, '...

javascript - Send Chart.js email with Laravel -

i'm using library https://github.com/fxcosta/laravel-chartjs generate graphics php variables. , after send chart email, unfortunately not possible send js email. $chartjs = app()->chartjs ->name('linecharttest') ->type('line') ->size(['width' => 400, 'height' => 200]) ->labels(['-1', '-0.5', '0', '0.5', '1']) ->datasets([ [ "label" => "p(theta) emp", 'backgroundcolor'=> "blue", 'bordercolor' => "blue", 'fill' => "false", 'data' => $acerto_bruto, ], [ "label" => "p(theta) 0", 'backgroundcolor'=> "red", 'bordercolor' => "red...

ruby on rails - Postgresql db:create doesn't work because password authentication failed for superuser? -

i working on rails website uses postgresql databse. config/database.yml looks this. default: &default adapter: postgresql pool: <%= env.fetch("rails_max_threads") { 5 } %> timeout: 5000 username: postgres password: mypassword host: localhost development: <<: *default database: my_db_development test: <<: *default database: my_db_test production: <<: *default database: my_db_production i not quite sure doing wrong installed postgresql on computer (windows 10) , during installation asked "please provide password database superuser (postgres)" , when entered "mypassword". goes in username , password? confused. i found similiar problem forgotten postgresql windows password , hope solve problem.

python - Caterpillars Eating Leaves Automatically in Caterpillar Game -

Image
i made caterpillar game , i'm trying convert two-player game. made second caterpillar , gave controls. when ran it, leaves automatically came caterpillars. here code : import random import turtle t t.bgcolor('yellow') caterpillar = t.turtle() caterpillar.shape('square') caterpillar.color('red') caterpillar.speed(0) caterpillar.penup() caterpillar.hideturtle() caterpillar2 = t.turtle() caterpillar2.color('blue') caterpillar2.shape('square') caterpillar2.penup() caterpillar2.speed(0) caterpillar2.hideturtle() leaf = t.turtle() leaf_shape = ((0, 0), (14, 2), (18, 6), (20, 20), (6, 18), (2, 14)) t.register_shape('leaf', leaf_shape) leaf.shape('leaf') leaf.color('green') leaf.penup() leaf.hideturtle() leaf.speed(0) game_started = false text_turtle = t.turtle() text_turtle.write('press space start' , align='center', font=('arial', 50, 'bold' )) text_turtle.hideturtle() score_tu...

python 2.7 - cannot display Google Earth Engine Image in Jupyter Notebook -

i'm working on getting google earth engine working python setup (windows 7, python 2.7.8) using tutorial found online ( here ). can ee initialize, cannot display image. import ee ipython.display import image,display ee.initialize() image = ee.image('srtm90_v4') url = image.getthumburl({'min':0,'max':3000}) image(url) the last line returns following error: "--------------------------------------------------------------------------- valueerror traceback (most recent call last) in () ----> 1 image(url) d:\miniconda\envs\py27\lib\site-packages\ipython\core\display.pyc in init (self, data, url, filename, format, embed, width, height, retina, unconfined, metadata) 750 751 if self.embed , self.format not in self._acceptable_embeddings: --> 752 raise valueerror("cannot embed '%s' image format" % (self.format)) 753 self.width = width...

Does SQL Server 2016 Evaluation version have a 10GB size limit? -

i installed new server , installed sql server 2016 evaluation version , sql server management studio 17.1 it. i'm trying restore database in supposed 'test environment' test few procedures before pushing production. my database 212gb large. while trying restore database server, got error message: msg 1827, level 16, state 4, line 5 create database or alter database failed because resulting cumulative database size exceed licensed limit of 10240 mb per database. msg 3013, level 16, state 1, line 5 restore database terminating abnormally. i thought evaluation version free use 180 days. has been 30 or days. i thought 10gb limit sql server express edition. i checked control panel confirm indeed have 2016 evaluation version , not express edition. it sounds you've installed express version, or licensing configuration has somehow gotten out of wack. i don't believe can manually convert express evaluation version. you'll need u...

javascript - Angular1: How to reflect ng-model errors on another element? -

i have directive following template <div> <span class="label">my label</span> <input ng-model="name" required> </div> i want label painted red when input field invalid. how can that? currently have directive sync errors ngmodelctrl wrapping div <div add-all-errors> ... </div> and directive's link function this: const ngmodel = $element.find('[ng-model]').controller('ngmodel'); $scope.$watch(()=>ngmodel.$error, addallclasses, true); where addallclasses makes sure correct classes appear on element.. i tried adding same ng-model <div ng-model="name"> ... </div> but did not see classes there.. any better way this? this why use angularjs form... i'm not sure why people against using handy feature. i've made plunker you. https://plnkr.co/edit/bgocqjwzlrq2atyzuynm?p=preview <form name="form"> <s...

dpi - I cannot open visual studio 2017 ProcessDPIawareness error -

i try open visual studio 2017 , gives me error : microsoft visual studio impossible de charger le type 'processdpiawareness' à partir de l'assembly 'windowsbase, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35'. ok i don't it, try uninstall , reinstall , doesn't want install anymore, did many research , have yet find solution. thank help i think yet problem .net 4.7 update on windows 7/8/8.1 systems. try installing updates in this web page . if doesn't help, try uninstalling .net framework 4.7 (instructions uninstall , reinstall in same web page )

html - Is there a way to change the size of the box form that I made, can the form also be on the right while I have left side text? -

how can make not form small on right had side , can put text on left side. couldn't find on google tried this. tried align form works images. #questions > .question, #languages > .language{ margin: auto; overflow: auto; padding: 8px; width: 75%; } .choices > .choice, #languages > .language{ background: #ffffff; border-radius: 8px; opacity: 0.7; overflow: auto; padding: 16px; } #questions, #languages{ margin-bottom: 48px; } #languages > .language{ margin-top: 8px; } .language > img{ float: left; margin-right: 24px; padding: } this works images src not actual forms yes can change form such labels on right , text on left , through transforming scale on whole form , on individual element make readable. demonstrated in below code: .flip { -moz-transform: scale(-1, 1); -webkit-transform: scale(-1, 1); -o-transform: scale(-1, 1); -ms-transform: scale(-1, 1); transform: scale(-1, 1); } .fname { width:90px; height:30px; d...

Instagram API using Facebook Graph Permissions -

Image
i'm trying develop simple platform instagram insights using new facebook graph instagram api , can't right permissions access instagram business page. current setup has instagram business page connected facebook business page shared ad account both. when make request grab instagram business page id facebook business page using graph api explorer (seen in documentation here ): /v2.10/{facebook_page_id}?fields=instagram_business_account i error: { "error": { "message": "(#100) no permission access instagram account", "type": "oauthexception", "code": 100, "fbtrace_id": "cu9onyet2+q" } } the documentation references need 1 of these permissions: instagram_basic instagram_manage_comments (optional) instagram_manage_insights (optional) however there no options in graph explorer of these permissions (see photo below). boiled down questions how authenticate ap...

css - Burger menu clickable area too small -

https://codepen.io/everybodysfeelingwonderland/full/ojyrpm/ for mobile size of website burger icon menu has way small clickable area, thin lines. i have problem other anchors i'd have bigger clickable area, don't want element become bigger on page. <div id="burger-container"> <div id="burger"> <span>&nbsp;</span> <span>&nbsp;</span> <span>&nbsp;</span> </div> </div> css #burger-container{ margin: 25px 0 0 0; width: 50px; float: right; padding-right: 70px; } #burger{ cursor: pointer; display: block; } #burger span{ background: black; display: block; width: 50px; height: 3px; margin-bottom: 10px; position: relative; top: 0; transition: ease-in-out 0.4s; } #burger-container.open span:nth-child(2){ width: 0; opacity: 0; } #burger-container.open span:nth-child(3){ transform: rotate(45deg); top: -13px; } #burger-container.ope...

python - apply numpy.histogram to multidimensional array -

i want apply numpy.histogram() multi-dimensional array along axis. say, example have 2d array , want apply histogram() along axis=1 . code: import numpy array = numpy.array([[0.6, 0.7, -0.3, 1.0, -0.8], [0.2, -1.0, -0.5, 0.5, 0.8], [0.25, 0.3, -0.1, -0.8, 1.0]]) bins = [-1.0, -0.5, 0, 0.5, 1.0, 1.0] hist, bin_edges = numpy.histogram(array, bins) print(hist) output: [3 3 3 4 2] expected output: [[1 1 0 2 1], [1 1 1 2 0], [1 1 2 0 1]] how can expected output? i tried use solution suggested in this post , doesn't me expected output. for n-d cases, can np.histogram2d making dummy x-axis ( i ): def vec_hist(a, bins): = np.repeat(np.arange(np.product(a.shape[:-1]), a.shape[-1])) return np.histogram2d(i, a.flatten(), (a.shape[0], bins)).reshape(a.shape[:-1], -1) output vec_hist(array, bins) out[453]: (array([[ 1., 1., 0., 2., 1.], [ 1., 1., 1., 2., 0.], [ 1., 1., 2., 0., 1.]]), array([ 0....

c++ - get HTML from QWebEnginePage in QWebEngineView using Lamda -

i want html code of web page opened in qwebengineview use tohtml() function in qwebenginepage class this qwebenginepage *page = ui->widget->page(); qstring html = ""; page->tohtml([&html](qstring html){qdebug() << "code \n\n\n" << html;}); the html code of html page appeared in qdebug without problem problem here when want use html string outside function when show size of html varible equal 0 , empty tried this qwebenginepage *page = ui->widget->page(); qstring html = ""; page->tohtml([&html](qstring html){html = html;}); // crash qdebug() << "i want use html here outside function = " << html; but app crash show should put html data in html variable can use outside function in advance your problem caused fact lambda run asynchronously. called after have exited method in call tohtml method , explains crash - html local variable within method has exited lambda randomly corru...

javascript - REACT JSX - Chained conditons -

the following code works me , gives me expected results have doubts if doing right. { conditon1?<childcomponent />:condition2?<p>hi</p>:<p>bye</p> } my concern chained conditional statement - valid? yes code statement wrote fine , work, prefer use better indentation while writing nested conditions other person reads code better understanding. when have more chained conditions, prefer using if/else rather ternary operators.

rust - Is there a way to count with macros? -

i want create macro prints "hello" specified number of times. it's used like: many_greetings!(3); // expands 3 `println!("hello");` statements the naive way create macro is: macro_rules! many_greetings { ($times:expr) => {{ println!("hello"); many_greetings!($times - 1); }}; (0) => (); } however, doesn't work because compiler not evaluate expressions; $times - 1 isn't calculated, fed new expression macro. while ordinary macro system not enable repeat macro expansion many times, there no problem using loop in macro: macro_rules! many_greetings { ($times:expr) => {{ _ in 0..$times { println!("hello"); } }}; } if need repeat macro, have procedural macros/ compiler plugins (which of 1.4 unstable, , bit harder write). edit: there better ways of implementing this, i've spent long enough on today, here goes. repeat! , macro duplicates b...

appmaker - Want To Copy Certain Fields From Previous Entry To New Fragment -

Image
short version: want have copy button in table able grab values existing entry , populate "create entry" page fragment. way users don't have reenter data when making new entry. long version: i have 2 buttons added rows in table: edit , copy. the edit button uses following code grab information specific row , uses fragment edit entry. widget.datasource.savechanges(); app.datasources.systemorders.selectkey(widget.datasource.item._key); app.showdialog(app.pagefragments.systemorders_edit); the copy button using following code duplicate entry , automatically create it. //allows copying table/row var rowdatasource = widget.datasource; var listdatasource = app.datasources.systemorders_hidecomplete; var createdatasource = listdatasource.modes.create; widget.datasource.savechanges(); // enter fields want duplicate below createdatasource.item.projectname = rowdatasource.item.showname; createdatasource.item.deliveryinfo = rowdatasource.item.deliveryinfo; creat...

go - golang struct from other package -

super golang noob here. this project structure root parser parser.go builtin exit.go hi.go structs base_structs.go main.go my base_structs.go file looks like package structs type built_in_func func([] string) type built_in struct { s string f built_in_func } then in main.go have imported package , i'm referencing struct structs.built_in_func . this i'm trying do: var builtin_list [] structs.built_in builtin_list = append(builtin_list, structs.built_in{s:"exit", f:builtin.exit}) builtin_list = append(builtin_list, structs.built_in{s:"hi", f:builtin.hi}) but i'm getting error: unknown structs.built_in field 's' in struct literal once again, i'm super golang noob. helps :) in go, visibility of name outside package determined whether first character upper case. so field s not visible outside package structs , error. if define struct (note upper case): ...

android - How to pass an Arraylist of Events through an Intent -

i'm trying pass list of events 1 activity 1 using intent, how tried it: on activity 1: arraylist<event> eventsselected= new arraylist(); eventsselected.add(new event(color.red, dateclicked.gettime(), "event1")); eventsselected.add(new event(color.red, dateclicked.gettime(), "event2")); eventsselected.add(new event(color.red, dateclicked.gettime(), "event3")); intent = new intent(firstactivity.this, secondactivity.class); i.putextra("eventsselected", eventsselected); startactivity(i); but didn't find how on second activity, tried way didn't work : on activity 2: intent intent = getintent(); arraylist<event> selecteddates = intent.getstringarraylistextra("eventsselected"); you need implements serializable object class public class event implements serializable { } also i.putextra("eventsselected",eventsselected);

cron job in google app engine not working -

i have taken basic python 3 tutorial website on flask google cloud tutorial , able set , website works fine. in addition , wanted run python script runs everyday collect data, cron job doesn't work. added login: admin restrict directly use url cron.yaml cron: - description: test dispatch vs target url: /cronapp schedule: every 5 hours app.yaml runtime: python env: flex entrypoint: gunicorn -b :$port main:app runtime_config: python_version: 3 handlers: - url: /cronapp script: cronapp.py login: admin i calling http://myproject.appspot.com/cronapp doesn't work , returns 404. doing wrong ? appreciated your app.yaml file mixing standard environment handlers element flexible environment configuration , ignored. can see cron requests in app's logs in developer console (likely errors, though). you need add handler /cronapp inside app code, not in app.yaml . not entirely sure how (i'm still using standard environment), depends on app ...

svn - Duplicate definition error -

[2017-07-28 10:36:17 - bruce] res\drawable-xhdpi-v4\convert_icon_new_1.png.svntmp:0: error: resource entry convert_icon_new_1 defined. [2017-07-28 10:36:17 - bruce] res\drawable-xhdpi-v4\convert_icon_new_1.png:0: defined here. but there`s no convert_icon_new_1.png.svntmp file in project.

Android notifications only showing first -

i developping instant messaging app, , want show notification when message received . upon first message, notification pops , there icon in status bar, expected. after first message, update notification reflects in status bar, notification not pop second time. i've tried several things such changing notification id, not work need have 1 notification, updated , shown, not several notifications. i stuck now, please advise. edit: added code. if (messagenotifications.isempty()) { return null; } int messagecount = 0; (messagenotification messagenotification : messagenotifications) { messagecount += messagenotification.getcount(); } messagenotification message = messagenotifications.get(messagenotifications.size() - 1); boolean showtext = false; notificationcompat.builder notificationbuilder = new notificationcompat.builder(application); notificationbuilder.setcontenttitle("secure messenger"); notification...

c# - MassTransit republish message for another consumer when a consumer throws exception -

i developing micro-services system using masstransit , rabbitmq. 1 service can publish jobs many subscriber services. 1 of subscribers execute job (competing consumer). if 1 subscriber consume message, execute job , throw exception, is there way message re-delivered queue, other subscribers can consume message. i use retry policy subscribers, allows me re-consume message inside same subscriber, not consume subscriber. you can schedule redelivery of message: http://masstransit-project.com/masstransit/usage/scheduling/redeliver.html you need have message scheduler, or use delayed exchange in rabbitmq. typically retrying discouraged, can set redelivery timer want.

selenium - Selenoid: recording video of a running session -

i'm using selenoid live browser screen functionality debug tests. recommended way capture browser screen video? selenoid supports showing video via vnc. need grab respective port. here 1 possible way record video vnc. requirements: selenoid must running in bin (not in docker) overwise mapped ports null . docker apis should exposed outside world. ( http://www.virtuallyghetto.com/2014/07/quick-tip-how-to-enable-docker-remote-api.html ) how that. 1 possible solution use vnc2flv script. download script: $ wget https://pypi.python.org/packages/1e/8e/40c71faa24e19dab555eeb25d6c07efbc503e98b0344f0b4c3131f59947f/vnc2flv-20100207.tar.gz\#md5\=8492e46496e187b49fe5569b5639804e unpack archive: $ tar zxf vnc2flv-20100207.tar.gz install script: $ python setup.py install --prefix=/usr/local record video: docker container id via selenoid /status , find docker commands port mapped container port 5900 (the vnc port). type: flvrec.py -p <filename_for_password_file...

database - API request limit work around -

i'm building react native app , want pull information api has 10 requests/minute limit. okay couple of users i'm concerned won't scale. example if 30 users using app @ once there 30 api requests , 20 users won't data. typical solution this? should create database requests api every minute stores data short term , users data database? overkill? i'm new , trying understand. in advance patience. from op's request, yes, should pull information api server (which not yours) every several seconds, not exceed limit (for example, 10 requests / per minute). and can: store them database. or better if data size not big: store them in memory. repopulate pulling server delegate api server. so every react native app can pull new delegation server, larger request limits.

r - Discrete value supplied to continuous scale - Dataset does not have any factors -

i know has been asked, not understand why keep getting discrete value supplied continuous scale error when trying customize axis on graph. on questions have read said happened because of variables on dataset defined factors, whic not happen in case. df <- data.frame(grupo = c('tratado', 'controle', 'tratado', 'controle', 'tratado','controle'), uf = c('sp','mg','mg','sp','ba','ba'), prop = c(0.166, 0.161, 0.121, 0.112, 0.092,0.084)) ggplot(df,aes(x = reorder(uf,prop), y = prop)) + geom_bar(aes(fill = grupo), position = 'dodge', stat = 'identity') + coord_flip() + theme_classic() + labs(x = 'importância na amostra', y = 'uf') + scale_x_continuous(labels = scales::percent) it's best think of coord_flip visual transformation gets applied right @ end of whole plot building process. prop y var...

java - How to use expression-based access control in spring? -

i new spring.i have created api user login.the user login method contains following codes: authentication auth =new usernamepasswordauthenticationtoken(repo.findbyemail(user.getemail()), null, repo.findbyemail(user.getemail()).getauthorities()); securitycontextholder.getcontext().setauthentication(auth); principal principal= securitycontextholder.getcontext().getauthentication(); return (user) auth.getprincipal(); the login api gives me following json: { "userid": 1, "username": "ramesh khadka", "email": "test@gmail.com", "enabled": true, "role": "manager", "username": "ramesh khadka", "authorities": [ { "authority": "role_manager" } ], "accountnonexpired": true, "accountnonlocked": true, "credentialsnonexpired": true } i have api users uses @preauthorize("hasauthority('role_manager')...

Why does my enemy attack after it is dead?(Javascript) -

function battle(){ //user turn alert("it's turn!"); var user_move = prompt("type 1 use fireball, 2 use lightning strike, or 3 earthquake"); if(user_move == 1){ var r = math.round(math.random()*(dmg.length-1)); alert("you did "+dmg[r]+" damage enemy!"); enemy_hp = enemy_hp - dmg[r]; } else if(user_move == 2){ var r = math.round(math.random()*(dmg.length-1)); alert("you did "+dmg[r]+" damage enemy!"); enemy_hp = enemy_hp - dmg[r]; } else if(user_move == 3){ var r = math.round(math.random()*(dmg.length-1)); alert("you did "+dmg[r]+" damage enemy!"); enemy_hp = enemy_hp - dmg[r]; } alert("your enemy has "+enemy_hp+"hp"); //enemy turn alert("now enemys turn!"); var = math.round(math.random(enemy_attack.length-1)); var r = math.round(math.random()*(dmg.length-1))...

Error while checkout git branch -

i new git. working on 1 of branch , having pending changes , machine got crashed. on new machine installed git again , did clone of repository(develop). when trying git status or git checkout mybranch i getting below error:- error: bad signature fatal: index file corrupt can please suggest how can resolve this? i think out. on osx/linux: rm -f .git/index git reset on windows: del .git\index git reset how resolve "error: bad index – fatal: index file corrupt" when using git

javascript - How to circumvent same origin policy error to reference elements loaded in an iframe? -

there iframe following structure loaded via external site external.com , being hosted @ domain example.com : <body> <!-- body of html i'm trying make reference --> <iframe> #document <html> <body> <script type="text/html" id="icon-close"><div class="icon icon-close"> <div class="icon icon close"</div> </script> </body> </html> </iframe> </body> i'm trying select icon-close element in case. i can select iframe using $("iframe") when try access contents in inspector code select elements using $("iframe").contents() receive following: domexception: failed read 'contentdocument' property 'htmliframeelement': blocked frame origin "https://external.com" accessing ...

javascript - setting and getting ages based on datepicker -

i asked similar question couldn't find right solution. have used code dynamically generate input fields includes date field followed age. i trying jquery's datepicker class pick dates , each age field calculates based on these select dates. the problem don't know how set value of age input field. tried , searched lots of posts , may simple fix since i'm not familiar jquery methods, got no luck it. please see excerpt codes: $(document).on('click', '.datepicker', function() { $(this).datepicker('destroy').datepicker({ onselect: function(value, ui) { var dob = new date(value), today = new date(), age = new date(today - dob).getfullyear() - 1970; $('.age').find('input').val(age); }, changemonth: true, changeyear: true, dateformat: "mm-dd-yy",yearrange: "1900:+10",showon:'focus'}).focus(); })...