Posts

Showing posts from September, 2015

php - How can I merge Nodes & Webform Submissions into instances of one general Content Type in Drupal 6? -

i built site using drupal 6 allows users submit information site owner in 3 different ways. are: webform a : quick contact - collects name, email, phone , message. webform b : free pdf book email webform - collects info similar above, , sends user email pdf attachment book written site owner. node create : case evaluation - form node creation page using multi-step module, cck , lot of conditional fields. anonymous users can fill out form , node data emailed site owner based on rule created. all 3 of these forms work in terms of doing supposed site. webform submissions accessed webform node owner, , set table view manage node submissions. even though forms gathering different data, @ end of day, important data personal contact information (each 1 collects name, email and/or phone), , each form submission (from of forms) considered lead owner , followed on. i centralize these various form submissions (2 webforms + 1 node) 1 content type (leads) managed 1 page, rather t...

security - How to sanitize user created filenames for a networked application? -

i'm working on instant messaging app, users can receive files friends. the names of files received set sender of file, , multiple files can sent possibility of subdirectories. example, 2 files sent might "1" , "sub/2" such downloaded results should "downloads/1" , "downloads/sub/2". i'm worried security implications of this. right off top of head, 2 potentially dangerous filnames "../../../somethingnasty" or "~/somethingnasty" unix-like users. other potential issues cross mind filenames characters unsupported on target filesystem, seems harder , may better ignore? i'm considering stripping received filenames ".." , "~" type of blacklist approach individually think of problem cases hardly seems recipe security. what's recommended way sanitize filenames ensure nothing sinister happens? if makes difference, app running on c++ qt framework. it's wiser replace ".....

java - JNLP isn't cooperating JFileChooser Access Denied -

i feel dumb...... so writing java app, , if can me work you'll able see it. so jar file here: http://team2648.com/otis2/admin/omninode2.8.jar i able used java web-start application, following tutorial here: http://download.oracle.com/javase/tutorial/deployment/webstart/deploying.html so wrote following jnlp file directed: <?xml version="1.0" encoding="utf-8"?> <jnlp spec="1.0+" codebase="http://team2648.com/otis2/admin" href="test.jnlp"> <information> <title>omninode mapper</title> <vendor>techplex engineer</vendor> </information> <resources> <!-- application resources --> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/> <jar href="omninode2.8.jar" main="true" /> </resources> <application-desc name="omninode mapper" main-class=...

geospatial - MongoDB Bound Queries: How do I convert mile to radian? -

i have collection of stores geospacial index on location propery. what trying given user's latitude, latitude , search radius (mi), want return list of stores within parameters. i saw following example on mongodb documentation ( http://www.mongodb.org/display/docs/geospatial+indexing ), looks distance in radians. center = [50, 50] radius = 10 db.places.find({"loc" : {"$within" : {"$center" : [center, radius]}}}) so, formula convert miles radians? solution awesome people @ mongodb-user helped me find answer. basically, looking way limit distance. per, updated documentation, there 3rd parameter $near query: can use $near maximum distance db.places.find( { loc : { $near : [50,50] , $maxdistance : 5 } } ).limit(20) the value $maxdistance in radians; so, had take distance in miles , divide 69. thank you! as docs say: all distances use radians. allows multiply radius of earth (about 6371 km or 3959 miles) distance in choice ...

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

i having super hard time compiling , using taglib 1.6.3 in qt project. i've tried can think of. taglib claims supported through cmake i'm not having luck. furthermore, i'm confused kinds of files need qt libs! i've built *.a files, *.lib, , *.dll. understand far... believe since i'm working in windows *.lib want. no matter do, end "undefined references" taglib functions try use when try compile qt project. have tried mingw32, msys, visual studio 2008, , cross-compiling windows on linux. turning nothing. what makes less sense me if compile same taglib source qt on mac (g++ think?) works fine! somewhere in windows compilation procedures have going wrong. have been smacking face on desk 30 (on , off) hours trying figure out. since qt uses mingw must compile taglib same compiler? if compile *.lib's visual studio not compatible? are *.a libraries usable in windows? (assuming mingw) i'm still trying handle on c++ stuff, after reading coun...

Using GO in SQL Server 2005 -

i working on sql server 2005 , have come accros issue have run multiple update query on single table 1 one. takes lots of time execute 1 one came know using "go" can run query 1 one. this update table .... go update table a go update table a i not sure can put seperate update statement , run query 1 one. doing on production need sure should work. can give me example can see using go, query runs 1 one , not parallel? from go (transact-sql) go not transact-sql statement; command recognized sqlcmd , osql utilities , sql server management studio code editor. sql server utilities interpret go signal should send current batch of transact-sql statements instance of sql server. current batch of statements composed of statements entered since last go, or since start of ad hoc session or script if first go.

c++ - cin skipping in while -

