Posts

Showing posts from May, 2011

c - Two semicolons inside a for-loop parentheses -

im customising code found on internet (it's adafruit tweet receipt). cannot understand many parts of code perplexing me for-loop 2 semicolons inside parentheses boolean jsonparse(int depth, byte endchar) { int c, i; boolean readname = true; for(;;) { //<--------- while(isspace(c = timedread())); // scan past whitespace if(c < 0) return false; // timeout if(c == endchar) return true; // eod if(c == '{') { // object follows if(!jsonparse(depth + 1, '}')) return false; if(!depth) return true; // end of file if(depth == resultsdepth) { // end of object in results list what for(;;) mean? (it's arduino program guess it's in c) for(;;) { } functionally means while (true) { } it break loop/ return loop based on condition inside loop body. the reason for(;;) loops forever because for has 3 parts, each of optional . first part initializes loop; second decides whether or not continue loop,

xsd - How to find values using XQuery and plist XML files -

the following sample plist file used question below. <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> <key>firstdictionary</key> <dict> <key>string</key> <string>sometext</string> <key>anarray</key> <array> <string>first</string> <string>second</string> </array> </dict> <key>seconddictionary</key> <dict> <key>subdictionary</key> <dict> <key>aboolvalue</key> <false/> </dict> </dict> </dict> </plist> so question is, since plist (working xcode), keys have element name <key> , v

c# - Validation - (Form) Cancel button doesnt work -

i having problems leaving form on cancelbutton_clicked event, because of validating events. i have 1 textbox has own validating methods, , returns e.cancel = true if input string null or empty, else e.cancel = false . now, have cancelbutton regular button, , close current form, this: cancelbutton_clicked(object sender, eventargs e) { this.close(); } but if this, , if textbox left empty doesnt pass validation, , cant close form. validation icons keep blinking. tried setting causesvalidation false , tried this: private void btncancel_click(object sender, eventargs e) { // stop validation of controls form can close. autovalidate = autovalidate.disable; close(); } but none of helped. hope could. cheers am assuming, have set btncancel.causesvalidation=false; either through code or designer. setting causesvalidation=false of button , allow call click event of button now there multiple things can do. simply unregister textbox validating e

java - IntelliJ not using external Jar's if not added via Maven when running JSF application? -

Image
i have simple line of code called .xhtml file ( in jsf 2.0 project ) looks like: try { class.forname("com.mysql.jdbc.driver"); }catch(exception e) { e.printstacktrace(); } so in c:\ folder have file: mysql-connector-java-5.1.24-bin . have added jar extenral jar in intellij idea 12. when start application this, "class not found exception." however, when add dependency pom.xml file: <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.6</version> </dependency> i no exception , class loaded fine. here screenshot: the jar file underlined green jar added externally **file -> project structure -> libraries ** the 1 underlined red jar file downloaded maven. my question is: why class not found exception, although have added jar externally? in case require jar file not able download via maven, supposed do? one information: created

java - JTable change Column Font -

helo, i've looked answer in many places haven't got solution, can me this? i'm making table want make first column higher font size. for example in column 0 want font size of 30 , on columns 1-3 y want font size of 13. here's code import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import javax.swing.jframe; import javax.swing.jscrollpane; import javax.swing.jtable; import javax.swing.table.defaulttablemodel; import javax.swing.table.*; public class kanji_list extends jframe { kanji_list(){ jtable table = new jtable(); jscrollpane scroll = new jscrollpane(); image icon = toolkit.getdefaulttoolkit().getimage("jlpt.jpg"); imageicon ima = new imageicon("jlpt.jpg"); defaulttablemodel model = new defaulttablemodel(get_data(), get_header()); table = new jtable(model){ public boolean iscelleditable(int rowindex, int vcolindex){ return false; } }; jt

php - setting query value to null from variable -

i trying insert null values database using pdo seem having problems code public function addbookcategory($id, $isbn, $category, $parent){ $id = $this->dbh->quote($id); $isbn = $this->dbh->quote($isbn); $category = $this->dbh->quote($category); $parent = $this->dbh->quote($parent); return $this->query( "insert book_categories values($id, $isbn, $category, $parent) on duplicate key update id = $id" ); } there instances parent column can null none of following set parent null, instead sets value empty string "" or null string "null". $database->addbookcategory("kujhg", "asdasd", "asdasd", null); $database->addbookcategory("kujhg", "asdasd", "asdasd", ""); $database->addbookcategory("kujhg", "asdasd", "asdasd", "null"); what can done overcome problem?

css - Nesting Media Queries -

by default want give body element green border. on device supports retina display want check size first. on ipad want give body red border , on iphone want give blue border. nesting media queries doesn't work: body { border: 1px solid green; } @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { @media (max-width: 768px) , (min-width: 320px) { body { border: 1px solid red; } } @media (max-width: 320px) { body { border: 1px solid blue; } } } no. need use and operator , write 2 queries. can, however, in scss, compile css, combine them unfolding them , using and operator. this common problem, , once first wrote less or scss, didn't ever want go writing long-hand. long-handed css: @media (-webkit-min-device-pixel-ratio: 2) , (max-width: 768px) , (min-width: 320px), (min-resolution: 192dpi) , (max-width: 768px) , (min-width: 320px) { body { border: 1px solid red; } } @media (-webkit-min-devi

web services - Outlook HTTP mail protocol? -

ms outlook supports http 1 of e-mail access protocols. provider, supports hotmail, msn , "other". question - can find description of protocol may implement custom http mail service outlook consume? better yet, there stock implementation out there?

compiler construction - Syntax Tree Generation in Clojure -

i'm writing compiler, educational purposes. have generated tokens input , want generate ast. have function takes list of tokens , recurses generate ast. in parsers you'd have pointer lexer every time process tokens in tree you'd advance lexer. dont know how advance lexer when hit part needs generate deeper nodes in tree since can't modify structure of lexer list. as example clojure program (+ 1 2 (+ 1 1)) . advance + , recurse , generate node properly, lexer reprocesses + 1 1 after returns generating node, end tree this: root ---> + ---> 1 ---> 2 -----> + -----> 1 -----> 1 ---> + ---> 1 ---> 1 in lisp/clojure program directly abstract syntax tree expressed via lisp data structures. moreover, can programmatically act on lisp data structures leading macros. so, in conclusion have ast.

java - Deploy Applet on Apache server -

i've written java applet game want deploy on apache server. code + resources in self signed .jar accompanying html doc both in root dir. run on local machine works fine. when try run on server class not found exception. index.html contains <applet code=spaceraiderz.class archive=spaceraiderz.jar width=1024 height=768> </applet> the class not found class named above. opened .jar , contents complete. file permissions set 755. if click index.html on local machine loads , runs perfectly. ftp same docs server , doesn't work. had problem? found similar question on here none of suggested solutions have worked in case. the applet (seen here ) works (e.g. showing asteroids style game featuring pale green ship appears suspiciously familiar + sound track) me in java 1.7.0_21 on windows using ff. refreshing class cache in console & refresh page might fix problem you. if fails, there still more options testing applet: usually installing browse

jQuery and IFrame load events -

i have read in several write-ups jquery can facilitate event listening on iframe - each reload. i'm getting initial event notice - subsequent reloads events silent/ignored. code sample: $('#some_frame_id').bind('load', modnamespace.ehandler()); however, if drop now-seemingly-frowned-upon onload syntax, expected results - using same handler: iframe(class='foo'src='/path/to/resource' id='some_frame_id' name-'some_frame_id' onload='modnamespace.ehandler();') this gets me results i'm looking i'd still understand problem jquery implementation. (note: iframe markup jade)

javascript - Determine offsetTop of an element and set it on other element -

there list of items. if item clicked anoter view revealed beside item. want view have same offsettop item. know how in jquery, cannot find solution in pure angularjs. tried far top = angular.element('#user'+user.id).prop('offsettop'); angular.element('#feed-details').css('margin-top', top); this has no effect. ideas how achieve in angularjs? lengths must have unit. offsettop unitless number. add "px" it. that said, in vanilla javascript : document.getelementbyid('feed-details').style.margintop = document.getelementbyid('user'+user.id).offsettop+"px";

.htaccess - Redirection of subdirectory to totally new domain -

i've got site merge that's little confusing. the old site lived at: oldsite.com/subdirectory the new site lives at: newsite.com/ i'm unsure put .htaccess 301 redirects. put them in sub-directory of oldsite.com/subdirectory? or add them root .htaccess oldsite.com/ i think make happen in oldsite.com .htaccess file: redirectmatch 301 ^/subdirectory/(.+)$ http://www.newsite.com/$1 i tried above , it's not working. help! (both sites hosted dreamhost, if matters @ all.) thanks! figured out. at first kept subdirectory , placed .htaccess file inside saying: rewriteengine on rewriterule ^(.*)$ http://newsite.com/$1 [r=301,l] but found out in forum this: redirectmatch 301 /subdirectory(.*) http://newsite.com$1 hope helps else!

How to exclude JQuery/Javascript fade in & out function on certain links? -

i'm using fade in , out jquery/javascript effect on site have each page fade in , out when link clicked. it's working great when link clicked leads different page, causing problems when link leads different part of page (such top link), when mailto link clicked, , when link suppose open in new page or tab clicked. when these type of links clicked lead blank white page because don't lead new page. here script: $(document).ready(function() { //fades body $("body").fadein(1500); //applies every link $("a").click(function(event){ event.preventdefault(); linklocation = this.href; $("body").fadeout(1000, redirectpage); }); //redirects page function redirectpage() { window.location = linklocation; } }); because of i'm trying figure out if there way can exclude fade in/out function links (such top link), don't know how it. know rather set links fade in/out can set

Disable login button till form is filled android sdk -

hello simple question how disable submit button till edittext filled if command or ?? b = (button)findviewbyid(r.id.login); et = (edittext)findviewbyid(r.id.username); pass= (edittext)findviewbyid(r.id.password); if (et & pass == ' ') { } b.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { dialog = progressdialog.show(login.this, "", "validating user...", true); new thread(new runnable() { public void run() { login(); } }).start(); } }); what might want use textwatcher , in ontextchanged() check see if each empty. want check text not view instead of checking et , pass , want string in each. string etstring = et.gettext().tostring(); string passstring = pass.gettext().tostring()

ios - UITextView changes font when detects action -

i've been looking solution problem while, , no 1 seems have come across similar issue. basically have multiple uitextviews use detect addresses, urls, phone numbers, etc (anything can detected via uidatadectortypeall) ekevent.notes. add these uitextviews subviews of uiscrollview. now, reason or another, once uitextview detects address or phone number , becomes actionable target, randomly draw font 2x specified font! i've setup tests redraw views if tap. when uitextview added view initially, can see in black proper text. detection deal , becomes actionable target. stays proper size, draws @ 2x font (but still in proper frame, gets clipped). it's straight forward, here's code below. variable correct values, frame correct, text correct, correct , 50% of time draws correct. other 50% of time becomes (apparently) 2x font! appreciated! uitextview *locationtextview = [[uitextview alloc] init]; locationtextview.datadetectortypes = uidatadetectortypeall; locati

Saving Files In New Directory (python) -

i'm trying take input file , save new folder on computer, can't figure out how correctly. here code tried: from os.path import join pjoin = raw_input("file name: ") filepath = "c:\documents , settings\user\my documents\'a'" fout = open(filepath, "w") path_to_file = pjoin("c:\documents , settings user\my documents\dropbox",'a') file = open(path_to_file, "w") when run it, it's putting 2 \ in between each sub-directory instead of 1 , it's telling me it's not existing file or directory. i sure there easier way this, please help. why have unescaped "'quotes_like_this_inside_quotes'" ? may reason failure. from can understand, directories saving "c:\documents , settings\user\my documents\' , 'c:\documents , settings\user\my documents\' . whenever messing directories/paths use os.expanduser('~/something/blah') . try this: from os.path i

java - Finding all hamiltonian cycles -

i'm trying implement method adding possible hamiltonian cycles list using recursion. far stopping condition isn't sufficient , "outofmemoryerror: java heap space" in line adds vertex list: private boolean gethamiltoniancycles(int first, int v, int[] parent, boolean[] isvisited, list<list<integer>> cycles) { isvisited[v] = true; if (allvisited(isvisited) && neighbors.get(v).contains(new integer(first))) { arraylist<integer> cycle = new arraylist<>(); int vertex = v; while (vertex != -1) { cycle.add(vertex); vertex = parent[vertex]; } cycles.add(cycle); return true; } else if (allvisited(isvisited)) { isvisited[v] = false; return false; } boolean cycleexists = false; (int = 0; < neighbors.get(v).size(); i++) { int u = neighbors.get(v).get(i); parent[u] = v; if (!isvisited[u]

javascript - How can I get Tweet Timeline with using Backbone.js? -

i'm beginner backbone.js. i've finished tutorials. http://backbonejs.org/docs/todos.html http://coenraets.org/blog/2011/12/backbone-js-wine-cellar-tutorial-part-1-getting-started/ i want create non-tutorial app myself , try create simple app display tweet timeline using backbone collection or model. here code. (oauth.js , sha1.js included in html) $(function(){ var tweet = backbone.model.extend({ }); var twitter = backbone.collection.extend({ model: tweet, initialize: function(api){ this.consumerkey = //consumerkey; this.consumersecret = //consumersecret; this.accesstoken = //accesstoken; this.accesstokensecret = //accesstokensecret; this.message = { method: "get", action: api, parameters: { oauth_version: "1.0", oauth_signature_method: "hmac-sha1", oauth_consumer_key: this.consumerkey,

php - Update echoed data using WHILE loop. Only updates one record -

i can't seem able update records except first one. not sure how modify of displayed records. <?php if(isset($_post["action"]) == "update") { $id = $_post['m_id'][0]; $type = $_post['type'][0]; // if echo $id & $type, gives me first record.** mysql_query(" update membership_type set mt_type ='$type' mt_id = '$id'" ); } ?> all of within same php page. <form name=form action='' method='post'> <?php $result=mysql_query("select * membership_type;"); while($rows=mysql_fetch_array($result)) { ?> <input size=35 class=textfield type=text name='type[]' value='<?php echo $rows['mt_type']; ?>'> <input type=hidden name='m_id[]' value="<?php echo $rows['mt_id']; ?>"> <input type=submit value

jquery - How can a class be added to a div via php? -

i have h tag below, <h3 id="reply-title"> & needed add class remotely. (this h3 tag located in comment-template.php. (line 1554) of wordpress core file in case wondering why can't hard code class it.) i've done 1 line jquery (add class on .load) now, concerned since if javascript turned off, class won't added. i have little knowledge of php , wondering if can done in php. i've done research on google & couldn't find reference. any php expert can provide insight? this in general bad practice, can this: echo "<script>$('#reply-title').addclass('class')</script>"; but repeat: this bad practice . javascript must in .js files, , php in .php files. however, if javascript disabled, think can't want. hope helps.

matlab - is it possible remove for loops from my code? -

i want remove nested loops code? can't remove them. k = 3; data = rand(100,5); m = zeros(size(data)); n = size(data,2); % number of features m = size(data,1); % number of objects bound = zeros(n,k+1); max = max(data); min = min(data); ii = 1:n bound(ii,:) = linspace(min(ii), max(ii), k+1); end bound(:,end) = bound(:,end)+eps; tic; ii = 1:m jj=1:n kk=1:k if bound(jj,kk)<=data(ii,jj) && data(ii,jj)<bound(jj,kk+1) m(ii,jj) = kk; end end end end you can away nesting upto limit. at glance, jj index seems uniform in operation within nested loop, can replace for ii = 1:m jj=1:n kk=1:k if bound(jj,kk)<=data(ii,jj) && data(ii,jj)<bound(jj,kk+1) m(ii,jj) = kk; end end end end by simply for ii = 1:m kk=1:k m(ii,(bound(:,kk)<=data(ii,:)' & data(ii,:)'<bound(:,kk+1)))

c# - SUM of the details in group header Crystal reports -

i generating crystal report in asp.net/c# website. require groupwise sum in header of group, when add sum field (running total field) shows first entry of records there way show total of records in details in header of same group? running totals won't work in group header section because of way evaluated. instead, use regular summary function , place in group header. can either right-clicking field summarize, selecting "insert", , "summary" or creating formula: sum({table.field_to_summarize},{table.field_you_are_grouping_on})

winforms - Why text box text not showing from starting position in c#? -

i confused this. please consider below scenario. scenario: have c# winform app few textbox controls. when input data in these text boxes, example, "this sample textbox", overlaps textbox's visible area , displaying "ample textbox". want text displayed starting position "this s" , if needed, overlaps. how can this? have tried below no luck. please help. thanks. (sender textbox).textalign = horizontalalignment.left; edit using autocompletemode.suggest when press key, corresponding list displayed similar dropdownlist. first item of list selected default, not want. can please suggest in also. thanks. final solution using solve issue (sender textbox).textalign = horizontalalignment.left; (sender textbox).select(0, 0); thanks @har har. i found solution, position cursor @ beginning of contents of textbox control, call select method , specify selection start position of 0, , selection length of 0. private void form1_load(obje

css - Need help understanding how I should define oocss objects and skins -

before ask question, here code referring to: box object used box off content island or islet in bootstrap. .box { margin-bottom: 24px; padding: 12px; } .box--s { padding: 8px 12px; } .box--l { padding: 24px 12px; } round skin makes rounded corners. used several abstraction classes, such box. .round { border-radius: 4px; } .round--s { border-radius:2px; } .round--l { border-radius:8px; } in code skin abstraction, write: <div class="round box"> example </div> i have other skins extend box such gray, alert, , label. now question i working on button object. since has same rules , modifiers box, , can have same modifiers of round, should declare skin? button add 4 rules "appearance" if messed margins or padding should object. in code write <a class="round btn box"> example </a> or resize smaller <a class="round btn box box--s"> example </a> is keeping dry overkill

c - Using File Descriptors with readlink() -

i have situation need file name can call readlink() function. have integer stored file descriptor via open() command. problem is, don't have access function open() command executed (if did, wouldn't posting this). return value open() stored in struct do have access to. char buf[path_max]; char tempfd[2]; //file descriptor number of temporary file created tempfd[0] = fi->fh + '0'; tempfd[1] = '\0'; char parentfd[2]; //file descriptor number of original file parentfd[0] = (fi->fh - 1) + '0'; parentfd[1] = '\0'; if (readlink(tempfd, buf, sizeof(buf)) < 0) { log_msg("\treadlink() error\n"); perror("readlink() error"); } else log_msg("readlink() returned '%s' '%s'\n", buf, tempfd); this part of fuse file system. struct called fi, , file descriptor stored in fh, of type uint64_t. because of way program executes, know 2 linked files have file descriptor numbers 1 apart. @ le

javascript - I can't find a way to change the canvas size -

i found amazing code (props creator) online , have been playing can't find how change canvas size. width , length of it. this java controls canvas. how change width/height? <script src="http://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.5/dat.gui.min.js" type="text/javascript"></script> <script> var glitcher = { init: function () { settimeout((function () { this.canvas = document.getelementbyid( 'stage' ); this.context = this.canvas.getcontext( '2d' ); this.initoptions(); this.resize(); this.tick(); }).bind(this), 100); }, initoptions: function () { var gui = new dat.gui(1), current = gui.addfolder('current'), controls = gui.addfolder('controls'); this.width = document.documentelement.offsetwidth; this.height = window.innerheight; this.font = 'bold 12vw arial'; this.context.font = this.font; this.text = "bryan chicas

html - Javascript mouseover Element Flickers & Uncaught TypeError -

i trying use javascript mouseover , mousout function elements dom. sourced child elements event.target , add styling childnode matches specified class name. issue occurring: error: uncaught typeerror: cannot read property 'style' of undefined displayed class flickers. when mouse moved in mouse on current dom element. i've tried elements tag name , childnodes filtered through statemant apply css, still issue's its easy fix baffled. any assistance great. the html <!doctype html> <html> <head> <title>gmail label list</title> <link rel="stylesheet" href="style.css"> <script type="text/javascript" src="func.js"></script> </head> <body> <div id="sidebar-left"> <div class="sbinner-body"> <ul id="label-list"> <li class="lb_li">

jquery - Cannot add two numbers correctly without using parseFloat in JavaScript -

i came across problem. adding numbers using parsefloat or parseint. if textbox1 value 4 , textbox2 value 2 got output (see script) my doubt why in addition alone parsefloat($('#txt1').val()) + parsefloat($('#txt2').val()) gives correct value parsefloat($('#txt1').val() + $('#txt2').val()) is not giving correct value whereas parsefloat($('#txt1').val() - $('#txt2').val()) , parsefloat($('#txt1').val() / $('#txt2').val()) , parsefloat($('#txt1').val() * $('#txt2').val()) are giving correct value. simple couldn't find solution. =====jquery function calculate() { //--> output $('#lbl1').html(parsefloat($('#txt1').val() + $('#txt2').val())); //--> 42 $('#lbl2').html(parsefloat($('#txt1').val()) + parsefloat($('#txt2').val())); //--> 6 $('#lbl3'

python - Django Queryset sort by order_by with relatedManager -

i tryint objects sorted. code: ratings = rate.objects.order_by(sortid) locations = location.objects.filter(locations_rate__in=ratings).order_by('locations_rate').distinct('id') this model: class rate(models.model): von_location= models.foreignkey(location,related_name="locations_rate") price_leistung = models.integerfield(max_length=5,default=00) bewertung = models.integerfield(max_length=3,default=00) how can locations in order equal of ratings ? what have above isnot working. edit : def sort(request): sortid = request.get.get('sortid') ratings = rate.objects.all() locations = location.objects.filter(locations_rate__in=ratings).order_by('locations_rate__%s' % sortid).distinct('id') if request.is_ajax(): template = 'resultpart.html' return render_to_response(template,{'locs':locations},context_instance=requestcontext(request)) you must specify field use sorting rate objec

web crawler - Error while downloading images from Wikipedia via python script -

i trying download images of particular wikipedia page. here code snippet from bs4 import beautifulsoup bs import urllib2 import urlparse urllib import urlretrieve site="http://en.wikipedia.org/wiki/pune" hdr= {'user-agent': 'mozilla/5.0'} outpath="" req = urllib2.request(site,headers=hdr) page = urllib2.urlopen(req) soup =bs(page) tag_image=soup.findall("img") image in tag_image: print "image: %(src)s" % image urlretrieve(image["src"], "/home/mayank/desktop/test") while after running program see error following stack image: //upload.wikimedia.org/wikipedia/commons/thumb/0/04/pune_montage.jpg/250px-pune_montage.jpg traceback (most recent call last): file "download_images.py", line 15, in <module> urlretrieve(image["src"], "/home/mayank/desktop/test") file "/usr/lib/python2.7/urllib.py", line 93, in urlretrieve return _urlopene

scripting - Monitor Drive. Using VB Script -

i want monitor drive file changes, using vbscript. have below code. works fine instancecreationevent , instancedeletionevent . instancemodificationevent not happening. googling got know need use cim_datafile instead of cim_directorycontainsfile monitor instancemodificationevent . not sure how modify code. can help. fyi: 1 script should monitor folders , subfolders in drive. ps: suggestion improve code , performance or other ideas welcome. my code: dim arrfolders dim strcomputer dim objwmiservice dim strfolder dim strcommand dim dim strquery strchangefile = "monitorfolder_log.txt" strmailidfile = "monitorfolder_mailids.txt" 'check if log file exists, if not ceate new file , exit script. restart script again. set ofso = createobject("scripting.filesystemobject") if not ofso.fileexists(strchangefile) 'wscript.echo "change log file not found. creating new file..." set otxtfile = ofso.createtextfile(strch

JavaScript - Cache bookmarklet but always load the latest version -

i'm working on javascript bookmarklet lets users send link website. possible cache bookmarklet reload if new version available? (maybe htaccess?) edit: bookmarklet: javascript:javascript:(function(){new_script=document.createelement('script');new_script.src='https://www.example.com/folder/bookmarklet.js?v=1';document.getelementsbytagname('head')[0].appendchild(new_script);new_script.type='text/javascript';})(); the nature of bookmarklets "cache" irrelevant them: exist entirely within browser's bookmark storage, there no server call (unless write 1 part of bookmarklet code). you have bookmarklet load , check version string website using ajax or jsonp.

c# - Store Primary Key after SQL Query -

following situation: i have asp.net website create vm's in esx environment. user can select settings , click on button create vm. the click-event of button checks values , write ms sql server. table has primary key (integer, identity) don't need insert (because identity ). but need primary key, because redirect user after event page , page needs primary key regular queries (send querystring). currently, make select query direct after insert into query , take last entry. works long 1 user uses page. my question is: is possible recieve identity primary key directly insert into query (like return value function) ? off top of head, @@identity want here. that of course assuming using ms sql server. eg insert xxx.... ; select @@identity edit: as mitch wheat pointed out, @@scope_identity better option @@identity. because @@scope_identity returns id in current scope, whereas @@identity may return id created trigger or udf.

url rewriting - .htaccess is not working in my PHP MVC Framework -

i building own php mvc framework scratch on ubuntu. .htaccess file not working in it. folder structure , .htaccess file content bellow. folder structure /mymvcproject /controllers index.php help.php /libs /modles /views .htaccess index.php .htaccess file content rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l rewriterule ^(.*)$ index.php?url=$1 [qsa,l] when type localh0st/mymvcproject/help gives me following error. not found requested url /mymvcproject/help not found on server. apache/2.2.22 (ubuntu) server @ localh0st port 80 and i'm sure have enabled mod_rewrite. try way , $_request array can url parameter , handle in index.php file. also testing purpose add echo <pre>; print_r($_request); echo </pre>; at first lines of index.php <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_uri} ^/$ [nc] rewrite

javascript - Execute a method whenever some method has finished executing completely -

i've javascript method defined follows: updtcrtedtpage = function() {primefaces.ab({source:'j_id_ev',formid:'j_id_es',process:'typenewlob_in lobidforedit j_id_ev',update:'createlobfullpagepanel',oncomplete:function(xhr,status,args){prepareforcrtedtfullpage();},params:arguments[0]});} i want execute method ( aftercomplete() ) whenever method has finished executing . (this method initiates ajax request & appends received html data on dom). want aftercomplete() method executed whenever ajax response has been received. i cannot directly like: updtcrtedtpage(); aftercomplete(); as call aftercomplete() after ajax request initiated & not finished executing yet. is there js/ jquery way ? you pass aftercomplete parameter function can call when ajax call complete. this... updtcrtedtpage = function(callback) { primefaces.ab({ source:'j_id_ev', formid:'j_id_es', process:'typen

c# - bind item's children control in ItemsControl wpf -

i binding itemscontrol list, in item template there control not binding current datasource, want bind datasource. but stuck @ accessing control my itemscontrol's datatemplate is---> <itemscontrol x:name="itemrequesterlist" istabstop="false"> <itemscontrol.itemtemplate> <datatemplate x:name="itemreqtemplate"> <stackpanel margin="10,0,0,0"> <textblock text="{binding displayname}"></textblock> <textblock text="requested on"></textblock> <textblock text="{binding}"></textblock> //<---this control, // want bind datasource </stackpanel> </datatemplate> so how can access control, lie in each item ? you bind datacontext of control static resource, example: <textblock text=&

Verify my permissions in a MySQL database (or table) -

in job, i've been granted access several databases, not same degree of liberty each of them. few minutes ago, attempting make update operation , got error message: error code: 1142. update command denied user 'clawdidr'@'192.168.1.105' table 'test_table' . db admin isn't around give me information i'm needing, i've figure out myself. so, question arises here is: there way verify on own (with query or else) databases or tables able use select , insert , update or delete operations? try with: show grants current_user

gcc - undefined reference to `lzma_code' -

i try pack application , static link libraries. error.the makefile shown below: cc = gcc incpath = -i/home/johnny/application/filebasedreg/include/realitygrid libs = -l/home/johnny/application/filebasedreg/lib/realitygrid -lreg_steer -l:libxml2.a -l:libncurses.a -l:libm.a -l:libz.a -l:libtermcap.a objects = mini_steerer.o target = mini_steerer ###### compile ###### all: $(target) $(target): $(objects) $(cc) $(incpath) -o $(target) $(objects) $(libs) mini_steerer.o: ./mini_steerer.c ./mini_steerer.h $(cc) -c $(incpath) -o mini_steerer.o ./mini_steerer.c i think need add 1 or 2 more static libraries, can't find are. on debian / ubuntu system, apt-get install liblzma-dev trick. link -llzma.

How to use PHP DOM to output filesize for files listed in the table of an HTML page? -

example.html (huge table contains hundreds of files impossible list of them arrays):- <table> <tbody> <tr> <td class="book"><a class="booklink" href="../file1.pdf" >book1</a></td> <td class="year">2007</td> <td class="pages">32p</td> </tr> <tr> <td class="book"><a class="booklink" href="../file2.pdf" >book2</a></td> <td class="year">2010</td> <td class="pages">12p</td> </tr> <tr> <td class="book"><a class="booklink" href="../file3.pdf" >book3</a></td> <td class="year">2013</td> <td class="pages">42p</td> </tr> <!--------and on... --------&g

zend framework2 - Cannot query a second result set without looping through the first result set -

i having issue zf2 trying use table gateways , getting result sets: i trying query 2 result sets (from 2 different tables/two different gateways) , send them view iterated through , placed on screen. (simplified example): function viewaction() { $table1 = $this->getservicelocator()->get('model\table\table1'); $table2 = $this->getservicelocator()->get('model\table\table2'); return new viewmodel([ 'table1' => $table1->fetchall(), 'table2' => $table2->fetchall() ]); } with model\table\table1 , model\table\table2 having fetch all: public function fetchall() { return $this->tablegateway->select(); } then in view: ... <?php foreach($table1 $row) { echo "<tr><td>{$row['col1']}</td><td>{$row['col2']}</td></tr>"; } ?> ... <?php foreach($table2 $row) { echo "<tr><td>{$row['col1'

php - Iterating through a large db -

i tried using php 5.3 dbase extension, doesn't work reliably large databases on 2 gb. need way iterate through subsection of large dbf , have ability read/edit fields. can done (i use windows)? first attempt: table = dbf.table('myhugedbf.dbf') #is way access dbf data? #i need last 10k records opposed whole 4.5 gb beast table.open() in xrange(len(table)-10000, len(table)): table[i].desc = (table[i].desc).replace("\n","") print "*" + str(table[i].desc) + "*" #for debug purposes table = dbf.table('myhugedbf.dbf') # way access dbf data? # yes. above reads header, though, can basic # info dbf (size, field names, etc.) table.open() # creates data structure 1 (small) element per record record in table[-10000:]: record: record.desc = record.desc.replace('\n','')

javascript - Send jquery array to controller for processing in Symfony2 -

i'm trying send array of row id's controller in order batch update, think did array part (i'm not @ jquery, still learning) have no idea how send controller array contains ids of rows update. here's twig: {% block javascripts %} <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script> $(document).ready(function () { $('#selectall').click(function () { $('.selectedid').prop('checked', ischecked('selectall')); }); }); function ischecked(checkboxid) { var id = '#' + checkboxid; return $(id).is(":checked"); } function resetselectall(id) { // if checkbox selected, check selectall checkbox // , viceversa if ($(".selectedid").length == $(".selectedid:checked").length) { $("#selectall").attr("checked", "checked"); var ids = []; ids.concat(id); } else {

ios - How do I set orientation of a second UIWindow -

i have following code in main viewcontroller viewdidload function window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; nav = [[navwithautorotateviewcontroller alloc] initwithrootviewcontroller:self]; [window addsubview:[nav view]]; [window makekeyandvisible]; [[self navigationcontroller] setnavigationbarhidden:yes]; my ipad app set work in landscape mode , i'm using new window show quicklook document , allowing nav bar provide button , save options document. main problem new uiwindow orientation doesn't match main applications uiwindow. i have custom uinavigationcontroller above called navwithautorotatecontroller , here code controller. -(id)init { if(self) { // _supportedinterfaceorientatoin = uiinterfaceorientationmasklandscape; // _orientation = uiinterfaceorientationlandscapeleft; } return self; } - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwith

how do I use my import package's struct as a type in go -

i'm working in project , using "database/sql" package in go. , want use struct "db" declare in package "database/sql" argument func, can use return value sql.open() , func's argument. possible? codes below: package main import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" ) func main() { var table string = "tablename" db, err := sql.open("mysql", "user:password@/dbname") // read data database read(db, table) } func read(db *db, table string) { // read } this code throws "undefined: db" error. you must use qualifier imported entities - package name 'name' comes from: func read(db *sql.db, table string)

QDialog - Prevent Closing in Python and PyQt -

i have login screen dialog written using pyqt , python , shows dialog pup when runs , can type in certin username , password unlock basicly. it's simple made in learning pyqt. i'm trying take , use somewhere else need know if there way prevent using x button , closing have stay on top of windows cant moved out of way? possible? did research , couldn't find me. edit: as requested here code: from pyqt4 import qtgui class test(qtgui.qdialog): def __init__(self): qtgui.qdialog.__init__(self) self.textusername = qtgui.qlineedit(self) self.textpassword = qtgui.qlineedit(self) self.loginbuton = qtgui.qpushbutton('test login', self) self.loginbuton.clicked.connect(self.login) layout = qtgui.qvboxlayout(self) layout.addwidget(self.textusername) layout.addwidget(self.textpassword) layout.addwidget(self.loginbuton) def login(self): if (sel