Monday, 15 March 2010

statistics - R-sq values, linear regression of several trends within one dataset -



statistics - R-sq values, linear regression of several trends within one dataset -

i running sticky spot trying solve variance accounted trend several times within single info set.....

my info structured this

x <- read.table(text = " sta year value 1968 457 1970 565 1972 489 1974 500 1976 700 1978 650 1980 659 b 1968 457 b 1970 565 b 1972 350 b 1974 544 b 1976 678 b 1978 650 b 1980 690 c 1968 457 c 1970 565 c 1972 500 c 1974 600 c 1976 678 c 1978 670 c 1980 750 " , header = t)

and trying homecoming this

sta r-sq n1 b n2 c n3

where n# corresponding r-squared value of locations info in original set....

i have tried

fit <- lm(value ~ year + sta, info = x)

to give model of yearly trend of value each individual station on years info available value, within master info set....

any help appreciated.... stumped on 1 , know familiarity r problem.

to r-squared value ~ year each grouping of sta, can take previous answer, modify , plug-in values:

# assuming x info frame (make sure don't have hmisc loaded, interfere) models_x <- dlply(x, "sta", function(df) summary(lm(value ~ year, info = df))) # extract r.squared values rsqds <- ldply(1:length(models_x), function(x) models_x[[x]]$r.squared) # give names rows , col rownames(rsqds) <- unique(x$sta) colnames(rsqds) <- "rsq" # have rsqds rsq 0.6286064 b 0.5450413 c 0.8806604

edit: next mnel's suggestion here more efficient ways r-squared values nice table (no need add together row , col names):

# starting models_x above rsqds <- data.frame(rsq =sapply(models_x, '[[', 'r.squared')) # starting original info in x, great: rsqds <- ddply(x, "sta", summarize, rsq = summary(lm(value ~ year))$r.squared) sta rsq 1 0.6286064 2 b 0.5450413 3 c 0.8806604

r statistics linear-regression

visual studio 2010 - What Are the Correct Web.Config Settings for the VS2010 F# Compiler? -



visual studio 2010 - What Are the Correct Web.Config Settings for the VS2010 F# Compiler? -

i've got aspx page this:

<%@ page language="f#" %> <!doctype html> <html> <head> <title></title> </head> <body> <%-- seek output "this test" 10 times --%> <% = 1 10 %> <p>this test</p> </body> </html>

and web.config looks this:

<?xml version="1.0"?> <configuration> <system.codedom> <compilers> <compiler language="f#;f#;fs;fsharp" extension=".fs" warninglevel="4" type="microsoft.fsharp.compiler.codedom.fsharpaspnetcodeprovider, fsharp.compiler.codedom, version=2.0.0.0, culture=neutral, publickeytoken=a19089b1c74d0809"> <provideroption name="compilerversion" value="v4.0" /> <provideroption name="warnaserror" value="false" /> </compiler> </compilers> </system.codedom> <system.web> <compilation debug="true" targetframework="4.0" /> </system.web> </configuration>

when run vs2010 webapp, error this: "the codedom provider type "microsoft.fsharp.compiler.codedom.fsharpaspnetcodeprovider, fsharp.compiler.codedom, version=2.0.0.0, culture=neutral, publickeytoken=a19089b1c74d0809" not located."

i've tried settings mentioned manojlds here, don't seem working me either. think because re-create of vs2010 pro has newer version of f# compiler, don't know how tell sure.

can help me understand right version settings should utilize in vs2010 web.config "compiler" , "provideroption" elements?

i have not tried this, configuration file looks right me - can check eversion of fsharp.compiler.codedom assembly installed in gac (by looking @ c:\windows\assembly)?

however, @ moment, not recommend using f# writing of aspx part of web page. works, won't smooth experience when mixing c# aspx or using razor templating engine (for asp.net mvc).

i think best way create server-side asp.net web applications in f# utilize f# code behind (in traditional webforms) or model , controller parts (in mvc). there number of templates , tutorials describe how this:

tutorial: creating web project in f# using online template and templates asp.net mvc 4 , older asp.net mvc 3 you might want check out web stacks page on fsharp.org

visual-studio-2010 f#

html - Show / Hide background image of div on hover -



html - Show / Hide background image of div on hover -

i'm trying figure out if @ possible show , hide background image on div hover state. here's code: html

<div class="thumb"> <div class="text"> header<br> sub-header<br><br> date </div> </div> <div class="thumb"> <div class="text"> header<br> sub-header<br><br> date </div> </div> <div class="thumb"> <div class="text"> header<br> sub-header<br><br> date </div> </div>

css

.thumb { width: 400px; height: 250px; background-color: silver; font-weight: bold; background: url("http://www.imageurlhere.com") no-repeat 50% 50%; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } .text { padding: 15px; }

so want alternate between background image , background color, when hover on div background image show, , on mouseout background image hidden , revert background colour (silver). found do-able via pseudo classes cms site images changed on fly, hence they'll have inserted via html:

style="background-image: url('insert url here')"

is @ possible hide , show background-image?

are against using javascript (or jquery)?

if not, have solution using .hover() function in jquery. said didn't want add together new classes new images. i'm proposing store urls in .thumb elements.

html:

<div class="thumb" data-hoverimage="http://placekitten.com/250/400"> <div class="text">header <br>sub-header <br> <br>date</div> </div> <div class="thumb" data-hoverimage="http://placekitten.com/250/300"> <div class="text">header <br>sub-header <br> <br>date</div> </div> <div class="thumb" data-hoverimage="http://placekitten.com/400/250"> <div class="text">header <br>sub-header <br> <br>date</div> </div>

i stored each thumbnail's url in data-hoverimage attribute (it can whatever want).

then, using jquery, can utilize hover function. first function when cursor over, sec when cursor out.

$(".thumb").hover(function(){ var imgurl = $(this).data("hoverimage"); $(this).css("background-image", "url(" + imgurl + ")") }, function(){ $(this).css("background-image", ""); });

i have working model here: http://jsfiddle.net/auurq/

html css hover

visual studio 2010 - How to fix profiling error "Couldn't add counter: cta_launched_vsm0" -



visual studio 2010 - How to fix profiling error "Couldn't add counter: cta_launched_vsm0" -

when effort run kernel profiling, series of couldn't add together counter: cta_launched_vsm0 errors. think might due profiler targeting fermi card, while there's kepler card in machine. i'm using code generation compute_30,sm_30. how can prepare error?

environment:

windows 7 64-bit visual studio 2010 cuda 4.2 + cuda 5.0 (5.0 installed on top of 4.2) occurs projects created cuda 5.0 wizard , 5.0 sdk samples. occurs projects created 4.2 wizard. both debug , release builds. gpus: single gtx660. (gtx570 installed before no longer installed). analysis activity: profile cuda application. experiments run: all. other settings on defaults. nsight 2.2, bundled cuda 5.

errors:

nsight: profiling kernel kernel nsight: achieved occupancy experiment ( 1/13):. nsight: achieved flops experiment ( 2/13):. nsight: instruction statistics experiment ( 3/13):couldn't add together counter: cta_launched_vsm0 (not supported device) nsight: issue efficiency experiment ( 4/13):couldn't add together counter: cta_launched_vsm0 (not supported device) nsight: branch experiment ( 5/13):.. nsight: memory global experiment ( 6/13):couldn't add together counter: cta_launched_vsm0 (not supported device) nsight: memory local experiment ( 7/13):couldn't add together counter: cta_launched_vsm0 (not supported device) nsight: memory atomics experiment ( 8/13):couldn't add together counter: cta_launched_vsm0 (not supported device) nsight: memory shared experiment ( 9/13):couldn't add together counter: cta_launched_vsm0 (not supported device) nsight: memory texture experiment (10/13):couldn't add together counter: tex0_cache_sector_misses_gpc0_tpc0 (not supported device) nsight: memory caches experiment (11/13):..couldn't add together counter: l2_slice0_read_sectors_l1_fb0 nsight: memory framebuffer experiment (12/13):couldn't add together counter: l2_slice0_read_sysmem_sectors_fb0 (not supported device) nsight: launch info experiment (13/13):. nsight: experiments complete, total replays needed: 7

nsight visual studio edition 2.2 shipped before gtx 660 (gk106) released market. nsight 2.2 has been refreshed multiple times , works drivers compatible gtx 660. however, pm programming library not updated 2.2.

nsight visual studio 3.0 rc1 available download here supports gtx 660 , tesla k20.

visual-studio-2010 cuda profiling

Finding the length of an array in C -



Finding the length of an array in C -

