Posts

qt - QDateTime Conversion -

i need convert string variable qdatetime format my code looks qstring date ="thu jun 18 2015"; qdatetime tmp = qdatetime::fromstring(date,"ddd mmm dd yyyy hh:mm:ss"); but result thu jan 1 00:00:00 1970 . later have convert date in foramt yyyy-mm-dd hh:mm:ss , first step have convert string in qdatetime have convert final format, there mistake above code? any appreciated. thanks haris your date string not include time, while mentioned want one, fail @ least in qt 5.4 . don't know though why epoche outputed, maybe dependant on qt version. your date format locale dependent . see example doucmentation "ddd" in qdatetime::fromstring : the abbreviated localized day name (e.g. 'mon' 'sun'). uses qdate::shortdayname(). which unfortunately not clear, while more clear qdatetime::tostring : the abbreviated localized day name (e.g. 'mon' 'sun'). uses system locale localize name, i.e. qlocal...

php - CodeIgniter Pagination only shows fixed numbers (1,2,3) -

Image
i did pagination pass data through ajax view. in case skip $config['uri_segemnt'] . here set total number of rows , per page manually. function creates html tags , pagination tags , append them view . working pagination shows 3 numbers every time. seems pagination not calculate total row count ,how can solve this? here function , view. php controller function public function getvoucherajax() { if (!empty($_post)) { $offset = $_post['limit']; $selecttedlist = $_post['listid']; } else { $offset = 0; } $count = $this->gettotalocount($selecttedlist); $vouchercount = $count[0]['vcount']; //$limit = perpage $allvouchers = $this->voucher_model->getallvouchers($this->perpage(), $offset, $selecttedlist); $config = array(); $config['total_rows'] = 56; $config['per_page'] = 10; ////bootstrap config pagin...

php - Multiple queries & LastInsertId -

how wrong query? can insert multiple queries that? can use lastinsertid that? $pdo = database::connect(); $dflt = 'default'; $query1 = "insert utilizador(email, pass, nome, dt_registo, tipo, activo) values (:email, '$hashed_password', :nome, :dt_registo, :tipo, :activo)"; $stmt = $pdo->prepare($query1); $stmt->execute(); $insertedid = $pdo->lastinsertid("utilizador"); $query2 ="insert aluno(morada, cd_postal, cidade, utilizador_id) values (:morada, :cpostal, :cidade,'$insertedid')"; $stmt2 = $pdo->prepare($query2); $stmt2->execute(); $hashed_password = hash( 'sha512', $_post['password']); $stmt->bindparam(':email',$_post['email']); $stmt->bindparam(':nome',$_post['nome']); $stmt->bindparam(':dt_registo',$dflt); $stmt->bindparam(':tipo',$dflt); ...

javascript - AngularJS: Why does $element.find('option') return an empty array when using ng-options? -

in angular 1.4, using ngoptions directive populate <select> tag <option> tags based on object looks this: {black: '#000000', red: '#ff0000', ...} that works fine using ng-options="value key (key, value) in vm.colors" , want add class each option tag matches key (e.g. '.black', '.red'). thought find option elements , use addclass() , i'm having trouble getting elements. (note: i'm not using jquery , avoid adding this.) here jsfiddle. i expect able bind results of $element.find('option') view model , watch using $scope.$watch('vm.options', function() {...}) , when log vm.options console seeing empty array. am using $scope.$watch incorrectly here? issue $element ? elements within scope of ngoptions unreachable controller? or making stupid mistake? any appreciated...thanks in advance! the docs pretty clear dom manipulation should done in directive. use rule of thumb: if find mys...

javascript - Google Translate API - No Access Control Origin with Text to Speech -

Image
i posted question on google translate text-to-speech work. google translate api text-to-speech: http requests forbidden i told needed key , enable billing. i've since done that. know billing enabled because, using specified endpoint words-only translations (not narrated speech) ( get https://www.googleapis.com/language/translate/v2?key=insert-your-key&source=en&target=de&q=hello%20world ), i'm able response both in dhc , in application $.get : in original question (above), told if api key, no longer blocked getting text-to-speech. tested request text-to-speech in dhc , postman: https://translate.google.com/translate_tts?key= mykeyhere &ie=utf-8&tl=zh-cn&q=你好 and got 200: excellent. however, in application, make get request: $.get('https://translate.google.com/translate_tts?key='+mykey+'&ie=utf-8&tl=en&q=hello+world', function (returned_data) { i blocked: no 'access-control-allow-o...

R, ggplot2, facetted histogram, decending order, factor x-axis labels -

Image
i have interesting problem need produce facetted histogram series want put in decending order each panel. below code replicates problem. library(ggplot2) set.seed(1) ngroup = 10; nsample = 10 df <- data.frame(group=rep(1:nsample,ngroup), category = factor(sample(letters, ngroup*nsample, replace=true), levels=letters), amount = runif(ngroup*nsample)) ggplot(df,aes(x=category,y=amount)) + geom_bar(stat='identity') + facet_wrap(~group,scales='free_x') + labs(title="some random histogram facets") which produces below output: i have tried following: library(ggplot2) set.seed(1) ngroup = 10; nsample = 10 df <- data.frame(group=rep(1:nsample,ngroup), category = factor(sample(letters, ngroup*nsample, ...

html5 - PHP getting enter from textarea to send email -

i created form users key in recipient, subject name, , message send mail via phpmailer. problem i'm facing textarea in form. i typed textarea: hi john, how's day? regards, best friend but right now, showing in email: hi john, how's day? regards, best friend any ideas on how format how user enters in text area? current script just $body= $_post["msg"]; i read should use nl2br isnt output? in advance what need add break each line. $text = trim($_post['textareaname']); // remove last \n or whitespace character $text = nl2br($text); // insert <br /> before \n if dont try this:(you may need play it.) //trim off excess whitespace off whole $text = trim($_post['textareaname']); //explode separate lines array $textar = explode("\n", $text); //trim lines contained in array. $textar = array_filter($textar, 'trim'); $str=''; //loop through lines foreach($textar $line){ $str .= $line."...