Posts

Showing posts from February, 2014

javascript - How to add dynamic events for view? -

how can add dynamic events in view class in backbone.js i have view class var myviewclass = backbone.view.extend({ events: { 'change select': 'changeselect', 'click a.changelink': 'clearselect' }, initialize: function() { this.delegateevents({'click select': 'changeselect'}); }, . . . }); this adding {'click select': 'changeselect'} event, somehow {'click a.changelink': 'clearselect'} doesn't woek. anybody knows solution? thanks, rohan backbone automatically delegates events events attribute of view. overrriding delegated events. can call $(this.el).delegate(...) can this.delegateevents(_.extend(this.events, {'click select': 'changeselect'}));

iphone - uitabbarController view not resizing -

Image
i having navcontroller in next loading tabbarcontrollor. using addsubview add tabbarcontrollor. part of tabbar hidden 1 please tell me whats wrong this. use tabbar controller rootviewcontroller, , set in app delegate. [_window addsubview:rootviewcontroller.view]; when app gets loaded, tab bar controller comes first, , default - first tab! should go view controller of first tab, , in viewdidload of file, use modalviewcontroller use loginviewcontroller . loginviewcontroller *lvc = [[loginviewcontroller alloc]initwithnibname:@"loginviewcontroller" bundle:[nsbundle mainbundle]]; [self presentmodalviewcontroller:lvc animated:no]; [lvc release]; if stage, login view controller pop right after launch app. if login successful, can dismiss it [self dismissmodalviewcontrolleranimated:yes]; if dismiss it, show rootcontroller, tabbarcontroller, , approach used programmers login , stuff.

javascript - Binding a js event according to mouse position : performance killer or not? -

i've done : http://jsfiddle.net/cs273/4/ on fiddle, when mouse reaches right area of text input, changes cursor (pointer) , creates click event listener. when mouse gets out of right area, same event listener destroyed. i call "on fly" event listener binding, perhaps has name. is thing or not ? all things being equal, you'll never notice performance hit, odd way want. i'd suggest re-working html 'x' isn't part of input , can attach normal event handler. example: http://jsfiddle.net/cwolves/cs273/6/

.net - Making a WrapPanel respect his parent's width -

ok here's code. note stackpanel directly in usercontrol. <stackpanel orientation="horizontal"> <scrollviewer width="450" verticalscrollbarvisibility="auto" horizontalscrollbarvisibility="disabled" > <rectangle width="400" height="4000" fill="blanchedalmond"></rectangle> </scrollviewer> <scrollviewer verticalscrollbarvisibility="auto" horizontalscrollbarvisibility="disabled" > <itemscontrol borderbrush="green" borderthickness="2" itemssource="{binding path=myobservablecollection}" itemtemplate="{staticresource fattemplate}" > <itemscontrol.itemspanel> <itemspaneltemplate> <wrappanel orientation="horizontal" ...

php - Problem with code to show ads to search engine visitors only -