i'm trying find length of array of "header" structures defined (a header holds few informational int members, if relevant here). effort passing fl, pointer start of array, , idx, index value indicates proper fl_tails pointer is stationed @ end of array (in other/repetitive words, 'fl_tails[idx]` pointer end):

int arr_size(header* fl, int idx){ int cnt = 1; /* passed guaranteed have @ to the lowest degree 1 */ while(fl != fl_tails[idx]){ fl++; cnt++; } }

i thought advance fl pointer , generate count until end reached, goes infinite loop. i'm wondering if caused in function or elsewhere need find. when printed addresses of origin , end unsigned ints, seemed innocuous enough---things 16777216 , 16777344, respectively. maybe wrong understanding of header construction , size/effect on steps?

you want compare addresses, so:

while(fl != &fl_tails[idx]) ^

c arrays pointers

naudio - how to play more than one wav file in c#.net -



naudio - how to play more than one wav file in c#.net -

i need play more 1 wav file simultaneously (at same time). must have alternative volume command , stop, pause, , play.

i using naudio dll this. works fine times application goes crash.

this code:

_wavout = new waveout(); _wavreader = new wavefilereader(soundfilepath); _wavreader = (wavefilereader)waveformatconversionstream.createpcmstream( _wavreader); _wavout.init(_wavreader); _wavout.play();

this stack trace get:

at naudio.wave.waveoutbuffer.writetowaveout() @ naudio.wave.waveoutbuffer.ondone() @ naudio.wave.waveout.callback(intptr, wavemessage, intptr, naudio.wave.waveheader, intptr)

if you're using soundplayer, impossible.

c# naudio

php - How to properly count a query in pdo -



php - How to properly count a query in pdo -

i trying dynamically load more posts scheme

this code...

$stmt = " select * `acmposting` (`sender`='$thisid' , `posttype`='a') or (`recip`='$thisid' , `sender`='$userid' , `posttype`='a') or (`sender` in ($friendsarray) , `recip`='$thisid' , `posttype`='a') order `timesent` desc limit $startlimit,10"; if($stmtcount = $conn->query($stmt)){ if($stmtcount->fetchcolumn() > 0){ $result = acmposts($conn, $site, $userid, $stmt); $jsonarray['a'] = $result; $jsonarray['b'] = 'go'; }else{ $jsonarray['a'] = '<div class="thisoutput" style="padding:12px;">there no more posts</div>'; $jsonarray['b'] = 'stop'; } }

everything works fine until gets lastly set of posts aka if limit 100,10 there 105 posts in phone call won't phone call fetchcolumn().

i hope question makes sense. in advance help can give.

edit

how can determine when have reached limit , deed accordingly

your description not precise maybe looking for:

http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows

php pdo

solr schema.xml validate -



solr schema.xml validate -

i have problem schema validation of solr, shows 500 error.

simpleposttool: version 1.4 simpleposttool: posting files http://localhost:8081/solr-project/update.. simpleposttool: posting file sample-solr.xml simpleposttool: fatal: solr returned error #500 error interno del servidor

the field of schema.xml of solr this:

<field> <field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="url" type="string" stored="true"/> <field name="content" type="text_es" indexed="true" stored="true" /> </field> <uniquekey>id</uniquekey>

no need follow order equal schema.xml, id field required.

sample-solr.xml

<?xml version="1.0"?> <add> <doc> <field name="id">id product</field> <field name="url">http://www.web.com/content/direct/index.html</field> <field name="content">field content text</field> </doc> </add>

compile project , execute test:

~/opt/solr/solr/example/exampledocs$ java -jar -durl=http://localhost:8081/solr-project/update post.jar sample-solr.xml

what can be?. thanks!.

if solr 4+, have @ console started solr or in admin web ui under logs screen. real message on server side , tell problem is.

xml solr

android fragment cannot setvisibility relativelayout -



android fragment cannot setvisibility relativelayout -

i usging fragments, , in activity want show/hide relativelayout(the last: xk1) when touch edittext :

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/xmlayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/linearborder" > <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/xsublayout" android:keepscreenon="true" android:orientation="vertical" android:layout_below="@+id/rl_boutton" android:layout_width="fill_parent" android:layout_height="fill_parent" > <edittext android:id="@+id/edittext_code_d" android:layout_width="304dp" android:layout_height="wrap_content" android:layout_below="@+id/rl_boutton" android:layout_centerhorizontal="true" android:background="@drawable/plaquehaut" android:ems="4" android:gravity="center_vertical|center_horizontal" android:inputtype="number" android:maxlength="4" android:text="123" android:textsize="80sp" android:focusableintouchmode="true" /> <edittext android:id="@+id/edittext_code_m" android:layout_width="304dp" android:layout_height="wrap_content" android:layout_alignleft="@+id/edittext_code_d" android:layout_below="@+id/edittext_code_d" android:background="@drawable/plaquebas" android:ems="4" android:gravity="center_vertical|center_horizontal" android:inputtype="number" android:maxlength="4" android:text="1337" android:textsize="80sp" /> </relativelayout> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:id="@+id/xk1" android:layout_height="wrap_content" android:orientation="vertical" android:visibility="gone"> <include android:id="@+id/xkeyboard" layout="@layout/keyboard"> </include> </relativelayout> </relativelayout>

here's code:

public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment_rsslist_overview,container, false); seek { mlayout = (relativelayout) view.findviewbyid(r.id.xk1); mklayout = (relativelayout) view.findviewbyid(r.id.xkeyboard); } grab (exception e) { log.w(getclass().getname(), e.tostring()); } met = (edittext) view.findviewbyid(r.id.edittext_code_d); met.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { edittext_onclick(v); } }); met1 = (edittext) view.findviewbyid(r.id.edittext_code_m); met1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { edittext_onclick(v); } }); met.setontouchlistener(this); homecoming view; } public boolean ontouch(view v, motionevent event) { enablekeyboard(); homecoming true; } private void enablekeyboard() { mlayout.setvisibility(relativelayout.visible); mklayout.setvisibility(relativelayout.visible); }

the activity stop when programme run here: mlayout.setvisibility(relativelayout.visible);

how can resolve this?

thx, in advance.

logcat:

02-18 12:06:27.364: i/dalvikvm(1044): wrote stack traces '/data/anr/traces.txt' 02-18 12:06:28.963: d/androidruntime(1044): shutting downwards vm 02-18 12:06:28.963: w/dalvikvm(1044): threadid=1: thread exiting uncaught exception (group=0x409c01f8) 02-18 12:06:29.104: e/androidruntime(1044): fatal exception: main 02-18 12:06:29.104: e/androidruntime(1044): java.lang.nullpointerexception 02-18 12:06:29.104: e/androidruntime(1044): @ fr.app.tutorielfragment.mylistfragment.enablekeyboard(mylistfragment.java:363) 02-18 12:06:29.104: e/androidruntime(1044): @ fr.app.tutorielfragment.mylistfragment.ontouch(mylistfragment.java:240) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.view.dispatchtouchevent(view.java:5536) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:1957) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1684) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:1957) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1684) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:1957) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1684) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:1957) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1684) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:1957) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1684) 02-18 12:06:29.104: e/androidruntime(1044): @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:1912) 02-18 12:06:29.104: e/androidruntime(1044): @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1371) 02-18 12:06:29.104: e/androidruntime(1044): @ android.app.activity.dispatchtouchevent(activity.java:2364) 02-18 12:06:29.104: e/androidruntime(1044): @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:1860) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.view.dispatchpointerevent(view.java:5721) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewrootimpl.deliverpointerevent(viewrootimpl.java:2890) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewrootimpl.handlemessage(viewrootimpl.java:2466) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewrootimpl.processinputevents(viewrootimpl.java:845) 02-18 12:06:29.104: e/androidruntime(1044): @ android.view.viewrootimpl.handlemessage(viewrootimpl.java:2475) 02-18 12:06:29.104: e/androidruntime(1044): @ android.os.handler.dispatchmessage(handler.java:99) 02-18 12:06:29.104: e/androidruntime(1044): @ android.os.looper.loop(looper.java:137) 02-18 12:06:29.104: e/androidruntime(1044): @ android.app.activitythread.main(activitythread.java:4424) 02-18 12:06:29.104: e/androidruntime(1044): @ java.lang.reflect.method.invokenative(native method) 02-18 12:06:29.104: e/androidruntime(1044): @ java.lang.reflect.method.invoke(method.java:511) 02-18 12:06:29.104: e/androidruntime(1044): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) 02-18 12:06:29.104: e/androidruntime(1044): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) 02-18 12:06:29.104: e/androidruntime(1044): @ dalvik.system.nativestart.main(native method) 02-18 12:06:29.693: i/dalvikvm(1044): threadid=3: reacting signal 3 02-18 12:06:29.726: i/dalvikvm(1044): wrote stack traces '/data/anr/traces.txt' 02-18 12:06:34.654: i/process(1044): sending signal. pid: 1044 sig: 9

you should define next top view: xmlns:android="http://schemas.android.com/apk/res/android" think why nullpointerexception layoutinflater can't find right view throuh hierachy.

android android-layout

PHP file doesn't rewrite -



PHP file doesn't rewrite -

i create site map, , create php file, generate mysql. alter host , have problem writing file. can't understand something. here example:

<?php $xml = 'bla bla xml'; //... xml generating code $fp = fopen($_server['document_root'].'/my_site_map.xml', 'w'); if($fp) echo 'we opened it'; else echo 'we failed'; $fwrite=fwrite($fp, $xml, strlen($xml)); if($fwrite==false) echo "another fail"; fclose($fp); echo "we done"; ?>

the question is: file my_site_map.xml have permission 664 (rw-rw-r--), , can't utilize script if open php page browser, so, if seek i'll see: "we failed fail done"; if open through crontab , see log file, can see this: "we opened done". want main problem file isn't have been rewritten. why? , how can prepare this? thanks.

my server nginx not apache, didn't thought info valuable

well don't have plenty rep comment have answer.

i'm going take stab in dark , file owned user or root, not process running webserver. nor file owned grouping webserver process run under.

so either chown/chgrp file owned apache(?!) process running, e.g. chown apache file or set file have write permissions everyone, e.g. chmod 666 file

don't chmod 777 commented above unless it's executable file , want able run it. 1st solution improve practice giving read access file.

edit: in comment comments on original reply above, if file isn't executable don't give 7 permisions. 6 read/write , suitable text file opening write (even 2 if comes that).

edit 2: seek catching exceptions fopen function runs in seek grab block:

try { $fp = fopen($_server['document_root'].'/my_site_map.xml', 'w'); } grab (exception $e) { echo "the error is" . $e->getmessage(); }

php file permissions fopen

laravel - Persistant Register_Globals Error -



laravel - Persistant Register_Globals Error -

i transferred site 1 hosting company another. changed on started intermittently error saying:

directive 'register_globals' depreciated in php 5.3 , greater

its shared hosting have no access php.ini file turn off. i've tried disable using htaccess no luck.

if go cpanel , in php configuration says on, on old server said off. have spoken hosting company , off if in info.php, half true... local value off , master value on. on old server master , local both off.

the server running php version 5.3.13, if interested. i'm using framework laravel 3 hosting company said also: "the 1 way prepare disable in php completely, not sure if there other client using not work on shared hosting platform." guess isn't alternative turn off completely, don't see why not!

i have gone application/config/error.php , added

'ignore' => array(e_warning, e_notice, e_user_notice, e_deprecated, e_user_deprecated)`

