Posts

Showing posts from September, 2010

javascript - Twitter Bootstrap alert (notification) dynamically change text -

simple question, didn't succeed finding satisfactory answer on so. when have bootstrap alert: <div id='alert' class='alert alert-error hide'>alert.</div> i want text controlled using either javascript of jquery, looked @ solution this problem , have complicated? really? as simple as: $("#alert").text("my new text");

command line interface - MySQL Query with LARGE number of records gets Killed -

i run following query shell : mysql -h my-host.net -u myuser -p -e "select component_id, parent_component_id myschema.components comp inner join my_second_schema.component_parents related_comp on comp.id = related_comp.component_id order component_id;" > /tmp/it_component_parents.txt the query runs long time , gets killed. however if add limit 1000 , query runs till end , output written in file. i further investigated , found (using count(*)) total number of records returned 239553163. some information server here: mysql 5.5.27 +----------------------------+----------+ | variable_name | value | +----------------------------+----------+ | connect_timeout | 10 | | delayed_insert_timeout | 300 | | innodb_lock_wait_timeout | 50 | | innodb_rollback_on_timeout | off | | interactive_timeout | 28800 | | lock_wait_timeout | 31536000 | | net_read_ti...

c# - calling procedure from sql -

i coding winform application call procedure in datagrid. have method define parameters of procedure public int add_nastavenie(out int typnastav, int nastavid, string hod) { resetparameters(); cmd.commandtext = "add_nastav"; cmd.commandtype = commandtype.storedprocedure; sqlparameter sqlparameter; var sqlparameterout = new sqlparameter("@typnastav", sqldbtype.int); sqlparameterout.direction = parameterdirection.output; sqlparameter = new sqlparameter("@nastavenieid", sqldbtype.int); sqlparameter.direction = parameterdirection.input; sqlparameter.value = nastavid; cmd.parameters.add(sqlparameter); sqlparameter = new sqlparameter("@hodnota", sqldbtype.nvarchar, 100); sqlparameter.direction = parameterdirection.input; sqlparameter.value = hod; cmd.parameters.add(sqlparameter); var sqlparameterret = new sqlparameter(...

android - \n appears in string is not funcional -

when getstring of database: inf = c.getstring(5); //inf equals "hello how you?\nfine , you\ni fine, thanks."; when print appears in same way , not execute parameters "\ n": tv1.settext(inf); //the text "is hello how you?\nfine , you\ni fine, thanks." but want: "hello how you? fine , fine, thanks." what problem? the solution me: string finalinf = inf.replace("\\n", system.getproperty("line.separator")); tv1.settext(finalinf); thanks : skaard-solo , rest. i think can try string finalinf = inf.replace("\\n", system.getproperty("line.separator")); tv1.settext(finalinf); system.getproperty("line.separator")) is system replacement new line

javascript - Position of a vertical div on an horizontal div with database dates in Rails (timeline) -

i create kind of timeline (horizontal line: div) data coming database creation date. place kind of marker (vertical line) automatically on timeline date. the issue timeline div fix size (responsive size in %) when there new data on timeline, others has resize. , example, if have 3 dates: 2009 -2010 -2045 of course there more space between 2010 , 2045 2009 , 2010 ... do have advises / algorithm please? thanks advance if want place them scale, can like: totaltime = maxdate - mindate each date ypercentage = (maxdate - date) / totaltime this put first date @ start, last date @ end, , others in between, proportionally.

Php file image upload security -

$filename=$_files['file']['name']; $type=$_files['file']['type']; $extension=strtolower(substr($filename, strpos($filename, '.')+1)); $size=$_files['file']['size']; if(($extension=='jpg' || $extension=='jpeg') && ($type!='image/jpg' || $type!='image/jpeg')){... i have input file, can let user upload jpg/jpeg image only, have check type, extension, size. however i'm not sure how check if user change extension.(ex. abc.php -> abc.jpg) any thing else need check before save user's image server? you can check image exif_imagetype() http://www.php.net/manual/en/function.exif-imagetype.php exif_imagetype() reads first bytes of image , checks signature.

python - tk: do I need to mention the widget master? -

i want rearrange frames in panedwindows @ runtime based upon user request. specified master each frame (here pw1). ex: import tkinter tk root = tk.tk() pw1 = tk.panedwindow(orient=tk.horizontal, sashpad=2, sashwidth=4, sashrelief=tk.raised) pw1.pack(fill=tk.both, expand=1) frame1 = tk.frame(pw1, bg='red',width=100, height=100) frame2 = tk.frame(pw1, bg ='yellow',width=100,height=100) # seems same thing: # frame1 = tk.frame(bg='red',width=100, height=100) # vs. tk.frame() # frame2 = tk.frame(bg ='yellow',width=100,height=100) pw1.add(frame1, sticky=tk.nsew) pw1.add(frame2, sticky=tk.nsew) root.mainloop() what advantage of specifying master? the master paremeter can interpreted parent . passing add new key in parent.children attribute. if print pw1.children when not pass master and not execute pw1.add() see returns empty dictionary. print pw1.children #{} the pw1.add() method includes added widget in pw1.children ...

c# - Security script based on Global Group? -

i'm not sure if possible, i'd limit users specific areas of intranet site based on membership in specific global groups created in sql server. for example, i've got following menu in asp: <div class="clear hideskiplink" id="mainmenu"> <asp:menu id="navigationmenu" runat="server" cssclass="menu" includestyleblock="false" orientation="horizontal" backcolor="#cc3300"> <items> <asp:menuitem navigateurl="~/default.aspx" text="home" selectable="true" /> <asp:menuitem navigateurl="~/forms/frmcensuslist.aspx" text="census editing"/> <asp:menuitem navigateurl="~/forms/frmroster.aspx" text="roster editing"/> <asp:menuitem navigateurl="~/forms/frmreportmenu.a...

parse.com - Page won't ccroll after dynamically creating HTML with Javascript -

i have created javascript function dynamically creates html string, reason once html loads page no longer scroll. if open chrome developer console of sudden allows page scroll. have checked , think have of required open , close div tags. has seen before. does have javascript not being able finish before page loads? any appreciated! html: //here call function dynamically create html <div id="memberlist"> <script> $(document).ready(function() { generatemembers(); }); </script> </div> javascript: function generatemembers(){ var donetask = false; var trebuser = parse.object.extend("trebuser"); var querytrebuser = new parse.query(trebuser); querytrebuser.find({ success: function(results) { //create member profiles var t ="<div class=\"row-fluid\"><div class=\"span12\">"; (i = 0; < results.length; i++) { ...

installation - Does android:installLocation in manifest affect updates as well as fresh installs -

i have 2 questions: 1 . " android:installlocation " tag in android manifest affect updates fresh installs? i have published app on market no "android:installlocation" @ all, thinking of adding 1 of following manifest: android:installlocation="auto" or android:installlocation="preferexternal" could affect users update app? app transferred external storage? my second question follows on assuming answer "yes". 2 . if app moved during update, data associated app affected? e.g. databases or shared preference files. the documentation says "the .apk file saved on external storage, private user data, databases, optimized .dex files, , extracted native code saved on internal device memory." but worried instead of normal update, system may perform full uninstall/install cycle wipe data. unacceptable in situation. i'm sorry cannot answer question myself through experimentation don't have access devices have...

delphi - Can anything bad happen, if I clear my array by assigning a non-initialized array to it in pascal? -

in pascal, way dared cleaning array iterate through , clear it, extremely inefficient. can't reinitialize assigning empty array it? program arrays; var working, empty : array [1..10] of integer; begin working[3] := 5; working:= empty; end. is ok this, can backfire? this absolutely fine. semantics of code need. delphi compiler emit code perform simple , efficient memory copy. compiler able because have fixed length array elements simple value types. i'd surprised if fpc did not produce similar code. even if array contained managed types (it doesn't), assignment operator result in code respected managed types. as final comment, array full of zeros should constant.

r - Create and Call Linear Models from List -

so i'm trying compare different linear models in order determine if 1 better another. have several models, want create list of models , call on them. possible? models <- list(lm(y~a),lm(y~b),lm(y~c) models2 <- list(lm(y~a+b),lm(y~a+c),lm(y~b+c)) anova(models2[1],models[1]) thank help! if have 2 lists of models, , want compare each pair of models, want map : models1 <- list(lm(y ~ a), lm(y ~ b), lm(y ~ c) models2 <- list(lm(y ~ + b), lm(y ~ + c), lm(y ~ b + c)) map(anova, models1, models2) this equivalent following loop: out <- vector("list", length(models1)) (i in seq_along(out) { out[[i]] <- anova(models1[[i]], models2[[i]]) } map example of functional, , can find out more them @ https://github.com/hadley/devtools/wiki/functionals

maven - Errors in pom.xml with dependencies (Missing artifact...) -

Image
a friend has passed me maven project i'm trying run locally in computer. have done in eclipse, selected: file -> import -> existing maven projects after that, project showed me 4 errors in pom.xml (missing artifact..): i tried removing content of .m2 folder , in eclipse clicked on project , chose "run as" -> "maven clean" , "run as" -> "maven install". still have same errors. i'm new spring dont know else do. edit: when try do: run as/ maven install, console says: slf4j: failed load class "org.slf4j.impl.staticloggerbinder". slf4j: defaulting no-operation (nop) logger implementation slf4j: see http://www.slf4j.org/codes.html#staticloggerbinder further details. [info] scanning projects... [info] [info] ------------------------------------------------------------------------ [info] building datalayer 0.0.1-snapshot [info] -...

silverlight - listbox not updating content when data source changes -

i'm working on large wp7 project, , current task implement offline functionality. i've got listbox should display items when device connected internet, , display empty view otherwise. i've got event handler wired fires when connectivity changes, retrieve neccesary data listbox if i've got connection. the problem when run app in offline mode, , turn wi-fi on, data listbox updates not ui itself here xaml: <listbox name="lstitemcategories" itemssource="{binding itemcategories, mode=twoway}" selecteditem="{binding selecteditemcategory, mode=twoway}" margin="0,-15,0,60" tap="lstitemcategories_tap"> <listbox.itemtemplate> <datatemplate> <stackpanel orientation="horizontal" margin="0,0,0,0" height="78" width="432"> <image height="70" w...

javascript - Selecting button with specific text only to activate on click event -

i have row of buttons difference between them inner text: <a href="#contact" class="btn btn-large btn-info" data-toggle="tab">text1</a> <a href="#contact" class="btn btn-large btn-info" data-toggle="tab">text2</a> <a href="#contact" class="btn btn-large btn-info" data-toggle="tab">text3</a> i want activate script when button 'text3' pushed . tried following works buttons not 'text3'. $(function(){ $('a.btn[text()="text3"]').click(function(){ console.log(id); // action here }); }); how can fix this? you can use :contains selector bind event handler specific anchor contains text $('a.btn:contains(text3)').click(function(){ ...

php-mysql database apostrophe and comma insertion -

i insert 10 field's value in mysql php code is. problem whenever user inserts apostrophe , comma(',) query code disturbed. functions there. necessary parse field's value these functions?? not time consuming :p here php code $rs = mysql_query(" insert _{$pid}_item values ( '$pid', '$item_brand', '$item_code', '$item_name', '$item_quantity', '$item_mrp', '$i‌tem_discount', '$item_vat', '$item_sat', '$item_selling_price', '$item_rating', '$item‌​_image' ) "); i passing values these variables.. try mysql_real_escape_string , or if using pdo , use pdo::quote . and please please please read on sql injection attacks. not matter of getting failed queries, matter of having attacker access entire database, other user's information. eve...

PHP : array in Format part to sprintf or vprintf -

student of php ! searched haven't got answer posting q i know sprintf ( string format [, mixed args]) sprintf description :returns string produced according formatting string format. and vsprintf ( string format, array args) though these pretty enough ran through problem is there simple way (i mean pretty iteration , sprintf each) "returns array produced according formatting array format. " ( desc:copied sprintf ) i have general $product array $product = array( "p_id" => '%s', "u_price" => '%s', "qty" => '%d' ); $newproductarray1= sprintf_special($product,"tomato","30","12"); $newproductarray2= sprintf_special($product,"carrot","20","10"); so that $newproductarray1= ( "p_id" => 'tomato', "u_price" =...

apache - .htaccess rewrite to add .php to no extension requests, BUT to not accept .php requests by users -

i want rewrite rules (mod_rewrite) block users accessing pages directly, using .php extension @ end of urls, want keep php files extension in website folders. problem , want server accept no extension url requests, , take user respective .php page. have following rewrite code: rewriteengine on rewriterule \.php$ - [r=404] rewriterule ^(.*)$ $1.php the first rule giving 404 error, wanted. second rule works when it's alone, no other rules. above block, when type no extension url think server "redirecting" request , adding .php extension, first rule act user request , give me 404 error, making 2nd not work want. i think need rewrite condition tell server apply first rule if request comes website user, , ignore if comes rewrite engine. possible? i not htaccess guru yet, hope helps: rewritecond %{the_request} \.php rewriterule \.php$ - [r=404] rewritecond %{request_uri} !(\.php) rewritecond %{request_uri} !(^\/error\/.*$) rewriterule ^(.*)$ $1.php [l] ...

javascript - Moving on deep function -

i have short question: how can move a b in code: for(var i=0;i<length;i++) { b <--------------- far if (/*condition*/) { if(/*condition*/) { ..... } else { <------------ here }; } else if(/*condition*/) { ... } } i know break , continue , doesn't work here thanks all! you use goto.js ( http://summerofgoto.com/ ) handle exact loop you're trying use, should consider finding different way factor code.

linux kernel - How to implement timer expire function in sysfs of driver.? -

scenario: suppose if doing echo 1 > sysfs_entry - start doing i/o operation until echo 0 > sysfs_entry . here, wanted implement timer in sysfs_entry should stop i/o operation after t seconds , if not give echo 0 > sysfs_entry . ps: not want use busy wait methods. preferred: deferred/delayed work please me resolve scenario. you can use add_timer() , del_timer() api this. event queue might work (depends on context). more details, please read chapter 7 «time, delays, , deferred work» of linux device drivers (aka ldd) book available free of charge right here . timer api described on page 198.

Update a field for a specific # of records in SQL Server 2005 -

say want 3 records flagged each product in table. if products 1 or 2 records flagged or no records flagged, how can make randomly flag remaining records total of 3 per product. ex: 1 record gets flagged product_a, 2 records flagged product_b , 3 records flagged product_c. once script complete, need 2 more records flagged product_a , 1 more product_b. this can loop or cte or whatever efficient way in sql. thanks! here's 1 way it: ;with selectedids as( select id, row_number() on ( partition productcode -- distinct numbering each product code order newid() -- random ) rowno productlines ) update p set isflagged = 1 productlines p join selectedids s on p.id = s.id , s.rowno <= 3 -- limit 3 records / product code ; here's full sample, including test data: http://www.sqlfiddle.com/#!3/3bee1/6

c - Pointer array and pointers in parantheses -

could tell me difference between int *p[n]; and int (*p)[n]; where n number? i know first case implies array of pointers, know second declaration implies. int * p[10] defines p array of ten int -pointers. int (*p)[10] defines p pointer array of ten ints. say: int a[10]; int (*p)[10] = &a;

xcode - Renaming Duplicated Target: Where do I fix the reference to the default plist name? -

environment: xcode 4.6.3 i wish duplicate target , rename default ' copy' ' (simulator)'. steps i've done: 1) select target & contextually click 'duplicate' option. 2) click/select copied target name , modify chose name: ' (simulator)'. 3) manage schemes: delete generated (copy) , auto-generate new scheme. ...the newly-generated scheme should correctly labeled '...(simulator)'. problems... either compiler error of conflicting piece of code, or following: error: not read data '/users/ric/desktop/iphone5_support/cg-mobile copy-info.plist': file “cg-mobile copy-info.plist” couldn’t opened because there no such file. question: what's simplest way a) duplicate , b) rename duplicate don't screw-up build? in these situations manually fix things in project.pbxproj text editor. close xcode open project.pbxproj in text editor (emacs, vim, sublimetext, etc) search/replace cg-mobile cop...

data annotations - Using dataannotations displayFormat to change to title case in ASP.Net MVC -

is possible use dataannotations specify fields display title case rather upper? if want change display name of particualr field, add [displayname("displayedname")] data annotation property in model. for example, if model has property "firstname", may want display space , colon in "first name:" seen here: public string firstname { get; set; } [displayname("first name:")]

android - Duplicate string names in strings.xml -

we have shared intellij project use build our android app. 1 person (out of 10) ran build error: android-apt-compiler: [ui] <path>\strings.xml:454: error: resource entry <name> defined. looking it, sure enough there duplicate definitions of string resource, both in same strings.xml file. these should fixed, because makes no sense @ all. but here's don't understand: else can build fine, despite duplicate entries in strings.xml. assume there difference between our global or project settings (despite project being shared) can't see. any ideas of look? thank you. i able fix problem downgrading intellij 13.0.3 , reimporting project maven. ymmv

Stopping debugging in Visual Studio fails to close browser -

i have opposite problem thread: visual studio - prevent stopping debugging closing internet explorer in both visual studio 2008 , 2010 whenever debug web projects, hitting [stop debugging] (or [shift-f5]) still stops debugging, no longer closes browser (ie10). if don't stay on toes, leads many many browser windows being open, , machine starts grinding stop. it's not show-stopper, it's bothersome nonetheless. john when stop debug, stop vs debugger, iis running yet , can continue browse site.

Python Error when imported from different directory -

in mydir/test/testing/pqtest.py import os,sys lib_path = os.path.abspath('../../lib/mine') sys.path.append(lib_path) import util <---- traceback import string import random # code traceback (most recent call last): file "pqtest.py", line 5 in ? import util file "mydir/lib/mine/util.py", line 89 yield v if l > 0 else '' error point @ if syntaxerror: invalid syntax however, there other files import util.py inside mydir/lib/mine not have problems file. so why giving me traceback when importing somewhere else, in case mydir/test/testing ? syntax error on yield v if l > 0 else '' def expand(): l,v in zip(field,val): yield l yield v if l > 0 else '' this python 2.5 not python 2.4 i assuming need tell pqtest.py use python 2.5 not sure how if you're willing change util.py, obvious thing rewrite co...

html - Same font files, same PC, same OS, same browser, same code--two different rendering results on two different sites. What gives? -

i'm running incredibly frustrating issue webfonts on employer's website. (screenshot here: http://imgur.com/pvb5lrl ) i've added font files and, best can tell, written code correctly. however, text rendering incredibly jagged , ugly in chrome , firefox. what's bizarre simple test set using same font files, same @font-face code, , same css text rendering fine in same browsers on same machine. idea might causing crappy rendering on full website? urls both below reference. company website: http://staging.lmsonline.com/services/email-marketing/ simple test: http://datafulfill.com/fonttest/demo.html screenshot (windows 7, chrome): http://imgur.com/pvb5lrl not sure, font supposed like. @ end arrives sort of arial, pretty same generic sans-serif anyway. playing around fonts in past taught me address issue in order: @font-face { font-family:"delitsch antiqua"; src:url("/path/to/fonts/delitschantiqua.eot"); } @font-face { font-family:...

ruby on rails - Parent-Child form -

how show parent-child relationship on single page in rails? don't need form want show information (no edits or updates required). parent customer , child orders. want able select customer, display customer information such address, , list orders placed in row format. thanks. assuming have model associations set properly.. in controller, @customer = customer.find(params[:id]) @orders = @customer.orders.all then in view, use orders variable.

file - Scope and Variable Resolution in Ruby Blocks -

there missing in following code. hostnames = [] ip_addrs = [] hw_addrs = [] file.open("/etc/dhcp/dhcpd.conf", "r").each_line |line| unless line.match('#') # make sure line not commented if line.match("host-name") hostname = line.scan(/"([^"]*)"/) # extract hostname elsif line.match("fixed-address") ip_addr = line.scan(/(\s*);/) # extract ip addr elsif line.match("ethernet") hw_addr = line.scan(/(\s*);/) # extract hw address end end hostnames + hostname.to_a if hostname # protect against `nil' values ip_addrs + ip_addr.to_a if ip_addr # same hw_addrs + hw_addr.to_a if hw_addr # same end puts hostnames.inspect # should list of hostnames... this should populate arrays values found in dhcpd.conf file. if print values inside file.open.each_lin...

jquery - Is it wrong to do this in HTML? -

this question has answer here: multiple id selector in different scopes? [closed] 6 answers can multiple different html elements have same id if they're different elements? 12 answers i know id's meant unique, i've got quick question. can use same id name on different elements? example, have: input#idname a#idname ...etc? same id, different element long call them element tag in jquery: $("a#idname") $("input#idname") etc? thanks. id's meant unique , id should exist once on webpage. element use id irrelevant in case.

ruby - Why does capistrano abort during deploy? -

my first day capistrano, , i'm total ruby noob. when run cap production deploy get: (about half-way down you'll see "cap aborted!") debug uploading /tmp/git-ssh.sh 0.0% info uploading /tmp/git-ssh.sh 100.0% info [a4358a68] running /usr/bin/env chmod +x /tmp/git-ssh.sh on 205.149.129.67 debug [a4358a68] command: /usr/bin/env chmod +x /tmp/git-ssh.sh info [a4358a68] finished in 0.094 seconds command successful. info [7e2d6b30] running /usr/bin/env git ls-remote git@github.com:johnnyfreeman/ng-phrases-node.git on 205.149.129.67 debug [7e2d6b30] command: ( git_askpass=/bin/echo git_ssh=/tmp/git-ssh.sh /usr/bin/env git ls-remote git@github.com:johnnyfreeman/ng-phrases-node.git ) debug [7e2d6b30] 870ca21b256ec53ffba50da1d8ecf7cb4c36e561 debug [7e2d6b30] debug [7e2d6b30] head debug [7e2d6b30] debug [7e2d6b30] 870ca21b256ec53ffba50da1d8ecf7cb4c36e561 debug [7e2d6b30] debug [7e2d6b30] refs/heads/master debug [7e2d6b30] info [7e2d...

C# OleDb Exception "No value given for one or more required parameters" while trying to delete from Access database -

i have table "semester, subject, offer, result" "semester" & "subject" primary key. when use query "delete course_information semester = 1 , subject = 'cse-414' ; its working in access database exception when tried use in c# code. moreover works if use "delete course_information semester = 1 ; i want use both "subject" & "semester" in condition (because there different subject in same semester) see code, connection_string = aconnection.return_connectionstring(connection_string); string sql_query = "delete course_information semester = " + this.textbox1.text + " , subject = " + this.textbox2.text + " ;"; oledbconnection connect = new oledbconnection(connection_string); oledbcommand command = new oledbcommand(sql_query, connect); try { connect.open(); oledbdatareader reader =...

php - Attempting to populate two arrays from two tables within a foreach loop -

the end-result of should arrays description , pass should populated , should able echo them. however, descriptions echo passwds not echo. testing, looks $value variable empty result1 query. can not figure out how use $value in second query. i these 2 errors: notice: undefined variable: pass in /var/www/html/manage/commit.php on line 60 warning: invalid argument supplied foreach() in /var/www/html/manage/commit.php on line 60 // manage.phones $result = mysqli_query($con_manage,"select * phones"); while($row = mysqli_fetch_array($result)) { $mac[] = $row['mac']; $mapped_to[] = $row['mapped_to']; } // asterisk.devices foreach($mapped_to $value) { $result = mysqli_query($con_asterisk,"select description description devices id='$value'"); while($row = mysqli_fetch_array($result)) { $description[] = $row['description']; } $result1 = mysqli_query($con_asterisk,"select data data sip id='$value'...

ios - Phonegap 3.0.0 - Facebook SDK 3.6 - FB plugin: Facebook connect not found -

i'm having problem phonegap 3.0.0 , facebook plugin. followed explanation letter (two times), , i'm beginning think either i'm doing stupendously wrong, or versions don't line properly. the error both hackbook , simple.html is: error: plugin 'org.apache.cordova.facebook.connect' not found, or not cdvplugin. check plugin mapping in config.xml. so according found online (which in case not whole lot seeing made mayor changes in recent versions), seems either plist or xml. so hoping has gotten running already, or knows i'm doing wrong. as config.xml, i'm using 1 in www folder (is correct one?), , added: <gap:plugin name="com.phonegap.plugins.facebookconnect"> <param name="app_id" value="[app_id]" /> <param name="app_name" value="[app_name]" /> </gap:plugin> as plist ended adding: <key>facebookdisplayname</key> <string>[app_name]<...

ios - How to use custom back button to return to main view controller -

i trying programmatically custom button return main view controller (ie. 'view controller home1' 'main view controller') - check link http://postimg.org/image/cnoq0hsct/ connect ibaction , use code: - (ibaction)youraction:(id)sender { [self dismissviewcontrolleranimated:yes completion:nil]; }

asp.net - LINQ to SQL Connection Strings with class library projects -

Image
linq sql connection strings class library projects by default, creating new linq sql model (.dbml) put connection strings in both application settings file , web.config / app.config. not of problem web projects, class library projects? have connection class can use check connection in pages have error cant read datacontext @ all. this photo shows problem. generally speaking, class libraries don't support config files. there ways make work, it's not considered practice since different applications may use same library interact different instances of database. recommend looking @ dependency injection or inversion of control solution ninject pass connection string constructor app references library. update: if absolutely must read config file assembly instead of calling application, can done configurationmanager.openexeconfiguration() . there several answers here on provide code samples doing so, i'm not going link them because encourag...

unicode - Django view param is not unquote with FastCGI -

i have django site in nginx+fastcgi, , if there special char in url view param parsed django not unquoted. example: # python manage.py runfcgi port=8099 --settings=settings browser url: http://127.0.0.1/contact/%e6%9c%b1/ django urlpattern: url(r'^(?i)contact/(?p<q>.*)/$', 'qsearch'), param 'q' catched qsearch function u'%e6%9c%b1' . expected u'\u6731' unquoted. the same program works fine u'\u6731' when using runserver debug. have use workaround method: q = unicode(urllib.unquote(str(q)), 'u8') nginx conf: location / { fastcgi_pass 127.0.0.1:8099; include /home/fastcgi_django.conf; } fastcgi_django.conf: fastcgi_param script_filename $document_root$fastcgi_script_name; fastcgi_param query_string $query_string; fastcgi_param request_method $request_method; fastcgi_param content_type $content_type; fastcgi_param content_length $content_length; fastcgi_param requ...

javascript - What exactly is stopping this script from working in IE8? (IE8 Issue) -

javascript not forte, found navigation script designed way want (jsfiddle below), cannot work ie8 (the best browser ever sarcasm ). please help! http://jsfiddle.net/jsjy4/1/ window.onload = function () { var fine = [36, 34, 34, 34]; var mitms = document.getelementsbyclassname('mitm'); var l0 = (mitms[0].offsetleft + fine[0]); document.getelementbyid("nav_arrow").style.marginleft = l0 + "px"; (var = 0; < mitms.length; i++) { mitms[i].fine = fine[i]; mitms[i].onclick = function() { arr(this); var tmp = document.getelementsbyclassname('mitm'); } } }; function arr(el) { var mitms = document.getelementsbyclassname('mitm'); var l = el.offsetleft + el.fine; document.getelementbyid("nav_arrow").style.marginleft = l + "px"; } you should not use default variable name, reserved . use different name instead. from documen...

mysql - Java : SQL syntax error for entering values in Table -

i trying add 2 methods withdraw , deposit money in bank class . database name javatest . table name bank , following code . problem when run code compiler says you have error in sql syntax; did check code 3-4 times unable please me . public static void main(string[] args) { connection connection= null ; statement stmt = null ; try { class.forname("com.mysql.jdbc.driver"); connection= drivermanager.getconnection("jdbc:mysql://localhost:3306/javatest","root",""); stmt= connection.createstatement(); withdrawfromchecking(connection, stmt, new bigdecimal(100), 1); depositinsaving(connection, stmt, new bigdecimal(444), 1); stmt.executebatch(); system.out.println("done"); } catch (classnotfoundexception e) {e.getmessage();} catch (sqlexception e) {e.printstacktrace();} { if(connection!=null){try {connection.close();} ca...

ios - Not sure how to set up a UITableViewController -

i created detailviewcontroller .h , .m files. created uitableviewcontroller in storyboard , connected files made. then added code detailviewcontroller.m file: #import "masterviewcontroller.h" #import "detailviewcontroller.h" // 1 #import "rageiaphelper.h" #import <storekit/storekit.h> // 2 @interface masterviewcontroller () { nsarray *_products; } @end @implementation masterviewcontroller // 3 - (void)viewdidload { [super viewdidload]; self.title = @"in app rage"; self.refreshcontrol = [[uirefreshcontrol alloc] init]; [self.refreshcontrol addtarget:self action:@selector(reload) forcontrolevents:uicontroleventvaluechanged]; [self reload]; [self.refreshcontrol beginrefreshing]; } // 4 - (void)reload { _products = nil; [self.tableview reloaddata]; [[rageiaphelper sharedinstance] requestproductswithcompletionhandler:^(bool success, nsarray *products) { if (success) { _p...

java - JBoss Tools: javax.servlet.* could not be resolved -

the namespace javax.servlet.* not resolved in eclipse. i'm using eclipse java ee developers + jboss tools. any idea clean solution? check classpath includes lib servlet-api. can seen in .classpath file in project directory. looks classpathentry kind="lib" path="extlib/servlet-api.jar"/

Android Facebook Integration without Fragments -

i creating social app , have integration facebook can grab information on friends, user info, post on users wall , upload picture facebook. have followed tutorials on facebook website using fragments. prefer not use fragments if @ possible. i'm sure facebook wouldn't tie api around use of fragments shut out people. i understand clear answer use newest api fragments rather not following reasons: i don't see why wouldn't able without fragments. i don't entirely understand point fragments , why becoming increasingly more popular. i have of application implemented without using fragments , implement facebook login/use @ point in development. that being said, how can go doing without use of fragments? why fragments becoming increasingly popular? if answer use facebook api fragments, there "easy" way alter app i've created, uses activities, uses fragments? cheers, jake if want sample reference on how switch activities fragme...

javascript - Get all events handlers attached to an element -

i need find events handlers attached #myselect , if event created via jquery can , here alert(e) show "change" without "click" javascript : $("#myselect").change(function(){ alert("changed"); }) $.each($._data( $("#myselect")[0], "events" ), function(e) { alert(e); }) html : <select id="myselect" onclick="alert('hello')" > <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> <option value="4">option 4</option> </select> the short answer it's not possible reliably determine listeners on element using javascript. the long answer there no standard mechanism list attached listeners. libraries keep list of listeners have been attached using library, don't know other listeners. listen...

php - Initializing sftp subsystem via libssh2 -

i trying file remote sftp server in php script. i'm using libssh2 library ani have been able 1) open connection ssh server , 2) authenticate properly. i'm hitting wall on creating sftp resource use ssh2_sftp* functions , wrapper. following line leaves $sftp null: $stfp = ssh2_sftp($ftp_conn); php error log shows no errors. ssh server logs show successful login, authentication, , log sftp subsytem being initialized. ideas on next?

c# - Using WPF for image display but have code in Winform? -

is possible have code (server , that) in winform , instead of setting image panel/picturebox, can set wpf (which faster?). if so, operation fast, or have invoke or causes delay in it? i have tried doing this, settings image on wpf winform, sadly wasn´t easy expected. i had windows forms project , able : create new wpf pages : add wpf controls existing windows forms first of need change .csproj in order have option of creating new wpf page , control available. not know heart, it's guid add. from read want second. while on windows forms designer can go toolbox , drop wpf control windows forms. doing vs creates things: 1. wpf control 2. elementhost control you can access wpf control usual accessing variable name.

html - Need a SVG file that is 150px wide, 20px tall, reads "THIS IS A TEST' with bold fonts, has a lime background -

this code have far it's not good <svg width="200" height="13"> <g id="layer1"> <text style="font-size:13px;font-family:arial;" x="0" y="13" id="">this test</text> </g> </svg> i trying text fit in box , etc. need add background color it. this can serve: <svg baseprofile="full" width="200" height="13"> <g id="layer1"> <rect width="100%" height="100%" fill="red" /> <text style="font-size:13px;font-family:arial;" x="0" y="13" id="">this test</text>

constructor - Java UNIXProcess not visible in Eclipse? -

i tried use unixprocess.class, eclipse keeps warning me unixprocess not visible. the code simple: import java.lang.process; public class simple { unixprocess process; } can know use unixprocess? thanks java.lang.unixprocess declared default visibility means cannot seen classes outside of package java.lang.* . use processbuilder or runtime.exec() , instead, create valid process object.

android - BluetoothAdapter.ACTION_REQUEST_ENABLE calls onActivityResult immediately -

according developer guides, request can made enable bluetooth such: http://developer.android.com/guide/topics/connectivity/bluetooth.html#settingup if (!mbluetoothadapter.isenabled()) { intent enablebtintent = new intent(bluetoothadapter.action_request_enable); startactivityforresult(enablebtintent, request_enable_bt); } in implementation creates request , user presented request dialog. my problem onactivityresult() called such before dialog appears have result. returned requestcode matches 1 set (9001 in case) , resultcode 0 (activity.result_canceled). i believe bug in 4.3, unfortunately have 4.3 devices. reading descriptions , source appears onactivityresult() should not called until user interacts dialog can confirm bug or explain doing wrong? tested on following same result: new nexus 7 nexus 7 nexus 4 galaxy nexus startactivityforresult doesn't work singleinstance. activity configured single instance ? (android:launchmode="singl...

syntax - Python for-else relationship -

this question has answer here: why python use 'else' after , while loops? 13 answers i can run below python script without errors. for n in range(3): print n else: print "done" but puzzled else without matching if. not make sense. can 1 explain why works ? the else clause of for , while only executes if loop exits normally , i.e. break never run. for in range(20): print if == 3: break else: print 'haha!' and else clause of try executes if no exception happened. try: = 1 / 2 except zerodivisionerror: do_something() else: print '/golfclap'

lisp - Filter a list into two parts by a predicate -

i want do (filter-list-into-two-parts #'evenp '(1 2 3 4 5)) ; => ((2 4) (1 3 5)) where list split 2 sub-lists depending on whether predicate evaluates true. easy define such function: (defun filter-list-into-two-parts (predicate list) (list (remove-if-not predicate list) (remove-if predicate list))) but know if there built-in function in lisp can this, or perhaps better way of writing function? i don't think there built-in , version suboptimal because traverses list twice , calls predicate on each list element twice. (defun filter-list-into-two-parts (predicate list) (loop x in list if (funcall predicate x) collect x yes else collect x no (return (values yes no)))) i return 2 values instead of list thereof; more idiomatic (you using multiple-value-bind extract yes , no multiple values returned, instead of using destructuring-bind parse list, conses less , faster). a more general version be (defun split-list (key list &...

Error Running Ruby on Rails App in Production Mode -

i'm starting use ruby on rails , going through tutorial started. have working testing, can use rails server command in directory make show basic "welcome aboard" page want see; however, when change rails server -e production see "the page looking doesn't exist." page. when happens, command prompt shows: [2013-08-07 19:54:26] info webrick 1.3.1 [2013-08-07 19:54:26] info ruby 1.9.3 (2013-06-27) [i386-mingw32] [2013-08-07 19:54:26] info webrick::httpserver#start: pid=12664 port=3000 i, [2013-08-07t19:54:26.515238 #12664] info -- : started "/" 127.0.0.1 @ 2013-08-07 19:54:26 -0700 f, [2013-08-07t19:54:26.752394 #12664] fatal -- : actioncontroller::routingerror (no route matches [get] "/"): actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `c all' actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `ca ll' railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app' rail...

java - Trying to add multiple views but get a blank screen -

i created custom xml file linearlayout , textview. have loop want go through arraylist , add view scrollview each object. below code tried achieve this, gives me blank screen. tried see if arraylist empty, that's not it. didn't know doing when tried this. wanted see if worked, didn't what's problem? for(int x = 0; x < runs.size(); x++){ inflater = getlayoutinflater(); view layout = inflater.inflate(r.layout.run_layout, (viewgroup) getcurrentfocus()); textview name = (textview) layout.findviewbyid(r.id.tvrunname); name.settext(runs.get(x).getname()); llruns.addview(layout); } heres run_layout xml.... <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:background=...

android - Using page adapter without fragments -

is possible use viewpager without fragments? examples find load several fragments viewpager. i want use listview . create custom adapter inflate layout according position pager in. if it's possible can point me example ? yes totally possible. since viewpager.setadapter() takes instance pageadapter , need create own subclass of pageradapter (its kinda subclassing baseadapter or arrayadapter use in listview ). remember, pageradapter docs say: when implement pageradapter, must override following methods @ minimum: instantiateitem(viewgroup, int) destroyitem(viewgroup, int, object) getcount() isviewfromobject(view, object) hope helps

asp.net - Convert Generic Handler to Server Control -

here have code resizing image fn query string opens image app_data/users , edit logo , resizing low quality , low size image , returns final image. using system; using system.web; using system.drawing; using system.drawing.imaging; public class usersimagethumb : ihttphandler { public void processrequest(httpcontext context) { { try { image t = image.fromfile(context.server.mappath("~/app_data/users/") + context.request["fn"]); image t1 = image.fromfile(context.server.mappath("~/favicon.png")); bitmap b = new bitmap(150, 200 * t.height / t.width); using (graphics gr = graphics.fromimage(b)) { /* codes can have better image @ final gr.compositingquality = compositingquality.highspeed; gr.interpolationmode = interpolationmode.highqualitybicubic; gr.compositingmode = compositingmode.sourcecopy; ...

Implementing arraylist in C -

i have created program add 2 types of items in system. have created 2 structures 2 different items. have created method add items system , store each item in array. encountered problem when gonna implement delete feature, problem if have record @ array memory index 2, if delete there unused space, between memory index 1 , 3. how can overcome ? in java , there arraylist dynamically allocates space. in c know there dynamic memory allocation , how can implement work delete feature ? here have done far :- #include <stdio.h> #include <string.h> struct routers { int device_no; char device_name[30]; int no_of_items; int price; char description[30]; }; /**declared of struct routers store structure objects **/ struct routers routerlist[5]; struct controllers { int device_no; char device_name; int no_of_items; int price; char description[30]; }; void addnewitem(); int main() { addnewitem(); return 0...