Posts

Showing posts from May, 2015

c++ - Cocos2d-x Remove sprites in specified rectangular area -

i'm using cocos2d-x , i'm looking efficient way remove sprites under rectangular region. for example if have lot of random located sprites on scene , want remove of them if belong rectangular (x1, y1),(x2, y2), need do? i see there 2 ways remove sprite scene: this->removechildbytag(tag); or sprite->removefromparent(); so these methods seems need somehow find sprites located inside area , after delete them. but efficient way it? thanks! the way using default cocos functionality iterate on each child detect overlapping , remove nodes match criteria. removefromparent() removechildbytag() invoke parent->removechild(this); . , removechild() uses std::find in vector of child nodes. complexity o(n). first step of optimization use detachchild utilizes index of child. but if not fast enough recommend using special data structure search overlapping interval tree.

postscript - Updating a variable in a procedure called multiple tmies -

i'm trying generate postscript "bitmap" making repeated calls block-drawing procedure. rather define position of block on each call, i'd procedure update starting position automatically, based on known block size of (say) 100 pixels, this: % starting position /px { 72 } def /py { 720 } def % block-drawing procedure, input= r-g-b /block { setrgbcolor px py moveto 0 100 rlineto 100 0 rlineto 0 100 neg rlineto fill % adjust px , py 100 , -100, ahead of next call } def % draw 3 increasingly lighter boxes, automatically shifted 0 0 0 box .25 .25 .25 box .5 .5 .5 box % etc... is there simple way of achieving this? yes, alter values of px , py. note code defines px , py executable arrays, which, when executed, leave value on operand stack. there no need that, this: /px 72 def /py 720 def works well. i think missing fact ' def ' associates key , value in current dictionary. since haven't started new dicti...

ios - imagePickerController crashes when fetching photos from camera. From photo library works fine. Why? -

in swift app i'm allowing user add photo - either camera or photo library. has choice: @ibaction func captureimage(_ sender: anyobject) { let imagefromsource = uiimagepickercontroller() imagefromsource.delegate = self imagefromsource.allowsediting = false let alertcontroller = uialertcontroller( title: "what want do?", message: "choose action.", preferredstyle: .actionsheet) let selectpictureaction = uialertaction( title: "choose image gallery", style: .default) { (action) -> void in imagefromsource.sourcetype = uiimagepickercontrollersourcetype.photolibrary self.present(imagefromsource, animated: true, completion: nil) } alertcontroller.addaction(selectpictureaction) let capturefromcamera = uialertaction( title: "capture photo camera", style: .default) { (action) -> void in imagefromsource.sourcetype = uiimagepick...

subquery - Cheapest method for querying multiple columns with multiple values (MYSQL) -

i'm looking @ passing multiple values query retrieve rows match exact matches of values passed, matched within multiple columns. for example, passing: "france", "special" return id 3. if pass "france" return both id 1 , 3. if pass "france","special","sacred" return empty. this illustrative purpose, real data have more columns interrogate, , more terms passed it. +----------------+-------------+---------+--+ | name | author | country |id | +----------------+-------------+---------+--+ | france | m. charmers | uk | 1 | | worlds apart | d. ramson | germany | 2 | | special | r. magee | france | 3 | | sacred special | d. monster | spain | 4 | +----------------+-------------+---------+--+ i'm querying quite large database , looking least expensive method interrogating data. sensible query using collection of in clauses or building subqueries?

GPU tensorflow install issue -

i new user ubuntu, , spent more week trying install gpu tensorflow. tried follow tutorials website , blogs. whenever import tensorflow in python console. shows: import tensorflow tensorflow/stream_executor/dso_loader.cc:128] opened cuda library libcublas.so.8.0 locally tensorflow/stream_executor/dso_loader.cc:128] opened cuda library libcudnn.so.5.1.5 locally tensorflow/stream_executor/dso_loader.cc:128] opened cuda library libcufft.so.8.0 locally tensorflow/stream_executor/dso_loader.cc:119] couldn't open cuda library libcuda.so.1. ld_library_path: :/usr/local/cuda/lib64:/usr/local/cuda/extras/cupti/lib64 tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: hanguo tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: not found: unable find libcuda.so dso loaded program tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: permission denied: not open driver version path reading: /proc/driver/nvid...