but did not work @ graduated , volunteer project, i'm literally pull hair out give thanks in advance!

if go cpanel , in php configuration says on, on old server said off. have spoken hosting company , off if in info.php, half true... local value off , master value on. on old server master , local both off.

the way 100% sure - run follow php command within project

<?=phpinfo();?>

it give total dump of actual values php using.

search register_globals , see server thinks.

maybe time swtich hosts?

laravel register-globals

Calling and Passing Javascript parameters as part of a HTML5 data attribute -



Calling and Passing Javascript parameters as part of a HTML5 data attribute -

based on solution cerbrus here;

passing function custom info attribute

is possible pass parameters part of custom attribute? like;

<div data-myattr="hello(foo)"></div>

why?

i mean, yes, if want regex match contents within parens, separated commas, , inject them. that's madness.

why not create sec data-attribute?

<div data-command="myfunction" data-params="one,two,three"></div>

and grab like:

var command = document.queryselector("[data-command]"), vars = command.dataset.params.split(","), funcname = command.dataset.command; window[funcname](vars[0], vars[1], vars[2]);

or alternatively:

window[funcname].apply(undefined, vars);

javascript html5 custom-data-attribute

audio - How do I filter out out-of-hearing-range data from PCM samples using C++? -



audio - How do I filter out out-of-hearing-range data from PCM samples using C++? -

i have raw 16bit 48khz pcm data. need strip info out of range of human hearing.

for i'm doing sum of samples , dividing sample count calculate peak sound level, need cut down false positives.

i have big peak level time, speaking , other sounds can hear increasing levels little, need implement filtering. not familiar sound processing @ all, not using filtering because not understand how create it. current code looks this:

for(size_t = 0; < buffer.size(); i++) level += abs(buffer[i]); level /= buffer.size();

how can implement kind of filtering using c++?

use band pass filter.

a band-pass filter device passes frequencies within range , rejects (attenuates) frequencies outside range.

this sounds sort of filter looking for.

i had quick google search , found this thread discusses implementation in c++.

c++ audio pcm

sql server - Create more then one column in a pivot table with one sql statement -



sql server - Create more then one column in a pivot table with one sql statement -

i need sort on date in pivot table project info same project number

the project looks this:

"project nr" "task" "task deadline" "task type production" 123 pack 1 apr 2013 pack 123 leave production 3 apr 2013 leave production 123 flight date 9 apr 2013 flight date

the "task type production" made ensure contents of field consistant can create 1 column in pivot table. there way display thes info in 3 columns this:

project nr ; pack ; leave production ; flightdate select [taskdeadline] packed msp_epmtask_userview [task type production] = 'packed' select [taskdeadline] leaveproduction msp_epmtask_userview [task type production] = 'leave production' select [taskdeadline] flightdate msp_epmtask_userview [task type production] = 'flight date'

thanks anne

this can done using aggregate function , case expression:

select [project nr], max(case when [task type production] = 'pack' [task deadline] end) pack, max(case when [task type production] = 'leave production' [task deadline] end) [leave production], max(case when [task type production] = 'flight date' [task deadline] end) [flight date] msp_epmtask_userview grouping [project nr]

see sql fiddle demo

if want utilize pivot function in sql server, query be:

select * ( select [project nr],[task deadline], [task type production] msp_epmtask_userview ) src pivot ( max([task deadline]) [task type production] in ([pack], [leave production], [flight date]) ) piv

see sql fiddle demo.

finally can done using multiple joins table:

select t1.[project nr], t1.[task deadline] pack, t2.[task deadline] [leave production], t3.[task deadline] [flight date] msp_epmtask_userview t1 left bring together msp_epmtask_userview t2 on t1.[project nr] = t2.[project nr] , t2.[task type production] = 'leave production' left bring together msp_epmtask_userview t3 on t1.[project nr] = t3.[project nr] , t3.[task type production] = 'flight date' t1.[task type production] = 'pack'

see sql fiddle demo

the result of queries is:

| project nr | pack | leave production | flight date | ------------------------------------------------------------ | 123 | 2013-04-01 | 2013-04-03 | 2013-04-09 |

sql-server pivot

java - gridview setOnItemClickListener not working -



java - gridview setOnItemClickListener not working -

i'm using gridview display numbers, want next activity, when click on number when click on n number nil happens there no error in logcat nor forcefulness close.

here code

public class cactivity extends activity { gridview gridview; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.cactivity); gridview.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view v, int position, long id) { intent myintent = new intent(getapplicationcontext(), abc.class); startactivity(myintent); //finish(); } }); } private void initcomponent() { gridview = (gridview) findviewbyid(r.id.month_gridview); }

i don't know problem gridview.setadapter(adapter); working. plz help

gridview.setadapter(adapter);

if utilize

gridview gridview = (gridview) findviewbyid(r.id.month_gridview);

then app forcefulness closes

logcat

02-07 21:10:12.721: w/dalvikvm(719): threadid=1: thread exiting uncaught exception (group=0x40015560) 02-07 21:10:12.780: e/androidruntime(719): fatal exception: main 02-07 21:10:12.780: e/androidruntime(719): java.lang.runtimeexception: unable instantiate activity componentinfo{com.indianic.demo.calendark/com.indianic.demo.calendark.calendaractivity}: java.lang.nullpointerexception 02-07 21:10:12.780: e/androidruntime(719): @ android.app.activitythread.performlaunchactivity(activitythread.java:1569) 02-07 21:10:12.780: e/androidruntime(719): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1663) 02-07 21:10:12.780: e/androidruntime(719): @ android.app.activitythread.access$1500(activitythread.java:117) 02-07 21:10:12.780: e/androidruntime(719): @ android.app.activitythread$h.handlemessage(activitythread.java:931) 02-07 21:10:12.780: e/androidruntime(719): @ android.os.handler.dispatchmessage(handler.java:99) 02-07 21:10:12.780: e/androidruntime(719): @ android.os.looper.loop(looper.java:123) 02-07 21:10:12.780: e/androidruntime(719): @ android.app.activitythread.main(activitythread.java:3683) 02-07 21:10:12.780: e/androidruntime(719): @ java.lang.reflect.method.invokenative(native method) 02-07 21:10:12.780: e/androidruntime(719): @ java.lang.reflect.method.invoke(method.java:507) 02-07 21:10:12.780: e/androidruntime(719): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 02-07 21:10:12.780: e/androidruntime(719): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 02-07 21:10:12.780: e/androidruntime(719): @ dalvik.system.nativestart.main(native method) 02-07 21:10:12.780: e/androidruntime(719): caused by: java.lang.nullpointerexception 02-07 21:10:12.780: e/androidruntime(719): @ android.app.activity.findviewbyid(activity.java:1647) 02-07 21:10:12.780: e/androidruntime(719): @ com.indianic.demo.calendark.calendaractivity.<init>(calendaractivity.java:44) 02-07 21:10:12.780: e/androidruntime(719): @ java.lang.class.newinstanceimpl(native method) 02-07 21:10:12.780: e/androidruntime(719): @ java.lang.class.newinstance(class.java:1409) 02-07 21:10:12.780: e/androidruntime(719): @ android.app.instrumentation.newactivity(instrumentation.java:1021) 02-07 21:10:12.780: e/androidruntime(719): @ android.app.activitythread.performlaunchactivity(activitythread.java:1561) 02-07 21:10:12.780: e/androidruntime(719): ... 11 more 02-07 21:10:18.061: i/process(719): sending signal. pid: 719 sig: 9

i used initcomponent() method before setting setonitemclicklistener()

the forcefulness close error gone , app opens normally,

