Posts

Showing posts from January, 2013

php - multiple image upload codeigniter with different input tag -

i have following codeigniter code depends on number of directors. means if nos of directors 2, following code of 2 times. used unique id. want upload images ( 3 images of 1 director ) in single click. names should start director1_ <div class="row"> <h5 style="padding: 0 15px;">details director 1</h5> <div class="form-group col-md-4"> <label>full name</label> <input type="hidden" name="director[0][cid]" value="9"> <input type="text" class="form-control" name="director[0][name]" required="required" placeholder="enter full name" autocomplete="off"> </div> <div class="form-group col-md-4"

Android Studio incorrectly flagging arguments annotated with Snackbar.Duration -

Image
background i wrote wrapper around default snackbar.make method apply custom styling snackbar instances. method signature of custom wrapper follows: public static snackbar makecustom( @nonnull view view, @stringres int resid, @snackbar.duration int duration) where snackbar.duration annotation defined in android.support.design.widget.snackbar.java follows: /** * @hide */ @intdef({length_indefinite, length_short, length_long}) @intrange(from = 1) @retention(retentionpolicy.source) public @interface duration {} when invoke makecustom following arguments: makecustom( activity.findviewbyid(android.r.id.content), messageresid, snackbar.length_short); i see following error in ide (android studio): i see no such error if directly invoke snackbar.make , has following signature: public static snackbar make( @nonnull view view, @stringres int resid, @duration int duration) { it appear when us

php - path in query parameter append to url in .htaccess -

i trying make below url http://localhost/base/path/to/redirect/1-2-master/list.xh redirect to http://localhost/base/list.php?r=path/to/redirect/1-2-master i have tried this. getting 404 error. rewriteengine on rewriterule ^(.*)base/(.*)/list.xh$ $1base/list.php?r=$2 [nc,l] but when tested on http://htaccess.mwl.be/ , working fine assuming there no base/.htaccess can use rule in root .htaccess: rewriteengine on rewriterule ^(base)/(.+)/list\.xh$ $1/list.php?r=$2 [l,qsa,nc]

android - Screen rotation while playing video -

i playing video , has got fullscreen icon.on clicking on forcefully rotating device orientation landscape mode.but when rotate screen,the video locked landscape mode only.it not coming potrait mode.i want video rotation happen similar youtube/hotstar app,where change of rotation happens both on button click , device orientation change.kindly suggest way forward. findviewbyid(r.id.landscape).setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { setrequestedorientation(activityinfo.screen_orientation_sensor_landscape); } } }); public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); setautoorientationenabled(this,false); } question: simple requirement after forcefully rotating activity using setrequestedorientation(activityinfo.screen_orientation_sens‌​or_landscape); how can again go potrait mode rotating device without calling setrequestedorientation(activityinfo.screen_ori

c# - Setting property values in class called from master class -

thank in advance, confusing hell out of me! i have 2 classes below store values in before converting them json, don't far can't load values them. public class mergefieldsreload { public string fname { get; set; } public string lname { get; set; } public string customerid { get; set; } public string dob { get; set; } public string cliniccode { get; set; } } public class datareload { public string email_address { get; set; } public string status { get; set; } public mergefieldsreload merge_fields { get; set; } } as can see mergefieldsreload called datareload, in order json.net see sub array (may have wrong name there, feel free correct me). however when attempting set value of field in mergefieldsreload so datareload data = new datareload(); data.merge_fields.fname = row["fname"].tostring(); i 'system.nullreferenceexception: object reference not set instance of object.' error. don't error 2 fields directl

r - Returning non-alphanumeric characters found by REGEX -

i have no problem finding , returning words containing non-alphanumeric characters, i'd return non-alphanumeric character found. example: a <- c("hello?", "goodbye","hi!") grep("[^[:alnum:]]", a, value=true) returns: [1] "hello?" "hi!" but i'd return is: [1] "?" "!" any thoughts? thanks! edit: love this...two user responses, 4 different ways done. i've learned lot. thank you! we can use gsub remove alphanumeric characters matching pattern ( [^[:punct:]]+ - meaning 1 or more non punctuation characters) , replace blanks ( "" ). remove blanks either nzchar or setdiff . setdiff(gsub("[^[:punct:]]+", "", a), "") #[1] "?" "!" or option str_extract stringr library(stringr) as.vector(na.omit(str_extract(a, "[[:punct:]]+"))) #[1] "?" "!"

javascript - How to return the response from an asynchronous call? -

i have function foo makes ajax request. how can return response foo ? i tried return value success callback assigning response local variable inside function , return one, none of ways return response. function foo() { var result; $.ajax({ url: '...', success: function(response) { result = response; // return response; // <- tried 1 } }); return result; } var result = foo(); // ends being `undefined`. -> more general explanation of async behavior different examples, please see why variable unaltered after modify inside of function? - asynchronous code reference -> if understand problem, skip possible solutions below. the problem the a in ajax stands asynchronous . means sending request (or rather receiving response) taken out of normal execution flow. in example, $.ajax returns , next statement, return result; , executed before function passed success callback

elasticsearch - How to define specific field tokenization on Logstash -

i using logstash index mysql data on elasticsearch: input { jdbc { // jdbc configurations } } output { elasticsearch { index => "" document_type => "" document_id => "" hosts => [ "" ] } } when checking results found elasticsearch automatically tokenizes text this: "foo/bar" -> "foo", "bar" "the thing" -> "the", "thing" "fork, knife" -> "fork", "knife" well, ok of fields. there 1 specific field i'd have custom tokenizer. comma separated field (or semi-colon separated). should be: "foo/bar" -> "foo/bar" "the thing" -> "the thing" "fork, knife" -> "fork", "knife" i wander if there way configure on logstash configuration. update: this 1 example of index have. specific field kind : {

python - Loop over groups Pandas Dataframe and get sum/count -

Image
i using pandas structure , process data. dataframe: and code enabled me dataframe: (data[['time_bucket', 'beginning_time', 'bitrate', 2, 3]].groupby(['time_bucket', 'beginning_time', 2, 3])).aggregate(np.mean) now want have sum (ideally, sum , count) of 'bitrates' grouped in same time_bucket. example, first time_bucket((2016-07-08 02:00:00, 2016-07-08 02:05:00), must 93750000 sum , 25 count, case 'bitrate'. i did : data[['time_bucket', 'bitrate']].groupby(['time_bucket']).agg(['sum', 'count']) and result : but want have data in 1 dataframe. can simple loop on 'time_bucket' , apply function calculate sum of bitrates ? ideas ? thx ! i think need merge , need same levels of indexes of both dataframes , use reset_index . last original multiindex set_index : data = pd.dataframe({'a':[1,1,1,1,1,1], 'b':[4,4,4,5,5,5],

dojo - Changing option value in dropdown item using excel vba -

i new learner programming , new excel-vba , learning scraping through it. trying programmatically change color on website having below html <div><select id="color" name="color" data-dojo- type="dijit.form.filteringselect"><option value="orange">orange</option><option value="green" selected="selected">green</option><option value="yellow">yellow</option></select></div> ie1.document.getelementbyid("color").value = "orange" ie1.document.getelementbyid("color").focus ie1.document.getelementbyid("color").click after doing can see "orange" being written on dropdown on webpage when submit form on website considers default selected "green" value , not changed value "orange". tried focus , click still no luck. could please me out here? tried searching existing vba solution not find any.

extjs - How do I minify my CSS files when compile my SASS files using Sencha CMD -

we using sencha ext js , i'm creating custom theme using sass variables. i'm able run sencha package build , output theme 1 big css file. under impression have output compressed minified version. i've through docs appears i've missed something.

c# - How to bind dynamic data to data grid in wpf? -

Image
i have below class datamodel: public class inspectoroutput { string m_symbolname; // each string column name value in double list<keyvaluepair<string, double>> m_listprices = new list<keyvaluepair<string, double>>(); public string symbolname { { return m_symbolname; } set { m_symbolname = value; } } public list<keyvaluepair<string, double>> listprices { { return m_listprices; } set { m_listprices = value; } } public void addresult(string strresultname, double nresult) { listprices.add(new keyvaluepair<string, double>(strresultname, nresult)); } } in xaml window data grid defined below: <datagrid x:name="gridstockdata"> </datagrid> later on, in mainwindow have below code: private void runpr

swift - Add webRTC in webview in iOS? -

i have created chat webview. problem chat has video , voice not supported ios because not support webrtc. the main question how can add rtc inside webview in swift support ios video , voice? unfortunately current webrtc support in ios web browser, can't add webrtc. have use native ios libraries ( https://webrtc.org/native-code/ios/ ).

java - Adding Session Beans in Spring boot results in No Scope registered for scope 'session' -

i have issue not able add session beans in spring boot. in application.xml have defined 2 beans scope session referenced in "leadsjobschedule" controller below. application.xml <bean id="leadsjobschedule" class="za.co.discovery.portal.vitality.util.leadsjobschedule"> <property name="leaddetailsmap" ref="leaddetailsmap"/> <property name="googleanalyticshelper" ref="googleanalyticshelper"/> </bean> <bean id="googleanalyticshelper" class="za.co.discovery.portal.vitality.util.googleanalyticshelper" scope="session"> <property name="readtimeout" value="${timeout.read}" /> <property name="connectiontimeout" value="${timeout.connect}" /> <property name="gatrackingid" value="ua-63460442-1"/> <property name="proxyauthenticator" ref=&q

bluetooth - in iOS 10, why "retrieveConnectedPeripheralsWithServices" have no use? -

in ios 10, why "retrieveconnectedperipheralswithservices" have no use? when call method in ios10 (i'm sure there @ least 1 peripheral connected system), returns 0 elements. in ios9, returns peripheral connected system! don't know why! thank much!!

how to increase viewpager performance in android -

i'm devoloping simple android app has 2 activity ( let's call activity1 , activity2 ). activity2 contain viewpager has 50 pages. because want increase performance when switching page of viewpager set offscreenlimit 15 page ( because app use activity 2 ). for reason when switch activity1 activity2 ( when start app begin activity1 , switch activity2 ) take quite lot of time , make app isn't smooth expected. to solve problem has been thinking preload activity2 when i'm working on activity1 it's seem android doesn't support preload activity. solution think preload viewpager. don't know how send loaded viewpager between activity can me out ? android viewpager automatically caches limited number of pages , not load of them @ once. create required pages on demand. default caches 3 views (one can see, , left 1 , right 1 of current one). optimizing performance, suggest use things using views small sized bitmaps (if have any). mean not use large i

javascript - What is "track by" in AngularJS and how does it work? -

i don't understand how track by works , does. main goal use ng-repeat add precision. using track by track strings & duplicate values normally ng-repeat tracks each item item itself. given array objs = [ 'one', 'one', 2, 'five', 'string', 'foo'] , ng-repeat attempts track changes each obj in ng-repeat="obj in objs" . problem have duplicate values , angular throw error. 1 way solve have angular track objects other means. strings, track $index solution haven't other means track string. track by & triggering digest & input focuses you allude fact you're new angular. digest way of saying changes manifest in angular based on changes occur through triggering actions. click button update model via ng-click , registers change in digest cycle. i'm not articulate in explaining should investigate further if didn't clarify things. so track by . let's use example: call servic

html - Navbar not collapsing -

i have these in header rather under body said bootstrap needs jquery run: <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-ccuebr6csya4/9szppfrx3s49m9vuu5bgtijj06wt/s=" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-tc5iqib027qvyjsmfhjomalkfuwvxzxupncja7l2mcwnipg9mgcd8wgnicpd7txa" crossorigin="anonymous"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> and actual navbar part. i'm pretty sure missing can't see i'm doing wrong: <nav class="navbar navbar-default navbar-fixed-top"> <div class="container-fluid"> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header"> <but

openerp - Restrict events acces in Odoo calendar -

in odoo calendar, each user can follow specific calendar , see events contained in calendar. there way prevent functionnality ? aim to: prevent "classic" user see events, can add own events admin user has full rights on calendars i've searched in configuration not find rules. yes, calendar open all. you have add record rule

css - JavaFx jar file tableView style properties not working when creating jar? -

Image
i using netbeans create jar fx application , application running fine in standalone jar . style properties of tableview column header , fonts not working . i have made table view transparent there in jar comes in grey colour font changes. here css file in application .button { -fx-font-size: 13.0px; -fx-font-weight:bold; -fx-base: #00a7d4; -fx-background: #e5f3f6; -fx-focus-color: #0093ff; -fx-control-inner-background: #ffffff; -fx-text-base-color: #ffffff; -fx-background-color: transparent; -fx-inner-border: linear-gradient(to bottom, derive(-fx-color,73.6%) 0%, derive(-fx-color,29.200000000000003%) 100%); -fx-body-color: linear-gradient( bottom, derive(-fx-color, 34.0%) 0%, derive(-fx-color, -18.0%) 100%); -fx-background-insets: 0px; -fx-border-radius: 10; -fx-background-radius: 10; -fx-border-color:black; -fx-padding: 0.166667em 0.833333em 0.25em 0.833333em; /* 2 10 3 10 */ /*-fx-text-fill: -fx-text-base-color;*/ -fx-alignment: center; -fx-content-display: left; } .b

functional programming - Java 8 Pattern predicate using Stream - how variable is inferred? -

i reading "java se 8 impatient" , see curious code. it's this: final pattern pattern = pattern.compile("....."); final long count = stream.of("cristian","daniel","ortiz","cuellar") .filter(pattern.aspredicate()) .count(); i thought aspredicate method like public boolean aspredicate(string stringtomatch){ ..... } but real implementation this public predicate<string>aspredicate(){ return s -> matcher(s).find(); } i know use legal: final long count = stream.of("cristian","daniel","ortiz","cuellar") .filter(a->pattern.matcher(a).find()) .count(); but question how stream passes string pattern instance? how " cristian "," daniel "," ortiz "," cuellar " each passed method s -> matcher(s).find() . mean how strings somehow passed , become s variable of aspredicate method. the p

javascript - Adding ng-href to a button in angularjs changes the position of the text inside the button -

i'm starting learn angularjs (using angular-material), , have little problem using ng-href. made toolbar @ top of web page, add "ng-href" attribute button, text inside button isn't centered anymore: example image the first 2 buttons have ng-href tag added. third 1 hasn't. otherwise, same. angular.module('angular2',['ngroute','ngmaterial','ngmessages']) .config(function ($mdthemingprovider,$routeprovider) { $mdthemingprovider.theme('default') .primarypalette('blue') .accentpalette('blue'); $routeprovider .when("/", { templateurl : "main.html" }) .when("/test1", { templateurl : "test1.html" }) .when("/test2", { templateurl : "test2.html" }) }) .controlle

bluetooth - GMS for Android Wearable communication -

i working on android wearable application development , have couple of question regarding android apis wearables. 1) wondering why android uses gms (wearable apis in turn use bluetooth) communication between wearable , handheld device(smartphone)? , why bluetooth apis android not being used communication between these devices? 2) why wearable apis packed inside separate library "google apis android" , why not part of android sdk or framework? thanks in advance!

R-Randomly pick a number and do it over and over until a condition is achivied -

i want randomly pick number vector 8 elements sums 35. if number 0 number. if number greater 0, make number -1. in loop until sum of vector 20. how can in r? example: vec<-c(2,3,6,0,8,5,6,5) pick number list randomly , make number -1 until sum of elements becomes 20. i'm really not sure want, understand of question, here solution. you'll of concept , key fonctions in script. use , help() understand them , optimize it. vec <- c(2, 3, 6, 0, 8, 5, 6, 5) summ <- 0 new.vec <- null iter <- 1 while(summ<20) { selected <- sample(vec,1) if(selected!=0) new.vec[iter] <- selected-1 summ <- sum(new.vec) iter <- iter+1 }

html - Detect if user is scrolling within a div -

i searched way detect if user scrolling within div angularjs . looked on documentation ( https://docs.angularjs.org/api?phpsessid=cae8e98e7ca559b4605d75c813b358ee ) , searched ng-click , didn't find regarding scrolling there. there no easy way this? this: <div ng-scroll="ctrl.dosomething()"> </div> i know, ng-scroll doesn't exist. wrote example. ideas without external plugins or directives have include? thanks. you can make own custome directive like: .directive("ngscroll", function ($window) { return function(scope, element, attrs) { angular.element($window).bind("scroll", function() { console.log('do something!'); scope.$apply(); }); }; }); and use this: <div ng-scroll> </div>

html - PHP mail function doesn't complete sending of e-mail -

<?php $name = $_post['name']; $email = $_post['email']; $message = $_post['message']; $from = 'from: yoursite.com'; $to = 'contact@yoursite.com'; $subject = 'customer inquiry'; $body = "from: $name\n e-mail: $email\n message:\n $message"; if ($_post['submit']) { if (mail ($to, $subject, $body, $from)) { echo '<p>your message has been sent!</p>'; } else { echo '<p>something went wrong, go , try again!</p>'; } } ?> i've tried creating simple mail form. form on index.html page, submits separate "thank submission" page, thankyou.php , above php code embedded. code submits perfectly, never sends email. please help. although there portions of answer apply usage of the mail() function itself, many of these troubleshooting steps can applied php mailing system. th

date - Symfony convert to user's timezone in controller or twig -

i store in database dates of time datetime on mysql on utc time. i'm using symfony 2.4.5 (yes old). i retrieve dates controller normal sql query propel. since not want query user timezone time database save in session user's timezone '{'timezone'=> 'europe/paris'}. should convert dates retrieved db in controller or in twig ? // in controller $dictionarythathaveotherdata = ... $datefromdbinutc = userquery::create()->... $datefromdbinutc->settimezone(new datetimezone($this->get('session')->get('timezone'))); $dictionarythathaveotherdata['dateforsomething'] = $datefromdbinutc; // in twig {{ dateforsomething | date('theformatiwant') }} or instead convert in twig: // in controller $dictionarythathaveotherdata = ... $datefromdbinutc = userquery::create()->... $dictionarythathaveotherdata['dateforsomething'] = $datefromdbinutc; // in twig {{ dateforsomething | date('theformatiwant',

javascript - Sorting an HTML list ascending and descending, with jQuery -

i have "numbered" list of names. want sort alphabetically @ click of button, after choosing sort criteria drop-down list (select). the problem that, if sort items ascending , descending, descending sorted items placed after ascending sorted ones. list gets bigger. $(document).ready(function(){ var sortitems = function() { var sortednames = []; var sorteditms = []; var rawnames = $('.list').find('li'); (var = 0; < rawnames.length; i++) { var names = $(rawnames[i]).text(); sortednames.push(names); } $('#choose_order').on('change', function(){ var currval = $(this).find("option:selected").val(); console.log(currval); if (currval != 'default') { $('#sortbtn').removeclass("disabled"); if (currval == 'asc') { sortednames.sort(); } else { sortednames.sort(); sort

html - Adding image to login page in cakephp -

i'm creating login page in cakephp. instead of writing "login", thought of showing image. how tried: <br> <div class="index large-4 medium-4 large-offset-4 medium-offset-4 columns"> <div class="panel"> <h2 class="text-center"><img src="img/cake.icon.png" /></h2> <?= $this->form->create(); ?> <?= $this->form->input('email'); ?> <?= $this->form->input('password', array('type' => 'password')); ?> <?= $this->form->submit('login', array('class' => 'button')); ?> <?= $this->form->end(); ?> </div> </div> in above layout, tried add image logo.png instead of showing "login". but, image did not load. i've placed image in webroot/img/logo.png. but, image not loading. what's wrong thi

Cassandra Bulk-Write performance with Java Driver is atrocious compared to MongoDB -

i have built importer mongodb , cassandra. operations of importer same, except last part data gets formed match needed cassandra table schema , wanted mongodb document structure. write performance of cassandra bad compared mongodb , think i'm doing wrong. basically, abstract importer class loads data, reads out data , passes extending mongodbimporter or cassandraimporter class send data databases. 1 database targeted @ time - no "dual" inserts both c* , mongodb @ same time. importer run on same machine against same number of nodes (6). the problem: mongodb import finished after 57 minutes. ingested 10.000.000 documents , expect same amount of rows cassandra. cassandra importer running since 2,5 hours , @ 5.000.000 inserted rows. wait importer finish , edit actual finish time in here. how import cassandra: i prepare 2 statements once before ingesting data. both statements update queries because have append data existing list. table cleared before starti

Polymer update style from child to parent -

Image
i have 2 elements. first 1 called test-layout using styles core-layout in test-layout: <link rel="import" href="../commons/core-layout.html"> <style include="core-layout"></style> <div class="containertest">test layout text</div> in core-layout: <style> .containertest{ color: var(--color, blue); } </style> <div class="containertest">core layout text</div> <script> _mediachanged(e){ if(this.mediadetail.desktop){ this.customstyle['--color'] = 'blue'; this.updatestyles(); } else if(this.mediadetail.tablet){ this.customstyle['--color'] = 'green'; this.updatestyles(); } else if(this.mediadetail.mobile){ this.customstyle['--color'] = 'red'; this.updatestyles(); } } </script> _mediachange() using iron-media-query notify me if view desktop, t