Sunday 15 May 2011

mysql - HTTP Request 500 when I call mysqli_connect with PHP -



mysql - HTTP Request 500 when I call mysqli_connect with PHP -

i want utilize database store user data. running apache server php , mysql installed. when seek mysqli_connect, there http 500 error. code:

$con = mysqli_connect("localhost","root","password","database"); mysqli_close($con);

i checked apache log; here's said:

[time] [error] [client localhost] php fatal error: phone call undefined function mysqli_connect() in [document address] on line 78, referer: [url]

and

php warning: php startup: unable load dynamic library 'ext/php_mysqli.dll' - specified module not found.\r\n in unknown on line 0

also, var_dump(function_exists('mysqli_connect')); outputs bool(false).

i've uncommented extension=php_mysqli.dll in php.ini, checked ext directory , there php_mysqli.dll file in it, checked other stackoverflow (and other) questions this, none of answered me. reply staring @ me in face? new this.

test phpinfo () , create sure function activated

php mysql apache internal-server-error

c# - can't see some cs files while Getting Latest Version from TFS -



c# - can't see some cs files while Getting Latest Version from TFS -

i'm using tfs source control, seek latest version, .cs files missing in visual studio, when open folder project these files there can't see in solution explorer whats problem?

sounds you've run in merge issue, files can in source , retrieved without beingness refrenced in proj file.

there button on top of solution explorer, right of minimize all, looks 1 document behind another. if click show files in directory. can right-click , add together on each file want

c#

How safe is cross domain access? -



How safe is cross domain access? -

i working on personal project , have beingness considering security of sensitive data. want utilize api accessing backend , want maintain backend in different server 1 user logon to. require cross domain accessing of data.

considering lot of accessing , transaction done, have next questions help guide me in right path have tried , tested cross domain access. don't want assume , implement , run troubles , redesign when have launched service thereby losing sleep. know there no right way many things in programming there many wrong ways.

how safe in handling sensitive info (even https). does have issues handling lot of users transactions. does have downside not mentioned.

these questions asked because post have read eve discouraged utilize of cross-domain access while encouraged it. decided hear professionals have used in bigger scale.

i building mobile app, using laravel backend.

thanks..

how safe in handling sensitive info (even https).