but next activity not opening or nil happens.when click on items. :(

as said tried different cases,still no success

public void onitemclick(adapterview<?> parent, view v3, int position, long id) { //setcontentview(r.layout.abc); switch (position) { case 0: intent myintent = new intent(getapplicationcontext(),abc.class); startactivity(myintent); break; case 1: intent myintent1 = new intent(getapplicationcontext(),abc.class); startactivity(myintent1); break; case 2: intent myintent2 = new intent(getapplicationcontext(),abc.class); startactivity(myintent2); break; case 3: intent myintent3 = new intent(getapplicationcontext(),abc.class); startactivity(myintent3); break; case 4: intent myintent4 = new intent(getapplicationcontext(),abc.class); startactivity(myintent4); break; case 5: intent myintent5 = new intent(getapplicationcontext(),abc.class); startactivity(myintent5); break; case 6: intent myintent6 = new intent(getapplicationcontext(),abc.class); startactivity(myintent6); break; default: break; } } });

you need phone call custom initcomponent() method before setting setonitemclicklistener()

public class cactivity extends activity { gridview gridview; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.cactivity); initcomponent(); gridview.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view v, int position, long id) { switch (position) { case 0://do same remaining items intent myintent = new intent(getapplicationcontext(), abc.class); startactivity(myintent); break; default: break; } } //finish(); } }); } private void initcomponent() { gridview = (gridview) findviewbyid(r.id.month_gridview); }

java android

android - Ext.device.Connection.isOnline() and Ext.browser.is.WebView not working on Sencha Touch 2.0.1 -



android - Ext.device.Connection.isOnline() and Ext.browser.is.WebView not working on Sencha Touch 2.0.1 -

i working on android app sencha touch, ext.device.connection.gettype() returning unknown me. have found work around navigator.online function (from determine if net connection available). little alarmed basic functionality not working documented (http://docs.sencha.com/touch/2-0/#!/api/ext.device.connection). looking source code (http://docs.sencha.com/touch/2-0/source/connection2.html#ext-device-connection) saw connection constructor checks ext.browser.is.webview , got curious. running next line logs lot of seemingly wrong information:

for (prop in ext.browser.is) { console.log('ext.browser.is.' + prop + ': ' + ext.browser.is[prop]); }

for example:

ext.browser.is.safari: true ext.browser.is.webview: false ext.browser.is.webview: false

are these ext.browser.is properties wrong? seems ext.browser.is properties cause lot of other issues in app , connection.isonline symptom of deeper issue. there specific technique or code getting ext.device.connection.isonline() work?

if got 'ext.device.device' & 'ext.device.connection' in apps' requirements , next permissions in androidmanifest.xml:

<uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.read_phone_state" />

i using sencha touch 2.0.1 (with phonegap/cordova 2.2.0) & testing device samsung stratosphere (with android 2.3.6)

android cordova sencha-touch-2 cordova-2.0.0 android-2.3-gingerbread

Simulating 'access denied' for a file in C# / Windows -



Simulating 'access denied' for a file in C# / Windows -

i'm attempting write integration tests little c# routine, reads different files.

and, well, accidentally thought great have test, specifies behavior case when access file denied.

does know nice , simple way simulate in test sandbox?

i suspect emulated using directorysecurity, however, i'm not sure if it's possible correctly cases:

assume that, example, can strip access rules current user, running tests (and require uac / elevation).

i guess in case i'd lose ability restore these rights , dispose sandbox correctly after test finished (without diving stuff impersonation , access token manipulations).

i moles or other mock-based approach, i'm more interested in general solution (for example, reuse test native application).

what missing? simple way this?

you don't want acheive via security settings, instead, why not exclusive access file somewhere else?

using(file.open(path, filemode.open, fileaccess.readwrite, fileshare.none)) { //hold here maintain file locked }

c# windows file testing

c++ - Which threading model should be used to create a Feed Handler Or Adaptor -



c++ - Which threading model should be used to create a Feed Handler Or Adaptor -

hi experts out there :)

this first question here.

problem description :

i have write market info feed handler. going windows service, using 2 sockets.

socket : communication between subscribing applications , feed handler (feed handler accepting connection request , item request).

socket b : communication between feed handler , external market info provider, reuters/bloomberg.

in both cases request/response using same port.

note : volume of info coming external scheme low (external scheme send info has been subscribed for, @ point of time). later on may want scale it, providers throw data, , feed handler has filter out locally, based on subscription.

my questions :

what threading model should use? which i/o strategy should use? keeping in mind both cases, should create separate request/response thread?

edit 1: after reading few tutorials on winsock, i'm planning utilize event objects asynchronous behavior.

the point of concern here that, single thread should hear incoming client connections (accept them) , connect other server, in turn send/recv on 2 different ports.

thread 1) listening incoming connections. (continuous) 2) receiving subscribe/unsubscribe request connected clients. (rarely) 3) connect external server (onetime only). 4) forwards request coming client external server. (rarely) 5) receive info external server. (continuous) 6) send info connected clients. (continuous)

my question can single thread deed both client , server, using asynchronous i/o models?

thanks in advance. deepak

the easiest threading model seems single threaded synchronous. if need implement filter provider, implement socket-in/socket-out separate process.

c++ asynchronous winsock feeds adaptor

php - Doctrine generates 300+ queries, how can I avoid that? -



php - Doctrine generates 300+ queries, how can I avoid that? -

i'd understand little problem on symfony's project.

the database simple :

article

--id --name

tarif

--id --idarticle --seuil (threshold) --prix (price) --devise (currency)

i want select article have cost in euro query :

doctrine_query::create()->from('article') ->innerjoin('article.tarif tarif') ->where('tarif.devise = ?', '0') ->execute();

but in debug page have more 300 query, main query :

select a.id a__id, a.lot a__lot, a.ref a__ref, a.reflama a__reflama, a.refoem a__refoem, a.designation a__designation, a.idfamille a__idfamille, a.idcategorie a__idcategorie, a.couleur a__couleur, a.contenance a__contenance, a.poids a__poids, a.nbpages a__nbpages, a.etat a__etat, a.pack a__pack, a.pcb a__pcb, t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise article inner bring together tarif t on a.id = t.idarticle (t.devise = '0')

and lot of other :

select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '2') 0.00s, "doctrine" connection select t.id t__id, t.idarticle t__idarticle, t.seuil t__seuil, t.prix t__prix, t.devise t__devise tarif t (t.idarticle = '3') 0.00s, "doctrine" connection

how can remove useless query ?

php mysql doctrine symfony-1.4

prolog - Incomplete to difference lists -



prolog - Incomplete to difference lists -

i want convert incomplete lists difference lists , vice versa.

this code convert regular list difference:

reg2diff(l,x-y):-append(l,y,x).

how go other direction?

incomplete difference list:

inc2diff(l,z):- ( nonvar(l) -> ( l=[_|t] -> inc2diff(t,z) ; l=[] -> z=[] ) ; l=z ).

use as

23 ?- l=[1,2,3|_],inc2diff(l,x). l = [1, 2, 3|x]. 24 ?- l=[1,2,3|z],inc2diff(l,x). l = [1, 2, 3|x], z = x. 25 ?- l=[1,2,3],inc2diff(l,x). l = [1, 2, 3], x = [].

prolog difference-lists

Pass php variables to external javascript -



Pass php variables to external javascript -

this question has reply here:

how pass variables , info php javascript? 13 answers

how can pass php variables external javascript file? found lot of questions regarding can't figure out anyhow.

in html file have link

<script type="text/javascript" src="myscript.php"></script>

this myscript.php file have been trying output javascript file:

<? header("content-type: text/javascript"); ?> $(document).ready(function() { $("#validate_form").validate({ rules: { page_title: "required", seo_url: "required" }, messages: { page_title: "<?=$page_title?>", seo_url: "<?=$seo_url?>" } }); });

append them using query string:

<script type="text/javascript" src="myscript.php?page_title=whatever&seo_url=whatever"></script> <? header("content-type: text/javascript"); ?> $(document).ready(function() { $("#validate_form").validate({ rules: { page_title: "required", seo_url: "required" }, messages: { page_title: "<?=$_get['page_title'];?>", seo_url: "<?=$_get['seo_url'];?>" } }); });

php javascript

android - Action bar tabs - how to retrieve value from fragments in Activity? -



android - Action bar tabs - how to retrieve value from fragments in Activity? -

i've settings activity, has 3 tabs (each tab contains fragment) + in main activity there buttons row - buttons ok, , cancel.when press ok, this:

1) custom variables fragments 2) save them shared prefs

but how access fragment variables? tried this:

adding tabs in main activity:

actionbar.tab tab1 = actionbar.newtab().settext(res.getstring(r.string.actsettingstab1)); tab1.settablistener(new mytabslistener(new tab1fragment(), "tab1")); actionbar.addtab(tab1); //...similar tabs

this tab listener:

class mytabslistener implements actionbar.tablistener { private fragment fragment; private string tag; public mytabslistener(fragment fragment, string tag) { this.fragment = fragment; this.tag = tag; } @override public void ontabreselected(tab tab, fragmenttransaction ft) { // nil } @override public void ontabselected(tab tab, fragmenttransaction ft) { ft.replace(r.id.fragment_container, fragment, tag); } @override public void ontabunselected(tab tab, fragmenttransaction ft) { ft.remove(fragment); } }

and how variables fragments:

tab1fragment tab1 = (tab1fragment) fm.findfragmentbytag("tab1"); tab2fragment tab2 = (tab1fragment) fm.findfragmentbytag("tab2"); tab3fragment tab3 = (tab1fragment) fm.findfragmentbytag("tab3");

but it's unusual - findfragmentbytag returns fragment selected tab, otherwise returns null. when have selected tab1 , press ok, findfragmentbytag homecoming fragment tab1, null others.

maybe i'm doing wrong, or whole tring goind wrong way. how retrieve values fragments in parent activity , save them shared preferences?

separate process 2 steps:

1) gather settings fragments in real time (i.e. changed user). utilize listener pattern, fragments expose interface notify attached listener when user modifies of settings given fragment responsible for. allow activity attach listener fragments, , capture changes (store them in construction suits you).

2) allow activity save settings using sharedpreferences when ok button clicked. not have access fragments settings user has changed.

this way not have access fragments @ once, impossible if removed memory (as not visible anyway @ given time). instead, can re-assign activity listener selected fragment every time gets selected/displayed.

android android-fragments android-actionbar

javascript - Why does storing a reference to a function then calling the function cause 'this' to have a context of window? -



javascript - Why does storing a reference to a function then calling the function cause 'this' to have a context of window? -

i reading tutorial @ can understand _.bind , _bindall: http://blog.bigbinary.com/2011/08/18/understanding-bind-and-bindall-in-backbone.html

the website has next code

function developer(skill) { this.skill = skill; this.says = function(){ alert(this.skill + ' rocks!'); } } var john = new developer('ruby'); john.says(); //ruby rocks!

vs

