Posts

Showing posts from April, 2013

regex - Use wget to crawl specific URLs -

i trying crawl links website use download manager download files. i've tried: wget --wait=20 --limit-rate=20k -r -p -u mozilla "www.mywebsite.com" i can't figure out how use wget or regular expressions save desired links only! wget offers wide variety of options fine tuning files download in recursive crawl. here few options can interest you: --accept-regex urlregex download url matching urlregex . urlregex regular expression matched against complete url. --reject-regex urlregex ignore url matching urlregex . urlregex regular expression matched against complete url. -l tells wget follow relative links. relative links example: <a href="foo.gif"> <a href="foo/bar.gif"> <a href="../foo/bar.gif"> non relative links: <a href="/foo.gif"> <a href="/foo/bar.gif"> <a href="http://www.server.com/foo/bar.gif"> references wget : re

php - SSO using session -

i have 2 website (www.mainwebsite.com)(community.mainwebsite.com). using 1 server(host) separately in folder , different database, , both have different login form. access both site , add custom code sso. trying using session.save_path on both website. ini_set('session.save_path',realpath(dirname($_server['document_root']) . '/../session')); session_start(); anyone have idea on want do?

Eclipse Kepler: Installing Plugins for Juno -

i downloaded eclipse kepler (version 4.3), , first thing did install google plugin eclipse (android, gwt, etc.). since there isn't version of plugin kepler, how reliable install , use plugin version designed juno (4.2)? it work fine, there no major differences, supported versions preferred eclipse backward compatible , don't see issue there.

android - Xamarin: Any difference between using Java.IO and System.IO -

i wondering if there difference between using java.io , system.io both can achieve same stuff. there difference between java.io , system.io . system.io namespace comes .net bcl. the system.io namespace contains types allow reading , writing files , data streams, , types provide basic file , directory support. whereas java.io package available part of jdk. java.io package provides classes system input , output through data streams, serialization , file system. since system.io part of bcl can use of classes in io operations across platforms each platform has different directory structure, , different filesystem capabilities - example xamarin.ios , xamarin.android support most system.iofunctionality.

python - Nested Template Functions as Parameters -

in python, there way of decorating function such can add additional functionality before and/or after function. in simple form, looks this: from random import systemrandom time import time import functools rdev = systemrandom() def time_function(func): @functools.wraps(func) def run(*args, **kwargs): start = time() ret = func(*args, **kwargs) print("took {:0.5f}s".format(time()-start)) return ret return run @time_function def foo(): x = [rdev.randint(1, 1000) _ in range(10000)] sorted(x) foo() # prints "took 0.04239s" i wanted write similar functionality in c++. pass function arbitrary parameters , return types function , have perform action. came with: #ifndef timeit_h #define timeit_h #include <string> #include <functional> #include <iostream> #if defined(_win32) #include <windows.h> namespace timeit { unsigned long gettime(void) { return gettickcount(); } }

java - How to extract a "registration" URL from a mail content -

i successful in reading content of gmail-email using "javamail" , able store in string. want specific registration url content (string). how can this, string contains plenty of tags , href want extract url provided in hyper link on word " click here" exist in below mentioned statement "please <a class="h5" href="https://newstaging.mobilous.com/en/user-register/******" target="_blank">click here</a> complete registration". on hyper link "click here" url href="https://newstaging.mobilous.com/en/user-register/******" target="_blank" i have tried using following code package email; import java.util.arraylist; import java.util.properties; import java.util.regex.matcher; import java.util.regex.pattern; import javax.mail.folder; import javax.mail.message; import javax.mail.messagingexception; import javax.mail.nosuchproviderexception; import javax.mail.session; import javax.m

java - Testing my program? -

i have class need implement in code. instructions are: code testing program/class. should construct or instantiate objects of class coded in step #1. testing program should call every method make sure work. should construct @ least 2 objects – 1 default constructor , 1 “other” constructor. second scenario, ask user values (radius and) height. may use input , output want this. this have far , i'm stuck: public class cube { private double height; public cube(){ height = 1.0; } public cube(double h){ height = h; } public double getheight(){ return height; } public void setheight(double h){ height = h; } public double calcvolume() { return height*height*height; } public double calcsurface(){ return height*height*6; } public string tostring(){ return this.tostring(); } public boolean equals(cube c){ return (c.getheight() == this.height); } } import java.util.* public c