ssl considered safe (it's used everywhere , considered standard). however, it's not less safe hitting different server. info still has traverse pipes , reach destination has same risks regardless of server.

does have issues handling lot of users transactions.

i don't see why would. server server. ultimately, server's ability handle volume transactions going based on power, efficiency of code, , application's ability scale.

does have downside not mentioned.

authentication thing comes mind. i'm confused question how log 1 access info another. seems 1 application. if want revise question, i'll update answer.

cross-domain

.net - How to implement default methods for an interface? -



.net - How to implement default methods for an interface? -

when creating new class in .net if declare "implements idisposable" , nail enter, see visual studio adds itselt differents methods , functions filled class. when seek interfaces, creates empty methods , functions.

is there way provide default implementations of methods , functions ?

i have been looking link didn't resolve issue.

example of implementation i'm looking :

#region "idisposable support" private disposedvalue boolean ' observe redundant calls ' idisposable protected overridable sub dispose(byval disposing boolean) if not me.disposedvalue if disposing ' todo: dispose managed state (managed objects). end if ' todo: free unmanaged resources (unmanaged objects) , override finalize() below. ' todo: set big fields null. end if me.disposedvalue = true end sub ' todo: override finalize() if dispose(byval disposing boolean) above has code free unmanaged resources. 'protected overrides sub finalize() ' ' not alter code. set cleanup code in dispose(byval disposing boolean) above. ' dispose(false) ' mybase.finalize() 'end sub ' code added visual basic correctly implement disposable pattern. public sub dispose() implements idisposable.dispose ' not alter code. set cleanup code in dispose(byval disposing boolean) above. dispose(true) gc.suppressfinalize(me) end sub #end part

cheers in advance.

further exaplanations of i'm looking :

let's assume next interface

here happens , i'm looking :

it knows how set basic idisposable implementation, there's mutual pattern should follow.

but how perchance know how implement interfaces? empty methods need fill in yourself.

your closest bet set snippet , insert rather letting visual studio adding unimplemented members.

.net vb.net visual-studio interface

html - PHP 'loop for' with input text form -



html - PHP 'loop for' with input text form -

i'm doing programme have insert number ("x"), , generate "x" number of "input forms" come in diferent numbers later, calculate operations.

i have generate forms using for, , then, pass results submit button $_post next page. then, when seek results for, doesn't works , problems.

notice: undefined variable: num4 in...

what doing wrong?

thank you!

<?php /*here number create "x" number of forms*/ if (isset($_post["num"])) { $num=$_post["num"]; $_post["num"]=$num; if ( is_numeric($num) , $num>=0) { echo"<form action=\"tercera.php\" method=\"post\">"; echo "quina operaciĆ³ vols fer?:<br><br> " . "<input type=\"radio\" name=\"operacio\" value=\"suma\"/>suma " . "<input type=\"radio\" name=\"operacio\" value=\"mitja\"/>mitja" . "<input type=\"radio\" name=\"operacio\" value=\"major\"/>major" . "<input type=\"radio\" name=\"operacio\" value=\"menor\"/>menor</p>"; /*here create loop generate forms "numero[$i]" */ ($i=1; $i<=$num; $i++) { echo" <input type=\'text\' name=\'numero[$i]\' maxlength=\'10\' size=\"10\"/>"; } echo "<p><input type='submit' value='calcula' /></p>"; } else { echo "<h3>has d'escriure united nations numero mes gran que 0, torna-ho intentar."; } }//isset*/ ?> /*/ next php page /*/ <?php if (isset($_post["operacio"])) $operacio=$_post["operacio"]; //here numbers of lastly page ($i=1; $i<=2; $i++) { if (isset($_post["numero[$i]"])) $num2=$_post["numero[$i]"] ; //here error: undefined variable: num2 echo $num2; } //this part ok ... if ($operacio == "suma") { echo "i equals 0"; } elseif ($operacio == "mitja") { echo "i equals 1"; } elseif ($operacio == "major") { echo "i equals 2"; } elseif ($operacio == "menor") { echo "i equals 3"; } if ( is_numeric($num) , $num>=0) { ($i=1; $i<=$num; $i++) { } } else { echo "<h3>has d'escriure united nations numero mes gran que 0, torna-ho intentar."; } //isset*/ ?>

in sec page don't utilize this:

if (isset($_post["numero[$i]"])) $num2=$_post["numero[$i]"];

because field doesn't exist. when utilize array of fields, need field, , after position, instance, work:

if(isset($_post["numero"]) && isset($_post["numero"][$i])) $num2=$_post["numero"][$i];

remember, using field array.

if don't want in troubles elements in array, utilize (after knowing $_post["numero] exists):

foreach($_post["numero"] $num) { echo $num; // or waht want do. }

i hope help you.

php html forms

arrays - PHP IF ELSE condition and Foreach -



arrays - PHP IF ELSE condition and Foreach -

i have little issue trying compare info 3 arrays, 1 of them source , other 2 conditions.

the scenario next:

$array1 = array('code' => '123', 'code' => '124', 'code' => '125', 'code' => '126', 'code' => '127'); $array2 = array( array('code1' => '123', 'country' => 'us', 'listed' => '0'), array('code1' => '124', 'country' => 'us', 'listed' => '1'), array('code1' => '125', 'country' => 'us', 'listed' => '1') ); $array3 = array( array('code2' => '123', 'country' => 'us', 'listed' => '1'), array('code2' => '126', 'country' => 'us', 'listed' => '0'), array('code2' => '127', 'country' => 'us', 'listed' => '1') ); $final = array_merge($array1,$array2,$array3); foreach ($final $f) { if ($f['code'] == $f['code1']) { if ($f['listed'] > 0) { $finallisted = $f['listed']; } } elseif ($f['code'] == $f['code2']) { if ($f['listed'] > 0) { $finallisted = $f['listed']; } } $newfinalarray = array( 'code' = $finalcode, 'listed' = $finallisted, 'country' = $finalcountry ); }

so need check first if code $array1 exist in $array2 , if if code $array2 listed if not check on $array3 , on.

so if code exist on $array2 , listed 1 update database values if not check $array3 if exist , listed 1 update values if not update values $array2

the thought $array2 1 site , $array3 another, so, if not in 1 sec if in both keek $array2

the problem cannot sort, have tried array_combine combines 2 arrays , parameters need exactly. array merge 3 arrays one, on foreach , on apply if conditions variable undefined.

first of see lots of issue in way arrays declared you

ex -

$array1 = array('code' = > '123', 'code' = > '124', 'code' = > '125', 'code' = > '126', 'code' = > '127');

is nil but

$array1 = array('code' => '127'); //because of same index consider lastly value

however have modified arrays , tried prepare solution might useful you. check 1 time below.

<?php $array1 = array('123', '124', '125', '126', '127'); $array2 = array(array('code' => '123', 'country' => 'us', 'listed' => '0'), array('code' => '124', 'country' => 'us', 'listed' => '1'), array('code' => '125', 'country' => 'us', 'listed' => '1')); $array3 = array(array('code' => '123', 'country' => 'us', 'listed' => '1'), array('code' => '126', 'country' => 'us', 'listed' => '0'), array('code' => '127', 'country' => 'us', 'listed' => '1')); function comparesitesandupdate($array1, $array2, $array3) { foreach($array1 $code) { if(iscodeexistsinarray($code,$array2)) { echo $code . ' in array2 , listed <br />'; } else { // ;( not in array2 check in array3 echo $code . ' not listed in array2 - checking in array3 <br />'; if(iscodeexistsinarray($code,$array3)) { echo $code . ' in array3 , listed <br />'; } else { echo $code . ' not listed in array3 - whatever want <br />'; } } } } //note $earray expected in format of $array2/$array3 //and key of $array2 , $array3 should 'code' - not necessary alter keys 2 diff arrays function iscodeexistsinarray($ecode, $earray) { foreach($earray $code_array) { if($ecode == $code_array['code']) { //code match found - check if listed if($code_array['listed'] == 1) { //got need - homecoming true , break homecoming true; } } } homecoming false; //any other case homecoming false; } comparesitesandupdate($array1, $array2, $array3); ?>

php arrays

java - Unable to connect to mysql jdbc database -



java - Unable to connect to mysql jdbc database -

i frustrated seeing error , not knowing solution. trying connect mysql db server url giving mysqlexception(stacktrace below). code works fine till here:

string dburl = "jdbc:mysql://server_url/db_name"; string driver = "com.mysql.jdbc.driver"; class.forname(driver).newinstance(); string user = "user"; string password = "password"; conn = drivermanager.getconnection(dburl,user,password);

this error i'm getting

java.sql.sqlexception: null, message server: "host '172.23.251.154' not allowed connect mysql server" @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:946) @ com.mysql.jdbc.mysqlio.dohandshake(mysqlio.java:1070) @ com.mysql.jdbc.connection.createnewio(connection.java:2775) @ com.mysql.jdbc.connection.<init>(connection.java:1555) @ com.mysql.jdbc.nonregisteringdriver.connect(nonregisteringdriver.java:285) @ java.sql.drivermanager.getconnection(drivermanager.java:582) @ java.sql.drivermanager.getconnection(drivermanager.java:185)

is because i'm using different version of mysql-connector jar? please help me.

from chapter 6. sql questions: how enable tcp connections mysql?,

by default, mysql won't allow users access of databases if connect on tcp connection. in order permit connection, must create entry in user table of mysql database (make sure select password function encrypt password). in particular, host field needs indicate host(s) permitted connect. if specify % (which not recommend), user able connect host.

java mysql database jdbc

pharo - SmallTalk - Printing contents of an OrderedCollection object using Transcript -



pharo - SmallTalk - Printing contents of an OrderedCollection object using Transcript -

|oc| oc := orderedcollection new. oc add: 2. oc add: #(4 9). oc transcript show: self; cr.

upon running next code in pharo, getting message:

messagenotunderstood: orderedcollection>> transcript

when replacing 'self' 'oc' still getting same error. looking way output collection using transcript.

why can't transcript receiver of code?

remember object message: parameter syntax: you're trying send transcript message oc object, , send show: message object returned that, self parameter.

what want inquire transcript object show: oc object. so, that: send transcript show: message oc parameter: transcript show: oc. show string representation of collection.

if print each fellow member of collection (instead of printing the collection itself), should utilize do: method iterate on them: oc do: [ :element | transcript show: element ]. here print each of collection's member string representation.

oc := orderedcollection new. oc add: 2. oc add: #(4 9). transcript show: 'show collection:'; cr. transcript show: oc; cr. transcript show: 'show each element:'; cr. oc do: [ :element | transcript show: element; cr ].

gives output:

show collection: orderedcollection(2 #(4 9)) show each element: 2 #(4 9)

smalltalk pharo

php - get city from ip not working on remote server -



php - get city from ip not working on remote server -

get city ip not working on remote server works in localhost. have improve ideas getting city class? server remote addr displays this:

::1

here code i'm using:

class iplocation{ public function ipgetcity(){ $ip=$_server['remote_addr']; $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=&#8217',$ip)); $city = stripslashes(ucfirst($addr_details['geoplugin_city'])); homecoming $city; } }

php get city

python - Raise Error when form has punctuation django -



python - Raise Error when form has punctuation django -

i need way raise error when submit punctuation in title. im beginner im not quite sure how so. form:

class neededform(forms.modelform): title = forms.charfield(max_length=120) likes = forms.integerfield(widget=forms.hiddeninput(), initial=0) body = forms.charfield(min_length=50,widget = forms.textarea) captcha = captchafield() def clean_title(self): info = self.cleaned_data['title'] homecoming info class meta: model = needed fields = ('title', 'body', 'likes')

the view:

def detail(request, needed_title_url): context = requestcontext(request) needed_name = needed_title_url.replace('_', ' ') context_dict = {'needed_name': needed_name} try: needed = needed.objects.get(title=needed_name) context_dict['needed'] = needed print "true!" except: pass homecoming render_to_response('needed.html', context_dict, context)

if user inputs like: i chicken! title need show user error.

i'm not totally sure question, looks reply looking may included in https://docs.djangoproject.com/en/1.6/ref/models/fields/#slugfield

the slugfield charfield can contain letters, numbers, underscores , hyphens (so understands max_length,...)

class neededform(forms.modelform): title = forms.slugfield(max_length=120) likes = forms.integerfield(widget=forms.hiddeninput(), initial=0) body = forms.charfield(min_length=50,widget = forms.textarea) captcha = captchafield()

i looking more complicated rule checking, have validator page https://docs.djangoproject.com/en/1.6/ref/validators/ , how utilize in form https://docs.djangoproject.com/en/1.6/ref/forms/validation/#using-validators illustration provided explaining slugfield implementation.

hope helps !

python django django-forms

android interval between sensor listeners -



android interval between sensor listeners -

i wrote simple android code, listens acceleration , orientation sensors, , writes acceleration x,y,z values, , angel north.

in app trying set 30 seconds interval between sending sensors event onsensorchanged() function, it's still updating few times every second.

this code:

package com.example.sensors; import java.util.list; import android.os.bundle; import android.util.log; import android.view.menu; import android.hardware.sensoreventlistener; import android.hardware.sensormanager; import android.app.activity; import android.hardware.sensor; import android.hardware.sensorevent; public class mainactivity extends activity implements sensoreventlistener{ private sensormanager sensormanager; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); sensormanager = (sensormanager)this.getsystemservice(sensor_service); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); homecoming true; } @override public void onsensorchanged(sensorevent event) { if (event.sensor.gettype() == sensor.type_accelerometer) // { float x = event.values[0]; float y = event.values[1]; float z = event.values[2]; log.i("acceleration:", "x, y, z" + " " + x + " " + y + " " + z + " "); } else if (event.sensor.gettype() == sensor.type_orientation) //@deprecated. utilize type_magnetic_field { log.i("orentation: " , "north:" + event.values[0]); } } @override public void onaccuracychanged(sensor sensor, int accuracy) { } @override protected void onresume() { super.onresume(); // register class listener accelerometer sensors , orientation sensormanager.registerlistener(this, sensormanager.getdefaultsensor(sensor.type_accelerometer),//this method default sensor given type 30000000);//sensormanager.sensor_delay_normal sensormanager.registerlistener(this, sensormanager.getdefaultsensor(sensor.type_orientation),//this method default sensor given type 30000000); } @override protected void onpause() { // unregister listener super.onpause(); sensormanager.unregisterlistener(this); } }

you can't set custom interval sensor rates. slowest rate possible sensor_delay_ui, , samples per sec depend on device. need filter these values saving lastly time printed values, wait until difference between time , current time on 30 seconds , print again.

android sensor

PSNR calclator of 2 YUV files using c++ segmentation fault -



PSNR calclator of 2 YUV files using c++ segmentation fault -

iam trying write code in c++ calculate psnr of 2 yuv video files should work segmentation fault error .. help here highly appreciated here code

#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "base.h" void makeaframe( yuvframe* f, int width, int height ) { f->lum.width = width; f->lum.height = height; f->cb .width = width/2; f->cb .height = height/2; f->cr .width = width/2; f->cr .height = height/2; } void readcolorcomponent( colorcomponent* cc, file* file ) { unsigned int size = cc->width*cc->height; unsigned int rsize; rsize = fread( cc->data, sizeof(unsigned char), size, file ); } double psnr( colorcomponent& rec, colorcomponent& org) { unsigned char* porg = org.data; unsigned char* prec = rec.data; double ssd = 0; int diff; ( int r = 0; r < rec.height; r++ ) { for( int c = 0; c < rec.width; c++ ) { diff = prec[c] - porg[c]; ssd += (double)( diff * diff ); } prec += rec.width; porg += org.width; } if( ssd == 0.0 ) { homecoming 99.99; } homecoming ( 10.0 * log10( (double)rec.width * (double)rec.height * 65025.0 / ssd ) ); } void getpsnr( double& psnry, double& psnru, double& psnrv, yuvframe& rcframeorg, yuvframe& rcframerec ) { psnry = psnr( rcframerec.lum, rcframeorg.lum ); psnru = psnr( rcframerec.cb, rcframeorg.cb ); psnrv = psnr( rcframerec.cr, rcframeorg.cr ); } void readframe( yuvframe* f, file* file ) { readcolorcomponent( &f->lum, file ); readcolorcomponent( &f->cb, file ); readcolorcomponent( &f->cr, file ); } int main(int argc, char *argv[]) { int acc = 10000; #define out "%d,%04d" int stream = 0; unsigned int width = 0; unsigned int height = 0; unsigned int temporal_stages = 0; unsigned int skip_at_start = 0; double fps = 0.0; file* org_file = 0; file* rec_file = 0; file* str_file = 0; char* prefix_string = 0; unsigned int index, skip, skip_between, sequence_length; int py, pu, pv, br; double bitrate = 0.0; double psnry, psnru, psnrv; yuvframe corgframe, crecframe; double averagepsnr_y = 0.0; double averagepsnr_u = 0.0; double averagepsnr_v = 0.0; int currarg = 5; int rpsnr = 0; width = 300; height = 240; org_file = fopen("foreman_qcif.yuv","rb"); rec_file = fopen("foreman_qcif2.yuv","rb"); temporal_stages=2; fseek( rec_file, 0, seek_end ); fseek( org_file, 0, seek_end ); size_t rsize = ftell( rec_file ); size_t osize = ftell( org_file ); fseek( rec_file, 0, seek_set ); fseek( org_file, 0, seek_set ); if (rsize < osize) { sequence_length = (unsigned int)((double)rsize/(double)((width*height*3)/2)); } else { sequence_length = (unsigned int)((double)osize/(double)((width*height*3)/2)); skip_between = ( 1 << temporal_stages ) - 1; } //here seek create frames out of images makeaframe( &corgframe, width, height ); makeaframe( &crecframe, width, height ); //looping on frames for( skip = skip_at_start, index = 0; index < sequence_length; index++, skip = skip_between ) { fseek( org_file, skip*width*height*3/2, seek_cur); readframe ( &corgframe, org_file ); readframe ( &crecframe, rec_file ); getpsnr ( psnry, psnru, psnrv, corgframe, crecframe); averagepsnr_y += psnry; averagepsnr_u += psnru; averagepsnr_v += psnrv; py = (int)floor( acc * psnry + 0.5 ); pu = (int)floor( acc * psnru + 0.5 ); pv = (int)floor( acc * psnrv + 0.5 ); fprintf(stdout,"%d\t"out"\t"out"\t"out"\n",index,py/acc,py%acc,pu/acc,pu%acc,pv/acc,pv%acc); } fprintf(stdout,"\n"); py = (int)floor( acc * averagepsnr_y / (double)sequence_length + 0.5 ); pu = (int)floor( acc * averagepsnr_u / (double)sequence_length + 0.5 ); pv = (int)floor( acc * averagepsnr_v / (double)sequence_length + 0.5 ); br = (int)floor( acc * bitrate + 0.5 ); if( stream ) { if( prefix_string ) { fprintf(stderr,"%s\t"out"\t"out"\t"out"\t"out"\n",prefix_string,br/acc,br%acc,py/acc,py%acc,pu/acc,pu%acc,pv/acc,pv%acc); fprintf(stdout,"%s\t"out"\t"out"\t"out"\t"out"\n",prefix_string,br/acc,br%acc,py/acc,py%acc,pu/acc,pu%acc,pv/acc,pv%acc); } else { fprintf(stderr,out"\t"out"\t"out"\t"out"\n",br/acc,br%acc,py/acc,py%acc,pu/acc,pu%acc,pv/acc,pv%acc); fprintf(stdout,out"\t"out"\t"out"\t"out"\n",br/acc,br%acc,py/acc,py%acc,pu/acc,pu%acc,pv/acc,pv%acc); } } else { fprintf(stderr,"total\t"out"\t"out"\t"out"\n",py/acc,py%acc,pu/acc,pu%acc,pv/acc,pv%acc); fprintf(stdout,"total\t"out"\t"out"\t"out"\n",py/acc,py%acc,pu/acc,pu%acc,pv/acc,pv%acc); } fprintf(stdout, "\n"); fclose ( org_file ); fclose ( rec_file ); if( stream ) { fclose ( str_file ); } homecoming (rpsnr*py); }

and base.h contains structures

typedef struct { int width; int height; unsigned char* data; } colorcomponent; typedef struct { colorcomponent lum; colorcomponent cb; colorcomponent cr; } yuvframe;

well, segmentation error arises trying access memory addresses not assigned ... w hot-fix avoid error add together function code

void foo( colorcomponent* cc ) { if( ! ( cc->data = new unsigned char[cc->width * cc->height])) { fprintf(stderr, "\nerror: memory allocation failed!\n\n"); exit(-1); } }

and alter these lines

void makeaframe( yuvframe* f, int width, int height ) { f->lum.width = width; f->lum.height = height; f->cb .width = width/2; f->cb .height = height/2; f->cr .width = width/2; f->cr .height = height/2; }

to

void makeaframe( yuvframe* f, int width, int height ) { f->lum.width = width; f->lum.height = height; foo( &f->lum ); f->cb .width = width/2; f->cb .height = height/2; foo( &f->cb ); f->cr .width = width/2; f->cr .height = height/2; foo( &f->cr ); }

things should work now

c++

algorithm - Trapez Method in Java -



algorithm - Trapez Method in Java -

i found formula in net calculating trapezoid method , works should, not see why should performed next lines in trapez method:

sum = 0.5 * bef + (h * sum); i= i+ 2

the first iteration performed next command in main :

tra[0] = 0.5 * ((b - a) / n) * (function(a) + function(b)); //calculates first step value

the trapez method next iterations:

/** * calculate next step trapez method * @param -lower limit * @param b -upper limit * @param bef -previous step value * @param n -number of dividing points * @return integral area */ public static double trapz(double a, double b,double bef, int n) { double sum = 0; double h = ((b - a)/n); (int = 1; <= n; = + 2) { sum += function(a + (i) * h); } sum = 0.5 * bef + (h * sum); homecoming sum; }

the function used in conjunction driver loop doubles number of subintervals @ each iteration, refining estimated integral until difference 1 iteration next less threshold criterion. desirable in such endeavor avoid repeating computations have been performed, , that's point of lines asked about.

consider function values needed when applying trapezoid rule on given number of subintervals. consider function values needed splitting each subinterval in half , applying trapezoid rule subintervals. half (give or take 1) of function values needed in latter case same ones needed in former. code presented reuses computed values (0.5 * bef), adding them new values (i = + 2). must scale downwards previous estimate factor of 2 business relationship splitting subintervals in two.

note code right, appears argument n must represent number of subintervals of integration region, not number of dividing points documentation claims.

java algorithm math integral

java - Cp command android from assets folder -



java - Cp command android from assets folder -

i want know if it's possible execute "cp" linux command re-create file assets folder of app /system/bin partition (obviously root access).

utility.exec("cp <file:///android_asset/my_file> /system/bin");

this code valid re-create files assets system/bin?

here clean example, assuming root acquired :

assetmanager assetmanager = context.getassets(); inputstream = null; outputstream os = null; seek { = assetmanager.open("my_file"); os = new fileoutputstream("/system/bin/my_file"); byte[] buffer = new byte[1024]; int length; // re-create file content in bytes while ((length = is.read(buffer)) > 0) { os.write(buffer, 0, length); } } grab (exception e) { // dealing exception, log or } { if (is != null) seek { is.close(); } grab (ioexception e) {} if (os != null) seek { os.close(); } grab (ioexception e) {} }

java android linux

jboss - Wildfly 8, mod_cluster & apache integration -



jboss - Wildfly 8, mod_cluster & apache integration -

i having problems getting mod_cluster 1.2 work apache. want configuration allow apache proxy traffic apps server myserver.com:9191 (apache) routes traffic myserver.com:9090 (jboss)

symptoms:

when start wildfly console produces next error every 3-5 seconds:

error [org.jboss.modcluster] (undertoweventhandleradapter - 1) modcluster000042: error null sending info command precise32/127.0.1.1:6666, configuration reset: null

i can see corresponding request in apache logs as: "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

the myserver:9191/mod_cluster-manager url shows page title , links, no cluster info, this: mod_cluster/1.2.6.final

auto refresh show dump output show info output

i running both jboss , apache on same virtual server.

server info:

virtual box 4.3.14 running:

ubuntu 12.04 lts

apache/2.2.22

wildfly 8.0

i can navigate web apps on wildfly straight without going through apache , works fine. if seek , navigate through apache, next errors in apache log:

[thu oct 16 03:12:33 2014] [debug] mod_proxy_cluster.c(2231): proxy: byrequests balancer failed

[thu oct 16 03:12:33 2014] [error] proxy: cluster: (balancer://mycluster). workers in error state

[thu oct 16 03:12:33 2014] [debug] mod_deflate.c(615): [client 10.0.2.2] zlib: compressed 410 276 : url /

my relevant apache configs like:

mod_cluster.load:

loadmodule proxy_module /usr/lib/apache2/modules/mod_proxy.so

loadmodule advertise_module /usr/lib/apache2/modules/mod_advertise.so

loadmodule manager_module /usr/lib/apache2/modules/mod_manager.so

loadmodule proxy_cluster_module /usr/lib/apache2/modules/mod_proxy_cluster.so

loadmodule slotmem_module /usr/lib/apache2/modules/mod_slotmem.so

mod_cluster.conf:

createbalancers 1

listen 127.0.1.1:6666 managerbalancername mycluster <virtualhost 127.0.1.1:6666> keepalivetimeout 300 maxkeepaliverequests 0 advertisefrequency 5 serveradvertise on <location /> order deny,allow allow 127.0.0 </location> </virtualhost>

virtual host:

#serveradmin me@domain.edu servername jboss.cluster serveralias jboss.cluster proxypass / balancer://mycluster stickysession=jsessionid|jsessionid nofailover=on proxypassreverse / balancer://mycluster proxypreservehost on <location /> order deny,allow allow </location>

sethandler mod_cluster-manager order deny,allow #deny allow 127.0.0

errorlog ${apache_log_dir}/jboss_cluster_error.log loglevel debug customlog ${apache_log_dir}/jboss_access.log combined

standalone.xml:

<extensions> <extension module="org.jboss.as.clustering.infinispan"/> <extension module="org.jboss.as.connector"/> <extension module="org.jboss.as.deployment-scanner"/> <extension module="org.jboss.as.ee"/> <extension module="org.jboss.as.ejb3"/> <extension module="org.jboss.as.jaxrs"/> <extension module="org.jboss.as.jdr"/> <extension module="org.jboss.as.jmx"/> <extension module="org.jboss.as.jpa"/> <extension module="org.jboss.as.jsf"/> <extension module="org.jboss.as.logging"/> <extension module="org.jboss.as.mail"/> <extension module="org.jboss.as.naming"/> <extension module="org.jboss.as.pojo"/> <extension module="org.jboss.as.remoting"/> <extension module="org.jboss.as.sar"/> <extension module="org.jboss.as.security"/> <extension module="org.jboss.as.transactions"/> <extension module="org.jboss.as.webservices"/> <extension module="org.jboss.as.weld"/> <extension module="org.wildfly.extension.batch"/> <extension module="org.jboss.as.modcluster"/> <extension module="org.wildfly.extension.io"/> <extension module="org.wildfly.extension.undertow"/> </extensions>

...

<mod-cluster-config advertise-socket="modcluster" connector="ajp"> <dynamic-load-provider> <load-metric type="cpu"/> </dynamic-load-provider> </mod-cluster-config> </subsystem>

......

<interface name="public"> <inet-address value="${jboss.bind.address:0.0.0.0}"/> </interface> <interface name="unsecure"> <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/> </interface> </interfaces> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/> <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/> <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/> <socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/> <socket-binding name="http" port="${jboss.http.port:9090}"/> <socket-binding name="https" port="${jboss.https.port:8443}"/> <socket-binding name="txn-recovery-environment" port="4712"/> <socket-binding name="txn-status-manager" port="4713"/> <outbound-socket-binding name="mail-smtp"> <remote-destination host="localhost" port="25"/> </outbound-socket-binding> </socket-binding-group>

vhost error log jboss_cluster_error.log:

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:49 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:11:51 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:13:55 2014] [debug] mod_deflate.c(615): [client 10.0.2.2] zlib: compressed 494 255 : url /mod_cluster-manager

[thu oct 16 18:13:58 2014] [debug] mod_proxy_cluster.c(1010): update_workers_node starting

[thu oct 16 18:13:58 2014] [debug] mod_proxy_cluster.c(1025): update_workers_node done

[thu oct 16 18:13:59 2014] [debug] mod_deflate.c(615): [client 10.0.2.2] zlib: compressed 494 255 : url /mod_cluster-manager

[thu oct 16 18:14:05 2014] [debug] mod_proxy_cluster.c(2231): proxy: byrequests balancer failed

[thu oct 16 18:14:05 2014] [error] proxy: cluster: (balancer://mycluster). workers in error state

[thu oct 16 18:14:05 2014] [debug] mod_deflate.c(615): [client 10.0.2.2] zlib: compressed 400 269 : url /

[thu oct 16 18:14:13 2014] [debug] mod_proxy_cluster.c(2231): proxy: byrequests balancer failed

[thu oct 16 18:14:13 2014] [error] proxy: cluster: (balancer://mycluster). workers in error state

[thu oct 16 18:14:13 2014] [debug] mod_deflate.c(615): [client 10.0.2.2] zlib: compressed 400 269 : url /

vhost access log jboss_access.log

127.0.0.1 - - [16/oct/2014:18:11:49 +0000] "options * http/1.0" 200 126 "-" "apache/2.2.22 (ubuntu) (internal dummy connection)"

127.0.0.1 - - [16/oct/2014:18:11:49 +0000] "options * http/1.0" 200 126 "-" "apache/2.2.22 (ubuntu) (internal dummy connection)"

127.0.0.1 - - [16/oct/2014:18:11:49 +0000] "options * http/1.0" 200 126 "-" "apache/2.2.22 (ubuntu) (internal dummy connection)"

127.0.0.1 - - [16/oct/2014:18:11:49 +0000] "options * http/1.0" 200 126 "-" "apache/2.2.22 (ubuntu) (internal dummy connection)"

127.0.0.1 - - [16/oct/2014:18:11:49 +0000] "options * http/1.0" 200 126 "-" "apache/2.2.22 (ubuntu) (internal dummy connection)"

127.0.0.1 - - [16/oct/2014:18:11:49 +0000] "options * http/1.0" 200 126 "-" "apache/2.2.22 (ubuntu) (internal dummy connection)"

127.0.0.1 - - [16/oct/2014:18:11:49 +0000] "options * http/1.0" 200 126 "-" "apache/2.2.22 (ubuntu) (internal dummy connection)"

10.0.2.2 - - [16/oct/2014:18:13:55 +0000] "get /mod_cluster-manager http/1.1" 200 556 "-" "mozilla/5.0 (windows nt 6.1; wow64; rv:32.0) gecko/20100101 firefox/32.0"

10.0.2.2 - - [16/oct/2014:18:13:59 +0000] "get /mod_cluster-manager http/1.1" 200 529 "-" "mozilla/5.0 (windows nt 6.1; wow64; rv:32.0) gecko/20100101 firefox/32.0"

10.0.2.2 - - [16/oct/2014:18:14:05 +0000] "get / http/1.1" 503 504 "-" "mozilla/5.0 (windows nt 6.1; wow64; rv:32.0) gecko/20100101 firefox/32.0"

10.0.2.2 - - [16/oct/2014:18:14:13 +0000] "get / http/1.1" 503 504 "-" "mozilla/5.0 (windows nt 6.1; wow64; rv:32.0) gecko/20100101 firefox/32.0"

vhost access log other_vhosts_access.log

precise32:6666 127.0.0.1 - - [16/oct/2014:18:13:43 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:13:53 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:14:03 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:14:13 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:14:23 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:14:33 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:14:43 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:14:53 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:15:03 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:15:13 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:15:23 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:15:33 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:15:43 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:15:53 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:16:03 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:16:13 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

precise32:6666 127.0.0.1 - - [16/oct/2014:18:16:23 +0000] "info / http/1.1" 501 529 "-" "clusterlistener/1.0"

message edited by: m p added in finish apache error , access logs. added in proxypass config vhost.

i able configuration working. problem mod_cluster.conf file. missing 2 directives:

serveradvertise on 127.0.1.1:6666 enablemcpmreceive

hope helps someone...

listen 127.0.1.1:6666 managerbalancername mycluster <virtualhost 127.0.1.1:6666> keepalivetimeout 300 maxkeepaliverequests 0 advertisefrequency 5 serveradvertise on 127.0.1.1:6666 enablemcpmreceive <location /> order deny,allow # allow 127.0.0 allow </location> </virtualhost>

apache jboss wildfly mod-cluster

html - Why is "float: right;" eliminating the background color of the div that contains it? -



html - Why is "float: right;" eliminating the background color of the div that contains it? -

i'm trying 3 divs on same line, pushed off right, side-by-side. divs of class nav-button. can see right now, stacked on top of each other left, , div containing them has bluish background. add together float: right; nav-buttons, line want them to, reason containing div loses background color. explain why?

link: http://jaminweb.com/bestoflr.php

html:

<!doctype html> <html lang="en-us"> <head> <meta charset="utf-8"/> <link rel="stylesheet" type"text/css" href="lr_styles.css"/> </head> <body> <div class="outer-container"> <div class="header-container"> <div class="header-bluetop"> <div class="logo-blob"> <span>l</span> <span>e</span> <span>t</span> <span>s</span> <span>r</span> <span>u</span> <span>n</span> <span>.</span> <span>c</span> <span>o</span> <span>m</span> </div> <div class="nav-container"> <div class="nav-button"> <h3>best posters</h3> </div> <div class="nav-button"> <h3>best posts</h3> </div> <div class="nav-button"> <h3>news</h3> </div> </div> </div> <div class="subheader"> </div> </div> <div class="middle-conatiner"> </div> <div class="footer-container"> </div> </div> </body> </html>

css:

div.outer-container {font-family: "lato","droid sans",arial,verdana,sans-serif;} div.header-container {} div.header-bluetop { background-color: #00325f; position: relative; } div.logo-blob { position: absolute; top: 0px; left: 30px; width: 250px; height: 64px; background-color: #f8c525; -moz-border-radius: 50%; -webkit-border-radius: 50%; border-radius: 50%; font-size: 25px; font-weight: 100; line-height: 64px; text-align: center; letter-spacing: 0.5px; border: 5px solid #fff; } div.logo-blob > span { font-family: "droid serif",serif; font-size: 25px; font-weight: 100; } div.logo-blob > span:nth-of-type(2n) { color: #306ab5; } div.logo-blob > span:nth-of-type(2n+1) { color: #d42222;; } div.nav-container {} div.nav-container > div.nav-button { } div.nav-container > div.nav-button > h3:nth-of-type(2n+1) { color: #fff; } div.nav-container > div.nav-button > h3:nth-of-type(2n) { color: #f8c525; } div.subheader {} div.middle-container {} div.footer-container {}

bonus point: why

div.nav-container > div.nav-button > h3:nth-of-type(2n+1) { color: #fff; } div.nav-container > div.nav-button > h3:nth-of-type(2n) { color: #f8c525; }

not working?

because when float nav-button elements, container element has no in-flow elements within it, logo-blob beingness absolutely positioned.

overflow:hidden has additional benefit of clearing floats:

of course, there other ways clear floats.

as nth-of-type() selectors, applying them wrong element:

class="snippet-code-css lang-css prettyprint-override">div.outer-container { font-family:"lato", "droid sans", arial, verdana, sans-serif; } div.header-container { } div.header-bluetop { background-color: #00325f; position: relative; } div.logo-blob { position: absolute; top: 0px; left: 30px; width: 250px; height: 64px; background-color: #f8c525; -moz-border-radius: 50%; -webkit-border-radius: 50%; border-radius: 50%; font-size: 25px; font-weight: 100; line-height: 64px; text-align: center; letter-spacing: 0.5px; border: 5px solid #fff; } div.logo-blob > span { font-family:"droid serif", serif; font-size: 25px; font-weight: 100; } div.logo-blob > span:nth-of-type(2n) { color: #306ab5; } div.logo-blob > span:nth-of-type(2n+1) { color: #d42222; ; } div.nav-container { overflow:hidden; } div.nav-container > div.nav-button { float:right; } div.nav-container > div.nav-button:nth-of-type(2n+1) > h3 { color: #fff; } div.nav-container > div.nav-button:nth-of-type(2n) > h3 { color: #f8c525; } div.subheader { } div.middle-container { } div.footer-container { } class="snippet-code-html lang-html prettyprint-override"><div class="outer-container"> <div class="header-container"> <div class="header-bluetop"> <div class="logo-blob"> <span>l</span> <span>e</span> <span>t</span> <span>s</span> <span>r</span> <span>u</span> <span>n</span> <span>.</span> <span>c</span> <span>o</span> <span>m</span> </div> <div class="nav-container"> <div class="nav-button"> <h3>best posters</h3> </div> <div class="nav-button"> <h3>best posts</h3> </div> <div class="nav-button"> <h3>news</h3> </div> </div> </div> <div class="subheader"></div> </div> <div class="middle-conatiner"></div> <div class="footer-container"></div> </div>

html css

regex - Python: re module to replace digits of telephone with asterisk -



regex - Python: re module to replace digits of telephone with asterisk -

this question has reply here:

python re.sub replace matched content 3 answers

i want replace digits in middle of telephone regex failed. here code:

temp= re.sub(r'1([0-9]{1}[0-9])[0-9]{4}([0-9]{4})', repl=r'$1****$2', tel_phone) print temp

in output, shows: $1****$2

but want show this: 131****1234. how accomplish ? thanks

i think you're trying replace 4 digits nowadays in middle (four digits nowadays before lastly 4 digits) ****

>>> s = "13111111234" >>> temp= re.sub(r'^(1[0-9]{2})[0-9]{4}([0-9]{4})$', r'\1****\2', s) >>> print temp 131****1234

you might have seen $1 in replacement string in other languages. however, in python, utilize \1 instead of $1. correctness, need include starting 1 in first capturing group, output include starting 1; otherwise, starting 1 lost.

python regex

xml - Simplify XSD Schema using XQuery -



xml - Simplify XSD Schema using XQuery -

we're building xquery tool create documentation xsd schemas (specifically ubl 2.1 schemas).

in order that, need simplify schemas built extensive utilize of element references , complex types, inline definitions.

so element this:

<xsd:element name="order" type="ordertype"/> <xsd:complextype name="ordertype"> <xsd:sequence> ... <xsd:element ref="cbc:ublversionid" minoccurs="0" maxoccurs="1"/> ... </xsd:sequence> </xsd:complextype> ... (in file) <xsd:element name="ublversionid" type="ublversionidtype"/> <xsd:complextype name="ublversionidtype"> <xsd:simplecontent> <xsd:extension base="xsd:string"/> </xsd:simplecontent> </xsd:complextype>

should converted to:

<xsd:element name="order"> <xsd:complextype> <xsd:sequence> ... <xsd:element ref="cbc:ublversionid" minoccurs="0" maxoccurs="1"> <xsd:complextype name="ublversionidtype"> <xsd:simplecontent> <xsd:extension base="xsd:string"/> </xsd:simplecontent> </xsd:complextype> ... </xsd:sequence> </xsd:complextype> </xsd:element>

taking in business relationship elements , types defined in imported schemas.

is there known method xquery?

thanks.

you might find useful process schemas saxon's scm format, xml representation of xsd schema components in normalized form. can generate form using

java com.saxonica.validate -xsd:schema.xsd -scmout:schema.scm

the documentation scm format schema component documentation in w3c spec.

the format opposite of asking for: components "out of line", accessed next references. it's highly uniform, , avoids complexities of managing includes, imports, namespaces, , qnames.

xml xsd xquery

java - ExtJS: Display additional data from servlet in window/Form -



java - ExtJS: Display additional data from servlet in window/Form -

in application, have grid populated data, displaying 2 columns in grid..ie, name , noofscripts. when double click on grid, want scriptname , parameters displayed( , number of times displayed based on noofscripts) in window/form.

i using java servlets backend, not sure if have add together script details same main class or not? how should handle script details?

check this: how add together these data: here

should save scriptname , parameters along main data? is possible store multiple values, if add together scriptname , parameters main store? or should create different store script? if creating different store called scripts..how should mapping info record? there methods provided extjs helps accomplish this?

not sure if explanation on problem clear or not. allow me know if not clear, seek create clear.

please suggest me if there helpful. suggestions, ideas or references help.

thanks in advance

i suggest create model , store script , on rowitem click - populate window info script store. extjs4 has back upwards model association (more here) mechanism complex prefer simplier take on it:

add mainmodelid script model , filter script store every time show modal window (grid item click)

java servlets extjs grid extjs4

r - List operations on variables containing string -



r - List operations on variables containing string -

i have admit i'm totally stumped on one, apologies no clear attempt, though can inquire question clearly:

i have list of dataframes. of them, there multiple date-type variables need formatted date (e.g., as.date(data$var, format = "%m/%d/%y")).

the problem date variable named different in each of dataframes. in illustration below, we've got "start_date" , "end_date".

is there way write function operates on variable names in dataframe , if finds text contains "date", formatting operation?

the dataframes:

west <- data.frame( spend = sample(50:100,50,replace=t), trials = sample(100:200,50,replace=t), start_date = sample(c("06/07/14","06/08/14","06/09/14"), 50, replace=t), country = sample(c("usa","canada","uk"),50,replace = t) ) east <- data.frame( end_date = sample(c("06/07/14","06/08/14","06/09/14"), 50, replace=t), spend = sample(50:100,50,replace=t), trials = sample(100:200,50,replace=t), country = sample(c("china","japan","skorea"),50,replace = t) )

and turning them list (in reality, much larger list):

combined <- c(west,east)

how take logical vector grepl statement , tell operate on variable logical vector "true" across list elements?

grepl("date", names(combined)) [1] false false true false false false true false

try

lst1 <- lapply(list(west, east), function(x) { indx <- grepl("date", names(x)) x[,indx] <- as.date(x[,indx], format="%m/%d/%y") x })

in case need update individual objects ie. east, west etc. (which not needed because of operations including saving file write.csv/write.table can done within list using lapply)

list2env(setnames(lst1, c("west", "east")), envir=.globalenv) update

if there multiple variables date

east <- data.frame( end_date = sample(c("06/07/14","06/08/14","06/09/14"), 50, replace=t), new_date = sample(c("06/07/14","06/12/14","06/09/14"), 50, replace=t), spend = sample(50:100,50,replace=t), trials = sample(100:200,50,replace=t), country = sample(c("china","japan","skorea"),50,replace = t)) lst2 <- lapply(list(west, east), function(x) { indx <- grepl("date", names(x)) x[,indx] <- lapply(x[,indx,drop=false], as.date, format="%m/%d/%y") x}) lapply(lst2, head,2) #[[1]] # spend trials start_date country #1 83 188 2014-06-09 usa #2 83 107 2014-06-08 usa #[[2]] # end_date new_date spend trials country #1 2014-06-08 2014-06-12 53 144 china #2 2014-06-08 2014-06-09 100 118 china

r

locking - Can I lock Centos yum updates to 1 specific base version? -



locking - Can I lock Centos yum updates to 1 specific base version? -

i'd lock downwards centos 6.3 x86_64 server receive updates released base of operations version, i.e. 6.3. possible? if so, how?

i not want upgrade kernel future base of operations versions such 6.4, 6.5, etc.

reason of our corporate apps run on 6.3 , can't take chance of them breaking ......for now!

many thanks

the reply multi-part.

generally, believe, 1 time newer versions of centos released older versions stop getting updates. saying "i want updates specific version" means "i don't want updates anymore" far know.

that beingness said, can prevent new kernels beingness installed adding exclude=kernel* yum configuration (in yum.conf).

additionally, if care disallowing automatic usage of newer kernels when installed can alter value of updatedefault in /etc/sysconfig/kernel no prevent that.

i should not above experience , inspection of centos 5 machine might or might not identical centos 6.

and lastly, if did want restrict scheme upgrades things available in given minor version need find centos mirror had broken out 6.x directories , them manually point yum repository configurations @ repositories. (most default repositories update latest version when released, reasons mentioned @ start updates old releases far know.)

centos locking yum

How to save relationship when creating an entity with Ruby on Rails -



How to save relationship when creating an entity with Ruby on Rails -

it seems learnt ruby on rails dissapeared mind.

i trying create simplest relationship ever, between products , categories. defined has_many :categories relationship in product model, , created migration have table product_id , category_id.

first, thought passing parameters product.new automatically add together categories. recall worked this.

then tried doing manually: @product.categories = product_params[:categories]. product_params generated scaffold, , follows:

def product_params params.require(:product).permit(:title, :description, :categories) end

however, doing way, @product.categories seems nil.

how can store product_id , category_id (or categories, since has many relationshop) in relationship table? have been looking @ old codes of mine ruby on rails 3 , seems handled automatically rails. missing?!

`product` model: class product < activerecord::base has_and_belongs_to_many :categories, :join_table => 'products_categories' accepts_nested_attributes_for :categories end

class="snippet-code-html lang-html prettyprint-override"># product.rb class product < ar::base has_and_belongs_to_many :categories end #products_controller.rb def new @product = product.new end def create @product = product.new product_params @product.save end private def product_params params.require(:product).permit(:product, :attributes, :category_ids => []) end end

and within view:

class="snippet-code-html lang-html prettyprint-override"><%= form_for @product |f| %> <%=f.select :category_ids, options_for_select(category.all.collect {|c| [c.name, c.id] }, @product.category_ids ), {}, :multiple => true %> <% end %>

ruby-on-rails ruby-on-rails-4

python - cannot concatenate 'str' and 'float' objects -



python - cannot concatenate 'str' and 'float' objects -

i trying concatenate string list values in order add together html attributes, error:

cannot concatenate 'str' , 'float' objects

productlist = ["pedegree","chum", "colesbrand"] pricelist = [6,5,3] priceandproduct = [] x,val in enumerate(productlist): priceandproduct.extend([productlist[x],pricelist[x]]) myhtml = "" x in priceandproduct: myhtml = myhtml + x + "<br/>" print priceandproduct

i presume because of elements of type float , string. tried converting each element string , effort concatenation.

x in priceandproduct: x = str(x)

this no avail.

if wanted modify list, following:

priceandproduct = [ str(x) x in priceandproduct ]

python web2py

c# - MVC Forms Authentication and Session, Authorize Issues -



c# - MVC Forms Authentication and Session, Authorize Issues -

i have mvc project i'm using forms authentication, , had implement roles pages, got in global.asax:

protected void application_authenticaterequest(object sender, eventargs e) { httpcookie authcookie = context.request.cookies[formsauthentication.formscookiename]; if (authcookie == null || authcookie.value == "") { return; } formsauthenticationticket authticket; seek { authticket = formsauthentication.decrypt(authcookie.value); } grab { return; } string[] roles = authticket.userdata.split(';'); if (context.user != null) { context.user = new genericprincipal(context.user.identity, roles); } }

and save user roles when log in model:

//after checking login/password httpcookie cookie = httpcontext.current.request.cookies.get(formsauthentication.formscookiename); if (cookie == null) { cookie = new httpcookie(formsauthentication.formscookiename); httpcontext.current.response.cookies.add(cookie); } string userroles = null; if (users[i].perfilid == userranks.admin) { userroles = "admin;users"; } else { userroles = "users"; } formsauthenticationticket ticket = new formsauthenticationticket(0, users[i].name, datetime.now, datetime.now.adddays(1), false, userroles, formsauthentication.formscookiepath ); cookie.value = formsauthentication.encrypt(ticket); httpcontext.current.response.cookies.set(cookie); httpcontext.current.session["userid"] = users[i].userid; httpcontext.current.session["lastlogin"] = users[i].lastlogin; httpcontext.current.user = new genericprincipal(httpcontext.current.user.identity, userroles.split(';'));

to retrieve values of session variables, have static property:

public static int userid { { object sessiondata = httpcontext.current.session["userid"]; if (sessiondata == null) { //i had here... homecoming 0; } homecoming convert.toint32(sessiondata); } private set { } }

before implemented roles authorization, used save userid in cookie userdata, , if userid in session, when requested, null, i'd retrieve cookie instead (and set session again). userdata beingness used roles management , i'm having issues session dropping faster cookie expiration, , have users logged in can't retrieve userids , fails operations.

so have set checker in each controller function such as:

if (myuser.session.userid == 0) { //redirect login }

...which defeats whole purpose of using [authorize] guess. there improve way handle login expiration , session variables this?

i thought using json or other format , save bunch of userdata in cookie, i'd simpler, if possible.

also, i'm doing in login:

httpcontext.current.user = new genericprincipal(httpcontext.current.user.identity, userroles.split(';'));

which seems same authenticaterequest (i got part elsewhere, seemed recommended way handle fellow member roles), doesn't work should. user gets redirected out on [authorize(roles="admin")] or [authorize] functions if leave (and remove global.asax part). why?

c# asp.net-mvc asp.net-mvc-4 session cookies

c++ - Alternate argument lists of pure virtual won't inherit (needed "using") -



c++ - Alternate argument lists of pure virtual won't inherit (needed "using") -

i've got base of operations class few pure virtuals, , want provide default implementations of several methods can overridden if needed. i've boiled problem downwards following:

class {}; class b {}; class base of operations { public: virtual void foo (const a&) {}; virtual void foo (const b&) = 0; }; class derived : public base of operations { public: virtual void foo(const b&) {}; }; int main(int argv, char** argc) { derived d; d.foo(a()); homecoming 0; }

for reasons don't understand @ all, fails on g++ 4.8.2:

g++ scratch.cpp -o scratch scratch.cpp: in function ‘int main(int, char**)’: scratch.cpp:17:12: error: no matching function phone call ‘derived::foo(a)’ d.foo(a()); ^ scratch.cpp:17:12: note: candidate is: scratch.cpp:12:16: note: virtual void derived::foo(const b&) virtual void foo(const b&) {}; ^ scratch.cpp:12:16: note: no known conversion argument 1 ‘a’ ‘const b&’

if define foo(const b&) in base , leave derived empty, problem goes away. i've read docs , of questions here, nil has suggested why problem. in real code, base::foo(const a&) build special object b of type b a object, , phone call foo(b).

add line derived class definition:

using base::foo;

this solve problem foo(b) definition in derived hides both foo(a) , foo(b) functions in base.

c++ inheritance pure-virtual

ios - Xcode pin menu for adding Auto Layout constraints is missing -



ios - Xcode pin menu for adding Auto Layout constraints is missing -

in other projects, menu not missing. however, in 1 project cannot see or find menu. know how create reappear? not find here or via google or in apple docs, perhaps not looking in right place. using v6.1, if matters.

many thanks!

select storyboard file in navigator, open utilities menu on top right, show file inspector (the left icon) , under interface builder document menu, click utilize auto layout.

regards

ios xcode

java - com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException -



java - com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException -

i trying deploy paper website. works fine main page (list of articles) when click on 1 of them, go article page, exception:

oct 31, 2014 11:41:35 com.sun.faces.application.view.faceletviewhandlingstrategy handlerenderexception severe: error rendering view[/noticia.xhtml] java.lang.nullpointerexception @ java.net.urlencoder.encode(unknown source) @ com.sun.faces.context.urlbuilder.addvaluestoparameter(urlbuilder.java:318)

i using maven , tomcat 7.0.

full stacktrace: http://pastebin.com/qjzaypll

noticia.xhtml: http://pastebin.com/xgy7cmqw

frontpagemb: http://pastebin.com/fbtnqphp

pom.xml: http://pastebin.com/0ekp6fr2

web.xml: http://pastebin.com/eeymsm1f

java spring maven jsf managed-bean

Python: sorting a dependency list -



Python: sorting a dependency list -

i'm trying work out if problem solvable using builtin sorted() function or if need myself - old school using cmp have been relatively easy.

my data-set looks like:

x = [ ('business', set('fleet','address')) ('device', set('business','model','status','pack')) ('txn', set('device','business','operator')) ....

the sort rule should value of n & y y > n, x[n][0] not in x[y][1]

although i'm using python 2.6 cmp argument still available i'm trying create python 3 safe.

so, can done using lambda magic , key argument?

-== update ==-

thanks eli & winston! didn't think using key work, or if suspected shoe horn solution isn't ideal.

because problem database table dependencies had create minor add-on eli's code remove item list of dependencies (in designed database wouldn't happen, lives in magical perfect world?)

my solution:

def topological_sort(source): """perform topo sort on elements. :arg source: list of ``(name, set(names of dependancies))`` pairs :returns: list of names, dependancies listed first """ pending = [(name, set(deps)) name, deps in source] emitted = [] while pending: next_pending = [] next_emitted = [] entry in pending: name, deps = entry deps.difference_update(set((name,)), emitted) # <-- pop self dep, req py2.6 if deps: next_pending.append(entry) else: yield name emitted.append(name) # <-- not required, preserves original order next_emitted.append(name) if not next_emitted: raise valueerror("cyclic dependancy detected: %s %r" % (name, (next_pending,))) pending = next_pending emitted = next_emitted

what want called topological sort. while it's possible implement using builtin sort(), it's rather awkward, , it's improve implement topological sort straight in python.

why going awkward? if study 2 algorithms on wiki page, both rely on running set of "marked nodes", concept that's hard contort form sort() can use, since key=xxx (or cmp=xxx) works best stateless comparing functions, particularly because timsort doesn't guarantee order elements examined in. i'm (pretty) sure solution does utilize sort() going end redundantly calculating info each phone call key/cmp function, in order around statelessness issue.

the next alg i've been using (to sort javascript library dependancies):

edit: reworked greatly, based on winston ewert's solution

def topological_sort(source): """perform topo sort on elements. :arg source: list of ``(name, [list of dependancies])`` pairs :returns: list of names, dependancies listed first """ pending = [(name, set(deps)) name, deps in source] # re-create deps can modify set in-place emitted = [] while pending: next_pending = [] next_emitted = [] entry in pending: name, deps = entry deps.difference_update(emitted) # remove deps emitted lastly pass if deps: # still has deps? recheck during next pass next_pending.append(entry) else: # no more deps? time emit yield name emitted.append(name) # <-- not required, helps preserve original ordering next_emitted.append(name) # remember emitted difference_update() in next pass if not next_emitted: # entries have unmet deps, 1 of 2 things wrong... raise valueerror("cyclic or missing dependancy detected: %r" % (next_pending,)) pending = next_pending emitted = next_emitted

sidenote: is possible shoe-horn cmp() function key=xxx, outlined in python bug tracker message.

python sorting topological-sort

javascript - Trying to figure the logic of the loop in a 2D midpoint subdivide -



javascript - Trying to figure the logic of the loop in a 2D midpoint subdivide -

i understand concept having problem implementing looping logic behind 2d subdivide. have 2d array representing grid corners seeded. believe need 3 loops. 1 loop number of subdivide iterations. sec 1 each column in row, , 3rd each row.

this have. shows results of top-left square subdivide. why row , column loops once. if basic logic rest should cake. loop not work on 3rd iteration. pretty sure loop needs more complex.

iterations manually set variable.

// iterate though subdivision levels for(i = 1; <= iterations; i++) { // iteration // iterate through each row for(row = 1; row <= 1; row += size / ) { // row // iterate through each column , subdivide for(col = 1; col <= 1; col += size / i) { // column //*** showing first subdivide of each iteration ***// // math.pow(2, iterations) / 2 / = 1 // = 1, iteration = 1 heightmap[0][1] = (heightmap[0][0] + heightmap[0][2]) / 2; // math.pow(2, iterations) / 2 / = 2 // = 1, iterations = 2 heightmap[0][2] = (heightmap[0][0] + heightmap[0][4]) / 2; // math.pow(2, iterations) / 2 / = 4 // = 1, iterations = 3 heightmap[0][4] = (heightmap[0][0] + heightmap[0][8]) / 2; // if iterations == 1, != 2 // math.pow(2, iterations) / 2 / = 1 // = 2, iterations = 2 heightmap[0][1] = (heightmap[0][0] + heightmap[0][2]) / 2; // math.pow(2, iterations) / 2 / = 2 // = 2, iterations = 3 heightmap[0][2] = (heightmap[0][0] + heightmap[0][4]) / 2; // if iterations == 1 or 2, != 3 // math.pow(2, iterations) / 2 / = 4/3 != 1 // = 3, iterations = 3 heightmap[0][1] = (heightmap[0][0] + heightmap[0][2]) / 2; } } }

if helps used 1d subdivide.

// increment number of segments for(var = 1; < size; *= 2){ // iterate through each segment calculating center point for(var j = (size / i) / 2; j < size; j += size / i){ points[j] = ((points[j - (size / i) / 2] + points[j + (size / i) / 2]) / 2); } }

it easier subdivide 1 direction @ time:

var points = [[ 0,-1,-1,-1, 1], [-1,-1,-1,-1,-1], [-1,-1,-1,-1,-1], [-1,-1,-1,-1,-1], [ 2,-1,-1,-1, 0]]; var size = 4; (var iteration = 1; iteration < size; iteration *= 2) { var step = size / iteration; // * . * . * // x . x . x // * . * . * (var row = step / 2; row < size; row += step) { (var col = 0; col <= size; col += step) { points[row][col] = ((points[row - step / 2][col] + points[row + step / 2][col]) / 2); } } // * x * x * // * x * x * // * x * x * (var row = 0; row <= size; row += step / 2) { (var col = step / 2; col < size; col += step) { points[row][col] = ((points[row][col - step / 2] + points[row][col + step / 2]) / 2); } } }

the result is:

[[ 0, 0.25, 0.5, 0.75, 1 ], [ 0.5, 0.5625, 0.625, 0.6875, 0.75 ], [ 1, 0.875, 0.75, 0.625, 0.5 ], [ 1.5, 1.1875, 0.875, 0.5625, 0.25 ], [ 2, 1.5, 1, 0.5, 0 ]]

javascript arrays loops logic heightmap

SSL CA Certificates - LibCurl C Language (Linux) -



SSL CA Certificates - LibCurl C Language (Linux) -

im working webservice , still cannot authenticate peer certificates. im using libcurl c language, output:

cannot perform post, err: peer certificate cannot authenticated given ca certificates

so i've tried test connection through openssl command:

openssl s_client -connect homnfce.sefaz.am.gov.br:443 -cert cert.pem -key nfcek.pem

then : verify homecoming code: 20 (unable local issuer certificate)

going farther looked around server certificates, , noticed have cert chain. i've downloaded them , added using keytool:

keytool -import -trustcacerts -file cert1.cer -alias mykey keytool -import -trustcacerts -file cert2.cer -alias mykey2 keytool -import -trustcacerts -file cert3.cer -alias mykey3

even these changes, still can't authenticate peer certificates.

i think can indicate error while setting curlopts, heres extract of code:

if (curl_easy_setopt(curl, curlopt_post, 1) != curle_ok) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_post, 1) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_url, "https://homnfce.sefaz.am.gov.br/nfce-services-nac/services/nfestatusservico2?wsdl") != curle_ok) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_url) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_port, 443) != curle_ok) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_port, 443) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_sslcert, "cert.pem") != curle_ok) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_sslcert) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_sslkey, "nfcek.pem") != curle_ok) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_sslkey) failed"); homecoming -1; } sprintf(szcertpath, "%s","/home/cacerts/"); if (curl_easy_setopt(curl, curlopt_capath, szcertpath) != curle_ok) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_ssl_verifypeer) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_postfieldsize, ilen) != curle_ok) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_postfieldsize) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_sslcertpasswd, szmypw) != curle_ok ) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_timeout) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_readdata, pfchk) != curle_ok ) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_postfieldsize) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_writedata, pfanswer) != curle_ok ) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_writedata) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_timeout, ionlineservertimeout) != curle_ok ) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_timeout) failed"); homecoming -1; } if (curl_easy_setopt(curl, curlopt_nosignal, 1) != curle_ok) { if ( debug_details ) vtrace("curl_easy_setopt(curl, curlopt_nosignal, 1) failed"); homecoming __line__; } if ( (res = curl_easy_perform(curl)) != curle_ok ){ if ( debug_details ) vtracestr("infce_curlreq(): cannot perform post, err: %s\n", (char *)curl_easy_strerror(res)); homecoming -1; }

something of import fact can't utilize insecure mode alternative ingnore peer authentication (curlopt_ssl_verifypeer = 0 ).

any ideas? can wrong?

thanks in advance

i've done it. problem servers cas. ive download certificate chain host, ive used openssl commands convert:

openssl x509 -in raiz_v2.cer -out raiz_v2.pem openssl x509 -in ac_certsign_g6.cer -out ac_certsign_g6.pem openssl x509 -in ac_certsign_mult_g5.cer -out ac_certsign_mult_g5.pem

so ive unified them using:

cat raiz_v2.pem > cacert.pem cat ac_certsign_g6.pem >> cacert.pem cat ac_certsign_mult_g5.pem >> cacert.pem

and ive pointed cacert.pem using curlopt_cainfo option.

c linux ssl certificate libcurl

rest - How do I solve this Yii2 RESTful Web Service API routing error? -



rest - How do I solve this Yii2 RESTful Web Service API routing error? -

i trying implement yii2 restful web service api described in guide. trying using advanced application template. problem 404 errors when seek access service. wanted start out trying simple going utilize country table , associated activerecord class seek out, here's code:

this in components configuration in frontend/config/main.php :

'urlmanager' => [ 'enableprettyurl' => true, 'enablestrictparsing' => true, 'showscriptname' => false, 'rules' => [ ['class' => 'yii\rest\urlrule', 'controller' => 'country'], ], ], 'request' => [ 'parsers' => [ 'application/json' => 'yii\web\jsonparser', ] ]

this code in frontend/controllers/countrycontroller.php :

namespace frontend\controllers; utilize yii\rest\activecontroller; class countrycontroller extends activecontroller { public $modelclass = 'common\models\country'; }

all of activerecord models country in common/models.

i used next seek it:

curl -i -h "accept:application/json" "http://myfrontendapp.loc/country"

this output get:

http/1.1 404 not found date: fri, 31 oct 2014 22:46:50 gmt server: apache content-length: 205 content-type: text/html; charset=iso-8859-1 <!doctype html public "-//ietf//dtd html 2.0//en"> <html><head> <title>404 not found</title> </head><body> <h1>not found</h1> <p>the requested url /country not found on server.</p> </body></html>

i have spent many hours on this. have adjusted setting, read documentation, , alot more without success. if can see problem please allow me know, thanks!!

you're nail default urlrule behavior of pluralizing class names: in line mutual rest conventions, it's smart plenty turn controller named country pluralized route named /countries.

try get http://myfrontendapp.loc/countries , it'll work fine. goes other routes created urlrule, e.g. get /countries/12345

or, if want disable behavior can set urlrule's $pluralize false. check http://www.yiiframework.com/doc-2.0/guide-rest-routing.html more information.

rest yii2

image - Android camera.action.CROP doesn't give consistent results -



image - Android camera.action.CROP doesn't give consistent results -

i trying pick , crop image straight gallery, reason crop intent doesn't work, on devices working stock gallery, , on devices working unofficial gallery apps (like g2).

i know should work on device because have other apps utilize same gallery crop function , works.

every time seek open intent stock gallery next message: couldn't find item (i want user pick image, not pass specific image location)

// start intent event image user private void getcroppedimage(){ // create output directory image string timestamp = new simpledateformat("ddmmmyy_hhmmsss").format(new date()); file dir = new file(environment.getexternalstoragedirectory () + file.separator + "myapp/images"); file picpath = environment.getexternalstoragepublicdirectory( environment.directory_pictures); file outputpath = new file(dir,"img_"+ timestamp + ".jpg"); // create sure output dir exists if (!dir.exists()){ dir.mkdirs(); } // start intent, if available intent cropintent = new intent("com.android.camera.action.crop"); //cropintent.setdata(uri.fromfile(picpath)); cropintent.settype("image/*"); cropintent.putextra("crop", "true"); cropintent.putextra("outputx", 512); cropintent.putextra("outputy", 512); cropintent.putextra("aspectx", 1); cropintent.putextra("aspecty", 1); cropintent.putextra("output", uri.fromfile(outputpath)); // verify intent resolve activity if (cropintent.resolveactivity(getpackagemanager()) != null) { startactivityforresult(cropintent, request_code_crop_image); }else{ cropintent.setaction(intent.action_get_content); // verify intent resolve activity if (cropintent.resolveactivity(getpackagemanager()) != null) { startactivityforresult(cropintent, request_code_get_picture); }else{ toast.maketext(this,"gallery not detected",toast.length_long).show(); } } }

any thoughts?

try this:

public class cropoptionadapter extends arrayadapter<cropoption> { private arraylist<cropoption> moptions; private layoutinflater minflater; public cropoptionadapter(context context, arraylist<cropoption> options) { super(context, r.layout.crop_selector, options); moptions = options; minflater = layoutinflater.from(context); } @override public view getview(int position, view convertview, viewgroup group) { if (convertview == null) convertview = minflater.inflate(r.layout.crop_selector, null); cropoption item = moptions.get(position); if (item != null) { ((imageview) convertview.findviewbyid(r.id.iv_icon)) .setimagedrawable(item.icon); ((textview) convertview.findviewbyid(r.id.tv_name)) .settext(item.title); homecoming convertview; } homecoming null; } } public class cropoption { public charsequence title; public drawable icon; public intent appintent; } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { if (resultcode != result_ok) return; switch (requestcode) { case pick_from_camera: /** * after taking picture, crop */ docrop(); break; case pick_from_file: /** * after selecting image files, save selected path */ mimagecaptureuri = data.getdata(); infolog("pick file"); docrop(); break; case crop_from_camera: bundle extras = data.getextras(); /** * after cropping image, bitmap of cropped image , * display on imageview. */ if (extras != null) { photo = extras.getparcelable("data"); bitmap circlebitmap = bitmap.createbitmap(photo.getwidth(), photo.getheight(), bitmap.config.argb_8888); bitmapshader shader = new bitmapshader(photo, tilemode.clamp, tilemode.clamp); paint paint = new paint(); paint.setshader(shader); canvas c = new canvas(circlebitmap); c.drawcircle(photo.getwidth() / 2, photo.getheight() / 2, photo.getwidth() / 2, paint); img.setimagebitmap(photo); } file f = new file(mimagecaptureuri.getpath()); /** * delete temporary image */ if (f.exists()) f.delete(); break; } } private void docrop() { final arraylist<cropoption> cropoptions = new arraylist<cropoption>(); /** * open image crop app starting intent * ‘com.android.camera.action.crop‘. */ intent intent = new intent("com.android.camera.action.crop"); intent.settype("image/*"); /** * check if there image cropper app installed. */ list<resolveinfo> list = getpackagemanager().queryintentactivities( intent, 0); int size = list.size(); /** * if there no image cropper app, display warning message */ if (size == 0) { toast.maketext(this, "can not find image crop app", toast.length_short).show(); return; } else { /** * specify image path, crop dimension , scale */ intent.setdata(mimagecaptureuri); intent.putextra("outputx", 200); intent.putextra("outputy", 200); intent.putextra("aspectx", 1); intent.putextra("aspecty", 1); intent.putextra("scale", true); intent.putextra("return-data", true); /** * there possibility when more 1 image cropper app exist, * have check first. if there 1 app, open * app. */ if (size == 1) { intent = new intent(intent); resolveinfo res = list.get(0); i.setcomponent(new componentname(res.activityinfo.packagename, res.activityinfo.name)); startactivityforresult(i, crop_from_camera); } else { /** * if there several app exist, create custom chooser * allow user selects app. */ (resolveinfo res : list) { final cropoption co = new cropoption(); co.title = getpackagemanager().getapplicationlabel( res.activityinfo.applicationinfo); co.icon = getpackagemanager().getapplicationicon( res.activityinfo.applicationinfo); co.appintent = new intent(intent); co.appintent .setcomponent(new componentname( res.activityinfo.packagename, res.activityinfo.name)); cropoptions.add(co); } cropoptionadapter adapter = new cropoptionadapter( getapplicationcontext(), cropoptions); alertdialog.builder builder = new alertdialog.builder(this); builder.settitle("choose crop app"); builder.setadapter(adapter, new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int item) { startactivityforresult( cropoptions.get(item).appintent, crop_from_camera); } }); builder.setoncancellistener(new dialoginterface.oncancellistener() { @override public void oncancel(dialoginterface dialog) { if (mimagecaptureuri != null) { getcontentresolver().delete(mimagecaptureuri, null, null); mimagecaptureuri = null; } } }); alertdialog alert = builder.create(); alert.show(); } } }

android image android-intent gallery crop

mobile - jQuery .hide() causing a ghost touchstart "click" of 2nd button -



mobile - jQuery .hide() causing a ghost touchstart "click" of 2nd button -

i have 2 buttons on page, need hide "calculate" button not clicked 1 time again , again, rather users select "reset" button.

this works great if both buttons showing if hide calculate button, 1 time has completed work, somehow automatically executing reset button though reset button not beingness clicked.

this happens on touch devices. works fine if run browser. touch devices (ex. iphone) issue occurring. clues? using jquery-2.1.1.min

here calculate button:

$(document).on( 'touchstart click' , '#calculate' , function () { // stuff //hide button done users don't maintain clicking $( '#calculate' ).hide(); });

here reset button:

$(document).on( 'touchstart click' , '#reset' , function () { $( "input.form-control" ).val(0); });

here working example:

http://investingcalculator.azurewebsites.net/

did seek without delegating?

$('#calculate').on( 'touchstart click', function () { // stuff //hide button done users don't maintain clicking $( '#calculate' ).hide(); }); $('#reset').on( 'touchstart click', function () { $( "input.form-control" ).val(0); });

jquery mobile

html - how to show data in grid/thumbnails -



html - how to show data in grid/thumbnails -

how show info database in grid/thumbnails like this or jsfiddle. using spring/jsp technologies. right showing in table this.

in jsp

<table class="pdttable" border="1" cellpadding="0" cellspacing="0" align="center"> <tr> <th>product name</th> </tr> <c:foreach items="${productlist}" var="product" > <tr> <td><a href="details${product.id}"> ${product.productname}</a></td> </tr> </c:foreach> </table>

use varstatus attribute in foreach loop , utilize check (using modulo operator) if need start or close row.

<table class="pdttable" border="1" cellpadding="0" cellspacing="0" align="center"> <tr> <th>product name</th> </tr> <c:foreach items="${productlist}" var="product" varstatus="status"> <c:if test="${status.index % 3 == 0}"><tr></c:if> <td><a href="details${product.id}"> ${product.productname}</a></td> <c:if test="${status.index % 3 == 2}"></tr></c:if> </c:foreach> </table>

this can leave table row unclosed, need build check that.

a improve solution using css , syle list of items using float example:

class="snippet-code-css lang-css prettyprint-override">ul.tiles { width: 400px; } ul.tiles li { float: left; list-style-type: none; width: 100px; height: 100px; margin: 10px; background: yellow; } class="snippet-code-html lang-html prettyprint-override"><ul class="tiles"> <li>item 1</li> <li>item 2</li> <li>item 3</li> <li>item 4</li> </ul>

html jsp

wrong reading numbers from a file c++ -



wrong reading numbers from a file c++ -

i have file matrix n x n, illustration got these numbers:

3.162277660168379 4.110960958218893 7.58946638440411 -1.110223024625157e-016 6.715653356152327 6.224264086189961 -5.551115123125783e-016 -1.332267629550188e-015 3.107818621696872

and got code:

std::ifstream in("r.txt"); std::string line; float b[4][4]; int u = 1, y = 1; while (std::getline(in, line)) { float value; int y = 1; std::stringstream ss(line); while (ss >> value) { b[u][y] = value; cout << setprecision(16) << b[u][y] << " "; ++y; } cout << endl; ++u; }

and reply when seek output in command line:

3.162277698516846 4.110960960388184 7.589466571807861 -1.110223024625157e-016 6.715653419494629 6.224264144897461 -5.551115123125783e-016 -1.332267629550188e-015 3.107818603515625

has any1 thought why numbers wrong readed ? 8th digit ? :) thanks

instead of using float utilize double, because float work upto 8 decimal places

c++