function developer(skill) { this.skill = skill; this.says = function(){ alert(this.skill + ' rocks!'); } } var john = new developer('ruby'); var func = john.says; func();// undefined rocks!

why storing reference function calling function cause have context of window?

when execute

a.b();

then a context of execution of b (this within b) unless b bound function.

if don't have a, if have

b();

then it's same as

window.b();

so window context of execution of b.

note that

a.b();

is same as

b.call(a);

and

b();

is same as

b.call(); // phone call replaces first argument global object if it's null or undefined

if want bind context, can (on modern browsers)

var func = john.says.bind(john); func();

or (more classically) utilize closure :

var func = function(){john.says()}; func();

javascript

How can I add \ symbol to the end of string in C# -



How can I add \ symbol to the end of string in C# -

please forgive me beginner's question :)

string s="abc"; s+="\";

won't complile.

string s="abc"; s+="\\";

will create s="abc\\"

how can create s="abc\" ?

your sec piece of code is want (or verbatim string literal @"\" others have suggested), , adds single backslash - print console , you'll see that.

these 2 pieces of code:

s += "\\";

and

s += @"\";

are exactly equivalent. in both cases, single backslash appended1.

i suspect you're getting confused debugger view, escapes backslashes (and other characters). can validate debugger looking @ s.length, you'll see 4 rather 5.

1 note doesn't alter info in existing string, sets value of s refer new string consists of original backslash on end. string objects in .net immutable - that's whole other topic...

c# string escaping

java - Using map to cache the data from the sql ( with <= timestamp col in it ) -



java - Using map to cache the data from the sql ( with <= timestamp col in it ) -

i set info next sql in map( because sql called many times , instead of going db everytime ), wondering how implement <= timestamp

edit:

i using oracle, updated tags, however, using preparedstatement in java caches queries, without beingness recompiled, our programme doesn't have cache solution cache info table. going db , getting info taking 2 ms roundtrip, getting info hashmap take nano second. query beingness executed around 20,000 times , load info , set within hashmap.

end of edit.

select ar table1 fk_col1 = ? , timestamp_col <= ? order date desc

the way did follows: not sure, timestamp_col in equals , hashcode right. suggest modifications?

public class table1key { private string fk_col1; private java.sql.timestamp timestamp_col; //setters , getters here. //implementing hashcode , equals. @override public int hashcode() { final int prime = 31; int result = 1; result = prime * result + ((fk_col1 == null) ? 0 : fk_col1.hashcode()); result = prime * result + ((timestamp_col == null) ? 0 : timestamp_col.hashcode()); homecoming result; } @override public boolean equals(object obj) { if (this == obj) homecoming true; if (obj == null) homecoming false; if (getclass() != obj.getclass()) homecoming false; table1key other = (table1key) obj; if (fk_col1 == null) { if (other.fk_col1 != null) homecoming false; } else if (!fk_col1.equals(other.fk_col1)) homecoming false; if (timestamp_col == null) { if (other.timestamp_col != null) homecoming false; } else if (!timestamp_col.equals(other.timestamp_col)) homecoming false; homecoming true; } }

...

private map<table1key, string> map = functions.gethashmapinstance(); public class functions { ... public static <k,v> hashmap<k,v> gethashmapinstance() { homecoming new hashmap<k,v>(); } }

so, populate map following:

private void populatemap() throws sqlexception { seek { ps = conn.preparestatement(table1sql); ps.setfetchsize(20000); resultset rs = ps.executequery(); while(rs.next()) { table1key rdk = new table1key(); string ar = rs.getstring(1); rdk.setfk_col1(rs.getstring(2)); rdk.settimestampcol(rs.gettimestamp(3)); if(actualratemap.get(rdk) == null) { actualratemap.put(rdk, ar); } } } grab (sqlexception e) { e.printstacktrace(); throw e; } { ps.close(); } }

//set key here.

table1key tk = new table1key(); tk.setfk_col1(col1); tk.settimestampcol(timestamp); string ar = actualratemap.get(tk);

//my main concern here .. work if sql has timestamp_col = ?, if timestamp_col < nowadays in map?

if(actualrate != null) { logger.info("actual rate:"+actualrate); }

hashmap doesn't job case, rather treemap can help.

a): rangemap solution

guava rangemap designed handle such case:

//initial rangemap final rangemap<java.sql.timestamp, string> cache = treerangemap.create(); ... string value = cache.get(thistimestamp); if(value == null){ string queryfromdb = ...;//query db cache.put(range.atmost(thistimestamp), queryfromdb); value = queryfromdb; }

of course, 'fk_coll' problem. define map<string/*fk_coll*/, rangemap<java.sql.timestamp, string>> handle case.

b): treemap solution

final treemap<java.sql.timestamp, string> cache = new treemap<>(); ... //get to the lowest degree key greater or equal 'thistimestamp' map.entry<java.sql.timestamp, string> entry = cache.ceilingentry(thistimestamp); if(entry == null){ string queryfromdb = ...;//query db cache.put(thistimestamp, queryfromdb); value = queryfromdb; } else { value = entry.getvalue(); }

and

hashmap<string/*fk_coll*/, treemap<java.sql.timestamp, string>>

handles 'fk_coll'.

plus: evict problem in cache case.

java sql caching collections oracle10g

Android showing database in SwipeView -



Android showing database in SwipeView -

i have swipeview 2 different views(fragments) via viewpager. want these 2 pages show different info sqllite database. problem cant figure out how this, main activity not able access views (tablelayout) on fragments , fragments sourcecode cant access database because adapter wont open (context of adapter super.getactivity()). there way this?

code of fragment:

dbadapter adapter = new dbadapter(getactivity()); @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // todo auto-generated method stub if(container==null){ homecoming null; } layout=(relativelayout)inflater.inflate(r.layout.layout_morning, container, false); adapter.open(); adapter.close();

code of dbadapter:

private static string db_name = "database.dat"; private final context context; private databasehelper dbhelper; private sqlitedatabase db; public dbadapter(context ctx) { this.context = ctx; dbhelper = new databasehelper(context); } private static class databasehelper extends sqliteopenhelper { databasehelper(context context) { super(context, db_name, null, 1); } @override public void oncreate(sqlitedatabase db) { } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { } } public dbadapter open() throws sqlexception { db = dbhelper.getwritabledatabase(); homecoming this; } public void close() { if (db!=null){ db.close(); } dbhelper.close(); }

error nullpointerexception

of course of study can access database within fragment, need utilize getactivity(); instead of this.

example save image file within fragment class:

db = new databasehandler(getactivity()); bytearrayoutputstream stream = new bytearrayoutputstream(); photo.compress(bitmap.compressformat.jpeg, 100, stream); byte[] imageinbyte = stream.tobytearray(); db.updateuser(imageinbyte); db.close();

android android-fragments android-viewpager android-sqlite android-context

java - Android: Camera preview doesn't look nice -



java - Android: Camera preview doesn't look nice -

i've written photographic camera app (activity) takes picture, preview shows live image of photographic camera doesn't nice, it's bit tall, :

here code photographic camera preview :

public class camerapreview extends surfaceview implements surfaceholder.callback { private surfaceholder mholder ; private photographic camera mcamera; public camerapreview(context context , photographic camera camera) { super(context) ; mcamera = photographic camera ; mholder = getholder(); mholder.addcallback(this); mholder.settype(surfaceholder.surface_type_push_buffers); } public void surfacecreated(surfaceholder holder) { seek { mcamera.setpreviewdisplay(holder); mcamera.startpreview(); } catch(ioexception e) { log.d(tag,"camera preview failed!: "+e.getmessage()); } } public void surfacechanged(surfaceholder holder , int m , int n , int w) { } public void surfacedestroyed(surfaceholder holder) { } } <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <framelayout android:id="@+id/camera_preview" android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="0.86" /> <button android:id="@+id/button_capture" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="16dp" android:gravity="center" android:onclick="capture" android:text="capture" /> <button android:id="@+id/button_accept" android:layout_width="115dp" android:layout_height="wrap_content" android:text="accept" android:visibility="gone" android:onclick = "accept" /> <button android:id="@+id/button_retake" android:layout_width="107dp" android:layout_height="wrap_content" android:text="retake" android:visibility="gone" android:onclick = "retake"/> </linearlayout>

