Posts

Showing posts from July, 2013

php - Upload image error in wordpress custom templete -

i trying code upload image in custom word-press template. working in php. when move on word-press template, shows warning , stop executing script. here code. assume table , folder created proper permission 777. <?php require('../../../wp-load.php'); require('../../../wp-config.php'); function getimageextension($imagetype) { if(empty($imagetype)) return false; switch($imagetype) { case 'image/bmp': return '.bmp'; case 'image/gif': return '.gif'; case 'image/jpeg': return '.jpg'; case 'image/png': return '.png'; default: return false; } } if (!empty($_files["uploadedimage"]["name"])) { $file_name=$_files["uploadedimage"]["name"]; $temp_name=bloginfo('template_directory').$_files["uploadedimage"]["tmp_name"]; $imgtype=$_files["uploadedimage"]["type"]; ...

android - Andriod:How to set lib path for aapt command? -

i trying compile android project using command line in windows. when use aapt generate r file, comes out error below: d:\sampleproject\myapplication>aapt package -f -m -j ./gen -s ./app/src/main/res -i "d:\programinstall\android\android sdk\platforms\android-21\android.jar" -m ./app/src/main/androidmanifest.xml .\app\src\main\res\values\styles.xml:4: error: error retrieving parent item: no resource found matches given name 'theme.appcompat.light.darkaction bar'. i've found theme.appcompact.light.darkactionbar related appcompat_v7 floder while floder under in libs floder, how can let complier know find lib need? i know late or may have found answer still posting: d:\sampleproject\myapplication>aapt package **--auto-add-overlay** -f -m -j ./gen -s ./app/src/main/res **-s "path_to_prebuilts\prebuilts\devtools\extras\android\support\v7\appcompat\res\"** -i "d:\programinstall\android\android sdk\platforms\android-21\and...

data structures - probabilistic skip list space complexity -

so have seen question probabilistic skip list space consumption: (answer) but think asker wasn't clear if wanted expected approach or worst case approach. so raise question debate again , explain why i'm confused. to clear - i'm looking space complexity of probabilistic skip list in the worst case . had in mind: on 1 hand, assume maximum levels number log(n) it's easy infer in worst case might have n nodes in each level give o(n logn). on other hand, assume there might more log(n) levels (e.g lists) , set bound n - n n => o(n^2) but! don't understand why have right limit levels, if new level depends on coin toss, let's assume in worst case infinte times heads (which means new level) , difer it's not bounded?! i'm confused. if don't set upper bound on height of skip list, there no upper-bound worst-case space usage. bound place, there's horribly unlucky , astronomically improbable execution of skiplist result in number of...

reading specific column of excel into java program -

i need read specific column of excel sheet , declare variables in java. program have done reads entire content of excel sheet. need read fixed column c. this have done: import java.io.file; import java.io.ioexception; import jxl.cell; import jxl.sheet; import jxl.workbook; import jxl.read.biff.biffexception; public class javaapplication4 { private string inputfile; string[][] data = null; public void setinputfile(string inputfile) { this.inputfile = inputfile; } public string[][] read() throws ioexception { file inputworkbook = new file(inputfile); workbook w; try { w = workbook.getworkbook(inputworkbook); // first sheet sheet sheet = w.getsheet(0); data = new string[sheet.getcolumns()][sheet.getrows()]; // loop on first 10 column , lines // system.out.println(sheet.getcolumns() + " " +sheet.getrows()); (int j = 0; j <sheet.getcolumns(); j++) { (int ...

ios - Needed help for complex core data query -

Image
i have table called userprofile mention below i need distinct location, count distinct location , count status value 0 @ distinct location user = user1. status value can between 0 t0 5(number) so output be abc 3 2 abd 1 1 where abc unique location, 3 total count abc in table , 2 total count status =0 @ location abc i can give inspiration, due assume, 'status' can 0 or 1. if that's not true, - think - have execute 2 separated fetch different predicated (one fetch count of location referring user1 , other count of status user = user1 , status = 1). nsfetchrequest *fetchrequest = [[nsfetchrequest alloc] init]; //create entity nsentitydescription *entity = [nsentitydescription entityforname:@"userprofile" inmanagedobjectcontext:self.managedobjectcontext]; [fetchrequest setentity:entity]; //filter user = user1 nspredicate *predicate = [nspredicate predicatewithformat:@"user == %@",user1]; [fetchrequest setpredicate:predicate]; ...

vim - Justify text in visual block -

is there way in vim justify text within visual block? p.e. partial example of file: text text |5 sm 23 | text text |1274 hc a4| text text | 33 rnd bc| text text | 28 yz 22 | text text |9808 yz 56| expected output: text text 5 sm 23 text text 1274 hc a4 text text 33 rnd bc text text 28 yz 22 text text 9808 yz 56 i enabled virtualedit: :set virtualedit=all . added column spaces (at right | in example) in order create 2 spaces after "23" , 1 space after "22". selected visual block , executed command :'<,'>ce without expected output. what describe commonly called justify (to left , right margins adding inner whitespace); whereas center adds whitespace left , right have equal amounts. there 2 plugins justifying entire lines : $vimruntime/macros/justify.vim ships vim justify plugin provides simple implementation as want applied blockwise selection , have delete blockwise selection, put them separ...

android - Gigya implementation , retype password dialog issue -

Image
i have implemented gigya in app, wherein logging gmail,facebook,twitter using gigya login apis. issue whenever logging in through gmail(which primary account on device), system's retype password dialog keeps appearing after few minutes. odd because not logging out gmail on device i 1 of engineers @ gigya , hope can out here. i'll start pointing out that, on android, gigya not ever trigger system password dialog that. method gigya uses log user not cross on system level account log in. i check password plugging in begin with. google chrome notification icon along 3 other warning icons indicates me either chrome or system trying log in , failing password. from personal experience can tell same google account, have 1 password log google services , password used syncing data , same account. @ point same password, after resetting new password, log in password reset sync password remained same before. i hope sheds light on why seeing dialog every often. best, c...

How to implement AJAX form submission using Flask-Admin? -

i'm trying use flask-admin pages on existing flask backed single page application. there way replace existing page-reload post method form submission while editing/creating model ajax post mechanism?

javascript - Modifying a simple jquery game -

i trying modify game, right shows 9 images @ random positions , user has click on them , when reaches 10 clicks game ends. want appear 1 image. share original function , function have modified it. original function createimages(){ var myarray= ["img/img1.gif","img/img2.gif","img/img3.png", "img/img4.gif","img/img5.gif","img/img6.gif", "img/img7.gif","img/img8.png", "img/img9.jpg"]; var count=0; var div; (var = 0; < 9; i++) { var randpos = 0 + math.floor(math.random() * 500); this.img = document.createelement("img"); div = document.createelement("div"); $("div").attr("id","div"+i); var randnew = 0 + math.floor(math.random() * (5)); var rand = 0 + math.floor(math.random() * (9-count)); this.img.src = myarray[rand]; $('#d...

java ee - jsf 2.0 property not found -

i looking problem since 2 days , can´t solve it! jsf managed bean looks that: @named(value = "hardwarerevisioncreatecontroller") @requestscoped public class hardwarerevisioncreatecontroller { private hardware.type type; public hardwarerevisioncreatecontroller() { } public hardware.type gettype() { return type; } public void settype(hardware.type type) { this.type = type; } public list<hardware.type> gethardwaretypes() { list<hardware.type> list = new arraylist<>(); list.addall(arrays.aslist(hardware.type.values())); return list; } } and want access variable hardwaretypes jsf page: <h:selectonemenu value="#{hardwarerevisioncreatecontroller.type}"> <f:selectitems value="#{hardwarerevisioncreatecontroller.hardwaretypes}" var="type" itemvalue="#{type}" itemlabe...

css - Page break styles not working using bootstrap3 -

we have created website using bootstrap3. while trying print page mobile view printed. have made necessary code changes print in desktop view. but page break styles not getting applied. have used following code: .avoid-break-inside { page-break-inside: avoid !important } .break-before{ page-break-before: !important } .break-after { page-break-after: always; }

android - loadConnectedPlayers returning a buffer of 0 players -

i'm working on unpublished google play app want integrate google play services. in game, want able display friends (people in google+ circles) play game, can send eachother gifts , visit eachother. seems loadconnectedplayers() ideal this. here's how i'm implementing this: games.players.loadconnectedplayers(mhelper.getapiclient(), true).setresultcallback(new resultcallback<players.loadplayersresult>() { @override public void onresult(players.loadplayersresult loadplayersresult) { if(loadplayersresult != null) { if (loadplayersresult.getstatus().getstatuscode() == gamesstatuscodes.status_ok) { if (loadplayersresult.getplayers() != null) { playerbuffer playerbuffer = loadplayersresult.getplayers(); log.d(tag, "number of players returned: "+ playerbuffer.getcount()); ...

html - Why is my clearfix not working in Firefox? -

this site: http://m2c.dreamhosters.com/wordpress/ the clearfix: .clearfix:after, .sub-menu:after, .sub-menu:after li { content: ""; display: table; clear: both; } works totally ok in chrome. in firefox doesn't show in element inspector (and makes parents div shrink. how can fix problem? as mentioned in comments, firefox dropping rule because .sub-menu:after li in selector invalid. in css2.1 , selectors 3 , 1 pseudo-element may appear @ per complex selector , must @ end of selector. when encountering invalid selector in ruleset browser must drop entire ruleset . why it's not showing in inspector. to fix it, either remove offending selector, appears mistake: .clearfix:after, .sub-menu:after { content: ""; display: table; clear: both; } or if meant apply :after pseudo-element .sub-menu li , relocate pseudo-element so: .clearfix:after, .sub-menu:after, .sub-menu li:after { content: ""; d...

wordpress - WPML language switch not redirecting to right domain -

i got wp installation wpml, did set them on different domains domain.com , domain.nl. when i'm on page following url: domain.com/free switch let go domain.nl/gratis. when i'm on domain.nl/gratis points domain.nl/free. when going not default language default language it's not taking correct domain. someone ever had same issue? or clue how solve / look. i had wp-config.php set site urls http_host lead problem.

r - Forecasting several time series models, dplyr -

i use dplyr forecast several models. models fitted on time series data, each hour own model. ie, hour = 1 model, , hour = 18 model. example: # historical data - basis models: df.h <- data.frame( hour = factor(rep(1:24, each = 100)), price = runif(2400, min = -10, max = 125), wind = runif(2400, min = 0, max = 2500), temp = runif(2400, min = - 10, max = 25) ) # forecasted data wind , temp: df.f <- data.frame( hour = factor(rep(1:24, each = 10)), wind = runif(240, min = 0, max = 2500), temp = runif(240, min = - 10, max = 25) ) i can fit each model, hour hour so: df.h.1 <- filter(df.h, hour == 1) fit = arima(df.h.1$price, xreg = df.h.1[, 3:4], order = c(1,1,0)) df.f.1 <- filter(df.f, hour == 1) forecast.arima(fit, xreg = df.f.1[ ,2:3])$mean but awesome this: fits <- group_by(df.h, hour) %>% do(fit = arima(df.h$price, order= c(1, 1, 0), xreg = df.h[, 3:4])) df.f %>% group_by(hour)%>% do(forecast.a...

php - Codemirror not working with Yii view, bootstrap -

Image
i trying integrate codemirror 1 of view in yii 1 but result not good. please me. in controller: registered $cs->registerscriptfile($baseurl.'/js/codemirror.js', \cclientscript::pos_begin); $cs->registerscriptfile($baseurl.'/js/php.js', \cclientscript::pos_begin); in view.php <textarea id="editor" name="editor" rows="10" style="width: inherit;"> <?= htmlentities($model->diff_content); ?> </textarea> <script type="text/javascript"> var e = codemirror.fromtextarea(document.getelementbyid("editor"), { mode: "application/x-httpd-php" //theme: 'blackboard' }); /*function app() { var txt = "mytext"; $('textarea#code').text(txt); }*/ </script> result: thank much i found answer question $cs->registercssfile($baseurl.'/css/codemirror.css', \cclientsc...

JSON data error-PHP -

am trying run below mentioned php code, errors out. php code: <?php public function setup() { parent::setup(); $this->citationstyles = $this->sm->get('citationstyleconversion\model\citationstyles'); $this->resettestdata(); } public function testsubmitactioncannotbeaccessedloggedout() { $this->dispatch($this->buildquery('submit', array(), false)); $this->assertresponsestatuscode(403); } public function testsubmitaction() { $stylemap = $this->citationstyles->getstylemap(); $keys = array_keys($stylemap); $data = array( 'filename' => "testfile.txt", 'filecontent' => base64_encode('test content'), 'citationstylehash' => $keys[0], ); $this->dispatch($this->buildquery('submit', $data)); $this->assertresponsestatuscod...

moving from c++ opencv to c# emgu cv? -

i'm new on c# want translate code c++ c#. program consist on determinig if image white or not that's why try value of pixel , comparing 0. int image_blanche(char * str, double prctage){ mat img=imread(str); int compt=0; for(int i=0;i<img.rows;i++){ for(int j=0;j<img.cols;j++){ if (img.at<uchar>(i,j)==0){ compt=compt+1; } } } if (compt< img.rows*img.cols*prctage) { return 1; } else if (compt> img.rows*img.cols*prctage){ return 0; } } i proced still don't working int image_blanche(string str,int prctge) { image<bgr, byte> img = new image<bgr, byte>(str); int compt = 0; int i; int j; ( = 0; < img.width; i++) { ( j = 0; j < img.height; j++) { bgr color = img[i, j]; if ((math.abs(color.green - 0) < 0) &&(...

jquery - is there $(document).find('selector') and $('selector') difference -

Image
i've started working on project , in code find combintions of $(document).find('selector') , $('selector'). cant find real reason why done. there significant differnece between 2 used simultaneously in project? should prefer 1 before in cases? $(document).find("selector") , $("selector") match same set of elements. there's no reason use $(document).find(...) on $(...) , , several reasons not to: it's longer write , more awkward read, inflating script size it results in more memory churn (more temporary objects created/destroyed) it's slower - http://jsperf.com/vs-document-find , http://jsperf.com/selector-vs-find-again

c# - Loading XML file -

i loading redirects xml file. the xml file looks this: <?xml version="1.0" encoding="utf-8"?> <arrayofredirectmodel xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <redirectmodel> <time>0001-01-01t00:00:00</time> <oldurl>/301/</oldurl> <newurl>/alloy-track/</newurl> <type>1</type> <id>6d278d45-aab1-4fa2-953f-f03963a29ff8</id> </redirectmodel> </arrayofredirectmodel> and read xml file code looks this. xmldocument xdoc = new xmldocument(); string mappath = httpcontext.current.server.mappath("~/clientresources/seocache"); xdoc.load(mappath + "//cache.xml"); xmlnodelist xmlselectednodes = xdoc.selectnodes("redirectmodel"); foreach (xmlnode node in xmlselectednodes) { but "xmlselectednodes" stays "null". i want "ol...

coordinates - Why screen y coodinate is counted from top to bottom -

when draw graps on mathematics or physics lessons origin of coordinate system in bottom left corner , y coord goes bottom. whe try draw on screen y-axis switches direction , coord system origin moves top-left corner. why so? it's historical thing. older crt monitors fire electrons @ screen in sweeping motion starting @ top, moving down screen, sweeping left right. complete sweep of screen typically 50-60 times second. here's link web page on subject.

casting one dimension array as two dimension array in c++ -

i need create 2 dimensional array dynamically allocated memory (both dimensions set @ runtime), efficiency purposes want create 1 dimension version of contiguous allocated memory, , yet again somehow want use 2 dimensional array. there way use casting implement this. usage want implement below, not work. best, int size = 4; int* arr = new int[size]; arr[0] = 10; arr[1] = 11; arr[2] = 12; arr[3] = 13; cout << (int[][2])arr[1][1] << endl; while think codor's solution in best compliance coding style of c++, share solution done in c-style. #include <iostream> typedef int (*pint2)[2]; //pint2 pointer array of 2 ints int main() { int arr[4] = { 0, 1, 2, 3 }; pint2 parr = (pint2)arr; std::cout << parr[0][0] << std::endl; std::cout << parr[0][1] << std::endl; std::cout << parr[1][0] << std::endl; std::cout << parr[1][1] << std::endl; getchar(); return 0; } hope helps! (o...

angularjs - How should I change the angular routing? -

good evening, i'm writing application on mobile platform steroids, angular.js , firebase.js. i've faced such problem: page not load, because trying access strange url: file://file:///users/patutinskijfedor/desktop/firebase/willy/www/ . error: failed execute 'replacestate' on 'history': history state object url 'file://file:///users/patutinskijfedor/desktop/firebase/willy/www/' cannot created in document origin 'null'. i read issue in internet , realized problem routing in angular. looks (file app.js): angular.module('scbi', ['scbi.controllers','ngroute']).config(function($routeprovider, $locationprovider){ $locationprovider.html5mode(true); $routeprovider.when('/teachers',{ templateurl: 'teachers.html'}); $routeprovider.when('/teachers/:id', {templateurl: 't.html', controller: 'teacherslistcontroller'}); $routeprovider.when('/', {templateurl: 'a...

html - Center Child dynamic divs -

i have centered div horizontally. cont1 div parent div . take width of device. , cont2 child div take width according content. , number of child div dynamic . divs centered . issue last div. want last div @ left side. have tried lots of techniques. unable fix . i dont want use javascript or jquery . here fiddle link fiddle link here html <div class="cont1"> <div class="cont2"> <div class="child"> </div> <div class="child"> </div> <div class="child"> </div> <div class="child"> </div> <div class="child"> </div> <div class="child"> </div> <div class="child"> </div> <div class="child"> </div> <div class="child"> </div> <div class="c...

javascript - Loading Json Objects from text file - Returning Uncaught SyntaxError: Unexpected token " [ " -

i'm having problem getting json objects text file , being able use them in javascript function. works if there 1 json object. when start having multiple json objects gives me error: uncaught syntaxerror: unexpected token [ here code below: ios nsstring *post = @""; nsdictionary *firstjsondictionary = [nsdictionary dictionarywithobjectsandkeys:@"1025", @"dateandtime", logstring, @"description", [self getlogtypename:(logs)level], @"logginglevel", nil]; nsmutablearray *arraytest = [[nsmutablearray alloc] init]; [arraytest addobject:firstjsondictionary]; nsdata *jsondata2 = [nsjsonserialization datawithjsonobject:arraytest options:nsjsonwritingprettyprinted error:nil]; nsstring *jsonstring = [[nsstring alloc] initwithdata:jsondata2 encoding:nsutf8stringencoding]; post = [nsstring stringwithformat:@"message=%@", jsonstring]; nslog(@"post data: \n%@", post); nsdata *pos...

excel - Find the maximum value associated with a specific value in a different column -

i need find largest value in column b associated specific value in column a. here's example of mean: b 2 1 2 14 2 22 5 6 5 8 5 99 i.e. want find the largest value, 22 , in column b on same row 2 in column a. i'm using try find value, finds first value: =vlookup(a2, a1:b20, 2, false) please try: =max(if(a:a=2,b:b)) entered ctrl+shift+enter.

bash - Why do I not see the full expected range of random numbers? -

this question has answer here: random number range in bash script 15 answers i expect below code generate (quasi) random numbers between 0.9 , 1.0 rh. randno5=$((random % 100001)) upper_limit5=$(echo "scale=10; 1*1.0"|bc) lower_limit5=$(echo "scale=10; 1*0.9"|bc) range5=$(echo "scale=10; $upper_limit5-$lower_limit5"|bc) rh=`echo "scale=10; ${lower_limit5}+${range5}*${randno5}/100001" |bc` however, when run code value between 0.9 , 0.933(3sf). why case? $random is, @ most, 32767: random each time parameter referenced, random integer between 0 , 32767 generated. sequence of random numbers may initialized assigning value random. if random unset, loses special properties, if subsequently reset. your modulus have no effect generated numbers restricted range.

android - For which kinds of work I need to use CPU WAKE_LOCK in Sleep Mode? -

for kinds of work need use cpu wake lock ? example in sleep mode using telephonymanager getcelllocation() , should use partial_wake_lock in case or not? didn't find info in documentation. p.s. telephonymanager has different api implementation on different devices me looks tricky. thanks. **flag value cpu screen keyboard** partial_wake_lock on* off off screen_dim_wake_lock on dim off screen_bright_wake_lock on bright off full_wake_lock on bright bright incase keep getting location regularly when phone screen turned off, use partial wake lock so. above table can see partial wake lock keeps cpu on while screen , keyboard off(you dont require them want location). anyways refer below link more info on wake locks http://developer.android.com/reference/android/os/powermanager.html also refer question on so, can helpful how can keep android...

java - HibernateTemplate query with list -

hibernate beginner here, basic question. say have 2 hibernate objects: employee , department in one-to-many relationship. 1 department can have many employees . i have list of department objects , want to retrieve employees in departments. example, in sql it's easy: select * employee employee.deptid in (1, 2, 6, 19); what correct , proper way in hibernatetemplate find? example i've seen seems hopelessly verbose , involves creating list of departmentids , overriding executefind() . can directly using list<department> instead of creating list of object ids? //verbose example list employees = gethibernatetemplate().executefind(new hibernatecallback<list>() { @override public list doinhibernate(session session) throws hibernateexception, sqlexception { query query = session.createquery( "select employee" + "from employee e " + "where e.deptid in...

How to change the posted values with a spring mvc interceptor -

does know how change posted values spring mvc interceptor ? have seen examples none subject. know how them don't know how modify them. @component public class cultureinterceptor implements handlerinterceptor { @override public void aftercompletion(httpservletrequest arg0, httpservletresponse arg1, object arg2, exception arg3) throws exception { } @override public void posthandle(httpservletrequest arg0, httpservletresponse arg1, object arg2, modelandview arg3) throws exception { } @override public boolean prehandle(httpservletrequest request, httpservletresponse response, object arg2) throws exception { // posted values string culture = request.getparameter("culture"); string = request.getparameter("a"); string b = request.getparameter("b"); system.out.println(string.format("[cultureinterceptor culture=%s, a=%s, b=%s]", culture, a, b)); ...

android - Descendents layouts not appearing -

Image
i'm trying define more 1 linearlayout fit form , button bar @ bottom of activity it's not appearing, before changes forms scrollview , removed because not use anymore, when removed layout not appearing anymore, has solutions did wrong ? or forget ? here new code, when turn orientation landscape buttons disappear. how can fix ? <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:focusableintouchmode="true" android:orientation="vertical" > <scrollview android:layout_width="match_parent" android:layout_height="wrap_content" > <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="vertical" > <textview android:layout_width="match_parent" ...

php - How to make var_dump();die in magento downloadble products -

i want make var_dump();die; obtain model of downloadble product, i tried add method when admin makes click on upload donwadle information magento\app\design\frontend\rwd\default\template\downloadable\catalog\product\links.phtml in _preparelayout() process doesn't work spected. protected function _preparelayout() { $this->setchild( 'upload_button', $this->getlayout()->createblock('adminhtml/widget_button')->adddata(array( 'id' => '', 'label' => mage::helper('adminhtml')->__('upload files'), 'type' => 'button', 'onclick' => 'downloadable.massuploadbytype(\'links\');downloadable.massuploadbytype(\'linkssample\')' )) ); $links=mage::getmodel('downloadable/link') ->getcollection() ->addfieldtofilter('product_id',array(...

c# - Application.ThreadException event for ALL GUI threads -

i have winforms application creates multiple forms, each in own gui thread, (not main gui thread). handle unhandled exception event (application.threadexception) these forms handle errors. handle exceptions worker threads - bit seems working correctly, i'm having trouble exceptions gui threads still: program.cs: [stathread] static void main() { attachexceptionhandlers(); application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); application.run(new form1()); } public static void attachexceptionhandlers() { application.threadexception += new system.threading.threadexceptioneventhandler(application_threadexception); application.setunhandledexceptionmode(unhandledexceptionmode.catchexception); appdomain.currentdomain.unhandledexception += new unhandledexceptioneventhandler(currentdomain_unhandledexception); dispatcher.currentdispatcher.unhandledexception += new system.windows.threading.dispatcherunhandledexceptioneventhandler...

SQL Server table add id of last visits in GROUP query -

i have sql server database table list of users , last visit. extract list of last visit visitors, table id. let me explain better giving example. here's simplified version visits | id | visitor | last_visit | |----|---------|------------| | 1| abc | 2014-04-06 | | 2| def | 2014-04-06 | | 3| ghi | 2014-04-07 | | 4| def | 2014-04-07 | | 5| abc | 2014-04-08 | | 6| jkl | 2014-04-10 | | 7| def | 2014-04-12 | and here's obtain: | id | visitor | last_visit | |----|---------|------------| | 3| ghi | 2014-04-07 | | 5| abc | 2014-04-08 | | 6| jkl | 2014-04-10 | | 7| def | 2014-04-12 | i managed result without id column doing simple group: select visitor, max(last_visit) visits group visitor but don't have clue on how add id, fundamental purpose. try this: select a.id, a.visitor, a.last_visit visits inner join (select visitor, max(last_visit) last_visit visits grou...

How to execute a program using c code in linux -

i want write program runs program dont know correct way using 1 of exec functions. thought of first using fork , make child run program. can me this? thank you! code: char * arg[] = {"./"} execve(argv[0],path,null); and other different combinations different exec functions you can use exec functions. int execl(const char *path, const char *arg, ...); for example, execl("/bin/ls","ls","-l",null); in path can give executable code run. if want give argument functions can give in double quotes.

To a find a year in a string using Regular expression in perl -

input.txt ken, robert. (1994). lessons hull house contemporary urban university 2008. social service review, 68(3), 299-321. robert, john. 1994. lessons hull house contemporary urban university 2008. social service review. output.txt ken, robert. (<y>1994</y>). lessons hull house contemporary urban university 2008. social service review, 68(3), 299-321. robert, john. <y>1994</y>. lessons hull house contemporary urban university 2008. social service review. i have tried following coding, tag last occyears can fine me solution print "enter exp file name without extension: "; chomp($filename = <stdin>); open(red, "$filename.txt") || die "could not open exp file"; open(writ, ">$filename.html"); while(<red>) { if(/(.+)(\d{4})/) { s/(.+)(\d{4})/$1<y>$2<\/y>/g; } print writ $_; } close(red); close(writ); you have greedy regex, last year in every line gets match...

curl post php 403 forbidden -

i'm tring post data using post methode , curl excute , result 403 - forbidden: access denied. not have permission view directory or page using credentials supplied. $request=''; $url='https://app.highwire.com/api/auth'; $header=array('mydata'); $con = curl_init(); curl_setopt($con, curlopt_url, $url); curl_setopt($con, curlopt_ssl_verifypeer, 0); curl_setopt($con, curlopt_ssl_verifyhost, 0); curl_setopt($con, curlopt_header, true); curl_setopt($con, curlopt_httpheader, $header); curl_setopt($con, curlopt_post, 1); curl_setopt($con, curlopt_postfields, $request); curl_setopt($con, curlopt_returntransfer, true); curl_setopt($con, curlopt_failonerror, 0); curl_setopt($con, curlopt_useragent, 'mozilla/5.0 (windows; u; windows nt 5.1; en-gb; rv:1.8.1.6) gecko/20070725 firefox/2.0.0.6'); $res = curl_exec($con); curl_close($con);

mysql - Exception in thread "main" java.sql.SQLException: No suitable driver found for -

i'm trying connect mysql database, created sql database phpmyadmin on localhost. code seems correct , have jar file added eclipse. have googled error , found on here many topics same haven't been able resolve problem. here code: import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; public class dbconnection { public static void main (string[] args) throws classnotfoundexception, sqlexception { class.forname("com.mysql.jdbc.driver"); connection con = drivermanager.getconnection("jdbc:msql://localhost:3306/g52apr","root", ""); java.sql.preparedstatement statement = con.preparestatement("select * std_details"); resultset result = statement.executequery(); while (result.next()){ system.out.println(result.getstring(1) + " " + result.getstring(2)); } } } this exact error: exception in ...

jquery - bootstrap set asp grid width based on media -

i have web page has several bootstrap rows , 1 of rows contains asp.net grid. need grid width not shrink below 800px , add horizontal scroll bar if client view shrinks below 800px . example following clients use 400px width , auto scroll grid. <div style="overflow-x:auto;width:400px;overflow:scroll"> <asp:gridview id="gridview1" runat="server" width="1280px"> <%-- grid stuff here --%> </asp:gridview> </div> i way of not hard coding width of div 400px. edit using bootstrap following example. <div class="container-fluid"> <div class="row" id="testgrid" style="overflow-x:auto;width:400px;"> <div class="col-lg-12 col-xs-12"> <asp:gridview id="gridview1" runat="server" width="1280px"> <%-- grid stuff here --%> </asp:gridview...

MATLAB curve fitting - least squares method - wrong "fit" using high degrees -

Image
anyone here me following problem? following code calculates best polynomial fit given data-set, is; polynomial of specified degree. unfortunately, whatever data-set may be, @ degree 6 or higher, matlab gets totally wrong fit. fit curves totally away data in sort of exponantial-looking-manner downwards. (see example: degree = 8). x=[1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5] % experimental x-values y=[4.3 6.2 10.1 13.5 19.8 22.6 24.7 29.2] % experimental y-values degree=8; % specify degree = zeros(length(x),degree); exponent=0:degree; data=1:length(x); a(data,exponent+1)=x(data).^exponent; % create matrix end; end; a=inv((transpose(a)*a))*transpose(a)*y'; % coƫfficients of polynom a=flipud(a); fitpolynoom=polyval(a,x); error=sum((y-fitpolynoom).^2); % calculates fit-error using least-squares method fitpolynoom=polyval(a,x); figure; plot(x,y,'black*',x,fitpolynoom,'g-'); error % displays value of fit-error in matlab command window thanks in advance. ...

java - copying Queue and Stack into each other -

i want use empty stack s check whether queue q contaitns element x, solution copy elements of q s , check if contain x, i'm asked return s elements q again originaly, must done using q , s without other arrays of sl, have written algorithm: boolean found ← false int element ← 0 while(q not empty) element ← q.dequeue() if(element equal x) found ← true s.push(element) while(s not empty) ( elements q) ? stuck in last step, if used q.enqueue(s.pop) order of elements in q reversed correct, order reversed. means if repeat algorithm yet again (all s , q) reverse yet again, meaning original order of elements, want.

java - Remove Parent Keep Childs- DOM -

this xml input <?xml version="1.0" encoding="utf-8" standalone="no"?> <ns0:emessage xmlns:ns0="http://www.abc/something"> <ns0:header> <ns0:snumber>1613</ns0:snumber> </ns0:header> <ns0:name>someevent</ns0:name> <ns0:namespace>http://www.abc/something.xsd</ns0:namespace> <ns0:id>3</ns0:id> <ns0:myproperty> <ns0:name>extid</ns0:name> <ns0:value>test_id_12</ns0:value> </ns0:myproperty> <ns0:myproperty> <ns0:name>cversion</ns0:name> <ns0:value>0</ns0:value> </ns0:myproperty> </ns0:emessage> convert <?xml version="1.0" encoding="utf-8" standalone="no"?> <ns0:emessage xmlns:ns0="http://www.abc/something"> <ns0:header> <ns0:snumber>1613</ns0:s...

android - NPE getCount in Adapter when trying to get user albums using FB SDK -

i trying users albums using fb sdk. have managed log-in , able retrieve users profile picture , acquire access token. i following this answer here , trying work, running issue java.lang.nullpointerexception in adapter class on at com.myapp.myapp.photosadapter.getcount(photosadapter.java:37) here's full set-up have: where going wrong? thanks fbgrid activity: public class fbgrid extends activity { private string url; // store paging url private string pagingurl; // flag current page int current_page = 1; // boolean check if new feeds loading boolean loadingmore = true; boolean stoploadingdata = false; gridview grid; arraylist<getphotos> arrphotos; photosadapter adapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_fbgrid); grid = (gridview) findviewbyid(r.id.gridview1); grid.setonscrolllistener(new onscrolllistener() { @override pub...