html - font-size changes margin, why? -

this question has answer here: how remove space between inline-block elements? 31 answers i'm creating side scrolling div mobile devices , have run odd problem. if run code below font-size commented out body style there margin added @ sides of .scroll_item. set font-size 0 , works fine. i'm trying avoid setting font size in .scroll_item style , rather inherit comes previous in page. why happening , there way correct without setting font-size 0? body { background-color: gray; padding: 0; margin: 0; overflow: hidden; /*font-size: 0;*/ } #scroll_cont { height: auto; background-color: red; margin: 0; padding: 0; white-space: nowrap; overflow: auto; } .scroll_item { width: 120px; height: 120px; padding: 5px; margin: 2px; background-color: blue; box-sizing: border-box; white-space: normal; display...

html5 - How to paas img src value dynamically from asp.net -

i want pass src value using asp.net , c# code. actually want use multiple html tags in want set values asp.net c# code c# webform code behind: public string path; public string posterpath; protected void page_load(object sender, eventargs e) { path = "../videos/2.mp4"; posterpath = "../images/user.jpg"; } html: <img src="[passed_value]" width="100" height="100" /> <video controls="controls" poster="[passed_value]" width="550" height="320"> <source src="../videos/2.mp4" type="video/mp4"> </video> i want pass dynamic src , poster value using asp.net webforms please me regarding this... the simplest solution write variable values using response.write shorthand syntax <%=variable%> so: c# webform code behind: public string path; public string posterpath; protected void page_load(object sender, ...

powershell - Remove-Item not working when a file name is provided in a variable -

this question has answer here: how can use object's property in double-quoted string? 4 answers i curious took me while couldn't figure out first, ran following script zip files in dir $entrylist = new-object system.collections.arraylist get-childitem -path "\\tools-backup.nas\tools-backup\fakes3\rollback\$servername" -erroraction stop | sort -property "lastwritetime" | foreach-object { if($_.name.contains(".zip")) { $entrylist.add($_.name) | out-null } } it showed below: 2016-08-30_21-15-17_server-1.1.20558_client-1.1.20518 - copy - copy.zip 2016-08-30_21-15-17_server-1.1.20558_client-1.1.20518 - copy (2).zip 2016-08-30_21-15-17_server-1.1.20558_client-1.1.20518 - copy (3).zip 2016-08-30_21-15-17_server-1.1.20558_client-1.1.20518 - copy.zip 2016-08-30_21-15-17_server-1.1.20558_client-1.1.2051...

Common Lisp Create matrix from the list -