public class iqcameraview extends viewgroup implements surfaceholder.callback { public static final int camera_error = 0; public static final int camera_result = 1; private final string tag = "preview"; private surfaceview msurfaceview; private surfaceholder mholder; private size mpreviewsize; private list<size> msupportedpreviewsizes; private photographic camera mcamera; private boolean mcameraactive; private iqcameracallback mcallback; /** * @param mcallback * of type iqcameracallback * @return of type null setter function mcallback * @since 10 oct 2012 */ public void setmcallback(iqcameracallback mcallback) { this.mcallback = mcallback; } /** * @param context * of type context * @return of type boolean function check scheme has photographic camera * or not * @since 10 oct 2012 */ public static boolean checkcamerahardware(context context) { if (context.getpackagemanager().hassystemfeature( packagemanager.feature_camera)) { homecoming true; } else { homecoming false; } } /** * @param context * constructor function * @since 16 oct 2012 */ public iqcameraview(context context) { super(context); msurfaceview = new surfaceview(context); addview(msurfaceview); mholder = msurfaceview.getholder(); mholder.addcallback(this); mholder.settype(surfaceholder.surface_type_push_buffers); } /** * @param photographic camera * of type photographic camera * @return of type null setter function mcamera * @since 16 oct 2012 */ public void setcamera(camera camera) { mcamera = camera; if (mcamera != null) { msupportedpreviewsizes = mcamera.getparameters() .getsupportedpreviewsizes(); requestlayout(); } } /** * @param of * type null * @return of type null function current frame * photographic camera * @since 16 oct 2012 */ public void takepicture() { if (null != mcamera && mcameraactive) { mcamera.takepicture(null, null, new iqphotohandler(getcontext(), this)); } } /** * @param result * of type string * @return of type null function called when image save * finish * @since 16 oct 2012 */ public void onimagecapture(final string result) { if (null != mcallback) { mcallback.oncameracallback(camera_result, result); } mcamera.startpreview(); } /* * (non-javadoc) * * @see android.view.view#onmeasure(int, int) * * @since 16 oct 2012 */ @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { // purposely disregard kid measurements because deed // wrapper surfaceview centers photographic camera preview instead of // stretching it. final int width = resolvesize(getsuggestedminimumwidth(), widthmeasurespec); final int height = resolvesize(getsuggestedminimumheight(), heightmeasurespec); setmeasureddimension(width, height); if (msupportedpreviewsizes != null) { mpreviewsize = getpreviewsize(msupportedpreviewsizes, width, height); } } /* * (non-javadoc) * * @see android.view.viewgroup#onlayout(boolean, int, int, int, int) * * @since 16 oct 2012 */ @override protected void onlayout(boolean changed, int l, int t, int r, int b) { if (changed && getchildcount() > 0) { final view kid = getchildat(0); final int width = r - l; final int height = b - t; int previewwidth = width; int previewheight = height; // center kid surfaceview within parent. if (width * previewheight > height * previewwidth) { final int scaledchildwidth = previewwidth * height / previewheight; child.layout((width - scaledchildwidth) / 2, 0, (width + scaledchildwidth) / 2, height); } else { final int scaledchildheight = previewheight * width / previewwidth; child.layout(0, (height - scaledchildheight) / 2, width, (height + scaledchildheight) / 2); } } } /** * @param of * type null * @return of type null function release teh photographic camera * @since 16 oct 2012 */ public void releasecamera() { if (null != mcamera && mcameraactive) { mcamera.stoppreview(); mcamera.release(); mcamera = null; } mcameraactive = false; } /* * (non-javadoc) * * @see * android.view.surfaceholder.callback#surfacecreated(android.view.surfaceholder * ) * * @since 16 oct 2012 */ public void surfacecreated(surfaceholder holder) { seek { if (mcamera != null) { mcamera.setpreviewdisplay(holder); } } grab (ioexception e) { log.e(tag, "ioexception caused setpreviewdisplay()", e); } } /* * (non-javadoc) * * @see android.view.surfaceholder.callback#surfacedestroyed(android.view. * surfaceholder) * * @since 16 oct 2012 */ public void surfacedestroyed(surfaceholder holder) { releasecamera(); } /* * (non-javadoc) * * @see * android.view.surfaceholder.callback#surfacechanged(android.view.surfaceholder * , int, int, int) * * @since 16 oct 2012 */ public void surfacechanged(surfaceholder holder, int format, int w, int h) { camera.parameters parameters = mcamera.getparameters(); parameters.setpreviewsize(mpreviewsize.width, mpreviewsize.height); parameters.setpicturesize(mpreviewsize.width, mpreviewsize.height); parameters.setpictureformat(pixelformat.jpeg); mcamera.setdisplayorientation(90); requestlayout(); seek { mcamera.setparameters(parameters); } grab (exception e) { system.out.print("hih"); } mcamera.startpreview(); mcameraactive = true; } /** * @param sizes * of type list * @param w * of type int * @param h * of type int * @return optionalsize of type size function find exact size * required teh photographic camera view * @since 16 oct 2012 */ private size getpreviewsize(list<size> sizes, int w, int h) { final double aspect_tolerance = 0.1; double targetratio = (double) w / h; if (sizes == null) homecoming null; size optimalsize = null; double mindiff = double.max_value; int targetheight = h; (size size : sizes) { double ratio = (double) size.width / size.height; if (math.abs(ratio - targetratio) > aspect_tolerance) continue; if (math.abs(size.height - targetheight) < mindiff) { optimalsize = size; mindiff = math.abs(size.height - targetheight); } } // cannot find 1 match aspect ratio, ignore requirement if (optimalsize == null) { mindiff = double.max_value; (size size : sizes) { if (math.abs(size.height - targetheight) < mindiff) { optimalsize = size; mindiff = math.abs(size.height - targetheight); } } } homecoming optimalsize; } /** * @author rajeshcp * @since 16 oct 2012 */ public static interface iqcameracallback { public void oncameracallback(final int type, final object param); } }

try code have used project, hope help

java android camera

.htaccess - htaccess seo friendly urls for all subfolders -



.htaccess - htaccess seo friendly urls for all subfolders -

i have script in index.php in folders

need create pretty url/seo friendly urls this: site.com/folder1/something.html

now have ugly urls this: site.com/folder1/index.php?category=something

this part index.php?category=something same in subfolders, want alter more seo friendly something.html

once again: find index.php?category=1$ , replace 1$.html not touch else, part of url

so when visit:

site.com/another-subfolder/and-one-more-folder-here/index.php?category=something

need see in address bar:

site.com/another-subfolder/and-one-more-folder-here/something.html

i hope it?

i tried folder1 in htaccess in root

rewriterule ^folder1/(.*).html$ folder1/index.php?category=$1 [l,r=301]

ok works, how can create work subfolders accross site this:

site.com/folder145/index.php?category=something site.com/subfolder/index.php?category=something site.com/another-subfolder/and-one-more-folder-here/index.php?category=something

there 1000s of subfolders different names manually making rewriterule each subfolder won't work

any help appreciated

first, need alter links generate index.php?category= form category.html form.

then in htaccess file in document root, add together these rules internally rewrite category.html form index.php?category= form:

rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.+?/)?([^/]+)\.html$ /$1index.php?category=$2 [l]

then, point links don't have command on (or ones generated using form) externally redirect direct access links in index.php?category= form:

rewritecond %{the_request} ^(get|head)\ (/.*?)?/index\.php\?category=([^&\ ]+) rewriterule ^(.+?/)?index\.php$ /$1%3.html? [l,r=301]

this should match , every subdirectory.

.htaccess

c# - Showing a +255 byte in a byte[] -



c# - Showing a +255 byte in a byte[] -

i hope can help me.

i have single byte[] has show amount of bytes in die byte[] follow. value above 255. there way display/enter big number?

a byte holds value 0 255. represent 299, either have utilize 2 bytes, or utilize scheme (which receiver have utilize well) value in byte interpreted more nominal value in order expand possible range of values. instance, value length / 2. allow lengths of 0 - 510, allow lengths (odd length arrays need pad byte).

c# bytearray byte

How to get validation error value(=inputed value, but not in model) angularjs way -



How to get validation error value(=inputed value, but not in model) angularjs way -

i’m trying user.name.length value @ error message. if jquery used, realizable, isn't there method unique angularjs?

<form novalidate name="myform" ng-submit="adduser()"> <p>name: <input type="text" name="name" ng-model="user.name" required ng-minlength="5" ng-maxlength="8"> <span ng-show="myform.name.$error.minlength">{{user.name.length}} short!</span>

can seek {{myform.name.$viewvalue.length}}, below:

<input type="text" name="name" ng-model="user.name" ng-minlength="5" ng-maxlength="8" /> <span ng-show="myform.name.$error.minlength">{{myform.name.$viewvalue.length}} short!</span> <span ng-show="myform.name.$error.maxlength">{{myform.name.$viewvalue.length}} long!</span>

angularjs

delete tr element in jquery -



delete tr element in jquery -

i have table of tr elements in click on delete each row, deletes table. html below

<tr class="tr_body"> <td> <input type="text" class="fabric_input createwoblockbg little ui-autocomplete-input" name="basefabrics[]" onfocus ="loaduniqueajax(' . "'fabric_input'" . ')" autocomplete="off"> </td> <td> <input type="text" class="fac_input createwoblockbg little ui-autocomplete-input" name="facsnapshots[]" id="facsnapshot" autocomplete="off"> </td> <td> <a class ="deleterow">delete</a> </td> </tr>

and jquery below

$('.deleterow').click(function(){ var elementdelete = $(this).parent().parent(); $('#tablelist').remove(elementdelete); });

however returns uncaught typeerror: object [object object] has no method 'replace' when click on deleterow anchor tag. in advance help.

working illustration on js bin.

$('.deleterow').click(function() { $(this).closest("tr") .remove(); });

jquery

Qt debugging: viewing vectors? -



Qt debugging: viewing vectors? -

does have tips viewing vectors when debugging qt creator? i've built debugger helper, can see start , end nodes. (i imagine true other stl containers well.)

it's drag on debugging time; know of fix? thanks.

qt debugging vector clang

Create a two dimensional javascript array from PHP array -



Create a two dimensional javascript array from PHP array -

how create php array:

array(12) { [0]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "8" ["name"]=> string(10) "accounting" ["main_category_id"]=> string(1) "1" } } [1]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "1" ["name"]=> string(17) "applications" ["main_category_id"]=> string(1) "2" } } [2]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "2" ["name"]=> string(19) "benefit claims" ["main_category_id"]=> string(1) "2" } } [3]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "3" ["name"]=> string(22) "evaluations" ["main_category_id"]=> string(1) "2" } } [4]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "4" ["name"]=> string(11) "leave forms" ["main_category_id"]=> string(1) "2" } } [5]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "5" ["name"]=> string(13) "payroll" ["main_category_id"]=> string(1) "2" } } [6]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "6" ["name"]=> string(17) "recruitment" ["main_category_id"]=> string(1) "2" } } [7]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "7" ["name"]=> string(24) "training" ["main_category_id"]=> string(1) "2" } } [8]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(1) "9" ["name"]=> string(13) "staff" ["main_category_id"]=> string(1) "2" } } [9]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(2) "10" ["name"]=> string(14) "codes" ["main_category_id"]=> string(2) "3" } } [10]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(2) "11" ["name"]=> string(28) "reports" ["main_category_id"]=> string(2) "3" } [11]=> array(1) { ["subcategory"]=> array(3) { ["id"]=> string(2) "12" ["name"]=> string(14) "plan" ["main_category_id"]=> string(2) "4" } } }