json - A JSONObject text must begin with '{' at character 0 -

i trying parse json can different parts of json. when use following code jsonobject jsonoutput = new jsonobject( aresponse.getentity(string.class) ); i'm getting error : org.json.jsonexception: jsonobject text must begin '{' @ character 0 aresponse.getentity(string.class) returns json below.... { "list": { "access_level": "readonly", "address": "995@mg.lmsnet.com", "created_at": "tue, 19 apr 2016 04:01:05 -0000", "description": "", "members_count": 0, "name": "995" }, "message": "mailing list has been created" } any ideas why i'm getting error? able validate json on line json validator turns out had string variable , error went away. string tempstr; clientresponse aresponse = createmailinglist( "9967" ); **tempstr = aresponse.getentity( string.class);** jsono

android - Something went wrong with the Activity lifecycle, not normal behavior by pressing home or task switch button -

something not ok in code. activity lifecycle - @ starting app: oncreate --> onstart --> onresume - @ closing app: onpause --> onstop --> ondestroy - pressing home button or task switch button: onpause --> onstop - coming opened app app: onstart --> onresume but reason app calls ondestroy when press home button or task switch button, , calls oncreate, when go opened app. my app has 2 activites: - loginactivity, should appear first, if nobody logged on, or if logout button pressed - mainactivity handle main functions. please me identify causes not normal behavior of lifecycle. thanks! mainactivity: public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { public helper helper = new helper(this); public static final string sp_data = "sp_data"; public static final string fb_login_status = "fb_login_status"; public static final string flrt = "flrt"; public sharedpref

r - RNeo4j Error: Client error: (404) Not Found -

i trying query neo4j graph has been made keep getting error (error: client error: (404) not found) when type line cypher(graph, query). the library seems have installed fine. also, have used rneo4j before without problems. try connecting full path in startgraph() function: graph <- startgraph("http://localhost:7474/db/data/") and enter username , password if necessary!

ios - How can I download Images off the web and load it in a UICollectionView then pass an array of images to the next view? -

so parsing json custom objects. inside these objects have url string make asynchronous call grab these images. load collection view. my problems are: 1) how can load these images on cells without them disappearing or appearing on different cells scroll? 2) when tap on cell has pass on view , show on imageview 3) after image shows must have array of images in previous collection view switching amongst each other in same order. please help! also no third party libraries please! import uikit class homepagecollectionviewcontroller: uicollectionviewcontroller { var imagecache = nscache() var hingeimagesarray = [hingeimage]() var arraytoholdconvertedurltouiimages = [uiimage]() var task: nsurlsessiondatatask? //full of urls var hingeimageurls = [string]() var testimagearray = [uiimage]() override func viewdidload() { super.viewdidload() // makes network call hingeimages refreshitems() } override f

Wpf TextBox event when firing edit is finished -

i have wpf textbox control used billing app. entered price in textbox, calculation done on every entered character text changed event. , tried lost focus event, times don't want modify price lost focus event fired when focus on textbox. want event text changed , edit finished , how rectify prob.. plz reply.. , thankz.,

android - getItem method in viewpager called two times. How to avoid second time calling -

getitem() method called 2 times first time.i know feature of view pager.according requirement, need load 1 page @ time. if know please me. thanks in advance. if activity or fragment having viewpager , can implement onpagechangedlistener() on that. in listener there's 1 method called onpageselected(int position) give position of current page. can use method call getitem() method, executed when page visible.

Where should I register JSON marshallers in a grails plugin? -

i creating grails plugin , want know json marshallers should registered? this article you. just register bean in plugin's "yourpluginplugin.groovy" (in dowithspring clojure) , call register() method plugin well.

c++ - (VS2015) Attempting to fill a static map with data from initializer list -

i have class sorta like: class object { public: struct flag { const uint32_t bit = 0; const wchar_t* name = l""; const wchar_t sign = l""; } static std::map<const char*, flag> flags; } i'm on vs2015, want support clang , gcc (the latest). problem is, can't figure out how initialize map data. i tried putting inline, like: static std::map<const char*, flag> flags = { { "foo1", { 0, l"foo1", l'a' } }, { "foo2", { 1, l"foo3", l'b' } }, { "foo3", { 2, l"foo3", l'c' } } } but complained const integral types can in-class. okay! left declaration in class definition (as shown in first code snippet), , put in associated cpp: static std::map<const char*, object::flag> object::flags = { { "foo1", { 0, l"foo1", l'a' } }, { &

PyQt : accessing elements from outside the class -

first of all, i'd state question similar this: accessing gui elements outside gui class . since newby in pyqt, more help. i have design.py file, exported qt designer # -*- coding: utf-8 -*- pyqt4 import qtcore, qtgui try: _fromutf8 = qtcore.qstring.fromutf8 except attributeerror: def _fromutf8(s): return s try: _encoding = qtgui.qapplication.unicodeutf8 def _translate(context, text, disambig): return qtgui.qapplication.translate(context, text, disambig, _encoding) except attributeerror: def _translate(context, text, disambig): return qtgui.qapplication.translate(context, text, disambig) class ui_mainwindow(object): def setupui(self, mainwindow): mainwindow.setobjectname(_fromutf8("mainwindow")) mainwindow.resize(150, 94) self.centralwidget = qtgui.qwidget(mainwindow) self.centralwidget.setobjectname(_fromutf8("centralwidget")) self.lineedit = qtgui.qlineedit(self

node.js - How do I retrieve developer's repository information from github using nodejs? -

this follows series of tutorials doing learn nodejs. want access repository information of users on developer.github.com. when try use following piece of code shows error: json.foreach(function(repo){ ^ typeerror: object # has no method 'foreach' var https=require("https"); var username= "ollieparsley"; var options={ host: "api.github.com", path: "/users/" +username+ "/repos", method: "get", /*customheaders: { "user-agent": "app" }*/ }; var request= https.request(options, function(response){ var body=''; response.on("data", function(chunk){ body+=chunk.tostring("utf8"); }); response.on("end", function(){ var repos=[]; var json=json.parse(body); json.foreach(function(repo){ repos.push({ name:repo.name, description:repo.descrip

asp.net mvc - I have second Model I am trying to fill in a View and return. MVC 5 -

i start in controller viewbag.emailstuff = new emailstuff(); then in view, try model because view based on different one. @{var es = viewbag.emailstuff emailstuff;} @using (html.beginform("contactstore", "store", formmethod.post, new {emailstuff=es)) and have validaton working these 2 fields, fires if empty @html.editorfor(m => es.eventname) @html.validationmessagefor(m => es.eventname, "", new { @class = "text-danger-yellow" }) <br /> @html.editorfor(m => es.messagebody) @html.validationmessagefor(m => es.messagebody, "", new { @class = "text-danger-yellow" }) but can't figure out how values controller if fields have info in them. at controller, model referencing returns nulls both inputs though dataannotations works. i know hack. i'm trying away forms collection , learn how use models. view using different model 1 trying validate. @ top of view can see different model has not

How to print this word "☻" in the console window?(c/c++) -

wcout.imbue(std::locale("chs")); wchar_t *a = l"☻"; wcout << *a; it's not work, why? should do? possible errors: your compiler possibly not recognising l"☻" unicode string in source file. your console doesn't support it you use unicode character code instead ( "\u263b" ). make sure console supports unicode , font has corresponding character it. it may easier (depending on compiler support) use unicode character literals c++ 11; char a[] = u8"my \u263b character"; cout << a;

javascript - Google Places API get details - Invalid Request -

so i'm trying details based on google places text search. text search working fine, details keep getting "invalid request". i've followed examples documentation, examples other people no avail, have failed.... this text search, working. var lat = '43.09182244507046' var lng = '-89.48985488807972' var places; function initialize() { var location = new google.maps.latlng(lat,lng); var map = new google.maps.map(document.getelementbyid('map'),{ center: location, zoom: 15 }); var request = { location: location, radius: '50000', query: 'food' }; var callback = function (results, status) { places = results; console.log(status); console.log(places); } var service = new google.maps.places.placesservice(map); service.textsearch(request, callback)

load balancing - Setup dynamic upstream with nginx -

suppose have upstream source upstream first { } upstream second { } and in server block map $geoip_country_code $is_china { default no; cn yes; } what achieve if $is_china , use different upstream proxy_pass http://$preferred_host/; i can't figure how nginx. map might sufficient. have tried following? map $geoip_country_code $preferred_host { default first; cn second; }

Footable does not show Font Aweseome icons/Glyphicons? -

i have create table , added latest version of footable work fine. when adding font awesome icons item(td) nothing happening, not accepting code either way inject in: html: <td>a-kasse hk <i class="fa fa-check" aria-hidden="true"></i></td> using css: .icon { position: relative; .accepted:before { content: '\25ae'; font-family: fontawesome; left:-5px; position:absolute; top:0; } } so far removing footable initiation script display font awesome icons, not great solution. can include icons anywhere else on page, not in table. anyone have come across problem? the solution suggested here edit css file , replace font-specific code font-awesome or similar css. file @ : https://github.com/bradvin/footable/blob/v2/css/footable.core.css (sry, link have answered it, not accepted, included entire post...)

android cannot find realm gradle dependency -

i error while building: failed sync gradle project 'myapp' error:could not find io.realm:realm-android:0.88.3. required by: myapp:app:unspecified search in build.gradle files in project level gradle have added as: classpath "io.realm:realm-gradle-plugin:0.88.3" in module level: compile 'io.realm:realm-android:0.88.3' how fix error? project level gradle: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0' classpath 'io.realm:realm-gradle-plugin:0.88.3' } } module level: apply plugin: 'com.android.application' apply from: '../config/quality/quality.gradle' apply plugin: 'realm-android' android { compilesdkversion 23 buildtoolsversion "23.0.3" defaultconfig { applicationid "xxxxx" minsdkversion 15 targetsdkversion 23 versioncode 1

java - How does Stream.max() handle equality? -

although suspect answer "it's not specified"... if there multiple "greatest/lowest" elements in stream comparator passed max or min methods considers equal (returns 0 ), specified somewhere element found? after reading source code, think should first greatest element found according collection order. can check out source code of stream.max(comparator<? super t> comparator) , implementation class referencepipeline.max @override public final optional<p_out> max(comparator<? super p_out> comparator) { return reduce(binaryoperator.maxby(comparator)); } that can see, when call stream.max , mean call stream.reduce(binaryoperator<p_out> accumulator) and @ source code of binaryoperator.maxby(comparator) public static <t> binaryoperator<t> maxby(comparator<? super t> comparator) { objects.requirenonnull(comparator); return (a, b) -> comparator.compare(a, b) >

c# - IIS 8.5 configuration on startup.cs (Azure webrole) -

using (servermanager servermanager = new servermanager()) { var config = servermanager.getapplicationhostconfiguration(); // configure iis compress requests coming through proxies (cdn). var httpcompressionsection = config.getsection("system.webserver/httpcompression"); httpcompressionsection["nocompressionforhttp10"] = false; httpcompressionsection["nocompressionforproxies"] = false; httpcompressionsection["staticcompressionignorehitfrequency"] = true; // configure iis threshold , time-period compression var serverruntimesection = config.getsection("system.webserver/serverruntime"); serverruntimesection["frequenthitthreshold"] = 1; serverruntimesection["frequenthittimeperiod"] = new timespan(24, 0, 0); // 1 day // configure iis compress files beforehand var urlcompressionsection = config.getsection("system.webserver/urlcompression"); urlcompression

java - Is JAVA2D the only rendering mode to display transparent PGraphics objects in Processing? -

is java2d rendering mode in processing in pgraphics objects can displayed transparent background (as opposed p2d , p3d )? have tried rewriting code in other 2 modes ( p3d , p2d ) backgrounds of pgraphics turn out opaque (black default)---perhaps i'm missing method turn them transparent? png s i'm displaying in pgraphics objects turning out transparent expected; it's backgrounds of pgraphics opaque. working on project , have selected java2d in order keep pgraphics transparent, wonder if can alternately use p3d , features instead. from looking around online believe java2d mode render pgraphics transparent in earlier versions of processing (1.*), , i'm wondering if has changed version 2? thanks in advance clarification , help! update: below sample of code (written in eclipse in java processing component). v.k.'s reply works great (with png s) in processing pde, i've been unsuccessful getting work in project in eclipse. thoughts? : main class

Groovy extension method with traits? -

i'd know if there way add methods library classes using groovy traits. from read here @mixin used this, or can use runtime mixin approach metaclass. since @mixin deprecated in favor of traits, chance achieve same behavior using traits or runtime mixin option? thank you groovy supports implementing traits dynamically @ runtime. allows "decorate" existing object using trait. you can decorate object, however, afraid not possible decorate class instances have method available. see below simple example may or find more details here . trait { string extra() { "i'm method" } } class { string dosomething() { 'something' } } def s = new something() assert s.extra() == "i'm method" assert s.dosomething() == 'something'

Markup for RentalCarReservation not shows in Gmail but in inbox.google yes -

Image
i'm looking add rentalcarreservation consumer-side confirmation. with templates of documentation official don't shows nothing, in inbox.gmail yes. why? @jordi salom, rentalcarreservation not integrate gmail flightreservation . however, integrate inbox , now . here's card triggered after sent myself test email. consumer's see added benefit cards.

ios6 - Unable to dismiss a UIPopover from another class -

i have ipad app, created in xcode 4.6.3, ios 6.2, arc , storyboards. i create uipopover programmatically in subviewdata.m. @property (strong, nonatomic) uipopovercontroller *popover; // make rectangle attach popover cgrect rectangle = cgrectmake( touchpoint.x, touchpoint.y, 110, 1); // 0 height puts arrow on exact touch point // addressability storyboard viewcontroller uiviewcontroller *popovermainview = [[uistoryboard storyboardwithname:@"mainstoryboard" bundle:nil] instantiateviewcontrollerwithidentifier:@"menuview"]; popover = [[uipopovercontroller alloc] initwithcontentviewcontroller:popovermainview]; [popover presentpopoverfromrect:rectangle inview:self permittedarrowdirections:uipopoverarrowdirectionany animated:yes]; i set notifications in class (quickappointment.m) when uibutton in popover has been tapped. notification , issue code calendarviewcontroller.m : subv

c++ - #define confusion with {} and declaration -

i got c++ program school test. #include<iostream.h> #define convert(p,q) p+2*q void main() { int a,b,result; cin>>a>>b; result=convert(a,b); cout<<result; } this works correctly. when put p+2*q in {}, gives me error : "expression syntax in function main()" now when declare result before output, this: int result=convert(a,b); it works. why , why not? avoid using macros if have trouble understanding compiler complains about. code looks when macro expanded, when put {} result={a+2*b} and looks declaration on same line int result={a+2*b} before c++11 standard, former syntax error. since c++11, copy-list-initialization of temporary (see syntax labeled (10) ). the latter aggregate initialization .

docker - Nesting variables in Apache config -

i'm building docker-based apache proxy, , i'd proxied port configurable. i link containers --link ...:proxied , docker makes environment variables proxied_port_80_tcp_addr , proxied_port_80_tcp_port . used proxypass / "http://${proxied_port_80_tcp_addr}:${proxied_port_80_tcp_port}/" reverse proxy port 80. i'd port configurable command line, when start container. pass variable -e "port=..." , , usable ${port} in apache config. i've tried nest variables, ${proxied_port_${port}_tcp_addr} without success, , using define plugin, still no luck.

asp.net - Check if user exist in LDAP before authorization -

i use asp.net identity 2.0 , ldap authentication in mvc project , loing method shown below. @ first step check if user authenticated in ldap, need detect if there no user in ldap or credentials wrong return correct message user. how can this? [httppost] [allowanonymous] [validateantiforgerytoken] public async task<actionresult> login(loginviewmodel model, string returnurl) { if (!modelstate.isvalid) { return view(model); } applicationgroupmanager groupmanager = new applicationgroupmanager(); // validate user using ldap if (membership.validateuser(model.username, model.password)) { formsauthentication.setauthcookie(model.username, model.rememberme); // formsauthentication.setauthcookie(model.username, false); //code omitted brevity if (this.url.islocalurl(returnurl) && returnurl.length > 1 && returnurl.startswith("/") && !returnurl.startswith(&quo

vb.net - Huge amount of textboxes repeated code -

i have around 200 textboxes in form. pressing "enter" takes next textbox. pressing "up" takes upper textbox, etc... know coding it's 200 textboxes it's gonna huge amount of copy/paste. there short way can 200 textboxes ? you want show users 200 textboxes on single form? should @ least group them in container control logically, example in panel . use oftype . you add constructor of form-class uses anonymous event handler: dim alltextboxes = txt in me.textboxpanel.controls.oftype(of textbox)() order txt.tabindex dim txtlist = alltextboxes.tolist() int32 = 0 txtlist.count - 1 dim thistxt = txtlist(i) dim nextindex = if(i + 1 >= txtlist.count, 0, + 1) dim previndex = if(i - 1 < 0, txtlist.count - 1, - 1) dim nexttxt = txtlist(nextindex) dim prevtxt = txtlist(previndex) addhandler thistxt.keydown, sub(txt object, e keyeventargs) if e.keycode = 38 'up me.ac

javascript - How to do pagination in jquery -

i new jquery. trying sorting , pagination here problem is displaying page number not contents on page. know doing wrong not able figure out wrong. i know problem onpageclick not able figure out write there. tried examples given here not helping. i posting code here. <!doctype html> <html> <head> <script type="text/javascript" src="../jquery-latest.js"></script> <script type="text/javascript" src="http://tablesorter.com/jquery-latest.js"></script> <script type="text/javascript" src="http://tablesorter.com/__jquery.tablesorter.js"></script> <script type="text/javascript" src="http://tablesorter.com/addons/pager/jquery.tablesorter.pager.js"></script> <script type="text/javascript" src="http://tablesorter.com/docs/js/chili/chili-1.8b.js"></script> <script type="text/javascr

How do we perform custom operations on WindowedStream in Flink? -

i want perform operations on windowedstream in flink, average. there limited operations available predefined sum, min, max etc. val windowedstream = valuestream .keyby(0) .timewindow(time.minutes(5)) .sum(2) //change average? suppose want find average, how can that? flink not have built-in function compute average on windowstream . have implement custom windowfunction this. the efficient way implement reducefunction compute count , sum of value average , subsequent windowfunction takes result of reducefunction , computes average. using reducefunction more efficient, because flink applies directly on incoming values. hence aggregates values on fly , not collect them in window. significantlyy reduces memory footprint of window. since output of reducefunction has same type input, need add field count before applying reducefunction . something following should trick: val valuestream

How can I replace a number of list elements between 2 boundary symbols in a python list -

given list of zeros , boundary elements (ones) there efficient way replace zeros, if less n of them appear between ones? for n=3: [1,0,0,1,1,1,0,0,0,1,0,0,0] => [1,1,1,1,1,1,0,0,0,1,0,0,0] some more cases: [1,0,0,1] => [1,1,1,1] [0,0,1] => [0,0,1] [1,0,0] => [1,0,0] you can convert list str , use replace method, convert list : data = [1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0] n = 3 repl = (("1" + "0" * + "1", "1" + "1" * + "1") in range(1, n)) data_str = "".join(str(i) in data) r in repl: while true: new_str = data_str.replace(r[0], r[1]) if new_str == data_str: break else: data_str = new_str new_data = list(int(s) s in data_str) print(new_data) this print [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0] it looks little convoluted works fine if have small lists not cause memory issues.

ios - Simulator doesn't reflects the output -

i working in ios app dev. i have more fields cant able them in simulator... my actual xib here here output, result here i removed things still same output comes... you need either use autolayout or resize interface builder file's content device's(or simulator's) screen size.

ios - How play music from php without quick time player -

i have question. how play music php/html , others without quicktime player. when pushed button in php mp3 url iphone open automaticly quicktime player. need play music site without quicktimeplayer. how it's make saying please.. you try using <audio> tag. see here: http://www.codeproject.com/tips/226992/back-ground-music-in-html5 if don't want play immediately, leave off autoplay attribute , call .play() function @ later point. (see also: playing audio javascript? )

android - LayoutTransition causes Fragment to not show up the second time is created -

i have activity implements method: public void pushfragment(myfragment fragment) { stack.add(fragment); fragmentmanager fragmentmanager = getfragmentmanager(); fragmenttransaction fragmenttransaction = fragmentmanager.begintransaction(); fragmenttransaction.replace(r.id.main_frame_layout, fragment); fragmenttransaction.addtobackstack(null); fragmenttransaction.commit(); settitle(fragment.gettitle(this)); } in fragment, have listview onitemclicklistener: getappactivity().pushfragment(anotherfragment); the anotherfragment oncreateview method: @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { sethasoptionsmenu(true); layouttransition t = new layouttransition(); container.setlayouttransition(t); view rootview = inflater.inflate(r.layout.another_layout, container, false); final viewgroup vg = (viewgroup)rootview.findviewbyid(r.id.avatar_image_layout); vg.getlayou

android - CollapsableToolbarLayout with custom Toolbar height -

i'm creating layout using coordinatorlayout holding appbarlayout collapsabletoolbarlayout , toolbar . below app bar recyclerview . when scrolling in recyclerview , toolbar should collapse, similar cheesesquare demo app. difference demo 1) want toolbar (including title) statically @ top (so i've set app:titleenabled on ctl ), , 2) don't want collapse app bar only showing single line toolbar since have text views etc below toolbar app bar should never collapse beyond. using custom behavior control these text views during collapsing, , works fine. problem is, don't seem grasp how best set anchor point @ collapsing end. know app bar collapse until snaps to height of toolbar . need either put custom views inside toolbar, hence increasing height of toolbar itself, or somehow instruct ctl anchor custom view instead. however, whenever change height of toolbar , title text gets strangely aligned , haven't found way of keeping aligned set of reasonable att

android - Text-to-Speech in on View Pager -

i have view pager, , few text in every page, have button ,on button press text-to-speech event fire i know how use text-to-speech, when comes viewpager dont know code : public class mainactivity extends activity implements texttospeech.oninitlistener { private texttospeech tts; private button btnspeak; private edittext txttext; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tts = new texttospeech(this, this); btnspeak = (button) findviewbyid(r.id.btnspeak); txttext = (edittext) findviewbyid(r.id.txttext); // button on click event btnspeak.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { speakout(); } }); } @override public void ondestroy() { // don't forget shutdown! if (tts != null) { tts.stop(); tts.shutdown(); } super.ond

c# - Order of calling methods -

i'm trying implment file upload feature users can upload multiple files @ once. i'm using dropzone.js on client side , c# in end. i'm using mvc razor views , have view user inputs details , upload files within same page. i've gone ahead , created following methods [httppost] public async task<actionresult> uploadedfile(int? id) { foreach (string filename in request.files) { httppostedfilebase file = request.files[filename]; if (file != null && file.contentlength > 0) { //upload file here //file gets uploaded } } return new emptyresult(); } i need store model details db done in method follows public async task<actionresult> savetodb(myviewmodel viewmodel) { if (modelstate.isvalid) { //store db here int? id = viewmodel.user.userid; //redirect home page if ok

difftime - R timediff - 22-JAN-16 04.56.14.325000000 PM -

i want calculate duration between 2 date of data frame formatted per below: start_date_time 22-jan-16 04.56.14.325000000 pm end_date_time 23-jan-16 05.56.14.325000000 am i run below command: jm16$diff <- difftime(strptime(jm16$start_date_time, format = "%d-%b-%y %h.%m.%s"), strptime(jm16$end_date_time, format = "%d-%b-%y %h.%m%s"), units="mins") however, ends entire field of jm16$diff "na". please advise make mistake? thanks han the formula need use is: jm16$diff <- difftime(strptime(jm16$end_date_time, format="%d-%b-%y %i:%m.%os %p"), strptime(jm16$start_date_time, format="%d-%b-%y %i:%m.%os %p"), units="mins") this corrects following issues: difftime() takes difftime(end_time, start_time) , not other way around %i deals hours in 1-12 opposed %h deals 0-23 the hour followed c

php - How to return a ajax error? -

i want show ajax error after submitting form. ends 'die' best way handle this? write in php file in 'script' tags? if($_post['postform'] == 'newsletter'){ $newslettersubscriber = new newslettersubscriber(); $newslettersubscriber->set('cms_newsletters_id', 2); $newslettersubscriber->set('created', date('y-m-d h:i:s')); $newslettersubscriber->set('firstname', $_post['voornaam']); $newslettersubscriber->set('lastname', $_post['achternaam']); $newslettersubscriber->set('companyname', $_post['beddrijfsnaam']); $newslettersubscriber->set('emailaddress', $_post['email']); $newslettersubscriber->set('subscribed', 1); $saved = $newslettersubscriber->save(); die('subscriber added'); } i tried several solutions found can't work. thanks! all need create array , place parameter