Posts

Showing posts from September, 2012

sql - remove duplicates/loops from graph data -

i have graph data arcs (consisting of start [s] , end [e]) of graph stored follows in relational table: if object_id('tempdb..#test') not null drop table #test; create table #test ( s nvarchar(1) ,e nvarchar(1) ); insert #test (s, e) values ('a', 'b'); insert #test (s, e) values ('b', 'a'); insert #test (s, e) values ('a', 'c'); so graph consists of these arcs: a -> b b -> a -> c i remove duplicates/cycles: -> b , b -> => -> b. possible? example ;with cte ( select * ,rn = row_number() on (partition case when s<e s+e else e+s end order s,e) #test ) delete cte rn>1 updated test s e b c wiki

android - Using Constraint Layout to center two items together in the center -

here intended layout. <- actionbar button [ image1 ] [image2][image3] [image4] doese know how support constraintlayout? image2,image3 in center , little or no margin between them. image1, , image4 near left right edges respectively. is there anyway achieve same linearlayout or relativelayout row of images? does coordinatorlayout have root layout? , if support actionbar? yes, possible (as long know images aren't wide overlap, , long image2 , image3 same width). positioning image1 , image4 easy; can constrain outside edges outside edges of parent. then use these constraints position image2 's right-hand edge exact center of parent: app:layout_constraintright_toleftof="parent" app:layout_constraintright_torightof="parent" and these constraints position image3 's left-hand edge exact center: app:layout_constraintleft_toleftof="parent" app:layout_constraintleft_torightof="parent"

javascript - How to find position of an object in an array in JSON -

here data: { "bracketname": "set bracket name", "bracketid": "ttzbuz", "modid": "b11ptvjerm", "creationdate": 1503352813796, "teams": [{ "name": "team 1", }, { "name": "team 2", }, { "name": "team 2", } ] } i trying position of team . here code: var content = fs.readfilesync('brackets/' + data.bracket + '.json'); content = json.parse(content); content.teams.indexof({"name": "team 2"}); but doesn't work. i'm not sure how this. me? content.teams.findindex(team => team.name == 'team 2') wiki

php - securing slim 3, RESTful API -

i know how implement token based authentication. concern user actions register,login or verify, against attacking bots. can imagine bot making requests through fake phone numbers , sms or mail server respond of them! or thousands of registered users in users table in database fake , not verified. know firewall strategies block these type of attacks , traffics in network layer. possible secure "unauthenticated" http actions captcha code or way? if yes, how can send captcha image api server client? in raw? if send captcha possible how can find captcha client? session can helpful? thanks attention. you implement form of csrf (cross site request forgery) trapping avoid this. use combination of csrf , honeypot fields. here basic rundown: the server populates field via hidden-type input tag containing value set on fly , stored on server session variable. the form contains textfield (type="text" or textarea) hidden using css. when form posted, hidden

javascript - Append / Insert button from a HTML page from a domain to another one -

Image
i have website , creating plugin button show on our partners website. green button, on right of page: the button created , it's in single html page on own domain. problem is, how insert on partner's website? since can't make javascript requests between different domains, how achieve this? thanks!! trying render component on different domain cross-site scripting issue. can use xcomponent create cross-domain components - https://github.com/krakenjs/xcomponent wiki

android - if statements possibly not working -

Image
i have simple calculator 2 tabs, tabs appear working fine first tab calculating should, calculating second tab keeps throwing catch error . in 2nd tab, have 2 if statements, checks see edittext field contains data. depending on contains data calculation does. below code when button pressed have put together, streamlined i'm amature go easy on me. any advice working please? calculate.setonclicklistener( new view.onclicklistener() { @override public void onclick(view view) { if ( tabs.getcurrenttab() == 0) { try { if (d.gettext().tostring().trim().length() == 0) { a1 = a.gettext().tostring(); double a2 = double.parsedouble(a1); b1 = b.gettext().tostring(); double b2 = double.parsedouble(b1); d

javascript - Mail content sent using TinyMCE editor does not display images at receivers end -

i using tinymce editor custom mail sending page in website. need copy , paste contents directly microsoft word editor, includes images well. and sending contents of editor getting html contents of editor control. var mailcontent = tinymce.get('maileditor').getcontent(); but after sent mail reciever not able see images have sent. i using cdn link, <script type="text/javascript" src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script> my code initialize editor given below. rmsm.initmaileditor = function () { tinymce.init({ content_style: ".mce-content-body{font-family:calibri(body);font-size:11pt;}",// set default content style since tinymce removes empty tags when font style set explicitly. selector: '#maileditor', height: 300, plugins: "link", menubar: false, plugins: "paste",

javascript - How to find scrollTop after DOM modification -

i working on mobile application, use ajax load pages based on framework7, since i'm loading pages & content dynamically, function supposed change header's color not working anymore. here fonction : function scroller(){ var target=$(window).scrolltop(); console.log(target); if(target>=150){ $('.navbar').css({'background-color':'rgba(191, 141, 87, 1)', 'box-shadow':'0px 0px 5px black', 'transition': 'all 1s ease'}); } else{ $('.navbar').css({'background-color':'rgba(191, 141, 87, 0)','box-shadow':'none'}); } } the console displaying 0 var target, , guess because modify dom , add content not here @ instanciation of page. how can make function work ? thanks edit : i call function in body : <body onscroll="scroller();"> see below example hope want this... fiddle function scroller(){

asp.net identity - How to display aspnetuser data on a profile page? -

i working mvc 5 identity. display data aspnetuser table in users profile page. how can so, have tried far. in profile controller public actionresult viewprofile(string id) { var user = db.users.single(u => u.username == id); return view(user); } my view @model carpool.models.applicationuser @{ viewbag.title = "viewprofile"; } <h2>viewprofile</h2> <div> <h4>applicationuser</h4> <hr /> <dl class="dl-horizontal"> <dt> @html.displaynamefor(model => model.nationality) </dt> <dd> @html.displayfor(model => model.nationality) </dd> <dt> @html.displaynamefor(model => model.email) </dt> <dd> @html.displayfor(model => model.email) </dd> in layout page <li>@html.actionlink("prof

java - Error with calling FileProvider from DialogFragment - null object of reference, -

i trying fix error kind of not seeing comes from. from fragment creates new user calling fragmentdialog (on imagebutton click) enables me pick photo camera or gallery. gallery works fine, camera not. in line: uri photouri = fileprovider.geturiforfile(globalcontext, getactivity().getpackagename() + ".provider", getcamerafile()); i getting error: java.lang.nullpointerexception: attempt invoke virtual method 'android.content.res.xmlresourceparser android.content.pm.providerinfo.loadxmlmetadata(android.content.pm.packagemanager, java.lang.string)' on null object reference all data displaying correctly (i check in logs). where cna issue? regards, grzegorz edit: full stack trace: fatal exception: main process: com.myapp.myapp, pid: 27523 java.lang.nullpointerexception: attempt invoke virtual method

Cannot successfully parse Django DateField in form -

i have: date_due = models.datefield(null=true, blank=true) and related model form class in above occurs. other values validate fine in model form, when put in date in format august 25, 2017, receive error message: "enter valid date". in settings.py have set use_l10n = true (and set use_l18n = false ensure use_l10n setting being observed). in the documentation says: a list of formats accepted when inputting data on date field. formats tried in order, using first valid one. note these format strings use python’s datetime module syntax, not format strings date template filter. and gives examples. using examples given, in settings have placed: date_input_formats = [ '%b %d %y', '%b %d, %y', # 'october 25 2006', 'october 25, 2006' '%b %d %y', '%b %d, %y', # 'oct 25 2006', 'oct 25, 2006' '%y-%m-%d', '%m/%d/%y', '%m/%d/%y', # '

How to POST a bitmap to a server using Retrofit/Android -

i'm trying post bitmap server using android , retrofit . currently know how post file, i'd prefer send bitmap directly. this because user can pick image off device. i'd resize save bandwidth before gets sent server , preferrably not have load it, resize it, save file local storage post file. anyone know how post bitmap retrofit ? bitmap bmp = bitmapfactory.decoderesource(getresources(), r.drawable.ic_launcher); bytearrayoutputstream stream = new bytearrayoutputstream(); bmp.compress(bitmap.compressformat.png, 100, stream); byte[] bytearray = stream.tobytearray(); you can convert bitmap byte array , after post byte array server else can make 1 tempory file example file file = new file(this.getcachedir(), filename); file directly uplaod server wiki

ios - Firebase Messaging shouldEstablishDirectChannel not establishing connection on first app launch -

problem when launching app first time, or after deleting , re-installing, messaging.messaging().shouldestablishdirectchannel not establish socket connection. if shut down app, , re-open it, socket connection established. steps reproduce: 1) place code in appdelegate: firebaseapp.configure() messaging.messaging().delegate = self messaging.messaging().shouldestablishdirectchannel = true 2) place code anywhere after check if connection established: messaging.messaging().isdirectchannelestablished returns false. 3) listen connection state change , observe notification never gets fired. notificationcenter.default.addobserver(self, selector: #selector(fcmconnectionstatechange), name: nsnotification.name.messagingconnectionstatechanged, object: nil) that problem in nutshell. if kill app, , re-launch it, works expected. socket connection made , messagingconnectionstatechanged notification fired. why messaging.messaging().shouldestablishdirect

if firebug does not saupport to install firefox, This add-on is not compatible with your version of Firefox -

when download firefox 23-8-2017 , go add-ones option , search firebug. when click firebug icon, see "this add-on not compatible version of firefox. " what should add firebug successfully? uninstall firefox go link https://ftp.mozilla.org/pub/firefox/releases/ , install version 54.0/ install firebug can update firefox working firebug wiki

java - Kafka ReassignPartitionsCommand: IllegalArgumentException: long is not a value type -

i'm trying reassign partitions within project , i'm getting error. 2017-08-22 15:57:28 debug zookeeperbackedadoptionlogicimpl:320 - calling reassignpartitionscommand args:[--reassignment-json-file=partitions-to-move.json.1503417447767, --zookeeper=172.31.14.207:2181, --execute] java.lang.illegalargumentexception: long not value type @ joptsimple.internal.reflection.findconverter(reflection.java:66) @ joptsimple.argumentacceptingoptionspec.oftype(argumentacceptingoptionspec.java:111) @ kafka.admin.reassignpartitionscommand$reassignpartitionscommandoptions.<init>(reassignpartitionscommand.scala:301) @ kafka.admin.reassignpartitionscommand$.validateandparseargs(reassignpartitionscommand.scala:236) @ kafka.admin.reassignpartitionscommand$.main(reassignpartitionscommand.scala:34) @ kafka.admin.reassignpartitionscommand.main(reassignpartitionscommand.scala) @ rebalancer.core.zookeeperbackedadoptionlogicimpl.reassignpartitiontolocalbroke

Is there a way to read a text file using java but the text file has over 20 000 characters -

i have program uses text file store forenames of people problem when use bufferedreader, or scanner read file not work because there many characters in text file (estimated 20 000). , know bufferedreader has limit of 8192 chars , scanner has limit of 1024 chars. so can read characters without error or of them being left out? bufferedreader br = new bufferedreader(new filereader(new file("names.txt"))); (edit) i found problem not bufferedreader text file. text file had become corrupted , when remade text file , deleted old 1 worked. thank tried me being idiot. the buffer size may specified, or default size may used. default large enough purposes. in case , 20,000 characters not , default buffer should more enough. wiki

html - How do I input media query that removes fixed banner on the top and replaces it with mobile one? -

i working on media query have original banner desktop removed (i have used display: none;), , replaced banner mobile uses. please refer code below: <div class="headercontainer"> <img class="banner" src="web-banner.gif"/> <img class="banner-phone" src="phone-img.jpg"/> <div class="complogo"> i having issues inputing media query remove fixed position of banner , replace mobile one. apologies if have skipped something, quite fresh web development. .headercontainer { background-color:#000!important; border-bottom: 0 none; box-sizing: border-box; margin: 0 auto; max-width: 1000px; padding: 0 1%; position: fixed; top: 0; z-index: 100; height: 110px!important; a

Passing Docker container's run parameters in Kubernetes -

i have 2 containers (gitlab , postgresql) running on rancheros v1.0.3. make them part of kubernetes cluster. [rancher@rancher-agent-1 ~]$ cat postgresql.sh docker run --name gitlab-postgresql -d \ --env 'postgres_db=gitlabhq_production' \ --env 'postgres_user=gitlab' --env 'postgres_password=password' \ --volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \ postgres:9.6-2 [rancher@rancher-agent-1 ~]$ cat gitlab.sh docker run --name gitlab -d \ --link gitlab-postgresql:postgresql \ --publish 443:443 --publish 80:80 \ --env 'gitlab_port=80' --env 'gitlab_ssh_port=10022' \ --env 'gitlab_secrets_db_key_base=64-char-key-a' \ --env 'gitlab_secrets_secret_key_base=64-char-key-b' \ --env 'gitlab_secrets_otp_key_base=64-char-key-c' \ --volume /srv/docker/gitlab/gitlab:/home/git/data \ sameersbn/gitlab:9.4.5 queries: 1) have idea how use yaml files provision pods, repl

node.js - [polymer]How should I view the log output? -

how should view log output? console not output corresponding content, can me? thank you. code image console image nothing special polymer - you'll see result of statement, console.info("log test") , in console of developer tools. e.g. chrome, https://developer.chrome.com/devtools#console firefox, https://developer.mozilla.org/en-us/docs/tools/browser_console#browser_console_logging wiki

javascript - Using JS, jQuery, ajax, & json, I need help optimizing page load speed -

i building user profile page, using jquery, pulling json type database. inexperienced @ using ajax populate page, right now, page load takes far long. if refining code, optimize , speed page load, appreciate it. goal: trying take info json database built number of users multiple data points capture. here example of json data. have information displayed once it's tab has been selected. there large amount of data within each profile, publications. user can have amount of pubs, , code loops through of data before writing page. { "error": false, "cached": false, "profile": { "firstname": "john", "lastname": "smith", "preferredname": "", "email": "johnsmith@example.com", "gender": "", "phonenumber": "1234567890", "office": "todd hall addition 570b", "end

ionic2 - Cordova "Error: Your .idea platform does not have Api.js" when adding plugins -

when trying install cordova plugin, error message. cordova "error: .idea platform not have api.js" i have searched entire app ".idea" file , found reference in .gitignore file. there few similar questions around error on stack overflow, no solution has worked me. updating node version 8 didn't nor did removing , re-adding cordova platforms. any '.ideas'? my build info: cordova cli: 7.0.1 ionic framework version: 3.2.0 ionic cli version: 2.2.1 ionic app lib version: 2.2.0 ionic app scripts version: 1.3.7 ios-deploy version: 1.9.1 ios-sim version: 6.0.0 os: macos sierra node version: v7.4.0 xcode version: xcode 8.3.3 build version 8e3004b so .idea hidden directory in platforms folder. removing seemed fix problem , can install cordova plugins again. wiki

java - How to quickly integrate the maven project into the docker -

i have maven project project structure follows: parentproject: parentproject: aporject.war bproject.war parentapiproject: aprojectapi.jar bprojectapi.jar i package project @ same time following 4 items copied 4 docker, , run up。 is there ideas , technical solutions? i prefer build images after jar/war files ready (another option integrate maven plugin ). in both options need create dockerfile first. you have 4 applications need 4 containers (one container - 1 thing or 1 service run). every container have own base image , setup depending on how run application. for example, dockerfile copy jar file image , run using openjdk: from openjdk:8-jdk volume /tmp copy ./target/application.jar /application.jar run bash -c 'touch /application.jar' entrypoint exec java $java_opts -jar /application.jar expose 7000 to run war files need tomcat image . after added dockerfiles custom applications next step create docker-compose.yml file. include con

reactjs - How to force Enter key to trigger "submit" function without need to focus an input -

i'm making app in react-redux , want simple feature that's starting tricky implement. :) i want able open webapp (i land on login screen) , hit enter (the browser has saved user , password , filled in in correct input fields) , have "enter" keystroke tigger login function without me needing click anywhere first focus something. (on non-root component) i've got password input (the last one) bound enter key correctly. so pressing enter when have password field focused works : handlesubmit() { const { authenticate } = this.props; const { tusername, tpassword } = this.state; const credentials = { username: tusername, password: tpassword, }; authenticate(credentials); } _handlekeypress = (e) => { if (e.key === 'enter') { this.handlesubmit(); } }; render() { return ( <div onkeypress={this._handlekeypress} > <card id="signin">

tomcat - apache mod_proxy url does not work unless / is appended -

i have apache 2.4 setup mod_proxy load balance 2 tomcats. here addition httpd.conf proxyrequests off proxypass /app balancer://mycluster stickysession=jsessionid|jsessionid proxypassreverse /app balancer://mycluster <proxy balancer://mycluster> balancermember http://tomcat1:8080/app route=tomcat1 balancermember http://tomcat2:8080/app route=tomcat2 </proxy> <location /balancer-manager> sethandler balancer-manager require granted </location> proxypass /balancer-manager ! <location /server-status> sethandler server-status require host localhost require granted </location> from browser if try " http://localhost:7000/app " not work. if use " http://localhost:7000/app/ " application comes up. note additional "/" , end of url. how can additional / avoided? update working structure: proxyrequests off proxypass /app balancer://mycluster/app stickysession=jsessionid|jsessionid proxyp

python - What does the "yield" keyword do? -

what use of yield keyword in python? do? for example, i'm trying understand code 1 : def _get_child_candidates(self, distance, min_dist, max_dist): if self._leftchild , distance - max_dist < self._median: yield self._leftchild if self._rightchild , distance + max_dist >= self._median: yield self._rightchild and caller: result, candidates = list(), [self] while candidates: node = candidates.pop() distance = node._get_dist(obj) if distance <= max_dist , distance >= min_dist: result.extend(node._values) candidates.extend(node._get_child_candidates(distance, min_dist, max_dist)) return result what happens when method _get_child_candidates called? list returned? single element? called again? when subsequent calls stop? 1. code comes jochen schulz (jrschulz), made great python library metric spaces. link complete source: module mspace . to understand yield does, must understand generators are. ,

r - How to deal with change in default of lubridate's ymd -

in ymd lubridate, default value of tz utc . don't know when change made know in 1.5 default utc in 1.5.8 default null . this changes output of ymd posixct objects date objects breaks lot of code rely on having posixct object have date . there convenient way make backwards compatible or need add tz='utc' of old code relied on this? write wrapper replace ymd ymd_hms default still tz = "utc" library(lubridate) ymd2 = function(x){ ymd_hms(paste(x, "00:00:00")) } ymd2("2017/3/4") #[1] "2017-03-04 utc" class(ymd2("2017/3/4")) #[1] "posixct" "posixt" wiki

android - Ionic v1 open populated .sqlite -

i'm creating ionic v1 project. have sqlite database 3 tables, , display data in 3 different pages, preferably ngcordova. database this: dados.sqlite i tried several methods , example didn't work. need detailed example since not aware of sqlite . wiki

python - popen sql string issue -

using popen run postgresql query. works: maxid = 10 psql = "psql -d db -u user -t -c 'select id, experiment_id results id > " + maxid + "'" ssh = subprocess.popen(['ssh', 'me@server', psql], shell=false, stdout=subprocess.pipe, stderr=subprocess.pipe) result = ssh.stdout.readlines() when add clause, fails: psql = "psql -d db -u user -t -c 'select id, experiment_id results status '%completed%' , id > " + maxid + "'" ['error: syntax error @ or near "%"\n', 'line 1: ...t_id" results status %completed...\n', ' ^\n'] i've tried several quotation alternatives can't seem right. any appreciated. td update: able preserve double-quoted column names across call psql original issue of passing clause in single quotes.

Get subset of row into a variable using excel vba -

i want copy adapted version of subset of headers' row of 1 workbook new workbook using vba. initially, idea to: read original header row range array of strings variable manipulate array, namely dropping/eliminating , adding entries write transformed array destination location/workbook since unable find tolerable way eliminate , add entries array, though maybe better to: only read wanted sections of original header array variable rename needed entries , in array write transformed array destination workbook i have little no experience in vba, such simple operation 1 seems nightmare. my try below: ' initialization dim wbkold workbook dim wbknew workbook set wbkold = workbooks.open(filename:="filepath", readonly:=true) set wbknew = workbooks.add wbknew.saveas filename:="filename" ' step 1: read wanted sections of original header ' know size of target headers row beforehand dim strheadersarr(1 6) string ' problem: ' foll

html - Django language for dynamic fields -

<table class="table"> <tr> {% item in summary.titles %} <th>{{ item }}</th> {% endfor %} </tr> <tr> {% title in summary.titles %} <td> {{ summary.data[title] }}</td> {% endfor %} </tr> </table> is possible data in similar way? exception value: could not parse remainder: '[title]' 'summary.data[title]' var summary = { data:{ title1: 1, title2:2 }, titles: [title1, title2] } wiki

Logical and physical address with MMU on? -

i'm having doubts how kernel physical , logical addresses handled mmu. i'll try explain question doing example. let's doing assumption on arm architecture. the system starts mmu off, addresses pass inside cpu physical. before enable mmu make page table our physical addresses mapped @ virtual addresses physical address + 0xc0000000 . after turn on mmu. of clear. questions start: since in pipeline architecture let's instruction after load address 0x8000. knowledge here should have page fault since mmu doesn't find address anywhere inside page table, it's invoked page fault handle situation. if we've set interrupt vector, inside there's branch physical address, mmu doesn't find address , fall unavoidably in endless loop. missing? wiki

php - How to implement composer in yii 1? -

hello have old project written in php framework yii 1.1. dependencies added manually uploading extensions in extension folder. i want make project use composer track third-party code vendor directory. "extensions" directory not exist. existing extensions not namespaced , used manually in controllers: yii::import('application.models.black_lists.domains'); so possible achieve , how? thanks you have require composer autoloader before vendor used in code. so, have unregister yii autoloader before require composer one spl_autoload_unregister(array('yiibase','autoload')); require yii::getpathofalias('application.vendor').directory_separator.'autoload.php'; spl_autoload_register(array('yiibase','autoload')); after this, should able call class in vendor folder, composer way. new \owner\module(); wiki

Maven cannot download spring-boot-starter-logging-1.5.6 -

i'm having problems maven. created new module intellij idea, , using terminal: ./mvnw clean install it started download dependencies, freezes on downloading: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-logging/1.5.6.release/spring-boot-starter-logging-1.5.6.release.pom wiki

ios - View doesn't display all subviews when viewDidAppear called again -

goal of task display n-times subview in superview, , when open tab (i have tab bar controller) subviews must redraw. now, when open application @ first time views draws in each other correctly. if open tab , again open previous subviews must redraw but, redraws first subview or two.. maybe constraints.. method draw subviews invoke in viewdidappear. here code: import uikit import chameleonframework class drawingvc: uiviewcontroller { let defaults = userdefaults.standard let countofviewskey = "countofviews" var viewscount : int { get{ return int(defaults.object(forkey: countofviewskey) as! string) ?? 0 } } var screenheight : int { get{ return int(uiscreen.main.bounds.height) } } var tabbarheight : int { get{ return int((tabbarcontroller?.tabbar.frame.size.height)!) } } var screenwidth : int { get{ return int(uiscreen.main.bounds.width) } } func drawviews(count : int, view : uiview){ let inscrib

ios - DropDownlist showing in every textfield of cell swift -

Image
i made custom uitextfield shows 'dropdownmenu'. happening if write in textfield , every textfield of cell starts showing dropdown. , there 1 other issue. have textfield in stackview . , stackview in cardview (used shadow). , cardview in cell. how can add suggestiontable inside cell instead of using super.super.super.super.addsuview(suggestiontable) add in cell open class suggestiontextfield: uitextfield, uitextfielddelegate { var identifier = "suggestioncell" var suggestiontable:uitableview! var suggestionlist = ["first","second","third","four","fifth","sixth","seven","eight","nine","ten"] var filtersuggestionlist = [string]() var heightconstraint:nslayoutconstraint! var defaultshow = true { didset { self.suggestiontable.reloaddata() } } convenience init() { self.init( frame: cgrect.zero) self.delegate = self notificat