look in javascript:

var subcat[ ["accounting"], ["applications","benefit claims","evaluations","leave forms","payroll","recruitment","training","staff"], ["codes","reports"], ["plan"] ];

i tried couple of different php:

<?php $jsarray = array(); foreach($data $row) { $jsarray[] = array($row['subcategory']['name']); } echo json_encode($jsarray); ?>

also tried this:

<?php echo "["; foreach($data $row){ foreach($row $subcat) { echo "\"" . $subcat['name'] . "\","; } }echo "]"; ?>

what doing wrong?

like said above, pretty close json_encode example. need introduce sec dimension under main_category_id.

<?php $data = array( array("subcategory"=> array("id"=>"8", "name"=>"accounting","main_category_id"=>"1")), array("subcategory"=> array("id"=>"1", "name"=>"applications","main_category_id"=>"2")), array("subcategory"=> array("id"=>"2", "name"=>"benefit claims","main_category_id"=>"2")), array("subcategory"=> array("id"=>"3", "name"=>"evaluations","main_category_id"=>"2")), array("subcategory"=> array("id"=>"4", "name"=>"leave forms","main_category_id"=>"2")), array("subcategory"=> array("id"=>"5", "name"=>"payroll","main_category_id"=>"2")), array("subcategory"=> array("id"=>"6", "name"=>"recruitment","main_category_id"=>"2")), array("subcategory"=> array("id"=>"7", "name"=>"training","main_category_id"=>"2")), array("subcategory"=> array("id"=>"9", "name"=>"staff","main_category_id"=>"2")), array("subcategory"=> array("id"=>"10", "name"=>"codes","main_category_id"=>"3")), array("subcategory"=> array("id"=>"11", "name"=>"reports","main_category_id"=>"3")), array("subcategory"=> array("id"=>"12", "name"=>"plan","main_category_id"=>"4")), ); $selected = 7; $js = array(); foreach($data $sub){ //get parent id (main_category_id) $parent = $sub['subcategory']['main_category_id']; //if parent doesn't exist, add together if(!isset($js[$parent])){ //add array name , id $js[$parent] = array(array('id'=>$sub['subcategory']['id'],'name'=>$sub['subcategory']['name'])); //parent exist } else { //append entry name , id $js[$parent][] = array('id'=>$sub['subcategory']['id'],'name'=>$sub['subcategory']['name']); } } echo json_encode($js);

working: http://codepad.viper-7.com/nox9bt

here modified jsfiddle working output php above: http://jsfiddle.net/wprld/5/

php javascript arrays

javascript - How to get the data value of 'SVG path'? -



javascript - How to get the data value of 'SVG path'? -

i want extract info d="m75.5 299.5 111.5 299.5 111.5 311.5 75.5 311.5 z" utilize in creation of element.

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="670px" height="400px" style="position: relative; display: block; background-color: red;"> <g> <path id="k19a56d40" data-model-id="k33d3f3bd" d="m75.5 299.5 111.5 299.5 111.5 311.5 75.5 311.5 z" stroke="#cc2900" stroke-width="1" stroke-linecap="square" stroke-linejoin="round" fill-opacity="1" stroke-opacity="1" fill="#ff3300"></path> <path id="k67a7e77a" data-model-id="k33d3f3bd" d="m75.5 299.5 111.5 299.5 111.5 311.5 75.5 311.5 z" stroke="#cc2900" stroke-width="1" stroke-linecap="square" stroke-linejoin="round" fill-opacity="1" stroke-opacity="1" fill="url(#kcd2b6a0)"></path> </g> </svg>

try this:

$('svg').find('path').attr('d');

find first 1 using .eq() , .first():

$('svg').find('path').first().attr('d'); $('svg').find('path').eq(0).attr('d'); // <--change index of selection

.last() can used if have 2 paths.

javascript jquery html svg

php - How does one interpret Xdebug computerized trace output? -



php - How does one interpret Xdebug computerized trace output? -

xdebug outputs computerized output in next form:

5 33 0 0.003569 193040 function_exists 0 e:\dropbox\websites\flyingpiranhas\wireframework\vendor\swiftmailer\swiftmailer\lib\swift_required.php 24 1 '_swiftmailer_init' 5 33 1 0.003609 193040 5 34 0 0.003620 193008 swift::registerautoload 1 e:\dropbox\websites\flyingpiranhas\wireframework\vendor\swiftmailer\swiftmailer\lib\swift_required.php 32 1 $callable = '_swiftmailer_init' 6 35 0 0.003661 193472 spl_autoload_register 0 e:\dropbox\websites\flyingpiranhas\wireframework\vendor\swiftmailer\swiftmailer\lib\classes\swift.php 79 1 array (0 => 'swift', 1 => 'autoload') 6 35 1 0.003712 193560 5 34 1 0.003728 193240

as can see, function id 33 entered stack, exited, normal. @ 34. function phone call 34 enters stack, 35 runs , executes, , 34's exit printed.

what i'm wondering is, how interpret this? mean function 34 lasted 108 miliseconds (until lastly line) , waited 35 finish, or should @ 41ms duration, is, until function 35 started? related "level"? if so, how?

you're correct, 34 waited 35 finish lasting 108 milliseconds.

php performance profiling xdebug php-extension

How to check if edge exists between two vertices of graph, in Python? -



How to check if edge exists between two vertices of graph, in Python? -

i have simple graph , want create method "get_edge" take 2 vertices arguments , homecoming border between them if exists, , none otherwise. here's snippet of i've tried. doesn't work because creates object instead of checking if there 1 in existence already. what's simplest way write get_edge()?

def add_edge(self, e): """adds , border graph adding entry in both directions. if there border connecting these vertices, new border replaces it. """ v, w = e self[v][w] = e self[w][v] = e def get_edge(self, v1, v2): try: edge(v1, v2) print 'edge exists' except: print 'edge not exist' homecoming none

i suspect want like:

def get_edge(self, v1, v2): try: e = self[v1][v2] # order shouldn't matter print("edge exists") homecoming e except keyerror: print("edge not exist") homecoming none

i'm assuming class derived dict or has __getitem__ method works , raise keyerror if inquire key doesn't exist. if don't need print statements (that is, they're debugging), can away e variable , homecoming result directly.

python graph

asp.net - onhashchange and backstack only working on localhost -



asp.net - onhashchange and backstack only working on localhost -

i using hash alter , onhashchange event in webpage. when testing locally (w/ asp.net development server), window.onhashchange event fires , hash changes pushed backstack. when website deployed server (iis 7.5), visiting same browser on same client machine, event doesn't fire , though can see hash changed in address bar, aren't pushed backstack , key leads previous page. there iis/asp.net config should tweak?

it turns out ie compatibility mode. problem solved answer: http://stackoverflow.com/a/5887271/986080.

asp.net web-config localhost

asp.net mvc 4 - Running System.Web.Razor 1.0 and 2.0 side by side? -



asp.net mvc 4 - Running System.Web.Razor 1.0 and 2.0 side by side? -

i'm trying deploy site hosting provider , maintain receiving next error:

could not load file or assembly 'system.web.razor' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)

[fileloadexception: not load file or assembly 'system.web.razor' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)]

