Posts

Showing posts from April, 2013

Android How to set click listener of a button which is from another layout xml file -

mainactivity shows viewpager there 3 layout files:activity_main.xml、card1.xml , card2.xml want view card1.xml , set listener. should do? i tried using this: layoutinflater layout=this.getlayoutinflater(); view view=layout.inflate(r.layout.card1, null); button b=(button)view.findviewbyid(r.id.b); then set onclicklistener: b.setonclicklistener(new myclicklistener(0)); but useless. public class myclicklistener implements onclicklistener { @override public void onclick(view v) { switch (v.getid()) { case r.id.your_btn_id: // code break; } } } another way can add button click listener in card1.xml fragment class.

display different image in same div in php -

i want display first image,title , description in col1 div, second in col3 , on in first image repeat in div . how solve this <?php include('connection.php'); $perpage=1; $i=1; if(isset($_request['act']) && trim($_request['act']=='load_data')){ $page=1; if(!empty($_get["page"])) { $page = $_get["page"]; } $start = ($page-1)*$perpage; if($start < 0) $start = 0; $msg=''; $q="select * addimages order id desc limit $start,$perpage "; $res = mysql_query($q); $row = mysql_fetch_array($res); $id = $row['art_id']; $qe="select banner images id=$id"; $rs=mysql_query($qe); $name=mysql_fetch_array($rs); //$id=$row['id']; //$no=mysql_num_rows($res); if(!$row==""){ $msg .= "<div class='article_index' id='".$row["art_id"]."'><div class='article banner_add'...

java - Using RxJava and Okhttp -

i want request url using okhttp in thread (like io thread) , response in android main thread, don't know how create observable . first add rxandroid dependencies, create observable this: subscription subscription = observable.create(new observable.onsubscribe<response>() { okhttpclient client = new okhttpclient(); @override public void call(subscriber<? super response> subscriber) { try { response response = client.newcall(new request.builder().url("your url").build()).execute(); if (response.issuccessful()) { if(!subscriber.isunsubscribed()){ subscriber.onnext(response); } subscriber.oncompleted(); } else if (!response.issuccessful() && !subscriber.isunsubscribed()) { subscriber.onerror(new exception("error")); } } catch ...

PHP Regex String Allow Chinese Word, alphanumeric & few special characters -

hi can in below code validation in username text field. allow chinese word, alphanumeric , special characters "_" , "-" only. added: i'm trying create validation username text field, allow chinese word, alphanumeric & "-" & "_" . i'm trying figure out regex below, not work expected. can hep. if (preg_match("/[~`!@#$%^&*()+={}\[\]|\\:;\"'<>,.?\/]/", "小明@ah meng")) { echo "invalid"; } else { echo "valid"; } the han unification comprehends multiple code points cjk. since pcre allows unicode categories \p token, can match chinese characters \p{han} . code: <?php $str = "小明ahmeng"; $regex = '/^[-_a-za-z0-9\p{han}]+$/u'; // notice spaces not included if (preg_match( $regex, $str)) { echo "valid"; } else { echo "invalid"; } ?> demo also, don't forget set /u mod...

amazon web services - AWS SWF Java: Activity returns value but promise never becomes ready -

i have unusual issue think, , i'm looking debugging help. problems: even though aws swf console shows activity returned valid response, flow framework never marks promise ready! e.g. in below code "activities.nexttask" never scheduled execution. the time "activities.nexttask" scheduled execution if result empty list! workflow code: @override public void myworkflow() { promise<list<validationerror>> result = activities.validate(input); handlevalidationresult(result); promise<void> nextresult = activities.nexttask(input, result); } @asynchronous public void handlevalidationresult(promise<list<validationerror>> result) { system.out.println("why isn't being executed?"); } and validationerror looks (with lombok): @value public class validationerror { string message; boolean isretryable; } validationerror missing default constructor (i.e. no-args constructor). changed co...

How to lock android screen orientation -

i'm making android video player.it has function user can watch video in orientation.i use code follow: settings.system.putint(getcontentresolver(), settings.system.accelerometer_rotation, 1); it works, when add function user can lock orientation, did it: settings.system.putint(getcontentresolver(), settings.system.accelerometer_rotation, 0); so met trouble. when i'm in landscape orientation , try lock orientation, screen turns portrait. can solve or tell me way it? setrequestedorientation(activityinfo.screen_orientation_landscape); or setrequestedorientation(activityinfo.screen_orientation_portrait); more info here: developing orientation-aware android applications

swift2 - expected identifier in function declaration swift -

when upgrade swift 1.2 swift 2.0 following error occurs expected identifier in function declaration swift here code internal func try(block: () -> int32) { perform { if block() != sqlite_ok { assertionfailure("\(self.lasterror!)") } } } can how solve this try keyword in swift 2.0 do ... try ... catch ... statement, should change name of function, instance: internal func mytry(block: () -> int32) { perform { if block() != sqlite_ok { assertionfailure("\(self.lasterror!)") } } }

visual studio 2015 - Cordova error Failed to load resource: the server responded with a status of 400 -

i've been working in visual studio 2015 , have handful of hybrid apps i'm making using cordova platform connect office 365 using office 365 api. of sudden i'm getting following error in projects during login: failed load resource: server responded status of 400 (bad request) i've restarted vs 2015 , i've restarted desktop. have changed affecting projects , not allowing me login?

Dynamics CRM 2013 throws SQL Timeout adding a user to a team -

i have simple tough problem. i trying add user team through user interface, i'm getting sql time out users. i got no plugins firing on association request. did not find familiarity between ones getting error. i have turned trace log on did not give me more details. following error log generated tracing tool. web service plug-in failed in sdkmessageprocessingstepid: {d3de2f15-53fa-4a12-a286-346cc4bfd310}; entityname: none; stage: 30; messagename: associate; assemblyname: microsoft.crm.extensibility.internaloperationplugin, microsoft.crm.objectmodel, version=6.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35; classname: microsoft.crm.extensibility.internaloperationplugin; exception: unhandled exception: system.reflection.targetinvocationexception: exception has been thrown target of invocation. @ system.runtimemethodhandle.invokemethod(object target, object[] arguments, signature sig, boolean constructor) @ system.reflection.runtimemethodinfo.unsafeinvokein...

android - Fragment is added to activity and fragments oncreateview is called but view is not being inflated? -

i have activity extends appcompatactivity , i'm adding fragment in framelayout inside activity.the fragments oncreateview being called fragments view not being inflated or shown. appcompat activity's layout: <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fff" > <framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/contain"> </framelayout> </framelayout> i'm adding fragment child framelayout.the code attach fragment below: onefragment m = new onefragment(); android.support.v4.app.fragmentmanager fm = getsupportfragmentmanager(); android.suppor...

java - How do I load data in RecyclerView asynchronously? -

i have blank recycler view inside fragment. upon receiving gcm notification, call webservice. webservice store data blank database. when done, how notify recycler view update new database content? i stuck @ portion need notify recycler view somehow update itself. implemented https://gist.github.com/skyfishjy/443b7448f59be978bc59 , works when there data in database. not work in scenario. i providing code have better understanding of problem: package mypackage; import android.app.activity; import android.app.loadermanager; import android.content.contentresolver; import android.content.contentvalues; import android.content.cursorloader; import android.content.loader; import android.database.cursor; import android.net.uri; import android.os.asynctask; import android.os.bundle; import android.os.handler; import android.support.v4.app.fragment; import android.support.v4.view.viewcompat; import android.support.v7.widget.linearlayoutmanager; import android.support.v7.widget.recycler...

ios - 'PFUser' does not have a member named 'subscript' -

this question has answer here: pfuser not have member named subscript? 2 answers i don't have enough reputation post images, i'm using parse signup , shows me 'pfuser' not have member named 'subscript' error please check code below var user = pfuser() user.username = usernametextfield.text user.email = emailtextfield.text user.password = passwordtextfield.text let imagedata = uiimagepngrepresentation(self.profileimage.image) let imagefile = pffile(name: "profilephoto.png", data: imagedata) user["photo"] = imagefile -> [error in line] user.signupinbackgroundwithblock { (succeeded, error) -> void in if error == nil { println("signup successful") } else { println("signup failed") } } it means ca...

sublimetext2 - Copy entire line shortcuts then paste it UNDER cursor -

on sublime text 3 (but guess it's same st2), know when copy ( ctrl + c ) when there nothing selected, entire line copied need know how paste below cursor. it paste above , doesn't seem logical me, there way modify behaviour ? it's not pastes "above" or "below", it's operating on current line. when copy without first making selection, copies current line. when paste that, operates on current line -- pastes buffer line, , side effect, whatever on line bumped out of way next line. can't bumped upward instead - file can grow or add new lines downward, can't grow upward beyond line 1. as how modify behavior, suggest trying make macro. http://docs.sublimetext.info/en/latest/extensibility/macros.html as pointed out in comments, macro works leaves 2 different ways paste, 1 normal use , other "entire line" behavior. unfortunate, though there (harder) solution. try write sublime plugin detect how behave , want in each ca...

spring - com.hazelcast.core.DuplicateInstanceNameException HazelcastInstance with name already exists -

i getting error while integrating spring hazelcast. please see hazelcast configuration in spring-servelt.xml. error occurs when autowired hazelcast. please help. hazel case configuration in spring.xml <hz:hazelcast id="srmscacheinstance"> <hz:config> <hz:instance-name>trunk</hz:instance-name> <hz:group name="trunk" password="trunk" /> <hz:management-center enabled="false" url="http://127.0.0.1:8080/mancenter-3.2.1" /> <hz:properties> <hz:property name="hazelcast.logging.type">log4j</hz:property> </hz:properties> <hz:network port="5701" port-auto-increment="true"> <hz:join> <hz:multicast enabled="true" multicast-group="224.2.2.3" multicast-port="54333" /> </hz:join> </hz:netw...

javascript - "SyntaxError: Unexpected token <" in WooCommerce? -

i getting error when changed woocommerce-2.3.13 version woocommerce-2.4.6: woocommerce: syntaxerror: unexpected token < as per knowledge, when adding script tag(< script>) on php file, open script tag < giving errors, means not reading script tag. i added plugin(on php file) connect checkout process payment gateway redirect bank list page. error coming when try redirect using javascript. redirect function header("location:$url") not working using javascript. ?> <script type='text/javascript'> window.location.href="<?php echo $url; ?>"; </script > <? i tried define('wp_debug', false);error_reporting(0);@ini_set('display_errors', 0); but getting same errors. when woocommerce checkout processed requires gateways return array (which converted json) telling checkout whether or not successful. it’s been way since v1. in 2.4+ made more strict in response must valid json. else...

multithreading - Python concurrent futures executor.submit timeout -

i want use many thread timeout thread. use following code : import concurrent.futures class action: def __init(self): self.name = 'initial' def define_name(self): # in real code method executed during 30-60 seconds self.name = 'name' action_list = [ action(), action(), ] concurrent.futures.threadpoolexecutor( max_workers = 20 ) executor: action_item in action_list: # without timeout arg, works ! executor.submit(action_item.define_name, timeout=1) action_item in action_list: print(action_item.name) i seen post how use concurrent.futures timeouts? don't need use result method python documentation don't me ( https://docs.python.org/3/library/concurrent.futures.html ). shows how define timeout map method not submit. do know way define timeout executor.submit method ? edit : example simple. in real case, have list of 15000+ items. each action run executor.submit() during 30 -...

javascript - checking individual element of an array by calling a method -

can optimize code bit more reduce number of line? i checking/passing individual array elements? can make re-write in generic way? for (var = 0; < $scope.studentreport.students.length; i++) { if (_isvaluenan($$scope.studentreport.students[i].age)) $$scope.studentreport.students[i].age = null; if (_isvaluenan($$scope.studentreport.students[i].number)) $$scope.studentreport.students[i].number = null; if (_isvaluenan($$scope.studentreport.students[i].height)) $$scope.studentreport.students[i].height = null; } var _isvaluenan = function (item) { var result = false; if (typeof item == 'number' && isnan(item)) result = true; return result; } you can nullify property internally in function, , pass item , property value in independently. example: for (var = 0; < $scope.studentreport.students.length; i++) { _checkvaluenan($$scope.studentreport.students[i], "age"); _checkvaluenan...

android - how to refresh listview -

i want enable , disable linearlayout. inside listview item. called notifydatasetchanged. getview not called , layout not getting visible. how can refresh view inside onclick in getview? @override public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub if (convertview == null){ convertview = inflater.inflate(r.layout.qna_list_item, parent, false); } final imageview openbtn= (imageview)convertview.findviewbyid(r.id.qna_list_item_open_btn); final linearlayout replyview = (linearlayout) convertview.findviewbyid(r.id.qna_list_item_reply); openbtn.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub replyview.setvisibility(view.visible); openbtn.setimageresource(r.drawable.list_btn_up); notifydatasetchanged(); ...

c - What is the difference between IF and ELSE IF clauses? -

i'm on path of learning c k&r. besides exercises in book, i'm doing myself. wrote following code, is, counts input, gives feedback how many words left reach "goal" of 10 words , congratulates reach 10 words. #include <stdio.h> main() { /* programm read input, check number of words, , congratulate when reach value of 10 words*/ int c, nw, counter; nw = 0; counter = 0; while (nw < 10) { c = getchar(); if (c == ' ' || c == '\t' || c == '\n') { counter = 0; } else if (c != ' ' || c != '\t' || c != '\n') { if (counter == 0) { counter = 1; ++nw; } printf("only %d words left\n", 10-nw ); } } } ok, in version code not count blanks words, resulting in correct output of words left. at first wrote code "if"...

apache - I need .htaccess redirection to video.domain.com/date/id -

i need redirect; http://video.domain.com/date/videoid to http://www.domain.com/video/video.php?date=$date&videoid=$id thanks lot... rewriteengine on rewritecond %{http_host} ^video\.domain\.com$ [nc] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^/]+)/([^/]+)/?$ video/video.php?date=$1&videoid=$2 [l] do note above work if both domain.com , video.domain.com hosted on same server.

c++ - How to initialize a bitfield inside structure declaration? -

this question has answer here: bit-fields “in-class initialization” results in “error: lvalue required left operand of assignment” 4 answers msvc++ gives me compiler error when try initialize bit field inside structure declaration: struct somestruct { bool : 1 = false; // compiler error bool = false : 1; // compiler error } ; what syntax initializing bit fields inside structure declaration? i bit surprised apparently visual studio correct here, if @ grammar section 9.2 of draft c++11 standard says: member-declarator: declarator virt-specifier-seqopt pure-specifieropt declarator brace-or-equal-initializeropt identifieropt attribute-specifier-seqopt: constant-expression and bit-fields not allowed have brace-or-equal-initializer . not clear me why restriction exists though. feels first time realized in-class initial...

how to implement android GPS service using google Api? -

i new in android, please here question: going implement simple gps apps using google map api have no idea that. suggestion/guide/link or step can help? please? ur helps appreciated. hi follow url step step android gps example

apache spark - broadcast variable fails to take all data -

when applying broadcast variable collectasmap(), not values included broadcast variable. e.g. val emp = sc.textfile("...text1.txt").map(line => (line.split("\t")(3),line.split("\t")(1))).distinct() val emp_new = sc.textfile("...text2.txt").map(line => (line.split("\t")(3),line.split("\t")(1))).distinct() emp_new.foreach(println) val emp_newbc = sc.broadcast(emp_new.collectasmap()) println(emp_newbc.value) when checked values within emp_newbc saw not data emp_new appear. missing? thanks in advance. the problem emp_new collection of tuples, while emp_newbc broadcasted map. if collecting map, duplicate keys being removed , therefore have less data. if want list of tuples, use val emp_newbc = sc.broadcast(emp_new.collect())

How to search a word in file in java -

i trying search string in file in java , what, tried . in below program getting output no data found , sure file has word searching import java.io.*; import java.util.scanner; public class readfile { static string[] list; static string sear = "create"; public void search() { scanner scannedfile = new scanner("file.txt"); while (scannedfile.hasnext()) { string search = scannedfile.next(); system.out.println("search content:"+search); if (search.equalsignorecase(sear)) { system.out.println("found: " +search); } else { system.out.println("no data found."); } } } public static void main (string [] args) throws ioexception { readfile read = new readfile(); read.search(); } } try : import java.io.*; import java.util.arraylist; import java.util.list; pub...

unity3d - In a Unity canvas a button and an image hide each other even though they don't overlap -

Image
in unity project have canvas button , image inside. have noticed though don't overlap (they quite distance) cover each other. when button below image in hierarchy panel image not shown. meanwhile when image below button cannot view image attached button. nevertheless can see button text...

wpf - Button touchDown and Button touchUp events -

i'm developing windows universal app (windows 8.1 + winwdows phone 8.1). can detect click event on button doing: <button x:name="menubutton" click="menubutton_click" /> i'd detect "press" event , "release" event on button. when button pressed have change image in app. when button released image returns init state. checked methods related button class, seems there's nothing me. thank in advance. you have implement it, this public class mybutton : button { public event routedeventhandler mypointerpressed; public event routedeventhandler mypointerreleased; public event routedeventhandler mypointerexited; public event routedeventhandler mypointermoved; public event eventhandler holdingstarted; protected override void onpointerpressed(pointerroutedeventargs e) { base.onpointerpressed(e); mypointerpressed?.invoke(this, e); } protected override void onpointe...

android - Error:Gradle: > java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options? -

error:gradle: execution failed task ':smartupdate:shri nkdebugandroidtestmultidexcomponents'. java.io.ioexception: output jar empty. did specify proper '-keep' options? what's wrong ? please me.very thanks. i annotated subproject build.gradle, follows. works well: defaultconfig { ........ //multidexenabled = true }

r - How to select range of year in uncleaned data in data.table? -

some of data in format: year persons 1: 2014 69 2: 2013 76 3: 2013 couldn't come 3 4: 2012 48 5: 2011 57 6: 1 as can see, data in column year not clean. when want select rows year 2011 2014, following code works: df[year %in% c("2014", "2013", "2012", "2011") ] select range of year: df[year >= 2011 , year <= 2014] # won't filter out row `2013 couldn't come`. if select regular year, (get rid of year other text, , empty year), guess can use regular expression: df[ year == '[0-9]{4}',] # doesn't work. however, doesn't work. how use regular expression in data.table ? select range of year; filter out untidy years. or just single string operation if want #1 & #2 , not clean data: dat[grepl("^201[1-4]$", year)]...

c++ - Why overloading of += never return nothing in other people's code? -

let's have simple class class c { private: int _a; int _b; public: c (int a, int b) :_a { }, _b { b } {} int () { return _a; } int b () { return _b; } bool operator== (c c) { return this->_a == c.a() && this->_b == c.b(); } }; and want overload operator += such that c foo(8, 42); c bar(1, 1); c zoo(9, 43); foo += bar; assert(foo == zoo); runs fine. as far i've read other people code, should write like c operator+= (c c) { return { this->_a += c.a(), this->_b += c.b() }; } but understanding, return ing useless. indeed, assertion above not fail when overload += as void operator+= (c c) { this->_a += c.a(); this->_b += c.b(); } or c operator+= (c c) { this->_a += c.a(); this->_b += c.b(); return c(0,0); } tl;dr: why shouldn't return void when overloading += ? returning left-hand side of expression allows ch...

django - Best Practice to handle form submission status pages reload -

i have django email form posts url in turn redirects , renders success/failure html. i using django messaging framework display success/failure messages on form submission status. all works except when user reloads status page, message popped , blank screen. i wondering correct treatment scenario is. should redirect homepage if there no messages, or maybe have generic two-liner fail-safe? ps: if not appropriate question on so, kindly recommend alternate site me ask question, couldn't find any. the messages displayed using django messages framework displayed once in subsequent request . if refresh page or go page, message disappear. intended behaviour of using messages. as per django messaging framework docs : quite commonly in web applications, need display one-time notification message (also known “flash message” ) user after processing form or other types of user input. the messages framework allows temporarily store messages in 1 request ,...

node.js - error[Error (E_UNKNOWN) Encountered an unexpected error] Details: MongoError: topology was destroyed -

this sample code creating zip file. examplefunction: function(req, res, next){ test.create({.... }).exec(function (error, hobj){ if(error) {console.log('error'+ error); return next(error)}; if(!hobj) {console.log('error'); return res.send({error : "error"});} var generateduuid=uuid.v4().replace(/[^a-za-z0-9]/g,'_'); var output = fs.createwritestream(path.join(__dirname,'../../assets/images/'+generateduuid+'.zip')); ziparchive.pipe(output); ziparchive.bulk([{ expand: true, cwd: path.join(__dirname,'../../assets/images/'), src: ['abc.mp3','xyz.mp3'], dest: 'newdir'}]); ziparchive.finalize(); return res.send({zipname : generateduuid+'.zip'}); }); } calling method in sailsjs controller continuously, cause mongo error[ error[error (e_unknown) encountered unexpected error] details: mongoerror:...

java - HTML5 offline support for JSR 286 portlets -

i want application developed using spring portlets work when not connected network. have used html5 offline (using appcache) feature , developed sample servlet , working fine. the same not working in portlets. is there limitation portlet-based applications? searched web not find information on this. i found problem why not working portlets. portal server adds "cache-control: no cache" in http header prevents caching though appcache available.

oracle - How to solve ORA-04063: view "SYS.ALL_QUEUE_TABLES" has errors? -

jdev version 11.1.1.7.1 i using oracle database 10g xe & able connect db , retrieve tables in hr schema. when trying create "business components table" getting above mentioned error. have uninstalled jdeveloper , once again reinstalled it. still getting same error. here description of error :- the following sql statement failed : select /*oracledictionaryqueries.all_oracle_object_query(3)*/ o.object_name, o.object_type, o.object_id all_objects o o.owner = ? , o.object_name ? , o.object_type in (?, ?, ?) , o.subobject_name null , o.secondary = 'n' , ( o.object_type <> 'index' or ( exists (select 1 all_indexes i.owner = o.owner , i.index_name = o.object_name , i.dropped = 'no' ) ) ) , ( o.object_type <> 'trigger' or ( exists (select 1 all_triggers tr tr.owner = o.o...

bitmap - Resizing a custom marker on Android maps -

im quite new android forgive me if have missed something. i've got following code displays custom marker on maps. custom marker has text on it. works point want resize marker amount when text longer. the code had custom marker was, private bitmap drawtexttobitmap(final int mresid, final string mtext) { resources resources = getresources(); // screen's density scale float scale = resources.getdisplaymetrics().density; bitmap bitmap = bitmapfactory.decoderesource(resources, mresid); bitmap.config bitmapconfig = bitmap.getconfig(); if ( bitmapconfig == null ) { bitmapconfig = bitmap.config.argb_8888; } bitmap = bitmap.copy(bitmapconfig, true); canvas canvas = new canvas(bitmap); paint paint = new paint(paint.anti_alias_flag); // set font color paint.setcolor(color.white); // set font size , scale paint.settextsize((int) (14 * scale)); /...

c# - List Filtering in Linq -

i have 2 lists. 1 list of ids. i've filter second list having ids in former list only. that, i've written below code var clientidlist = list.groupby(p => new {p.companyname, p.userid}) .select(s => s.min(m => m.id)); var olist = list.where(x => clientidlist.contains(x.id)) .orderby(x=>x.companyname).tolist(); but think there wrong in it. can me?

jquery - Javascript gets current Controller and Action on Rails -

is there way javascript knows current controller , action in rails? i have idea create hidden container current controller , controller. know if javascript has function know current controller , action. javascript runs client side , has absolutely no idea controller or action is, there cannot function use obtain sort of information. but can teach javascript concept. alter layout sth (haml assumed): %body{data: {controller: params[:controller], action: params[:action]}} you can obtain data using jquery: controllername = $('body').data('controller') actionname = $('body').data('action') now quesstion is, why want this. client side client side , mixing client side logic server side implementation might dangerous.

javascript - How to build navigation menu by webservice response content? -

my goal retrieve both navigation menu bar , content show backend rest webservice. how can achieve it? have following code, not work far: testpage.html: <div ng-controller="testcontroller> <li ng-repeat="nav in navs"> <a href="{{nav.link}}">{{nav.name}}</a> </li> </div> <!-- content... --> <script src="js/main.js"></script> <script src="js/navigationservice.js"></script> <script src="js/testcontroller.js"></script> main.js: app.config(function($routeprovider, $locationprovider) { $routeprovider.when("/test", { templateurl : "templates/testpage.html", controller : "testcontroller" }).otherwise({ templateurl : "templates/error.html" }); }); navigationservice.js: angular.module("test").service('navigationservice', function(data) { ...

html - Is there a way to select an open select box in css? -

i set background image (arrow down) select box after setting webkit-appearance attribute none. when option list opened want display background image (arrow up). there pseudo class or it? couldn't find during reasearch... it's not possible detect if html select element opened using css, or javascript. if wish customise arrow symbol of custom dropdown, best option use custom dropdown component maps hidden select element.

javascript - JS weeks, hours and days to seconds.. and back again -

i trying convert number of weeks, days , hours seconds , convert them again. when convert them back, days , hours not correct: var weeks = 3, days = 5, hours = 1; //convert seconds sec_in_w = weeks * 604800, sec_in_d = days * 86400, secs_in_h = hours * 3600, secs = sec_in_w + sec_in_d + secs_in_h; //convert weeks, days, , hours new_w = math.floor(secs / 604800); secs -= new_w; new_d = math.floor(secs / 86400); secs -= new_d; new_h = math.floor(secs / 3600); console.log('weeks: ' + new_w); console.log('days: ' + new_d); console.log('hour: ' + new_h); demo: http://codepen.io/anon/pen/avzwbp //convert weeks, days, , hours new_w = math.floor(secs / 604800); secs = secs % 604800; new_d = math.floor(secs / 86400); secs = secs % 86400; new_h = math.floor(secs / 3600); using modulus gives remainder.

c# - How to make each method wait to complete another inside of parallel.Foreach? -

i have big problem "parallel for" using task parallel. want make methods , functions synchronous (wait on each other). parallel.for(items, item=> { var = myclass1.function(foo.x); var b = myclass2.function(zoo.y, b.z); ---> should wait "a" result... var c = myclass2.method1(a.x,b.z); -----> should wait b result... }); how can that? parallel.for run in parallel across collection of items . each item processes, invoke given delegate synchronously. meaning, execute myclass1.function myclass2.function myclass2.method1 . assuming methods synchronous, , you're not doing in background threads inside of them. imagine this: items | | | | item1: item2: item3: item4: function1 function1 function1 function1 function2 function2 function2 function2 method1 method1 method1 method1

hadoop - sqoop export from hive to sql server error -

we trying export data hive sql server table sqoop export -d mapred.child.java.opts='\-djava.security.egd=file:/dev/../dev/urandom' --connect 'jdbc:sqlserver://' --username $$$$ --password #### --table ib_c3 --columns bill_to_customer_name,contract_number,service_line_id,service_line_name,service_line_status,sts_code,instance_id,serial_number,item_name,quantity,inventory_item_id,warranty_type,warranty_end_date,ship_date,party_site_id,last_dos,ib_product_type,product_family,erp_item_type,sku_list_price -m 1 --input-fields-terminated-by '\001' --export-dir /app/dev/smartanalytics/apps/csp/hivewarehouse/csp.db/csp_ib_c3_export --input-null-string '\\n' --input-null-non-string '\\n' -- --schema staging during export getting below error sqoop. can issue. caused by: java.io.ioexception: com.microsoft.sqlserver.jdbc.sqlserverexception: current transaction cannot committed , cannot support operations write log file. roll transaction. ...

php - ZipArchive::getStatusString(): Invalid or uninitialized Zip object -

the following code fail create zip file in php 5.6.12 , fail print out zip error message, instead displaying error / warning warning: ziparchive::getstatusstring(): invalid or uninitialized zip object in /tmp/x.php on line 9 but why? once worked in php 5.4. <?php // todo: check errors $temppath = tempnam('/tmp', 'ztmp'); $zip = new ziparchive(); $res = $zip->open($temppath, ziparchive::overwrite | ziparchive::create | ziparchive::excl); if ( $res !== true ) die($zip->getstatusstring()."\n"); it looks semantics have changed somewhat; unclear whether deliberate or bug. anyways, problem have empty file not valid zip being opened nonetheless , not initialized though requested file overwritten. so workaround or fix delete existing file , recreate it: <?php $temppath = tempnam('/tmp', 'ztmp'); // delete first @unlink($temppath); $zip = new ziparchive(); $res = $zip->open($temppath, ziparchive::ove...

Matlab, 1 x M matrix from N x M matrix -

this question has answer here: how subtract vector each row of matrix? [duplicate] 2 answers i'm trying substract 1 x m matrix n x m matrix. lets 1 x m matrix [1 2] and n x m matrix [3 4; 5 4; 1 6] and want result [2 2; 4 2; 0 4] i know how loop etc, i'm trying figure out is there math way of doing in single line? thanks. you can use repmat function extend 1xm matrix nxm , perform subtraction. >> m = [1 2]; >> n = [3 4; 5 4; 1 6]; >> n - repmat(m, length(n), 1) ans = 2 2 4 2 0 4 alternatively pointed out divakar can use >> bsxfun(@minus, n, m) ans = 2 2 4 2 0 4

sql - Conditionally return values from LEFT JOIN between 3 tables based on CASE -

first off, apologies long post. it's more simple looks ;-) i'm trying think conceptually simple, , believe i'm of way there, there's 1 last part can't implement without errors can't figure out how fix. i have 3 related tables. orders : each row order unique id, there never duplicates. +---------+---------+ | orderid | name | +---------+---------+ | 1 | order 1 | | 2 | order 2 | | 3 | order 3 | +---------+---------+ order details: relational table each row product line on order. +---------+-----------+ | orderid | productid | +---------+-----------+ | 1 | | | 2 | b | | 2 | c | | 3 | | | 3 | b | | 3 | b | +---------+-----------+ as can see orders have 1 product (1), have multiple products (2) , have duplicate products (3). products each row product unique id, there never duplicates. +-----------+-------------+ | productid | description ...