there plugin (for wordpress) show ads search engine visitors only.. person able modify code shows ads if land , click page...but doesnt appear on landing page. can me know whats wrong on code? function wp_ozh_wsa_is_fromsearchengine($doset = false) { global $wp_ozh_wsa; $ref = $_server['http_referer']; $yes = false; if (isset($wp_ozh_wsa['my_search_engines'])) { $se = $wp_ozh_wsa['my_search_engines']; } else { $se = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.', ); } foreach ($se $url) { if (strpos($ref,$url)!==false) { if ($doset) { $url = parse_url(get_option('home')); setcookie('wsas', 'yes', time() + 60*60, $url['path'] . '/'); } } } if (isset($_cookie['wsas'])) { return true; } return false; } ...

grails - IntelliJ Idea 10 is picking up old compiled classes. I cannot clean them -

i using intellijidea 10.0.3 grails application , of sudden when run app picks , old compiled class. tried doing grailsclean several times, , appears clean successfully. however, when run application , access known screen still shows old hard coded value no longer have anywhere in application. tried make , rebuild project, not success either. anybody know how can solve without renaming class? thanks lot frustrating , slowing me down tremendously. try 10.5.1 update, may fix problem. if doesn't, can enable clean output directory on rebuild in settings | compiler , rebuild again. contact support sample project , steps reproduce if cannot resolve it.

Java File.list() consistent order? -

this awful question (in mind) , i've tried best find myself useful documentation little luck - anyway, here goes: i have code needs operation on files in directory. set directory in file object , use fileobject.list() iterate on files in directory. left code running overnight , (after chugging) crashed @ point. i'm trying figure out @ point happened (yes had awful logging). now, according this javadoc there no guarantee of order (alphabetical or otherwise) when listing files, i'm wondering if there guarantee of consistency? meaning when run same code twice, exact same order of files? logic tells me should , i've resumed operations based on i'm suspicious of this. also, i'm curious on 'no specific order means' javadoc. that language means should not rely on property of order including consistency run run. if there linked list of files in in-memory data structure, driver might move accessed front of list optimize repeated file access. m...

jQuery - Not this or prev or next? -

how can select divs of class except 'this', , not next , previous div? code below selects except 'this': $(".image-div").not(this).each(function() { $(this).animate({ width: '250px' }, 500, function() { // animation complete. }); } }); thanks update - here full code: $(".image-div").click(function () { if ($(this).css('width') != '500px') { $(this).animate({ width: '500px' }, 500, function() { // animation complete. }); $(this).prev().animate({ width: '125px' }, 500, function() { // animation complete. }); $(this).next().animate({ width: '125px' }, 500, function() { // animation complete. }); } else { $(this).animate({ ...

python - How do I keep score in a rock paper scissors game? -

i'm starting python , writing simple rock paper scissors game. here's have far. can play game player perfectly. want know how keep score of wins, if player 1 wins first game say: player 1 = 1 player 2 = 0 and on. if there's tips make code more efficient (with nice explanation), nice. thanks! consider pseudo-code suggestions (some parts need implemented): # player class. should have name , score class player(): def __init__(name): self.name = name self.score = 0 # displays prompt , reads in players name returning string def getplayername(): # needs code here, see next function idea of pass # ask player make choice, takes player object # , returns string def getplayerattack(player): print "%s, choose?" % player.name return raw_input("> ") # determines wins , updates score accordingly # takes in player objects , attack choices def attack(player1, choice1, player2, choice2): if choice1 == choice2:...

linux - How can I disable to be my open source software recompiled for windows? -

i want build open source software e.g. linux don't want able recompile (rebuild) windows else. possible ? (please don't leave questions why don't want give windows' users too.) porting software linux windows can hard . if examples of when , why it's hard, , choose include these in code, might make harder people port code windows. but making impossible impossible . a lot of work has been done of excellent linux tools , applications windows. gnu tools have windows version, , semi-emulators cygwin enormously too. linux being free, , windows users being able run linux in (free) virtual machine , can still execute application way, too.

eclipse - Create a GWT Maven Project -

i'm trying create new project eclipse in order create gwt application under maven 2 system. have create project follow mvn command mvn archetype:generate -darchetyperepository=repo1.maven.org -darchetypegroupid=org.codehaus.mojo -darchetypeartifactid=gwt-maven-plugin -darchetypeversion=2.3.0 i have installed follow eclipse plugins: * m2eclipse * egit * gwt plugin here pom file: <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <!-- pom file generated gwt webappcreator --> <modelversion>4.0.0</modelversion> <groupid>com.mobc3.paperquid</groupid> <artifactid>backoffice</artifactid> <packaging>war</packaging> <version>1.0.0-snapshot</version> ...

c++ - Round Double and Cast to String -

i suppose question follow previous question had regarding casting double string. i have api i'm given string represents number. need round number 2 decimals of precision , return string. attempt follows: void formatpercentcommon(std::string& percent, const std::string& value, config& config) { double number = boost::lexical_cast<double>(value); if (config.total == 0) { std::ostringstream err; err << "cannot calculate percent 0 total."; throw std::runtime_error(err.str()); } number = (number/config.total)*100; // format string return 2 decimals of precision number = floor(number*100 + .5)/100; percent = boost::lexical_cast<std::string>(number); return; } unfortunately cast captures "unrounded" values. (i.e. number = 30.63, percent = 30.629999999999) can suggest clean way round double , cast string 1 naturally want? thanks in advance help. :) stream...

web services - Amazon S3 Signed URL in PHP -

this function pulled out of old wp plugin returning signed amazon s3 url, can't work! when visit signed url returns, this: the request signature calculated not match signature provided. check key , signing method. function s3url($text) { $aws_s3_key = 'key'; $aws_s3_secret = 'secret'; $tag_pattern = '/(\[s3 bucket\=(.*?)\ text\=(.*?)\](.*?)\[\/s3\])/i'; define("aws_s3_key", $aws_s3_key); // replace aws s3 key define("aws_s3_secret", $aws_s3_secret); // replace secret key. $expires = time()+get_option('expire_seconds'); if (preg_match_all ($tag_pattern, $text, $matches)) { ($m=0; $m<count($matches[0]); $m++) { $bucket = $matches[2][$m]; $link_text = $matches[3][$m]; $resource = $matches[4][$m]; $string_to_sign = "get\n\n\n$expires\n/".str_replace(".s3.amazonaws.com","",$bucket)."/$resource"; ...

vbscript - VBS check for the output of netstat -

i created check: ' check if windows or mac if not objfso.folderexists("\\client\c$\.") wscript.quit end if that check see if windows system or not. if windows machine run script if not want exit. need check make sure both conditions true not sure how. there output using netstat command. under local address there address has port 1494 machine name of cag.domain.com. how can include check both parts must true run script if not script closes. if \client\c$. = true , local address :1494 , foreign address = cag.domain.com = false script not run. i'm not @ windows machine can't give right parameters netstat nor correct regex pattern check output of netstat i'd along lines of: dim wshshell, oexec set wshshell = createobject("wscript.shell") set myregexp = new regexp myregexp.ignorecase = true myregexp.global = true myregexp.pattern = ":1497[ ]cag[.]domain[.]com" set oexec = wshshell.exec("netstat -a") 'wait ...

android - Can I make the entire activity scroll instead of the ListView? -

i'm populating activity listview exceeds window size vertically. instead of user being able scroll listview, want listview take space needs , let users scroll in activity instead. possible? here image clarification: http://imgur.com/1i2bc on both sides there listview containing 8 elements, right 1 takes space needs show list though, pushing other views down , making entire activity scrollable. you need use methods addheaderview , addfooterview add views before , after listview. to add several views, first put views in layout or viewgroup , add viewgroup header or footer view (viewgroup subclass of view).

c# - Display small image catalog in asp -

hi want put products catalog, how can crop picture small , save small , orginal? try here: c# thumbnail image getthumbnailimage or here: convert bitmap thumbnail create thumbnail , reduce image size create thumbnail image update for example can save image folder , can this: var filename = "sourceimage.png"; using(var image = image.fromfile(filename)) { using(var thumbnail = image.getthumbnailimage(20/*width*/, 40/*height*/, null, intptr.zero)) { thumbnail.save("thumb.png"); } } update to resize proportionally try this: public bitmap proportionallyresizebitmap (bitmap src, int maxwidth, int maxheight) { // original dimensions int w = src.width; int h = src.height; // longest , shortest dimension int longestdimension = (w>h)?w: h; int shortestdimension = (w<h)?w: h; // propotionality float factor = ((float)longestdimension) / shortestdimension; // default width greater height double newwidth = maxwid...

tortoisesvn - SVN Rename Folder in branch, Conflict -

i have branch in folder renamed. i'm trying merge changes trunk branch, files modified in trunk still under original folder name, svn throws tree conflict. how can resolve this? the folder renamed using svn rename. this case merge give tree conflict complete merge. shortcut avoid conflict , merge code that, after merging complete trunk branch ... ignoring tree conflict , merge individual folder(s). eg: /trunk /foldera /folderb /folderc /branhes /branch1 /foldera /folderb /renamed folder (previously folder c) merge /trunk /branches/branch1 merge /trunk/folderc /branches/branch1/renamed folder cheers!!

c# - Format data in the UpdatePanel before save -

i'm using updatepanel in asp.net webforms upload image. want save filename in database, not path. i'm using following code <asp:templatefield footertext="image 1" headertext="image 1"> <itemtemplate> <asp:image id="image11" runat="server" imageurl='<%# bind("pic") %>' height="50px" onerror="this.style.display='none'" /> </itemtemplate> <edititemtemplate> <asp:updatepanel id="updatpanelimg1" updatemode="conditional" runat="server"> <triggers> <asp:postbacktrigger controlid="uploadbutton" /> </triggers> <contenttemplate> <asp:fileupload id="fileupload1" runat="server" /> <asp:button runat="server" text="add image" onclick="uploadbuttoncli...

java - MenuItem in blackberry application -

i use menuitems in application , have question run method override. private menuitem menuitemupdate = new menuitem("update", 0, 0) { public void run() { // can write gui code here? } }; as comment states, can write gui code here? can`t right? since not on gui thread? should use invokelater-method when have code changes gui? , dialogs, should invoked in invokelater-methods well? and necassary override run-method of menuitem if have made thread invoked when user selects menu item? start thread in constructor instead? , leave run method un-overridden? you can write ui code there, because ui thread handles user's actions, , calls menu item code. user interaction handled ui thread.

Oracle/SQL - Join one table multiple times to the same table -

i'm trying wrap brain around query , hoping can help. have 2 tables: customer_table , product_table this name sku_num1 sku_num2 sku_num3 sku_num4 ---------------------------------------------------- bob b c d frank e tom g shelly g e justin e g sku_num widget_name ------------------- widget_a b widget_b c widget_c d widget_d so want return list of customers have @ least 1 product sku appears in product table. above information receive records for bob frank justin any ideas how this? there no need join 1 table twice: select * customers sku_num1 in (select sku_num product_table) or sku_num2 in (select sku_num product_table) .... the reason why need multiple conditions full table scan on product_table wrong database design. products customer bought should not go multip...

Rails: Dividing up a single database between multiple subdomains -

i'm relatively new rails, , here situation: i'm building inventory management app rails 3 separate branches of company manage own product inventory. each of these 3 branches keeping track of same products, use same data models, managed separately. plan build single app using single database, 1 keeps track of inventory in 3 branches. my plan have this: branch1.inventoryapp.com branch2.inventoryapp.com branch3.inventoryapp.com each subdomain lead same interface same functions , same views. difference actual content of inventory, list of products physically @ branch @ time. will able rails subdomain routing? should have separate controllers each branch? should use controller namespaces? nested resources? thanks in advance! in application_controller, simply: class applicationcontroller < actioncontroller::base before_filter :current_account helper_method :current_account def current_account @account ||= account.find_by_domain(reque...

php - While loop only retrieving one result -

update: still can't seem figure out. if can lend hand, appreciated ^^. i having problem , i'm not sure code breaking down. have 'follow' function can follow different registered users. userid's of followed stored in array (follower_array). it's retrieving each member array, of each member that's followed instead of displaying content, it's displaying 1 latest 1 each member. $broadcastlist= ""; if ( $follower_array != "" ) { $followarray = explode(",", $follower_array); $followcount = count($followarray); $i = 0; $broadcastlist .= "<table>"; foreach( $followarray $key => $value ) { $i++; $sqlname = mysql_query(" select username, fullname members id='$value' limit 1 ") or die ("error!"); while ( $row = mysql_fetch_array($sqlname) ) { $friendusername = substr($row["username"],0,12); ...

java - Library for canonicalizing (normalizing but NOT just cleansing) email addresses -

there multiple ways produce email address strings differ straight string comparison (see below), logically equivalent (i.e. mail sent both goes same mail box). allows users give seemingly unique email addresses, if strict equality disallowed. i hoping find library try normalization, allow finding of duplicates large sets of email addresses. goal here find many duplicates possible. given how useful multiple purposes (in case simple abuse detection, abuse accounts tend (try to) reuse accounts), thinking there might existing solutions. so kind of things can vary? know of @ least things like: domain name part case-insensitive (as per dns); local part may or may not be, depends on mail provider (for example, gmail considers case-insensitive) many domains have aliases (googlemail.com equivalent gmail.com) some email providers allow other variations ignore (gmail, example, ignores dots in email address!) ideally in java, although scripting languages work (command-line tool) ...

php query database print to html table with headers -

i have never programmed in php before , haven't touched html in 10 years. use help. querying postgresql database using php. trying display query results in table format headers this: first_name last_name employee_id tom jones 111 bob barker 112 bill davis 113 sample code trying work correctly: echo("<table border=2"); while ($line = pg_fetch_array($result, null, pgsql_assoc)) { foreach ($line $col_value => $row_value) { echo("<tr><td>$col_value</td><td>$row_value</td></tr>\n"); } } echo("</table>"); my formatting being displayed this: first_name tom last_name jones employee_id 111 first_name bob last_name barker employee_id 112 first_name bill last_name davis employee_id 113 as can see storing query in associative array. thanks help. echo("<table border=2><tr><td>first_name</td><td>...

jquery - REST api authentication through json -

i'm trying simple rest api in cakephp app, using rest plugin found, authorization uses http headers. my question is, how can supply through jquery using json, header example: authorization: truerest username=wwwww&password=zzzzz&apikey=xxxxxyyyyyyy $.ajax({ // ... beforesend: function(x) { x.setrequestheader('authorization', 'truerest username=wwwww&password=zzzzz&apikey=xxxxxyyyyyyy'); }, // ... }); docs: http://api.jquery.com/jquery.ajax/

asp.net mvc 3 - Asp MVC3 one to many Create and View -

i can not figure out way create 1 many model in single view, ? in model, include "many". example public class parent { public int parentid; } public class child { public int childid; public int parentid; } then create view model public class parentviewmodel { parent p; ienumerable c; } then iterate foreach(var child in model.c) on view

office365 - Office 365 development API like Google Docs? -

is there office 365 development api google docs? searching web unable find. there's api exchange part of office 365. lync has api. can managed sharepoint sites via client object model , web services or webdav apis uploading , downloading files however don't believe there's manipulating documents online outside of using webdav push sharepoint site.

asp.net mvc - What does the RTM in MVC 3 RTM standfor -

i found mvc 3 rtm project on codeplex. rtm stand for? , source code suppose match used mvc 3 today? it stands "release market". beleive final stage when got ctp, beta, rtm. ctp community tech preview (limited release techs care , give feedback.)

ruby on rails - .htaccess rewrite frustrations -

i made website in php , used parameters page/product identification. ex.) http://mysite.com/?pid=my_products&sid=golf_clubs&gtin=111111111111 i've moved on using ror , i'd set redirects clean urls http://mysite.com/my_products/golf_clubs/111111111111 i've looked @ tutorials , arrived @ this: rewriterule ^([^/]+)/([^/]+)/([^/]+)$ ?pid=$1&sid=$2&gtin=$3 [nc] i've tested url , doesn't redirect @ all. i've tried putting in .htaccess file debug , chmodded log folder 775 500 error: rewritelog "/home/myaccount/rails_apps/myapp/log/rewrite.log" rewriteloglevel 3 as far rewrite statements in .htaccess goes, have: rewriteengine on rewritelog "/home/myaccount/rails_apps/myapp/log/rewrite.log" rewriteloglevel 3 rewritebase / rewritecond %{request_uri} ^/downloads.* rewriterule .* - [l] rewriterule ^([^/]+)/([^/]+)/([^/]+)$ pid=$1&sid=$2&gtin=$3 [nc] rewriterule ^$ index.html [qsa] rewriterule ^([^.]+)$ $1....

javascript - In Express.js, how do I make my template display the flash messages? -

app.get('/',function(req,res){ res.render('home'); // want template able access flash message.. }); app.get('/go',function(req,res){ req.flash("info", "you went go, , got redirected home!"); res.redirect('/'); }); the user first goes "/go". after that, redirected "/" , want flash message show javascript alert. how can that? add local call render: res.render("home", {info: req.flash("info")}); and use in template: #flash p= info

python - Validating URL paramaters -

how should 1 validate url parameters in view? accomplished using a bunch of ìf statements or there better way go it? i'd validate parameters when request comes in rather having scattered across view, model , manager. when validation i'm referring basic checks such existence of key, checking data type, integer ranges, etc. thanks. i think in case depends on scale of application if it's small application doing data validation via simple if statements easiest route, django have features support nicer form validation( https://docs.djangoproject.com/en/1.3/ref/forms/validation/ ), might cleaner way, still boils down if statements in end.

osx - link error with fcntl in macos -

there code sinppet using fcntl, goes trouble when linking: #include <poll.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <fcntl.h> int main() { struct addrinfo hints, *ai, *cur_ai; int port, fd = -1; memset(&hints, 0, sizeof(hints)); hints.ai_family = af_unspec; hints.ai_socktype = sock_stream; char portstr[10]; char hostname[] = "www.google.com"; snprintf(portstr, sizeof(portstr), "%d", port); int ret = getaddrinfo(hostname, portstr, &hints, &ai); if(ret) { printf("die"); return ; } printf("getaddrinfo !!!"); cur_ai = ai; fd = socket(cur_ai->ai_family, cur_ai->ai_socktype, cur_ai->ai_protocol); fcntl(fd, f_setfl, fcnt(fd, f_getfl) | o_nonblock); ret = connect(fd, cur_ai-...

how to change the background or the image source when a clickable imageview in android is clicked? -

i set android:clickable="true" imageview in android app. want change background or image source when clicked, how that? try this: myimageview.setonclicklistener(myonclickhandler); and write handler like: onclicklistener myonclickhandler = new onclicklistener() { @override public void onclick(view v) { myimageview.setimageresource(r.id.imageview1); myimageview.setbackgroundresource(r.id.imageview2); //myimageview.setimagebitmap(bm); //myimageview.setimagedrawable(r.drawable.image1); } };

How do I access an JSON array with boost::property_tree? -

int main(int argc, char *argv[]) { qcoreapplication a(argc, argv); // string s = "{\"age\":23,\"study\":{\"language\":{\"one\":\"chinese\",\"subject\":[{\"one\":\"china\"},{\"two\":\"eglish\"}]}}}"; string s = "{\"age\" : 26,\"person\":[{\"id\":1,\"study\":[{\"language\":\"chinese\"},{\"language1\":\"chinese1\"}],\"name\":\"chen\"},{\"id\":2,\"name\":\"zhang\"}],\"name\" : \"huchao\"}"; ptree pt; stringstream stream(s); read_json<ptree>( stream, pt); int s1=pt.get<int>("age"); cout<<s1<<endl; string s2 = pt.get<string>("person."".study."".language1"); cout<<s2<<endl; now want value of langu...

inversion of control - Solution-Architecture using Castle.Windsor Installers -

i've been doing quite lot of research introducing dependency injection framework organisation - better late never! far research has focussed heavily on castle.windsor. research has led me concepts such installers, interceptors (specifically logging cross-cutting concern), , facilities, of plan on using. my question how structure solution (my project architecture in visual studio) di framework replaced @ point in future (perhaps if better comes along in 2 years time). i'm developing framework library organisation uses common-service-locator service location, configuration of container? if put installers in same project service implementations, front-end project need reference these projects (assuming fluent configuration) when configure container installers. these service implementations data-access-layer concerns, dont want front-end referencing specific layer (to 100% ensure no leakage of concerns). i haven't found addressing question, i'm thinking might on...

apache - Permission access to php page -

i have website on 1 host(host a) , website include iframe (on host b). from iframe go 1 of pages host a, error you don't have permission access /pages/online.php on server. additionally, 404 not found error encountered while trying use errordocument handle request. how can fix that? worked when using server. apache error logs: [fri jul 01 03:24:37 2011] [error] [client some-ip-here] file not exist: /home/etcorg/public_html/proba/500.shtml, referer: proba.etc.org.rs/pages [fri jul 01 03:24:37 2011] [error] [client x.x.x.x] softexception in application.cpp:256: file "/home/etcorg/public_html/proba/pages/online.php" writeable group, referer: somepage.com i think host has program checks permissions aren't set high (over 644). error. change rights 644 files , 755 directories.

php - Error 500 - Internal server error And Cart is not showing products with success message Magento -

Image
i keep receiving error on magento pages in frontend , back-end. error 500 - internal server error internal server error has occured! please try again later. in front-end pages working fine when hit proceed checkout showing error , url /index.php/checkout/onepage/ . my cart not showing products in when add cart. shows empty cart message product has been added in cart , button proceed checkout or continue shopping. what causes? ho go this? it's hard what's going on based solely on 500. magento has behaviour of shielding real issue @ hand avoid exposing vulnerabilities end-users. in order find out what's going on you'd have real error report. i can think of 4 ways find out what's going on: check magento logs, can find these in magento_root/var/log check error report has been generated error. i'm not 100% sure if magento versions generate these, might have enabled somewhere. if being made, appear in magento_root/var/report check...

PERL -- Regex incl all hash keys (sorted) + deleting empty fields from $_ in file read -

i'm working on program , have couple of questions, hope can help: first need access file , retrieve specific information according index obtained previous step, in indexes retrieve found , store in hash. i've been looking way include array elements in regex can use in file search, haven´t been able make work. i've found way works: my @atoms = (); $natoms=0; foreach $atomi (keys %{$atome}){ push (@atoms,$atomi); $natoms++; } @atoms = sort {$b cmp $a} @atoms; and use regex way: while (<in_lig>){ if (!$natoms) {last;} ...... if ($_ =~ m/^\s*$atoms[$natoms-1]\s+/){ $natoms--; ..... } is there way create regex expression include hash keys? numeric , must sorted. keys refer line index in in_lig, content this: 8 c5 9.9153 2.3814 -8.6988 c.ar 1 mlk -0.1500 the key found in column 0 (8). have added ^ , \s+ make sure refers first column. my second problem input files not identical , make contain white spaces before ind...

jquery - Can i fire or execute a javascript function on the change of class on object? -

i want execute function when element 's class updated (any new class add or remove). how can in jquery you'll need set custom event. //function receive event $('#foo').bind('class_change', function() { alert("class changed"); }); //use trigger() fire custom event $('#foo').addclass("newclass").trigger('class_change'); $('#foo').removeclass("newclass").trigger('class_change');

ruby - how to access variables in the "default" scope -

how access var in "default" scope in other class definition , this? var = 1 class myclass def self.show var end myclass.show #=> 1 and btw notice self in "default" scope return main , what's this? it's not possible. variables defined var = ... local variables. defining global variable done $var = ... . another more hacky approach defining instance variable ( @var = ... ), require somehow main instance myclass.show doesn't seem worth work.

Coloring specific cells with Excel VBA off by one cell -

i'm generating excel worksheet based on entries in userform. 1 entry reporting interval on project duration. let's reporting interval 3 months , duration of phase2 10 months , phase3 3 months. my columns structured distance of 1 cell between phases: phase1: starting phase phase2: working phase phase3: closing phase phase1 phase2 phase3 |||||| ||||||||||||||||||||||||||| |||||| the reporting intervals should marked colored cells in phase2 , phase3 this: phase1 phase2 phase3 |||||| |||||||o|||||||||||o|||||||| ||o|||| this code color cells: for x = 1 (implementationduration + closingduration - 1) / 3 select case x case < implementationduration: call setfontandbackground(cells(rowindex, phase1celllast() + columncounter * 3), cells(rowindex, phase1celllast() + columncounter * 3), false, false, "", 10, false, "b", "lcyan", false) ...

asp.net - jQuery button not showed as a jQuery button in a tabbed page -

Image
i have button in jquery tabbed page declared this: <input id="buttonsave" type="submit" value="save" /> i have script below: $('#buttonsave').button(); $("#buttonsave").live('click', function () { alert('button clicked'); }); when button clicked have message 'button clicked'. that's ok. button has not look'n feel of jquery button. any idea? to clear, add here screenshots. below can see page tabbed page @ bottom. i trigger script below in order render buttons jquery buttons: $(":button").button(); this script update page showed below: as can see, button located on main page rendered jquery. others buttons (located on tabbed page) didn't render correctly. try this: change live function bind . if don't see 'button clicked' message, try put script after html code.

python - make ChoiceField() take any value -

i'm using forms framework , i'm using of javascript magic inject values on fly select box (the values of select box relies on value form another). basically have team , players. need define player, players data comes team. in form class have team = forms.modelchoicefield(queryset=team.objects.all() player = forms.choicefield() in front end when user selects team select box, (empty) players boxes gets correctly updated new data. when hit submit, player select box throws error select valid choice. 2 not 1 of available choices. 2 valid choice however. is there way around this? can make choicefield() take value? ordered complexity desc: prepopulate possible choices. example, if select player's id, choices = player.objects.values_list('id', flat=true) define charfield , render manually in template select box. don't define in form, pass it's value form's constructor (which need override process value.)

regex - JAVA: replaceAll reg pattern -

considering following string: string s = "/static/201105-3805-somerandom/images/optional-folder/filename.gif"; how can remove "static/201105-3805-somerandom/" part? "201105-3805-somerandom" part random composed of: - 6 digits - "-" char - {1, n} digit chars - "-" char - {1, n} digit , letter chars if use "/static/[0-9]*-[0-9]*-*/"; , replaces last / instead of 1 after "{1, n} digit , letter chars", missing? s = s.replaceall("^/static/\\d{6}-\\d{1,}-.*?/","")

layout - WPF Drag Drop Panel (like iGoogle, BBC website, blacklight) -

does know of control libraries provide layout management functionality along lines of igoogle, bbc website or blacklight drag drop panel? blacklight drag drop panel fantastic, project seems have been removed codeplex. i'm looking sexy drag & drop layout manager include in wpf application, , none of regular control vendors such devexpress, infragistics or telerik include want. provide visual studio style dock manager, feels clunky , difficult use. want users able naturally drag , drop 'widgets' without fighting dock manager. see here examples of type of control i'm looking for: http://mightymeaty.members.winisp.net/blacklight.silverlight/ http://10rem.net/blog/2011/06/27/marketsplus-evolve-ux-inspiration-from-a-great-silverlight-application i developed marketsplus evolve 1 (the silverlight app used example). couldn't find controls after, searched quite while before ended building our own. isn't perfect answer, it's pretty unlikely ...

Is it possible to log message to cmd.exe in C#/.Net? -

is possible log message winforms app cmd.exe process started programmatically? i've tried kinds of variations of following code: private void button1_click(object sender, eventargs e) { log("button has been pressed"); } private void log(string message) { var process = process.start(new processstartinfo("cmd.exe", @"/k ""more""") { useshellexecute = false, redirectstandardinput = true, }); process.standardinput.writeline(message); } unfortunately, console window blinks half of second , that's it. please don't answer want do, because right i'm curious if it's possible :) you're in luck. solved code generator toy project had floating around here. using attachconsole or allocconsole win32 api's can achieve result, using system.console.writeline (or read, or error.writeline etc) would. the following snippet figures out when forms app started console wi...

translation from Datalog to SQL -

i still thinking on how translate recursivity of datalog program sql, such as p(x,y) <- q(x,y). q(x,y) <- p(x,z), a(y). where a/1 edb predicate. this, there co-dependency between p , q . longer queries, how solve problem? moreover, there system implement translation? if there is, may know system or paper may refer? if adopt approach of "tabling" previous conclusions , forward-chain reasoning on these infer new conclusions, no recursive "depth" required. bear in mind datalog requires restrictions on rules , variable assure finite termination , hence finitely many conclusions. variables must have finite range of possible values, example. let's assume example refers constants rather variables: p(x,y) <- q(x,y). q(x,y) <- p(x,z), a(y). one wrinkle want a/1 implemented extended stored procedure or external code. propose tabling results of calling a on possible arguments (finitely many). these after among conclusions (prov...

ASP.NET Why is this shortening url code redirecting to page -

hey have following method public static string getshortenedurl(string inurl) { string shorturl = ""; string queryurl = "http://api.bit.ly/shorten?version=2.0.1&longurl=" + inurl + "&login=&apikey="; httpwebrequest request = webrequest.create(queryurl) httpwebrequest; using (httpwebresponse response = request.getresponse() httpwebresponse) { streamreader reader = new streamreader(response.getresponsestream()); string jsonresults = reader.readtoend(); int indexofbefore = jsonresults.indexof("shorturl\": \"") + 12; int indexofafter = jsonresults.indexof("\"", indexofbefore); shorturl = jsonresults.substring(indexofbefore, indexofafter - indexofbefore); } return shorturl; } which worked fine on development machine, on live server reason whenever call method seems visit url aswell. reason why problem because url updates status of record...

java - Sort a map on key and value -

i want sort map on key , value. first on key on value. example, should result; 1,2 1,3 2,1 2,2 anyone has suggestion on how achieve effectively? i've been seeing people using treemap sort keys, need values. or ofcouse other method of sorting pairs on key , value welcome. import java.util.sortedset; import java.util.treeset; public class sortmaponkeyandvalue { public static void main(string[] args) { sortedset<keyvaluepair> sortedset = new treeset<keyvaluepair>(); sortedset.add(new keyvaluepair(1, 2)); sortedset.add(new keyvaluepair(2, 2)); sortedset.add(new keyvaluepair(1, 3)); sortedset.add(new keyvaluepair(2, 1)); (keyvaluepair keyvaluepair : sortedset) { system.out.println(keyvaluepair.key+","+keyvaluepair.value); } } } class keyvaluepair implements comparable<keyvaluepair>{ int key, value; public keyvaluepair(int key, int value) { super(...

Merging two arrays in PostgreSQL as index and value? -

assuming have 2 array fields in table, this: column | type | --------+-----------+ index | integer[] | value | integer[] | where both index , value equal in length, , values in 'index' guaranteed unique, example: select * arraytest; index | value -----------+----------------------------------- {1,3,5,6} | {100, 103, 105, 106} how make query returns new array, values in 'index' used array indexes, , values in 'value' become values associated given index, i.e. like: select some_array_function(index, value) newarray; new_array -------------------------------- {100, null, 103, null, 105, 106} what want achieve same array_combine in php. while overall bad idea store data this, 1 way use unnest function , process results on client side: select unnest(index), unnest(value) arraytest; unnest | unnest --------+-------- 1 | 100 3 | 103 5 | 105 6 | 106 if must hav...

opengl - glDrawArray+VBO increasing memory footprint -

i writing windows based opengl viewer application. using vbo + triangle strip + gldrawarrays method render meshes. every thing working on machines. in case of windows desktop nvidia quadro cards working/peak working memory shoots when first call gldrawarray. while in case of laptops having nvidia mobile graphic cards working memory or peak working memory not shoot. since last few days checking forums/post/tuts vbo memory issue. tried combinations of vbo gl_static_draw/dynamic/stream, glmapbuffer/glunmapbuffer. nothing stops shooting memory on desktops. suspect vbo ogl 1.5 missing flags. ps: have 500 600 vbo's in application. using array of structures ( i.e. v,n,c,t in structure). , not aligning vbos 16k memory. can 1 suggest me how should go ahead solve issue. hints/pointers helpful. do run out of memory or application increasingly consume memory? if not, why bother? if opengl implementation keeps working copy itself, reason. there's little can on opengl side avoi...

iphone - Getting length of an array inside a Dictionary Key -

i'm sure obvious question i'm not getting anywhere , i've been trying half hour or now. i have nsmutabledictionary has keys & values, obviously. each key stores array of objects. need find specific array in key , list of array. catch don't know value of key, know it's index. (eg: know need find array in 2nd key). i easy & trivial thing it's escaping me, i've been doing obj-c short while not entirely @ home yet! thanks, jack. use allkeys: access keys of dictionary. - (nsarray *)allkeys use below . nsarray* dictallkeys = [dict allkeys]; if([dictallkeys count] > 2) { nsarray* myarrayindict = [dict objectforkey:[dictallkeys objectatindex:1]]; // length of array in dict @ 2nd key int length = [myarrayindict count]; }

Crystal-Reports XI - sub report unwilling to split over two pages -

i have checked , "keep together" not ticked. have un-checked within details section of sub report still makes no difference + have tried "blank page before" option formula of 1 = 2 had no joy ...any thoughts? i know old post, of else looking same answer: go format subreport, uncheck keep on common tab.

Javascript memory leak in simple code -

i'm having kind of memory problem in javascript code. i've been searching online memory leak patterns in javascript, none of patterns seem apply code. it's simple code, there no closures, don't have internal functions, variables merely hold simple values, dom objects or booleans, don't define properties in variables. yet somehow manage leak memory firefox (3.6.11) freezes , ie tells me i'm running out of memory @ line 73, i've marked line. functions there references in dom tree toggle, replyform , replyexpand. <script type="text/javascript"> function toggle(expandable){ if(expandable.parentnode.getelementsbytagname("ul")[0].classname=="hide"){ expandable.parentnode.getelementsbytagname("ul")[0].classname="show"; expandable.innerhtml="▼"; } else{ expandable.parentnode.getelementsbytagname("ul")[0].classname="hide"; expand...

How can django debug toolbar be set to work for just some users? -

right away: yes know internal_ips. i'm have django app opened @ work integration , testing. know there debugging , plenty modifications and/or optimizations made i'd love have django debug toolbar . however, i'd prefer not have of co-workers (who 'clients'). the reason internal_ip setting doens't work me (btw: have static ip on development computer) using nginx reverse-proxy , serving gunicorn . because of reverse-proxy, using internal_ip of 127.0.0.1 shows djdt computer on network , using ip way i've been able see myself. what i'm looking either way ip or login name 1 access toolbar. once saw thread user name limited access can't find it... and side question- know why toolbar doesn't render in ie? me shows tables on bottom of page. try: def show_toolbar(request): return not request.is_ajax() , request.user , request.user.username == "yourusername" debug_toolbar_config = { 'show_toolbar_callback...

jquery - How to control frame height and width in chrome extension? -

Image
i working chrome extension. here in button click required open menu. when toolbar loaded in memory make space menu item want remove in page load. assuming there no visible elements taller 100px on popup page: document.body.style.height="100px"; document.getelementsbytagname("html")[0].style.height="100px"; if doesn't work element still considered visible (chrome picky this). the best way figure out use popup inspector. right click on popup icon, select "inspect pop-up". set height <html> , <body> elements set height container div play height , overflow:hidden , float:left , display:none on container div , children until popup shrinks required height

Bash: Brace expansion in scripts not working due to unwanted escaping -

i want in bash script. i'm using bash 4.1.10 . # rm -rf /some/path/{folder1,folder2,folder3} works nicely (and expected) shell itself. deletes 3 desired folders leaving others untouched. when put script unwanted happens. example, script: #!/bin/bash set -x var="folder1,folder2,folder3" rm -rf /some/path/{$var} when execute script, folders not deleted. i think due fact unwanted quoting occurring. output script using #!/bin/bash -x : rm -rf '/some/path/{folder1,folder2,folder3}' which of course cannot succeed due ' marks. how can working within script? according the man page : the order of expansions is: brace expansion, tilde expansion, parameter, variable , arithmetic expansion , command substitution (done in left-to-right fashion), word splitting, , pathname expansion. so around this, add level of expansion: eval "rm -rf /some/path/{$var}"

iphone - Monotouch UITabBarController + UINavigationController -

i'm getting little lost trying use both uitabbarcontroller , uinavigationcontroller in monotouch. i can create navigation based project, , navigate using navigationcontroller, fine. or can add tabbarcontroller , navigating couple of main screens, fine. however, can't seem navigate without using tabbarcontroller if 1 present. e.g, i'm doing app deals "foo", 2 views on tabbar, foohome, , foosettings. how navigate new view if user click "add foo" on foosettings view. the navigationcontroller.pushtoview doesn't seem have effect, , don't want add view tabcontroller since nice , simple 2 items. should using this.view.addsubview? idea sort of sounds dialog box, i'm not sure how monotouch... add foohome , foosettings controllers uinavigationcontrollers , set navigation controllers tab controller. so example, first tab contain navigation controller root controller foohome , second tab contain navigation controller root controlle...

java - Query Android's SQLiteDatabase using Regex -

i trying fetch entries sqlitedatabase in android program using query function using selection parameter. have had success simple pattern matching using sqlite's , % wildcard. want more complex pattern matching using regular expressions. according sqlite website , regexp operator function, must user defined. has had success creating use defined sqlite functions android's sqlitedatabase? or has found way use regular expressions when searching through strings in database? as described here the regexp operator special syntax regexp() user function. no regexp() user function defined default , use of regexp operator result in error message. if application-defined sql function named "regexp" added @ run-time, function called in order implement regexp operator. but there glob little more advanced like.

mySql copy rows into same table with key value changed (not overwriting existing) -

how copy selection of rows mysql table , insert key value changed. can select , insert in same query? to precise, want this: table cols, id , iso3 keys: [id][iso3][text] 1,enu,a text in english 2,enu,another text in english 3,enu,bla bla 1,jpn,与えられた枠 after insert want table this: 1,enu,a text in english 2,enu,another text in english 3,enu,bla bla 1,jpn,与えられた枠 2,jpn,another text in english 3,jpn,bla bla insert your_table (id, iso3, text) select id, 'jpn', text your_table id in ( list_of_ id's ) if want change value in 1 cell, hard-type tthe value instead of selecting table (like did 'jpn').

.net - Generics and Enumerations -

how use(constraint) enumeration generic parameter in .net? i used somthing like public function getenumstringvalues(of etype {structure, _ icomparable, iconvertible, iformattable})() list(of string) but not good. you can use enum types generic parameters method (for example list<etype> , cannot restrict generic parameters enum types. however, there tricks can use almost guarantee enums used in methods: public static t parseenum<t>(this string enumvalue) t : struct, iconvertible see converting string enum more full explanation , code samples.

jquery - Triggering resize of jqGrid after user shows/hides columns -

in jqgrid, after users chooses remove column(s), grid's width becomes smaller. therefore, think appropriate trigger resize @ point using $("#mygrid").trigger("resize") . however, to jqgrid event should attach this? i tried triggering resize manually on firebug console after using column chooser , worked well. i tried recommendations in this question without results. i solved own problem: $("#mygrid").jqgrid("columnchooser", { done: function() { $("#mygrid").trigger("resize"); } });

The [super dealloc] in dealloc of UIViewController giving problem in iPad -

i working on application pushing 1 view controller on uinavigationcontroller , releasing navigation controller retains it.when poping view controller dealloc method being called expected problem app getting crashed.if observe in gdb enabling nszombie saying -[myviewcontroller iskindofclass:]: message sent deallocated instance 0x6847a00 . if remove [super dealloc] from view controller's dealloc method working fine .i have nothing else in dealloc method except [super dealloc].what problem here, can 1 please help.the code snippet below: myviewcontroller *myviewcontroller = [[myviewcontroller alloc] initwithnibname:nil bundle:nil]; myviewcontroller.path = selectedpath; //very important set path here myviewcontroller.parentviewcontroller = self; [self cleanbookshelf]; [self.navigationcontroller pushviewcontroller:myviewcontroller animated:no]; [myviewcontroller release]; [indicatorview removefromsuperview]; [loadingindicator stopanimating]; and poping in 1 action method of myv...