[fileloadexception: not load file or assembly 'system.web.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)]

...

[configurationerrorsexception: not load file or assembly 'system.web.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)]

...

[httpexception (0x80004005): not load file or assembly 'system.web.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)]

...

the site built using asp.net 4 , mvc 4. works fine on development machine running windows 8. i've copied system.web.razor.dll bin folder on server doesn't create difference, though appears v1.0 versioned assembly (~260k).

i've looked in c:\windows\assembly , don't see in there system.web.razor. however, have next 2 files:

c:\windows\assembly\nativeimages_v4.0.30319_64\system.web.razor\04eb82505c0086e8eb097d1408183aa0\system.web.razor.ni.dll (776k, file version: 1.0.20105.407)

c:\windows\assembly\nativeimages_v4.0.30319_64\system.web.razor\ab032b45c588b488ebca535054d827bc\system.web.razor.ni.dll (1823k, file version: 2.0.20715.0)

however, copying v2 assembly here didn't work, though don't think right file anyway v1 assembly file sizes don't match either.

any ideas on going on here?

i'm guessing hosting provider doesn't have installed (as maintain telling me set in bin folder), i'm curious why can't find system.web.razor v2 dll anywhere.

to debug, uploaded empty website basic template worked fine. interestingly, when added reference postal , deployed again, got error - when reverted files back, error persisted! why happen?

any help appreciated. starting sense little out of ideas.

edit 1

created new empty project, added razor 2 nuget, set system.web.razor.dll re-create local (2.0.20715.0, 260k), published, grabbed file , uploaded it, , still same error? seems dll won't picked up.

edit 2

eventually gave trying utilize hosting provider in question. didn't have asp.net mvc 4 installed on server, think problem. tried different host have installed , works fine.

razor asp.net-mvc-4 hosting razor-2

jquery - Is it possible to add parallax scrolling effect to other pages? -



jquery - Is it possible to add parallax scrolling effect to other pages? -

normally parallax scrolling sites 1 page, , scrolls other pages. there way scroll other pages in same site using jquery , ajax?? index.html aboutus.html. possible that? or parallax scrolling work on 1 page websites?

thanks

jquery ajax

junit - Cannot instantiate class: org.apache.naming.java.javaURLContextFactory -



junit - Cannot instantiate class: org.apache.naming.java.javaURLContextFactory -

i'm working on junit test file loads sql file , loads oracle:

import java.io.bufferedreader; import java.io.file; import java.io.filereader; import java.sql.connection; import java.sql.sqlexception; import java.sql.statement; import javax.naming.context; import javax.naming.initialcontext; import javax.naming.namingexception; import javax.sql.datasource; import oracle.jdbc.pool.oracleconnectionpooldatasource; import org.junit.beforeclass; import org.junit.test; public class oraclecreatescheme1 { public oraclecreatescheme1() { } @beforeclass public static void setupclass() throws exception { // rcarver - setup jndi context , datasource seek { // create initial context system.setproperty(context.initial_context_factory, "org.apache.naming.java.javaurlcontextfactory"); system.setproperty(context.url_pkg_prefixes, "org.apache.naming"); initialcontext ic = new initialcontext(); ic.createsubcontext("java:"); ic.createsubcontext("java:/comp"); ic.createsubcontext("java:/comp/env"); ic.createsubcontext("java:/comp/env/jdbc"); // build datasource oracleconnectionpooldatasource ds = new oracleconnectionpooldatasource(); ds.seturl("jdbc:oracle:thin:@192.168.1.104:1521:oracle"); ds.setuser("admin"); ds.setpassword("qwerty"); ic.bind("java:/comp/env/jdbc/oracle", ds); } grab (namingexception ex) { //logger.getlogger(mydaotest.class.getname()).log(level.severe, null, ex); } } @test public void createoraclescheme() throws sqlexception, namingexception { context initcontext = new initialcontext(); context webcontext = (context) initcontext.lookup("java:/comp/env"); datasource ds = (datasource) webcontext.lookup("jdbc/oracle"); // read file ------------------------------------------------------------------ string s = new string(); stringbuffer sb = new stringbuffer(); seek { filereader fr = new filereader(new file("oraclescheme.sql")); bufferedreader br = new bufferedreader(fr); while ((s = br.readline()) != null) { sb.append(s); } br.close(); // here our splitter ! utilize ";" delimiter each request // sure have formed statements string[] inst = sb.tostring().split(";"); connection c = ds.getconnection(); statement st = c.createstatement(); (int = 0; < inst.length; i++) { // ensure there no spaces before or after request string // in order not execute empty statements if (!inst[i].trim().equals("")) { st.executeupdate(inst[i]); system.out.println(">>" + inst[i]); } } } grab (exception e) { system.out.println("*** error : " + e.tostring()); system.out.println("*** "); system.out.println("*** error : "); e.printstacktrace(); system.out.println("################################################"); system.out.println(sb.tostring()); } } }

when test file problem:

cannot instantiate class: org.apache.naming.java.javaurlcontextfactory

can tell me how can solve problem? , find problem java code?

i fixed adding libraries apache tomcat run-time test libraries.

in netbeans:

project properties -> libraries -> run tests add together jar/folder

the 2 libraries needed catalina.jar , tomcat-juli.jar. mileage may vary.

i found them under installation directory tomcat. e.g:

apache-tomcat-7.0.34/bin/tomcat-juli.jar apache-tomcat-7.0.34/lib/catalina.jar

note 1 of jars in bin directory, other in lib directory

this isn't best way prepare problem. improve have different way inject datasource.

java junit

c# - Expose Class properties to Visual Studio Properties window -



c# - Expose Class properties to Visual Studio Properties window -

i have visual studio extensions project vspackage extending microsoft.visualstudio.shell.package.

there class:

public class propertypageitem { private string _item1; private string _item2; public propertypageitem() { _item1 = "item1"; _item2 = "item2"; } [description("item1")] [category("item-field")] public string item1 { { homecoming _item1; } set { _item1 = value; } } [description("item2")] [category("item-field")] public string item2 { { homecoming _item2; } set { _item2 = value; } } }

the class above not dynamic (doesn't consider events etc), it's sake of understanding method.

how can link/expose class visual studio property window? it's same window can see file properties while browsing through solution explorer. objective utilize window , not create property grid control.

tried next instructions on link confused me further.

after little research figured out how it.

follow instructions in link

in step 6 of walkthrough, replace 'this' 'new propertypageitem()'

public override void ontoolwindowcreated() { arraylist listobjects = new arraylist(); listobjects.add(new propertypageitem()); selectlist(listobjects); }

following until step 7 on "exposing properties properties window" section, objective achieved , properties in propertypageitem class exposed onto visual studio propertywindow.

hope helpful.

c# visual-studio visual-studio-extensions visual-studio-sdk

iphone - UIScrollView PhotoViewer receives memory warning after 125 photos on iPod -



iphone - UIScrollView PhotoViewer receives memory warning after 125 photos on iPod -

i stuck in weird problem,tried find out solution possible sources no luck yet.

my requirement similar photoviewer app of iphone,but there more uploading image,downloading etc .so technically doing creating main scrollview,which has content size equal selected image size * image width .i have little view within equal no. of images selected picker .the view contains little scrollview,and image view allows user zoom,pinch etc , main scroll view has gesture listner allows swipe. access images storing asset url , image when user swipes left or right .at point in time keeping 1 image memory i.e if user swipe 2nd photo delete 1st photo main scrollview .

but still facing memory issues on ipod if selected 125 photos , swipe multiple times end , come .

sample code.:-

***//innerscrollview class contains view scroll , imageview //the values of initial , final counter diffrence of 1 creates 1 object** for(int j=initialcounter;j<finalcounter;j++) { innerscrollview *innerscrollviewobj=[[innerscrollview alloc] initwithframe:cgrectmake(320*j, 0, 320, 480) url:[selectedimagelist objectatindex:j] tag:self.initialimageviewcounter]; innerscrollviewobj.delegate=self; [mainscrollview addsubview:innerscrollviewobj]; [innerscrollviewobj release]; innerscrollviewobj=nil; } **//this main scrollview gets created once** mainscrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0,0 , 320, 480)]; mainscrollview.pagingenabled = yes; // mainscrollview.delegate=self; mainscrollview.showshorizontalscrollindicator = no; mainscrollview.showsverticalscrollindicator = no; mainscrollview.maximumzoomscale = 4.0; mainscrollview.minimumzoomscale = 1.0; mainscrollview.backgroundcolor=[uicolor blackcolor]; [mainscrollview setcancancelcontenttouches:no]; mainscrollview.clipstobounds = yes; mainscrollview.scrollenabled = false; mainscrollview.contentsize = cgsizemake(320*[selectedimagelist count], mainscrollview.bounds.size.height); [self.view addsubview:mainscrollview]; //this method gets called when swipe left , previous images gets deleted -(void)deletescrollviewformmainview:(nsnumber*)indextodelete{ @try{ nslog(@"scrollview deleted %@",[[mainscrollview subviews] objectatindex:0]); [[[mainscrollview subviews] objectatindex:0] removefromsuperview]; } @catch (nsexception *e) { nslog(@"scrollview view exception %@",[e description]); } } - (id)initwithframe:(cgrect)frame url :(alasset*) imageurl tag:(int)tag { self = [super initwithframe:frame]; if (self) { self.userinteractionenabled=yes; // self.tag=tag; uiimage *image = [uiimage imagewithcgimage:[[imageurl defaultrepresentation] fullresolutionimage ]]; uiimageview* imageview = [[uiimageview alloc] initwithimage:image]; imageview.tag = view_for_zoom_tag; imageview.frame=cgrectmake(0, 0, self.frame.size.width, self.frame.size.height); imageview.backgroundcolor=[uicolor clearcolor]; imageview.contentmode=uiviewcontentmodescaleaspectfit; uiscrollview* pagescrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0, 0, self.frame.size.width, self.frame.size.height)]; nslog(@"page scrollview %@",pagescrollview); pagescrollview.tag=tag; pagescrollview.minimumzoomscale = 0.4f; pagescrollview.maximumzoomscale = 2.0f; pagescrollview.zoomscale = 1.0f; pagescrollview.backgroundcolor=[uicolor clearcolor]; pagescrollview.delegate = self; pagescrollview.showshorizontalscrollindicator = no; pagescrollview.showsverticalscrollindicator = no; [pagescrollview setcancancelcontenttouches:no]; [self addsubview:pagescrollview]; [pagescrollview addsubview:imageview]; uitapgesturerecognizer *singletap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handlesingletap)]; singletap.numberoftapsrequired=1; singletap.delegate=self; [self addgesturerecognizer:singletap]; singletap=nil; uitapgesturerecognizer *doubletap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handledoubletap)]; doubletap.numberoftapsrequired=2; doubletap.delegate=self; [self addgesturerecognizer:doubletap]; singletap=nil; doubletap=nil; imageview=nil; pagescrollview=nil; } homecoming self; }

should create innerimageview class singelton class?will help,because think memory issues can because multiple objects getting created(though release properly).

please help guys.!! in advance.

can post definition of innerscrollview? problem delegate property retain, keeping innerscrollviewobj beingness deallocated.

so, assume have like:

@property (nonatomic, retain) id delegate;

which should be:

@property (nonatomic) id delegate;

or, if enable arc should be:

@property (nonatomic, weak) id delegate;

also, maintain in mind [mainscrollview subviews] holds views, not controllers. if deallocate controller not able respond events or command anything, , may errors due sending messages deallocated objects.

iphone objective-c uiscrollview memory-warning photoviewer