i have: list lists of values ,e.g. (list (list 1 2) (list 3 4 5) (list 1)) note: 2 dimensional array, cant structure this: (list (list (list 1))) , in other words there can numbers\letters inside secondary list. i want: create function, make list have same number of columns using nil's fill empty fields, if have list above input, output be: ((1 2 nil nil) (3 4 5 nil) (1 nil nil nil)) i sorry, has easy, novice in lisp , functional programming. note: has use cons , append only, (this main problem) cons put each element inside different list , append remove nil's. upd: have done said below, still have 1 problem (defun findmlength (input) (cond ((null input) nil) (t (and (cond ((< maxlength (length (car input))) (setq maxlength (length (car input))))) (findmlength (cdr input)))))) (defun makesquare (input rownumb) (prog (a)) (cond ((null input) nil) (t (and (setq sqmatr (append sqmatr (list (append (car ...

m3u8 - #EXT-X-BYTERANGE Avplayer not playing -

m3u8 file content : extm3u ext-x-version:4 ext-x-targetduration:13 ext-x-media-sequence:0 extinf:12.746078, ext-x-byterange:2221972@0 content_2006.ts extinf:7.941278, ext-x-byterange:2003140@2221972 content_2006.ts ...... ext-x-endlist if #ext-x-byterange: tag part of avplayer not able play file. if remove player able play files. suggestion helpful. thanks

javascript - Access object using dynamic object name -

this question has answer here: dynamically access object property using variable 10 answers i have object data inside. first level of data 2 arrays (body, cause). each body , cause array have arrays inside of them (date, year). totals:[{body:[ {date:[54,9,3,17]}, {year:[437,61,31,140]}]}, {cause:[ {date:[54,9,3,17]}, {year:[437,61,31,140]}] }] what access body/cause array dynamically based on user has changed. this how accessing them now. totals[iscause].body[isyear].date[filternumber]); my issues body , date hard coded in there, , have access either body/cause date/year. can't seem find these property names stored as. tried set var , this var bodycause = "body"; then tried pass retriever statement. totals[iscause].bodycause[isyear].date[filternumber]); but fails. i'm...

multithreading - Raspberry pi, tkinter and threading -

hi guys here, newbie on python , modules. so, developing app monitor office light system. using tkinter develop gui, try run loop within buttom comand , freezes gui. read little treading module. want use value returning variable var in loop. try can see below, function 'enable_automatico' don't call thread function 'acionamento_automatico'. don't error> #!/usr/bin/python3 # importando os pacotes import sys import time import threading import rpi.gpio gpio tkinter import ttk tkinter import* import tkinter tk tkinter import messagebox #configurando i/o gpio.setmode(gpio.bcm) gpio.setwarnings(false) #configurando os pinos de entrada gpio.setup(18, gpio.in) #sensor de presença vendas gpio.setup(23, gpio.in) #sensor de luminosidade vendas gpio.setup(24, gpio.in) #sensor de presença engenharia gpio.setup(25, gpio.in) #sensor de luminosidade engenharia gpio.setup(12, gpio.in) #sensor de presença compras gpio.setup(16, gpio.in) #sensor de luminosidade ...

lua - how to represent nil in a table -

let's suppose want store list of element. including nil values. position of values significant, , need represent absence of value in list @ given position. here problem: a = {1,2,3,nil,4} k,v in ipairs(a) print(k,v) end print(a[4]) print(a[5]) the loop print elements 1,2 , 3. stops @ nil. first print statement prints nil, i'm not sure if stored in table or not. (who knows?) second print statement prints 4 - expected. so here question: how represent list of elements in table, , iterate through them efficiently? given conditions above, e.g. position significant, , of positions "empty". in other words: have no value, absence of value @ position has meaning. this module "null.lua" local function null(...) local t, n = {...}, select('#', ...) k = 1, n local v = t[k] if v == null t[k] = nil elseif v == nil t[k] = null end end return (table.unpack or unpack)(t, 1, n) end _g.null = null u...

dynamics ax 2012 - AX2012 AIF X++ class that contains list of classes -

i have class structure class { list blist; } class b { int i; } i need aif web service operation accept single object may have multiple instances of b in it. error when try deploy service. do need explicitly specify aifcollectiontypeattribute b in operation method though b contained in a? you have use aifcollectiontypeattribute('return') , type. example: [ datamemberattribute('attributevalues'), aifcollectiontypeattribute('return', types::class, classstr(attributevaluedc)), aifcollectiontypeattribute('attributevalues', types::class, classstr(attributevaluedc)) ] public list parmattributevalues(list _attributevalues = attributevalues) { attributevalues = _attributevalues; return attributevalues; }

nginx - How to use Eclipse (remote) debugger with spawn-fcgi (or similar process launchers) -

i can (cross-) compile , (remote-) debug c applications eclipse. have bunch of fcgi-applications work when started spawn-fcgi (because need connected running nginx web server way), such as: sudo -u www-data /usr/bin/spawn-fcgi -s/tmp/fcgiapp.socket -n /var/www/fcgiapp/fcgiapp.bin is there way instruct eclipse gdb copy latest binary server, launch application in special way outlined above, , attach spawned fcgi process? note have put "cross" , "remote" in parentheses, because think actual problem (debugging spawned process) persists if run eclipse , webserver on same local machine. i have found answer myself, more workaround specific problem fcgi: it possible create required socket connection within application itself, in code snippet: #if standalone int sockfd = fcgx_opensocket("/tmp/fcgitest.socket", 1024); char command[] = "chmod ag+rwx /tmp/fcgitest.socket"; system( command ); #endif fcgx_request request...

multithreading - windows universal app passing ref class object to a native c++ thread -

i'm trying use c++ native threads in windows universal app(windows 10) classname^obj=ref new classname(); std::thread t1(function,obj);//or thread t1(function,std::ref(obj));// t1.detach(); -------------------------------- function(classname^x){ //do on x } an exception occurs , error : x information not available, what correct form passing ref obj thread?

Android development saving/reading files efficiency -

i'm new android , working on application stores grades , calculates overall grade (for school). i've implemented serializable arraylist of grade objects saved , loaded. how should save/update list file? after every modification or upon closing application?

How to select all elements in the list box using Python selenium -

i can select single element present in list box of website using this, select = select(browser.find_element_by_id("id")) and can selected using select_by_visible_text method how can select items in list box(not combo box/drop down box) if select 1 item other deselected how select items in python answer how figured out: select = select(browser.find_element_by_id("ddlamc")) count = 0 o in select.options: print(o.text) if(count>1): select.select_by_visible_text(o.text) browser.save_screenshot("phase%d.png"%count) count+=1

ios - UIView elements relevant to subclass of UIView are showing up outside of their container -

Image
i trying add 2 uibutton s , uilabel subclass of uiview made. here subclass: invitedview.m #import "invitedview.h" #import "appdelegate.h" @class viewcontroller; @interface invitedview() { uibutton *accept; uibutton *decline; uilabel *question; uiview *gray; viewcontroller *myviewcontroller; nsstring *holduser; } @end @implementation invitedview - (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { gray = [[uiview alloc] initwithframe:frame]; if(![(appdelegate*)[[uiapplication sharedapplication] delegate] invitedby]) { // } else { holduser = [[nsstring alloc] initwithstring:[(appdelegate*)[[uiapplication sharedapplication] delegate] getinvitedby]]; } question = [[uilabel alloc] initwithframe:cgrectmake(0, 0, frame.size.width, frame.size.height / 2)]; accept = [[uibutton alloc] initwithframe:cgrectmake(0, frame...

android - Read versionName of build.gradle from Jenkins -

i'm using jenkins android app builds. on every build, info, build number, etc... i'm searching way read versionname value of in build.gradle when jenkins build job. know can buildnumber $build_number env variable, how versionname ? you adding execute shell step determines versionname , , exporting environment variable using envinject plugin . assuming build.gradle contains: versionname = myname you can add script: v=$(cat build.gradle | grep versionname | awk '{print $3}') echo my_version_name=${v} > env.properties

Calculating a Minimum and Maximum in Java? -

the first part of exercise calculate test score average. next problem asked me build off problem , calculate minimum , maximum. can me? code far. import java.util.scanner; import java.io.*; import java.text.decimalformat; public class hw { public static void main ( string[] args ) { int maxgrade; int mingrade; int count=0; int total=0; final int sentinel = -1; int score; scanner scan = new scanner( system.in); system.out.println( "to calculate class average, enter each test score."); system.out.println( "when finished, enter -1."); system.out.print( "enter first test score > "); score = scan.nextint(); while (score != sentinel ) { total += score; count ++; system.out.print("enter next test score > "); score = scan.nextint(); } if (count != 0) { decimalformat onedecimalplace = new decimalformat("0.0"); ...

str replace - Proper use of multiple str_replace -

my code (simplified) <div class="row-one">...</div> <div class="row-two">...</div> i want add these 2 divs inside wrapper <div class="row-wrapper">... <div class="row-one">...</div> <div class="row-two">...</div> </div> using str_replace $search = array('<div class="row-one">','</div>'); $replace = array('<div class="row-wrapper"><div class="row-one">', '</div>'); $purchase_form = str_replace( $search, $replace, $purchase_form ); but need add $search = array('<div class="row-two">','</div>'); $replace = array('<div class="row-two">', '</div></div>'); most examples of str_replace replacing words, me should between beginning div , ending div tag. any appreciated.

javascript - How to avoid GET request on form submit with Backbone -

Image
i trying write editable table using backbone.js. this backbone.js app : <!doctype html> <html lang="en"> <head> <title>resume builder!</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script> <style> .jumbotron { ...

javascript - Purpose to create anonymous function and call it immediately -

this question has answer here: what purpose of wrapping whole javascript files in anonymous functions “(function(){ … })()”? 9 answers i following angularjs tutorial, , encountered this: (function(){ 'use strict' angular.module('users',['ngmaterial]); })(); i wondering difference between , this: angular.module('users',['ngmaterial']); as far understanding goes, both define new angularjs module, guessing there more it? var module1=angular.module('users',['ngmaterial']); console.log(window.module1); <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> with above snippet. global variable , copied global object(window) (function(){ 'use strict' var module1=angular.module('users',['n...

java - How/where to include and read build information in an EAR? -

i've been trying come clean way include , display in webpage build information ear (containing web app war). my first instinct put bulls metadata in ear meta-inf/manifest.mf file. chance have ear's manifest not part of classpath , consequently there no way read without using file operations - no no in jee container. another option add bulls info war manifest, isn't giving me necessary info on ear. lastly, have build process create properties file in jar in ear/lib folder, feels wrong well... creating lib on fly screams poor practice. is there clean/property way this? in java ee 6 , newer can place <env-entry> elements in ear's application.xml file. therefore can place whatever additional metadata need 1 or more <env-entry> sections , load values either via @resource injection or old fashioned jndi lookups.

Firebase.ServerValue.TIMESTAMP returns different value on immediate child_added -

i have firebase push server timestamp, child_added listener listening. extremely surprisingly, value returned child_added event ~300ms different in fact stored in firebase database node. subsequent reads @ same node, provides 'correct' time stored @ node. initial child_added event triggered right when push occurring, returning wrong time. has observed issue? ref = new firebase(/some/path); ref.on('child_added', function (childdata) { console.log('childdata.pushtime = ' + childdata.pushtime); }); ref.push({pushtime: firebase.servervalue.timestamp}); what console.log prints off ~300ms in fact stored @ path. the behaviour seeing expected behaviour. it occurs because child_added event fired locally, using value servervalue.timestamp that's determined using local time , offset of local clock server clock. however, it's not possible account time take request arrive @ server - hence differing timestamps. if listen child_changed ...

java - What is a StackOverflowError? -

what stackoverflowerror , causes it, , how should deal them? parameters , local variables allocated on stack (with reference types object lives on heap , variable references object). stack typically lives @ upper end of address space , used heads towards bottom of address space (i.e. towards zero). your process has heap, lives @ bottom end of process. allocate memory, heap can grow towards upper end of address space. can see, there potential heap "collide" stack (a bit tectonic plates!!!). the common cause stack overflow bad recursive call. typically, caused when recursive functions doesn't have correct termination condition, ends calling forever. however, gui programming, it's possible generate indirect recursion. example, app may handling paint messages, and, whilst processing them, may call function causes system send paint message. here you've not explicitly called yourself, os/vm has done you. to deal them you'll need examine code. if y...

Firebase CLI: database:set keeps complaining about 'Path must begin with /' -

according the cli docs , own help command, need pass path (which assume path on project), json file, , options. (while i'm in folder containing json data): firebase database:set --project myproject / myjsondata.json where want / root of project, want wipe out existing data , replace data in myjsondata.json . whenever run this, changing parameter order, or putting / in quotes, tells me error: path must begin / . path / , don't know it's complaining about. there's no examples of command in use, don't know it's expecting... turns out answer put // path. unexpected error while setting data , that's issue.

C: Why does the "Enter" key trigger output in this code? -

here's code exercise 1-13 in "the c programming language": #include <stdio.h> int main() { int c, currentindex, currentlength; currentlength = currentindex = 0; while ((c = getchar()) != eof){ if (c == '\t' || c == '\n' || c == ' '){ if (currentlength == 0){ continue; } printf("length of word %d: ||", currentindex); (int = 0; < currentlength; i++){ putchar('-'); } putchar('\n'); currentlength = 0; ++currentindex; } else { ++currentlength; } } return 0; } so can compile , run ./a.out, when press "enter" start new line of input ('\n') runs printf() , putchar() functions(and neither ' ' or '\t' trigger output). while loop doesn't end (it ends should end-of-file(ctrl-d)) i'm wo...

ios - childViewControllers is empty after calling addChildViewController -

Image
i have question regarding add/remove childviewcontrollers containerview. i have uiviewcontroller named "containerviewcontroller" contains containerview, , containerview has uiviewcontroller named "containerlinkviewcontroller". have 4 other uiviewcontrollers added or removed "containerlinkviewcontroller" whenever user clicks 1 of tab button placed @ bottom of "containerviewcontroller". storyboard looks below. note custom segues connected 4 uiviewcontrollers empty segue nothing show visual connection in storyboard. so first add first tab viewcontroller "containerlinkviewcontroller" childviewcontroller using below code in viewdidload(). let firsttabviewcontroller = self.storyboard?.instantiateviewcontroller(withidentifier: "firsttabviewcontroller") as! firsttabviewcontroller self.addchildviewcontroller(firsttabviewcontroller) firsttabviewcontroller.view.frame = self.view.bounds self.view.addsubview(firsttabviewcontr...

plot - Mathematica 1/0 Infinite expression while plotting -

Image
j = 0.05; b = 0.02; tload[t_] := 0.0; r1 = 2; \[alpha] = 30*\[pi]/180; d = 0.05; g = 0.001; nturns = 200; \[mu]0 = 4*\[pi]*10^(-7); r = 0.03; lm = 0.02; d = 0.1; w = sqrt[2*r^2 - 2*r^2*cos[2*a]]; rgmax = g/(\[mu]0*r*d); rm = lm/(\[mu]0*w*d); square[x_, x1_, x2_] := unitstep[x - x1]*(1 - unitstep[x - x2]) rg[\[theta]_] := rgmax/((2 \[alpha] - mod[\[theta][t], \[pi]])* square[mod[\[theta][t], \[pi]], -2 \[alpha], 2 \[alpha]] + (2 \[alpha] - mod[-\[theta][t], \[pi]])* square[mod[-\[theta][t], \[pi]], -2 \[alpha], 2 \[alpha]]) l[\[theta]_] := nturns^2/( 2*rg[\[theta]] + rm) *(square[mod[\[theta][t], \[pi]], -2 \[alpha], 2 \[alpha]] + square[mod[-\[theta][t], \[pi]], -2 \[alpha], 2 \[alpha]]) plot[l[\[theta]], {\[theta][t], -8 \[alpha], 8 \[alpha]}, plotrange -> all] i'm sorry not paste mathematica can show (newbie here). however, tried several solutions rid of 1/0 inf expression of l[theta] didn't it. please, copy , paste notebook , run ...

java - How can I recover from vaadin's 'com.vaadin.DefaultWidgetSet' error -

i'm using win7, java 1.8, eclipse luna 4.4.2, tomcat 8, , have started exploring vaadin's touchkit write mobile browser application. have chrome default browser, both on win7 machine , servlet-based apps in eclipse. it's going pretty well, looks - or has looked - i'll able complete little application in 80-100 hours of effort or so. @ least, if can figure out how keep having wrestle vaadin environment , plug-in. i have developed pattern development; in order make coding changes, following: stop server make coding changes execute maven 'install' goal (right-click project, select 'debug as', select 'maven install'). (usually) compiles project , deploys tomcat server configured run eclipse (and set default server). execute 'debug on server' (right-click project, select 'debug as', select 'run on server'. i've been doing day -- have done 50 times since got up. it's been working. i have resource files...

javascript - How to pass variables into dynamic UIkit Modal? -

how pass variables uikit modal? the button: <button type="button" class="uk-button" data-uk-modal="{target:'#info',center:true}" data-added="added-test" data-modified="modified-test"><i class="uk-icon-info"></i></button> the modal: <div class="uk-modal" id="info"> <div class="uk-modal-dialog"> <h4 style="margin-bottom:5px;">added:</h4> <div id="added"></div><br> <h4 style="margin-bottom:5px;">modified:</h4> <div id="modified"></div> <div class="uk-modal-footer"> <button type="button" class="uk-button uk-modal-close">close</button> </div> </div> </div> the script: $(document).ready(function () { $(...

android - Can a fragment's onAttach be called before the Activity's onCreate has finished? -

i experiencing rare (1 in few thousand sessions) crash trying track down. have activity which, during it's oncreate override, creates fragments doesn't show or attach of them: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.activity_main); mainmenufragment = new mainmenufragment(); locationfragment = new locationfragment(); mainpresenter = new mainpresenter(this); } in code create "mainpresenter" comes library contains our business logic. presenter used onattach method of fragments: @override public void onattach(activity activity) { super.onattach(activity); mainactivity mainactivity = (mainactivity) activity; mainpresenter = mainactivity.getmainpresenter(); mainpresenter.refreshui()...

turn baced adventure python 2.7.12 -

im working on basic turn baced game , need cleaning script , ading battle sequence im not coding can great its not finished, ideas or criticism great thnx p.s. pleas excuse spelling mistakes have dislexia :^( import time import random import os hp = (0) spell = (0) atack = (0) time.sleep (0.5) print(" +-----------------------------------+") print(" | welcome tomb of horrors |") print(" +-----------------------------------+") time.sleep (1) print 'set caricters name' name = raw_input(">") print 'set caricters fighting fightingclass:' print ' 1. mage hp=50 spell=50 atack=10' print ' 2. warior hp=40 spell=10 atack=50' print ' 3. asasin hp=20 spell=10 atack=70' style = raw_input (">") if style == "1": hp = (50) spell = (50) atack = (10) fightingclass= "mage" wepon= ...

html - Page loads with navbar extended - already checked for "collapse in" -

anyone know why page loading navbar pre toggled down looking @ code? the navbar loads extended, click on toggle button "refreshes" extended position. second click retracts navbar position initialized in. <div class="nav-gradient"> <nav class="navbar navbar-default navbar-fixed-top"> <div> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </b...

string - Remove punctuation java -

i'm trying remove punctuation string keep spaces, need able distinguish different words. end goal find length of each word in string. i set for loop check length of word until hits space count punctuation letter. know have change variable in if statement reflect length of substring between i , indexof space in string. for(int i=0; > stringlength - 1;){ original.substring(i, original.indexof(' ')); if(i > minlength) while might tempting throw bunch of fors , ifs, cleaner use regular expression: pattern.compile("[.,; ]+").splitasstream(input) a full example: import java.util.regex.pattern; import java.util.stream.collectors; public class counting { public static void main(string... args) { string text = "this string. punctuation, care words."; string wordswithlengths = pattern.compile("[.,; ]+") .splitasstream(text) .map(word -> word + " => " + w...

java - Iterating Numbers and Alphabet for hashmap -

i'm trying associate each letter of alphabet corresponding number. 0=a, 1=b, 2=c, etc. although numbers sequencing properly, letters coming out "z." doing wrong (with loop)? public static void ciphermap (map<integer, character> map) { (int = 0; <= 25; i++) { (character alphabet = 'a'; alphabet <= 'z'; alphabet++) { map.put(new integer(i), alphabet); } } } output: 0: z 1: z 2: z 3: z 4: z 5: z ... on the last step of inner loop sets every i z . remove inner loop , like, public static void ciphermap (map<integer, character> map) { (int = 0; <= 25; i++) { map.put(i, (char) ('a' + i)); } }