why cin being skipped in following while? int main() { int option; cin >> option; while(!cin.good()) { cout << "looping" << endl; cin >> option; } } errors in iostreams sticky. need clear error state before cin works again. int main() { int option; cin >> option; while(!cin.good()) { cout << "looping" << endl; cin.clear(); // ignore erroneous line of input: cin.ignore(numeric_limits<streamsize>::max(), '\n'); cin >> option; } }

android - GPS update interval is faster with good signal? -

i'm trying limit program take location updates every 10 seconds instead of constant updates in order reduce battery drain. works fine when i'm debugging indoors , signal weak (i.e. gps icon flashes), if phone gets proper fix (i.e. gps icon static) update interval increases second. i know code mlocationmanager.requestlocationupdates(locationmanager.gps_provider, updateinterval*1000, 0, this); not force gps take updates @ given interval, in opinion shouldn't depend on strength of signal , fluctuate much. any ideas? update: see comment i suspect gps radio works in manner either it's connected gps satellites or it's not. when it's connected, android sdk sends updates they're available gps hardware. when doesn't have full gps connection falls sending agps updates according you've requested. if want updates every 10 seconds, should save last received location 's time value in listener, , when receive new location check time aga...

On which pattern are ASP.NET webforms and MVC based? PageController, FrontController? -

i trying understand asp.net webforms , mvc point of view of understanding design patterns used. while mvc looks implementation of frontcontroller, not sure webforms pages. so, appreciate if can following questions around this. is webforms based on pagecontroller pattern? are front controller , page controller both modified versions of mvc? can webforms called special case of mvc distinction between controller , view blurred? finally, there resources on web can provide detailed reference on topic? following order of questions: 1//no. webforms based on the "smart ui" pattern, ie, control app writing event handlers. smart ui has issues, when entirely based on desktop works ok, in sense no major "fiction" introduced framework work. web, however, works on stateless http, major fiction introduced, in form of viewstate holds state of controls when page sent client browser. result, web forms introduce layer of complexity applications there sustai...

mysql - Two similar applications on different domains but same users -

i'm planning on building 2 applications using zend framework similar serve 2 different purposes can't part of same application or combined one. however, modules i'm considering. the issue i'm running if user registers first application want information available second application, hence sharing user table or user database. because applications similar have same database tables having different fields, i'm not sure if should have three, 2 or 1 databases. 3 databases user database, app1 database, app2 database. 2 databases user database , app1+2 database prefixed tables. 1 database user , app1+2 database. i'm trying give information possible, because client can't discuss details in depth. also, client wants , other not being able figure out how set up, i'm not sure best. my questions of options above, serve best, or other? should have shared user dataset across 2 applications or should users have register again? no matter of choice think be...

latex - How to extract the size of PDF? (Dimensions, not file size) -

i have many hundreds of small pdf images (created in adobe illustrator) inserted latex document. need know size of these images in real-world dimensions (e.g. 20mm x 14mm), or @ least latex can understand. is there command line tool can produce these dimensions? (i running mac os x.) a second best solution way latex extract dimensions. [i have tried pdftk, data dump command seems tell me number of pages (1).] use pdfinfo or pdfinfo.exe (from xpdf suite ): pdfinfo ^ -f 1 ^ -l 10 ^ -box ^ 20-pages.pdf this extract page sizes , box info (mediabox, cropbox, bleedbox, trimbox, artbox) pages 1 - 10 of pdf.

mfc - ON_EN_KILLFOCUS called multiple times -

i using cedit control. , have assigned event handler on_en_killfocus message. gets called correctly. problem that, when ever, close dialog box, event handler gets called 4 times. how can prevent this? why try prevent it? make sure handler ignores ones don't matter -

c++ - Linear congruential generator: How important is setting seed? -

i'm learning linear congruential generator in algorithms , data structures course. after thinking rng implementation we've been using (a=429493445, c=907633385, mod=4294967296, x _uint32), 1 thing came mind: program has function setting seed. how important function in c , c++? here's line of thought: once program starts, os assigns addresses used variables. data in memory location given seed can interpreted number. i understand in small computers may happen operating system (if there one) assigns several times same address seed wouldn't data contained in address different every time? unless system sets free ram value after every start, data contained in ram pretty random , provide enough seed. even if data contained in space given seed used program, don't see how make impact on generator itself. while unserious playing around rngs, seeding "junk in memory" work ok. bad way things: have no guarantee data in memory is random, though ca...

sql - how do i combine two selects from one table where one has a GROUP BY and the other has a DISTINCT -

both of these work individually select ponumber, count(requestnumber) "innumofrequests", sum(amount) "sumofamounts" tableview group ponumber select distinct ponumber, (10 * ceiling((datediff(day,poapproveddate,getdate()))/10)) "binofdayssincepoapproved" tableview and want end with: ponumber | innumofrequests | sumofamounts | binofdayssincepoapproved po1 | 2 | 100 | 180 po2 | 1 | 50 | 179 tableview looks like: requestnumber | ponumber | amount | poapproved date 1 | po1 | 100.00 | 2010-01-01 2 | po1 | 100.00 | 2010-01-01 3 | po2 | 50.00 | 2010-01-02 note po1 po 2 requests , poapproved data , amount same 2 requests. it seems easy book i'm using (the language of sql) can't figure out. :( alex ...

How to find out if the iPhone is on silent mode? -

i have mailing application. if user sends mail successfully, need notify mail sent successfully. that, need know if phone on silent mode (in case there 'vibrate') or regular mode (in case there 'beep'). can me it? thanks in advance cfstringref state; uint32 propertysize = sizeof(cfstringref); audiosessioninitialize(null, null, null, null); audiosessiongetproperty(kaudiosessionproperty_audioroute, &propertysize, &state); if(cfstringgetlength(state) == 0) { //silent } else { //not silent } if state string empty phone on silent - otherwise phone has audio output edit: remember add audiotoolbox framework , import. – thomas clayson answer taken (http://iphone-dev-tips.alterplay.com/2009/12/iphone-silent-mode-detection.html)

jquery - Need help to re-enable dragging of a draggable -

i have draggable element $(".element").draggable({ helper: "clone", revert: 'invalid', containment: '#parent', appendto: '#parent' }); i have 2 issues: after element dropped, original gets disabled automatically. a close anchor tag appended dropped element. on click of 'close' original element should again become draggable , should removed droppable 'div'. i have written handler close anchor follows, removes element droppable doesn't make draggable aggain. $('.cancel a',ui.helper).click(function() { $(ui.helper).remove(); $(ui.draggable).draggable('enable'); }); please help. in advance. the answer first issue set disabled option of draggable element false. $(".element").draggable({ helper: "clone", revert: 'invalid', disabled: false, containment: '#parent', appendto: '#parent' }); on handl...

.net - Class-level validation -

i validating class dataannotations utils. i have class has title property , item property. want apply requiredattribute title property should invalid if item property null; if item property set object, title not required. in short words, want requiredattribute validate if condition in class satisfied. how can done. update as didn't find other way, , since don't need functionality often, decided make rough way using class-level validator. question then, there way manually update ui make title textbox red frame, i.e. invalidate it? update 2 want class-level validator summarize on field. example, have fields cost , salesprice, wanna make sure salesprice > cost , invalidate salesprice otherwise, don't want global validation error on class level. i prefer xamly way. you may able creating custom validation attribute class. unfortunately dataannotation attributes assigned properties cannot access other properties of parent class far aware ...

PHP OpenID geting nickname & email -

for openid authentication i'm using "php openid library" ( http://www.janrain.com/openid-enabled ). how, of library, ask additional information (nickname, email)? i've got problems lightopenid, when ask email @ yandex lightopenid-> valid returns false( class ncw_openid extends lightopenid { const openid_mode_cancel = 'cancel'; public function __construct() { parent::__construct(); $this->required = array('nameperson/friendly', 'contact/email'); $this->optional = array('contact/email'); //$this->returnurl = 'http://' . site_uri . '/users/login'; } public function getattributes() { $attr = parent::getattributes(); $newattr = array(); foreach ($attr $key => $value) { if (isset(parent::$ax_to_sreg[$key])) $key = parent::$ax_to_sreg[$key]; $newattr[$key] = $value; } return $newattr; ...

c++ - how to convert a boost::weak_ptr to a boost::shared_ptr -

i have shared_ptr , weak_ptr typedef boost::weak_ptr<classname> classnameptr; typedef boost::shared_ptr<x> xptr; how convert weak_ptr shared_ptr shared_ptr = weak_ptr; xptr = classnameptr; ????? as said boost::shared_ptr<type> ptr = weak_ptr.lock(); if not want exception or use cast constructor boost::shared_ptr<type> ptr(weak_ptr); this throw if weak pointer deleted.

Could not initialize class java.awt.Rectangle -

client: [character: demian[268482346] - account: zayko - ip: 127.0.0.1] - failed running: [c] 03 enterworld - l2j server version: ${l2j.revision} - dp revision: ${l2jdp.revision} ; not initialize class java.awt.rectangle java.lang.noclassdeffounderror: not initialize class java.awt.rectangle @ java.awt.polygon.calculatebounds(unknown source) @ java.awt.polygon.getboundingbox(unknown source) @ java.awt.polygon.contains(unknown source) @ com.l2jserver.gameserver.instancemanager.dimensionalriftmanager$dimensionalriftroom.checkifinzone(dimensionalriftmanager.java:454) @ com.l2jserver.gameserver.instancemanager.dimensionalriftmanager.checkifinriftzone(dimensionalriftmanager.java:255) @ com.l2jserver.gameserver.network.clientpackets.enterworld.runimpl(enterworld.java:436) @ com.l2jserver.gameserver.network.clientpackets.l2gameclientpacket.run(l2gameclientpacket.java:62) @ com.l2jserver.gameserver.network.l2gameclient.run(l2gameclient.java:973) @ java.u...

javascript - Find the list of defined sammy.js routes -

sammy.js controller library in javascript. have 404 because our route doesn't seems valid sammy. how know route defined sammy.js in page ? something ruby on rails' rake routes . like answers can search on app.routes. have in coffee script : jquery.each app.routes, (r) -> console.log(json.stringify(r)) jquery.each app.routes[r], (u) -> console.log(json.stringify(u)) or in js jquery.each(app.routes, function(r) { console.log(json.stringify(r)); return jquery.each(app.routes[r], function(u) { return console.log(json.stringify(u)); }); }); but it's not output routes have in output : "get" 0 1 "post" 0 1 2 etc... so code ? you can try that var app = $.sammy.apps['body']; jquery.each(app.routes, function(verb, routes) { jquery.each(routes, function(i, route) { console.log(route.verb, route.path); }); });

flash - AS3 Refresh Stage -

i have been using evt.updateafterevent() whenever mouse clicked. is possible call update on entire stage remove pixels no longer being used? thanks ~ kyle. you possibly try dispatching event.resize bubbling set true, depends situation really.

c# - x509 and digital signature -

i'm rewriting application can stop using old microsoft.web.services2.security.x509 microsoft.web.services2.dll , start using system.security.cryptography.x509certificates. there 1 method can't figure out, though: bool microsoft.web.services2.security.x509.x509certificate.supportsdigitalsignature() i can't find equivalent in system.security.cryptography.x509certificates.x509certificate2 . do need test whether certificate supports digital signature? don't see how cannot... first of certificate must have private key in order used signing. use x509certificate2.hasprivatekey property check this. use x509certificate2.extensions property access key usage extension . 1 of key usages digital signature. looking for.

c# - How do I sign a pdf with electronic signature in PDFSharp? -

is possible sign pdf document electronic signature in pdfsharp? how it? thanks suggestions. probably right answer itextsharp , open source java library pdf generation written entirely in c# .net platform.

.net - SSIS: Curious: why is the last parameter in FireInformation method a ref bool? -

i'm working on ssis package , after 80th time using fireinformation inside script task, have wonder: why method require pass in ref boolean last parameter? documentation doesn't state how should respond value once method returns. missing here? the run-time engine has ability modify “fireagain” parameter , prevent further firing of events. in order this, run-time must have access modify variable. can if parameter passed ref.

flex3 - Issue of alignment of string in textarea in Flex 3.0 -

i need display long string in textarea in form of 2 columns. 20 characters of string in left side , space , 20 character on right side of textarea . @ next line again doing same thing till string complete. but happening @ right column rows not aligned exactly. happening because each character has different pixel width alignment of right column depends on character printed on left column. if on left column characters 'iiii' second column row starts bit in textarea , if on left column, characters 'mmmmmm' second column row starts bit late. i using <textformat> tag text formatting string. try setting fontfamily of textarea courier new. fontfamily="courier new"

How does my browser convert my http request to https? -

friends want know when secured hosting done, require unique ip address associate our ssl certificate it. also, kinda read in 1 tutorial when browser requests secured conncetion ssl process initiates. how browser request secure connection. don't write www.chase.com? , our browser converts http https? whats happening in background? step step: the client types www.example.com in address bar the browser assumes http protocol , sends call www.example.com www.example.com responds moved status code , gives new location: http/1.1 301 moved permanently location: https ://www.example.com/ the browser reads , knows must start secure http connection. ...and on. things more complicated because browser , server exchange multiple messages until secure connection established. anyway, if need install ssl certificate must make sure client redirected http https. should accomplished server configurations.

crystal reports - Trying to use crystalreportviewer to display .rpt's using vb.net -

i've been trying build simple vb.net app displays built .rpt reports in crystalreportviewer. no matter how many times try code it, run problems. reports have worked, others have thrown errors such load report failed, invalid path, etc.. of reports work when run them in crystal. ideally, i'm looking have menu report names, , crystalreportviewer user can click report, , app prompts them parameter values. i'm working crystal 9 believe, , vs.net 2003, or have access 2005 well. can me this, or explain why i'm running problems? nothing has been consistent - i'm @ loss right now. help highly appreciated!! in advance you need them working in development environment, on client side, make sure dependent files installed , network drive names mapped consistently if code's dependent on it. here's example in vb.net 2005: public class frmcrystal public sub _init(byval windowtitle string, byval rptpath string) dim rptdoc crystaldecis...

Add year to Java Calendar doesn't work -

please enlight me on : i'm trying add 10 years current date substract expiration date return number of years: public int getmaxyears() { int max = 0; calendar ten_year_later = calendar.getinstance(); ten_year_later.settime(new date()); ten_year_later.add(calendar.year, 10); calendar expiration = calendar.getinstance(); expiration.settime(expiration_date); max = (int) (ten_year_later.gettimeinmillis() - expiration.gettimeinmillis())/(365 * 24 * 60 * 60 * 1000); return max; } when debug this, calendar stay @ current year. anyone ? you have problem int / long conversion: 365 * 24 * 60 * 60 * 1000 evaluates 31536000000 , therefore exceeds integer.max_value 2147483647 works: public static void main(string[] args) { calendar ten_year_later = calendar.getinstance(); system.out.println( ten_year_later.gettime() ); ten_year_later.settime(new date()); ten_year_later.add(calendar.year, 10); system.out.p...

jQuery .html().length not returning correct value -

i'm trying 1) remove default text in textarea when user focuses on it. 2) if doesn't enter , clicks away, default text should reinserted. my code below handles case #1, fails case #2 in chrome , safari (but not firefox). when enter in text (so $(this).html().length > 0) , click away, jquery incorrectly determines $(this).html().length == 0, removes entered text , reinserts default text. jquery(document).ready(function inputhide(){ $('textarea').each(function(){ var this_area = $(this); var this_area_val; this_area_val = this_area.html(); this_area.focus(function(){ if(this_area.html() == this_area_val){ this_area.html(''); } }).blur(function(){ if(this_area.html().length == 0){ this_area.html(this_area_val); } }); }); thanks help. slaks right. here's why: html() / innerhtml gives text node conte...

java - Three greatest values in an array -

to find 3 greatest elements in array(length 100), combination of loop , if statement(s) effective way, or there more efficient method? your question not clear me. the efficient way maintain max heap of size 3 , insert array elements max heap 1 one. at end 3 elements in max heap 3 largest elements in original array. in general problem of finding max m elements in array of size n best solved maintaining max heap of size m .

html - How to divide a large text into multiple chunks, all with the same max-height? -

css3's column-module allows divide text multiple columns. either 1) specifying column-height property (all columns have same author-defined height, column count dynamic) or, 2) specifying column-count property (all columns have same computer-generated height, number of columns defined author). what have option 1, instead of having columns next each-other i'd have them underneath each other. way wouldn't columns , more rows defined height. this way text divided pages of same height. (like when print out webpage.) any ideas on how achieve this? ( project requires webkit-support. ) the column module won't that. better off declaring class on div declared height. if you're looking dynamic columns, may need programming via js or php.

regex - Regexp to grab protocol from URL -

let's have variable called url , it's assigned value of http://www.google.com . can received url via ftp, hence it'll ftp://ftp.google.com . how can have grab before : ? i'll have if/else condition afterwards test logic. /^[^:]+/ if want prevent 'www.foobar.com' (which has no protocol specified) match protocol: /^[^:]+(?=:\/\/)/

java - Force JTable to "commit" data to model while it is still in editing mode -

Image
i have jtable follow. so, while jtable still in editing mode (there keyboard cursor blinking @ dividend column), clicking ok directly not commit data table model. clicking ok merely close dialog box. i need press enter explicitly, in order commit data table model. while jtable still in editing mode, before closing dialog box, there way can tell jtable saying, "hey, time commit changes model" the source code dialog box follow dialog box source code . @ jbutton1actionperformed executed code when ok pressed. i'm not sure if work (it have been nice have scce), try this: tablecelleditor editor = table.getcelleditor(); if (editor != null) { editor.stopcellediting(); }

Android: PopupWindow.showAtLocation(anchorView) -> how to get the whole screen as a anchorView? -

i have popupwindow , i'd place in center of screen. however, have access keyboardview (since i'm implementing ime ) @ bottom of screen , whenever center popupwindow using keyboardview , gravity.center of course centered above keyboard, not in whole screen. is there way whole screen anchor view? you cannot popup window. should create own window using windowmanager instance.

.NET: Posting Xml to a web-server? -

what proper way post xmldocument web-server? here skeleton function: public static void postxml(xmldocument doc, string url) { //todo: write } right use: //warning: not use postxml implmentation //it doesn't adjust xml match encoding used webclient public static void postxml(xmldocument doc, string url) { using (webclient wc = new webclient()) { wc.uploadstring(url, documenttostr(doc)); } } where documenttostr valid , correct method: /// <summary> /// convert xmldocument string /// </summary> /// <param name="doc">the xmldocument converted string</param> /// <returns>the string version of xmldocument</returns> private static string documenttostr(xmldocument doc) { using (stringwriter writer = new stringwriter()) { doc.save(writer); return writer.tostring(); } } the problem implementation of postxml posts string exactly is. means (in case) http request is: post https://...

jquery - Detecting the clicked links after ajax load in Chrome using $("a:focus") -

i have page has list item, , each item has delete button. clicking delete button loads child page (delete.asp?id=123) in hidden div. delete.asp has javascript alert (on document ready) fires when button clicked. has $("a:focus").hide(); removes clicked link. can't seem work in chrome. alert fires link doesn't remove itself. besides using a:focus, there better way this? rather removing link loaded page, should removing in same event loads hidden page. this: $('a.delete').click(function() { //load delete.asp $('#myhiddendiv').load('delete.asp?id=123'); //hide link $(this).hide(); });

Are NServiceBus handler's members safe for storing message related (and not related) data? -

are handlers reused proceed message? public abstract class somehandler : ihandlemessages<myevent> { public ibus bus { get; set; } public string message { get; set; } public void handle(t message) { message = "test"; someinstancemethod(); } public void someinstancemethod() { if (message = ...) // can use message here? return; } } by default, message handlers configured componentcallmodelenum.singlecall, means each call on component performed on new instance. so, 2 messages processed different instances of class , cannot share state. however, have here setting class property , calling method in class retrieves property. work fine. however, in opinion, kind of confusing, , if you're after, you're better off passing values method parameter.

javascript - html5 offline caching with php driven sites -

i have simple php driven website running , i'm trying figure out how treats php pages. of php documents routing logic , includes individual pages. how go making work offline? what though i'd have re-create routing logic in javascript. option? in case, possible have site driven php while online , switch js offline? can't make sense of it. if site static, html5's cache manifest may of way there. have php output cache.manifest file in correct format routing system's urls , urls stored locally in compliant browser. attempting access them pull them out of cache if possible. if you're looking more dynamic, though, you're going have more legwork. here's info on offline caching.

c++ - Issues with #includes -

i thought use #pragma once solve problems it's not working. here issue. i have agui.h wanted main header includes: it: #pragma once /* header includes required headers required agui author: josh */ //standard library (stl) #include <stdlib.h> #include <iostream> #include <string> #include <sstream> #include <vector> #include <list> #include <algorithm> #include <queue> //c runtime #include <cmath> #include <ctime> //allegro 5 #include <allegro5/allegro.h> #include <allegro5/allegro5.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_primitives.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_ttf.h> #include "aguibasetypes.h" #include "aguiwidgetbase.h" aguibasetypes.h looks this: #pragma once #include "agui.h" #define aguibitmap allegro_bitmap /* header contains classes basic types. ...

SqlAlchemy: get object instance state -

this: intro object states lists 4 permutations of presence-in-db/presence-in-session: transient, pending, persistent & detached is there way of querying given object return of 4 states object in? i tried rooting around in _sa_instance_state couldn't find relevant. thanks! better use inspection api : from sqlalchemy import inspect state = inspect(obj) # booleans state.transient state.pending state.detached state.persistent

Android: Inflate View under a View then slide top view off -

my issue have main screen, , dynamically spawn view under button click, slide main view off screen revealing view below it. i've accomplished this, feel there's got better way. way i've done limited in can't spawn views on , on again under main. my main xml file looks this: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <relativelayout android:id="@+id/subpage" android:layout_width="fill_parent" android:layout_height="fill_parent" > </relativelayout> <relativelayout android:id="@+id/homescreen" android:layout_width="fill_parent" android:layout_height="fill_parent" > <relativelayout android:layout_width="fill_parent" a...

osx - Batch convert on Mac OS X html files to UTF-8 with Unix (LF) -

i on mac os x snow leopard. i need batch convert lot of .htm files created on windows utf-8 unix (lf) line breaks. i can batch rename of files .html namemangler. i can search/replace of of files update hyperlinks reflect extension change .html using texfinderx. now last step batch convert utf-8 , unix (lf) line breaks. does know of app can this? hope don't have manually open each of files in text editor , save each 1 individually. afraid might accidentally miss of files…and take long time this. tia, linda you'll want check out dos2unix port macos. haven't used myself since don't own mac, dos2unix general unix utility conversion of windows files unix files.

php - Multiple responses from function -

i'm trying have function return multiple results in array(?). so instead of running lookup("354534", "name"); , lookup("354534", "date"); mutiple times different results, how can return both name & date function, echo out have use function once? function lookup($data, $what) { $json = file_get_contents("http://site.com/".$data.".json"); $output = json_decode($json, true); echo $output['foo'][''.$what.'']; } thanks! have function return whole json result: function lookup($data) { $json = file_get_contents("http://site.com/".$data.".json"); $output = json_decode($json, true); return $output["foo"]; } then can $result = lookup("354534"); echo $result["name"]; echo $result["date"]; this idea, because otherwise, you'll make (slow) file_get_contents request multiple times, want avo...

c# - When I publish a ASP.NET MVC 3 project my Razor views aren't copied -

looks publish doesn't copy razor views @ asp.net mvc 3 beta. known limitation of beta? fixed @ release? try selecting razor file , in properties make sure build action set content .

c# - How do i force a wpf window/control refresh of disabled elements -

i pulling out hair trying figure out why normal dispatcher.invoke command did not work redrawing window, issue seems related content being disabled. i'm using dotnet 4.0 full framework. if use private void dosomething() { handlebusyenabledisable(false); dosomethingthatkeepsitbusy(); handlebusyenabledisable(true); } private void handlebusyenabledisable(bool enabling) { cursor = enabling ? cursors.arrow : cursors.wait; canvasfunctions.isenabled = enabling; canvasright.isenabled = enabling; canvasright.dispatcher.invoke(system.windows.threading.dispatcherpriority.render, emptydelegate); i see cursor change content not disabled. if add canvasright.opacity = enabling ? 1 : .5; then think works, sometimes. there else can do? task that's running validating user entered data, easier run on gui thread. shouldn't hard. not controls visually represent being disabled, may note wont usable client side. to frank should implement inotifychange...

php - Counting distinct values in a multidimensional array -

i have array looks 1 below. i'm trying group , count them, haven't been able work. the original $result array looks this: array ( [sku] => array ( [0] => 344 [1] => 344 [2] => 164 ) [cpk] => array ( [0] => d456 [1] => d456 ) ) i'm trying take , create new array: $item[sku][344] = 2; $item[sku][164] = 1; $item[cpk][d456] = 1; i've gone through various iterations of in_array statements inside loops, still haven't been able working. can help? i wouldn't use in_array() here. this loops through creating array goes. it seems work without needing first set index 0. $newarray = array(); foreach($result $key => $group) { foreach($group $member) { $newarray[$key][$member]++; } }

Using *this in C++ class method to fully overwrite self instantiation -

is following code safe? (i know compiles properly.) void tile::clear() { *this = tile(); } int main() { tile mytile; mytile.clear(); } it might work. depends on how tile& operator = (const tile&); implemented. however, there's nothing intrinsically erroneous assigning *this new value.

android - disabling and greying out list items -

i have list view. in list view, have grey out , disable items, , enable rest list items seperate color. how this? you should write custom adapter extending baseadapter listview. disable items, have override "boolean isenabled(int position)" in adapter, , return false every position you'd disabled. as changing background color list elements: store background color value in data structure you're displaying. in custom adapter's 'getview()' method, should check color value current element, , return view correct background color set. or call 'getchildat()' on listview, getting view object desired element in list, , change it's background color. think i'd rather use previous solution. remember call 'notifydatasetchanged()' on listview's adapter after make changes this.

shell - Unix Sed to get lines from a last occurance of a given word -

i want lines file line contains last occurance of given word. ex: true, there have been some changes in plot. in original, kane tried buy high political office himself. in new version, puts politicians on payroll. if give "in" need office himself. in new version, puts politicians on payroll. try: grep 'yourword' yourfile.txt | tail -n1 or sed: sed -n '/yourword/{$p}' yourfile.txt

apache - .htaccess how to substitute urls -

how can substitute urls of web application in sub folder installed on root. e.g. need map example.com/index.php example.com/new/index.php i not want redirection url rewrite exempt folder name. help me learn , define rules. you can use following rule rewrite request that’s url path (without path prefix) not start new/ : rewritecond $1 !^new/ rewriterule ^(.*)$ new/$1 this work in .htaccess files other in document root directory. but want use rule in .htaccess file in document root directory, use request_uri : rewriterule !^new/ new%{request_uri}

javascript - Get values of js generated controls, from server side -

let me explain case; on asp.net page, have repeater generates <tr> s , <td> s. on clientside, have js function adds or deletes rows repeater-generated-table. the problem is, in function, dont generate simple row, textbox (which have value on server side) generated too. is there way value of client-generated controls ? you can use ajax make connection between client side , server side. can try this or read this article.

c++ - How to resolve linker error "cannot find -lgcc_s" -

i have 3 tiny files use make static library , app: test.h #ifndef test_h #define test_h class test { public: test(); }; extern test* gptest; #endif test.cpp #include "test.h" test::test() { gptest = this; } test test; main.cpp #include "test.h" #include <iostream> using namespace std; test* gptest = null; int main() { return 0; } build g++ -c test.cpp -o test.o ar cr test.a test.o g++ -c main.cpp -o main.o g++ main.o -o app -wl,--whole-archive -l/home/dumindara/intest/test.a -wl,-no--whole-archive error (linking step) /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lgcc_s collect2: ld returned 1 exit status i tried everything: using -static-libgcc , linking static libstdc++. can't work. due --whole-archive flag. can't without it. i think -- problem here: -wl,-no--whole-archive try with -wl,-no-whole-archive edit about not seeing test sym...

c - expected specifier-qualifier-list before -

i have struct type definition: typedef struct { char *key; long cantag; long canset; long allowmultiple; conftype *next; } conftype; when compiling, gcc throws error: conf.c:6: error: expected specifier-qualifier-list before ‘conftype’ what mean? doesn't seem related other questions error. you used conftype before declared it. (for next). instead, try this: typedef struct conftype { char *key; long cantag; long canset; long allowmultiple; struct conftype *next; } conftype;

Qt 4.1.4 Source Compile on Windows with MinGW -

i having issue compiling source of qt framework version 4.1.4. (see attached picture exact compiler error text) i using source of qt (http://get.qt.nokia.com/qt/source/qt-win-opensource-src-4.1.4.zip) and i'm using mingw (latest here http://sourceforge.net/projects/mingw/files/ ) has gcc version 4.5.0.1 to me seems function prototypes diff in qatomic.h , gcc include winbase.h , might due qt 4.1.4 bit old. can tell me how solve issue? changing mingw version? or other environmental setting? it nice if has compiled qt 4.1.4 mingw in past please let me know version of mingw , gcc used? compiler output: d:\qt\qt-win-opensource-src-4.1.4>mingw32-make cd src && mingw32-make -f makefile mingw32-make[1]: entering directory `d:/qt/qt-win-opensource-src-4.1.4/src' cd winmain && mingw32-make -f makefile mingw32-make[2]: entering directory `d:/qt/qt-win-opensource-src-4.1.4/src/winma in' mingw32-make -f makefile.debug mingw32-make[3]: enteri...

javascript - Edit returned results before appending on screen -

i have following script need combine somehow. each function works individually @ moment. // check if file exists clientside function fileexists(path) { var fso = new activexobject("scripting.filesystemobject"); fileexist = fso.fileexists(path); if (fileexist == true){ return true } else { return false } } // links database function getsearchresults() { var search; search = $(".txtheadersearch").val(); $.ajax({ url: 'results.aspx', type: 'post', data: { strphrase:search }, success: function(results) { // need somehow stop .exe links appearing on screen if fileexists == false $("#divsearchresults").empty().append(results); } }); } // returned data looks <div><a href="link1.xls">link 1</a></div> <div><a href="link2.exe">link 2</a></div> <div...

Ending char* vector in c -

how mark end of char* vector '\0' null-terminate it? if have char* vector: char* param[5]; i thought of either param[4] = '\0'; or char c = '\0'; param[4] = &c; but none of them seem work? param char-pointer vector, supposed point 5 strings(char-vectors). ok trying end vector of strings, similar passed main argv . in case need assign null pointer: param[4] = 0;

Photoshop Automation won't let me choose a filename -

Image
hey, today tried create photoshop automation saves me area of image i've masked. the steps are: copy flattened (ctrl+cmd+c), new file, paste, save web, close without save my problem: save web step choose same filename , overwrites old file without question. how photoshop steps ask me filename use? greetings, chris there's "pause" option in macro explorer, click next save-as action.

objective c - NSControl subclass can't read the target? -

the following code: - (void) settarget:(id)anobject { nslog(@"anobject: %@",anobject); [super settarget:anobject]; nslog(@"target: %@",[self target]); } has output: anobject: <dropzoneviewcontroller: 0x15dd5770> target: (null) this in subclass of nscontrol. doing wrong? what i'm trying achieve: have nscontrol accepts dragging objects. when dragging ends, i'd send control's action target. how control's action & target if above doesn't work? nscontrol doesn’t store it’s own target, it’s cell supposed do. so there 2 reasons might fail: your control doesn’t have cell in case should create subclass of nsactioncell implement control. subclass of nscontrol shouldn’t besides setting cell. if don’t want right way using nscell you’ll have add instance variables nscontrol subclass store target , action , override getters , setters use them. your cell not subclass of nsactioncell . regular nscell ...

ruby - Testing ssh connection -

an important part of project log in remote server ssh , files on it: net::ssh.start(@host, @username, :password => @password) |ssh| ssh.exec!(rename_files_on_remote_server) end how test it? think can have local ssh server on , check file names on (maybe in test/spec directory). or maybe point me better solution? i think it's enough test you're sending correct commands ssh server. you're application presumably doesn't implement server - have trust server correctly working , tested. if implement server you'd need test that, far ssh stuff goes, i'd mocking (rspec 2 syntax): describe "ssh access" let (:ssh_connection) { mock("ssh connection") } before (:each) net::ssh.stub(:start) { ssh_connection } end "should send rename commands connection" ssh_connection.should_receive(:exec!).ordered.with("expected command") ssh_connection.should_receive(:exec!).ordered.with("next expe...

jQuery bind unbind click event -

i trying jquery calculate amount of times id has been clicked. instance if #kwick_1 clicked once, want load video 'else' nothing. and looking @ applying throughout function same goes 2, 3, 4 etc. how achieve this? var timesclicked = 0; $('#kwick_1, #kwick_2, #kwick_3, #kwick_4, #kwick_5, #kwick_6, #kwick_7').bind('click', function(event){ var video = $(this).find('a').attr('href'); /* bunny.mp4 */ var clickedid = $(this).attr('id'); /* kwick_1 */ var vid = 'vid'; timesclicked++; $(this).removeattr('id').removeattr('class').attr('id',clickedid + vid).attr('class',clickedid + vid); if(timesclicked == 1) { $.get("video.php", { video: video, poster: 'bunny.jpg', }, function(data){ $('.'+clickedid+vid).html(data); }); } else { /* nothing */ } return false; }); you can use .one() bit easier, this: $('#...

.net - How to implement decision tree with c# (visual studio 2008) - Help -

i have decision tree need turn code in c# the simple way of doing using if-else statements in solution need create 4-5 nested conditions. i looking better way , far read little bit rule engines. do have else suggest efficient way develop decision tree 4-5 nested conditions? i implemented simple decision tree sample in book. code available online here , perhaps use inspiration. decision represented class has references true branch , false branch , contains function test: class decisionquery : decision { public decision positive { get; set; } public decision negative { get; set; } // primitive operation provided user public func<client, bool> test { get; set; } public override bool evaluate(client client) { // test client using primitive operation bool res = test(client); // select branch follow return res ? positive.evaluate(client) : negative.evaluate(client); } } here, decision base class contains evaluate method , source c...

jsf - How to resolve this facelets warning message -

what error message mean? values should provided rid of warning? 15:10:58,024 warning [component] facelets.recreate_value_expression_on_buil d_before_restore set 'true' facelets.build_before_restore set 'false' or unset. use facelets.recreate_value_expression_on_build_bef ore_restore must set facelets.build_before_restore 'true'! in web.xml file, seems have parameter defined: <context-param> <param-name>facelets.recreate_value_expression_on_build_before_restore</param-name> <param-value>true</param-value> </context-param> so stated warning message, add: <context-param> <param-name>facelets.build_before_restore</param-name> <param-value>true</param-value> </context-param> another solution remove first parameter web.xml ...