Posts

Showing posts from July, 2013

iis - Step-By-Step ASP.NET Automated Build/Deploy -

seems there many different ways of automating one's build/deployment becomes difficult parse through different scenarios people support in tutorials on web. wanted present question stackoverflow crowd ... best way set automated build , deployment system using following configuration: visual studio 2008 web application project cruisecontrol.net one of first things tried have ccnet automatically zip output , copy server, requires manual work unzip @ destination. however, if try copy files individually, potentially take long time if it's large application (build server lives outside of datacenter in our office ... know). also of particular interest how support multiple environments have dev, qa, uat, , of course prod. msdeploy seems interesting, unless i'm interpreting literature incorrectly, doesn't in scenario of deploying output of build server. if anything, seems it'll useful in deploying 1 build across build farm ... deploying 1 environment ano...

How to attach debugger to step into native (C++) code from a managed (C#) wrapper? -

i have wrapper around c++ function call call c# code. how attach debugger in visual studio step native c++ code? this wrapper have calls getdata() defined in c++ file: [dllimport("unmanaged.dll", callingconvention=callingconvention.cdecl, entrypoint = "getdata", bestfitmapping = false)] public static extern string getdata(string url); the code crashing , want investigate root cause. thanks, nikhil check debug tab on project's properties page. there should "enable unmanaged code debugging" checkbox. worked me when developed new .net ui our old c++ dlls. if unmanaged dll being built project (for while ours being built using vs6) make sure have dll's pdb file handy debugging. the other approach use c# exe target exe run dll project, can debug dll normally.

java - Exclude selected packages in jar command - build script -

my project structure has these base packages. a.b.c.core a.b.c.web a.b.c.common and core,web,common packages have sub packages. have compiled java files under src dir , copied class files dir. <javac srcdir="${src}" destdir="${build}/myapp" debug="true"> <classpath refid="compile.classpath"/> <classpath refid="ant.classpath" /> </javac> now want build jar core.jar class files belonging a.b.c.core , subpackages. web.jar , common.jar. can give sample code jar task accompolish this? thanks rather excluding specific areas, i'd include ones want: <jar destfile="core.jar" basedir="${build}/myapp" includes="a/b/c/core/**" /> <jar destfile="common.jar" basedir="${build}/myapp" includes="a/b/c/common/**" /> <jar destfile="web.jar" basedir="${build}/myapp" inclu...

Registry key that contains the folder for the local user's Programs folder on Vista -

i'm troubleshooting problem creating vista shortcuts. i want make sure our installer reading programs folder right registry key. it's reading from: hkey_current_user\software\microsoft\windows\currentversion\explorer\shell folders\programs and it's showing directory programs: c:\users\nonadmin2 uac off\appdata\roaming\microsoft\windows\start menu\programs from i've read, seems correct, wanted double check. use windows installer properties. easier. http://msdn.microsoft.com/en-us/library/aa370905(vs.85).aspx#system_folder_properties

Update schema and rows in one transaction, SQL Server 2005 -

i'm updating legacy system allows users dictate part of schema of 1 of tables. users can create , remove columns table through interface. legacy system using ado 2.8, , using sql server 2005 database (you don't want know database using before attempt modernize beast began... digress. =) ) in same editing process, users can define (and change) list of valid values can stored in these user created fields (if user wants limit can in field). when user changes list of valid entries field, if remove 1 of valid values, allowed choose new "valid value" map rows have (now invalid) value in it, have valid value again. in looking through old code, noticed extremely vulnerable putting system invalid state, because changes mentioned above not done within transaction (so if else came along halfway through process mentioned above , made own changes... well, can imagine problems might cause). the problem is, i've been trying them update under single transaction, whe...

erlang - wxErlang fails loading driver -

after several attempts managed compile , install both wxwidgets 2.8.11 , erlang r13b04 wxerlang on mac os x, version 10.4.11. however, testing wxerlang fails immediately: 1> wx:new(). = error report==== 21-jul-2010::18:37:23 === wx failed loading "wxe_driver"@"/usr/local/lib/erlang/li/wx-0.98.5/priv/i386-apple-darwing8.11.1" ** exception error: {load_driver, "dlopen(/usr/local/lib/erlang/li/wx-0.98.5/priv/i386-apple-darwin8.11.1/wxe_driver.so, 2): symbol not found: __zn5wxapp10initializeerippw\n referenced from: /usr/local/lib/erlang/lib/wx-0.98.5/priv/i386-apple-darwin8.11.1/wxe_driver.so\n expected in: flat namespace\n"} in function wxe_server:start/0 in call wx:new/1 i did see thread "wxerlang" jun 7, 2009 on mailing list. did retry following it's advise (ensuring wxwidgets build directory first in path), didn't make difference. any suggestions? otool -l says: /system/library/frameworks/opengl.framework/...

Is it possible to implement an EJB in PHP, using REST? -

is possible create ejb implementation in php, accessible through rest (not rmi)? ejb programming model, ejb components deployed , managed application server provides managed facilities ejb, declarative transactions, dependency injection, security, etc. can not code ejb in php , deploy in app. server. you can code want in php , expose rest, access rest resource other ejb. doesn't make rest resource code php ejb.

c# - Using .NET, how can you find the mime type of a file based on the file signature not the extension -

i looking simple way mime type file extension incorrect or not given, similar this question in .net. in urlmon.dll, there's function called findmimefromdata . from documentation mime type detection, or "data sniffing," refers process of determining appropriate mime type binary data. final result depends on combination of server-supplied mime type headers, file extension, and/or data itself. usually, first 256 bytes of data significant. so, read first (up to) 256 bytes file , pass findmimefromdata .

Count non-whitespace characters for selection in Visual Studio 2010 -

does know of tool or extension visual studio 2010 count non-whitespace (e.g. characters not spaces, new lines etc.) current selection in document? nice have code golfing :) i have command line tool, integrated tool nice. prefer evaluate current selection. i got creating crude macro below first recording temporary macro in visual studio , modifying below: option strict off option explicit off imports system imports envdte imports envdte80 imports envdte90 imports envdte90a imports envdte100 imports system.diagnostics public module countnonwhitespacecharacters sub count() dim selection envdte.textselection = dte.activedocument.selection() dim text string = selection.text text = text.replace(" ", "") text = text.replace(vbcrlf, "") text = text.replace(vbtab, "") msgbox("count " + text.length.tostring()) end sub end module this can bound keybord shortcut if ...

C# Http Proxy ideas? -

i need system redirects connection requests client machines different sites i.e. if type google.com should redirected mysite.com therefore thought of creating app installs proxy on user's machines app check outgoing connections , redirect accordingly. are there open source http proxies available on net? have tried mentalis seems quite buggy around 8 years old. maybe this one you. i haven't tested myself, looks promising.

.net - Copy the entire contents of a directory in C# -

i want copy entire contents of directory 1 location in c#. there doesn't appear way using system.io classes without lots of recursion. there method in vb can use if add reference microsoft.visualbasic : new microsoft.visualbasic.devices.computer(). filesystem.copydirectory( sourcefolder, outputfolder ); this seems rather ugly hack. there better way? much easier //now create of directories foreach (string dirpath in directory.getdirectories(sourcepath, "*", searchoption.alldirectories)) directory.createdirectory(dirpath.replace(sourcepath, destinationpath)); //copy files & replaces files same name foreach (string newpath in directory.getfiles(sourcepath, "*.*", searchoption.alldirectories)) file.copy(newpath, newpath.replace(sourcepath, destinationpath), true);

java - nullPointer Exception with my validator Form -

hello have class form implement validator public class loginform extends actionform { private string login; private string password; public void setlogin(string login) { this.login = login; } public string getlogin() { return login; } public void setpassword(string password) { this.password = password; } public string getpassword() { return password; } public actionerrors validate(actionmapping mapping,httpservletrequest request) { actionerrors errors = new actionerrors(); if ( login==null || login.lenght()<=8) { errors.add("error",new actionmessage ("error.login")); } if ( password==null || password.lenght()<=8) { errors.add("error",new actionmessage ("error.password")); } return errors; } } the problem have nullpointerexception in line errors.add("error",new actionmessa...

linux - Developing drivers with no info -

how open-source/free software community develop drivers products offer no documentation? how reverse engineer something? you observe input , output, , develop set of rules or models describe operation of object. example: let's want develop usb camera driver. "black box" software driver. develop hooks os and/or driver can see inputs , outputs of driver generate typical inputs, , record outputs analyze outputs , synthesize model describes relationship between input , output test model - put in place of black box driver, , run tests if need, you're done, if not rinse , repeat note regular problem solving/scientific process. instance, weather forecasters same thing - observe weather, test current conditions against model, predicts happen on next few days, , compare model's output reality. when doesn't match go , adjust model. this method safer (legally) clean room reverse engineering, decompiles code, or disassembles product, a...

How to? WPF Window - Maximized, No Resize/Move -

i'm trying make wpf window opens maximized, no resize/move (in systemmenu, nor in border). should maximized time, except when user minimize it. i tried put windowstate="maximized" , resizemode="canminimize", when window opens, covers task bar (i don't want it). i have hook wndproc cancels sc_move , sc_size. can make control conditions in wndproc "if command restore , minimized, restore, else, block" , on. but point if have way make it. thankz read guys =) it necessary write windowstate="maximized" resizemode="noresize" in xaml of window: <window x:class="miscellaneous.editform" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="edit form" windowstate="maximized" resizemode="noresize"></window>

Detecting application hangs with ActiveX controls in .Net -

i working on upgrades screen scraping application. using activex control scrape screens out of ibm mainframe. mainframe program hangs , crashes activex control causing our application crash. don't have access mainframe or activex source code. not going write our own active x control. what bast way encapsulate activex control detect application hangs control can kill process , restart code? should create 2 separate applications? 1 controller checks on other , kills/restarts process when hangs? would have on separate app domains? possible have 2 programs communicate each other if on separate app domains? you can start executable system.diagnostics.process.start(). returns process object responding property can use check periodically if process still active. you'll need 2 separate applications though. , application you're monitoring needs have main window because monitoring works checking if application still processes messages main-window messagequeue. s...

io - Starting a process with inherited stdin/stdout/stderr in Java 6 -

if start process via java's processbuilder class, have full access process's standard in, standard out, , standard error streams java inputstreams , outputstreams . however, can't find way seamlessly connect streams system.in , system.out , , system.err . it's possible use redirecterrorstream() single inputstream contains subprocess's standard out , standard error, , loop through , send through standard out—but can't find way , let user type process, or if used c system() call. this appears possible in java se 7 when comes out—i'm wondering if there's workaround now. bonus points if result of isatty() in child process carries through redirection. you need copy process out, err, , input streams system versions. easiest way using ioutils class commons io package. copy method looks need. copy method invocations need in separate threads. here basic code: // assume have processbuilder configured , ready go final process proce...

drupal - Disable links to parent menus and breadcrumbs? -

1) can disable links of parents items in drupal menus ? (in particular if i'm using nice menu module ? don't have page link parent items. 2) can disable links on breadcrumbs ? guess have change php code that. thanks try special menu items module. more details module (from project page): special menu items drupal module provides placeholder , separator menu items. a placeholder menu item not link. useful dynamic drop down menus want have parent menu item not linking page acting parent grouping menu items below it. a separator menu item "-------" not linking anywhere merely mean structure menus , "separate" menu items visually.

c# - XmlSerializer - There was an error reflecting type -

using c# .net 2.0, have composite data class have [serializable] attribute on it. creating xmlserializer class , passing constructor: xmlserializer serializer = new xmlserializer(typeof(dataclass)); i getting exception saying: there error reflecting type. inside data class there composite object. need have [serializable] attribute, or having on top object, recursively apply objects inside? look @ inner exception getting. tell field/property having trouble serializing. you can exclude fields/properties xml serialization decorating them [xmlignore] attribute. i don't think xmlserializer uses [serializable] attribute, doubt problem.

security - Loading Assemblies from the Network -

this related this question , answer maybe same i'll ask anyways. i understand can start managed executables network .net 3.5 sp1 assemblies loaded inside executable? same thing apply? you have been able load assemblies network @ leasst .net 2.0. have used on previous project. thing watch size of assembly , number , size of dependancies loading. if using seperate appdomain, need take special consideration of dependancies.

visual studio 2008 - How can I make my VS2008 x86 installer install x64 assemblies on x64? -

i'm using vs2008 installer (plus custom orca action) create installer .net product. i found out 1 of third-party assemblies using x86-specific (as includes native code); thus, x64 customers getting crashes on startup errors assembly not being appropriate platform. i sent such customer copy of x64 version of third-party assembly, , told him copy on existing x86 one. worked, sweet! need make installer me. this appears nontrivial :(. ideally, want installer (which x86, since can run on both platforms) include both x86 , x64 versions of third-party assembly, , install appropriate one. in other words, want single installer makes users' lives easy. i thought had worked out, using msi conditional statements , that. apparently no... vs2008 setup projects won't compile unless specify "x86" or "x64." if specify x86, gives compilation error saying can't include x64 assembly. if specify x64, result cannot executed on x86 computer. damn! someone mus...

SQLite/PHP read-only? -

i've been trying use sqlite pdo wrapper in php mixed success. can read database fine, none of updates being committed database when view page in browser. curiously, running script shell update database. suspected file permissions culprit, database providing full access (chmod 777) problem persists. should try changing file owner? if so, to? by way, machine standard mac os x leopard install php activated. @tom martin thank reply. ran code , looks php runs user _www. tried chowning database owned _www, didn't work either. i should note pdo's errorinfo function doesn't indicate error took place. setting pdo somehow opening database read-only? i've heard sqlite performs write locks on entire file. possible database locked else preventing write? i've decided include code in question. going more or less port of grant's script php. far it's questions section: <?php $db = new pdo('sqlite:test.db'); $ch = curl_init(); curl_setopt($ch...

How do you resolve .Net namespace conflicts with the 'using' keyword? -

here's problem, include multiple assemblies , add 'using namespacex' @ top of code file. want create class or use symbol defined in multiple namespaces, e.g. system.windows.controls.image & system.drawing.image now unless use qualified name, there crib/build error due ambiguity inspite of right 'using' declarations @ top. way out here? (another knowledge base post.. found answer after 10 minutes of searching because didn't know right keyword search for) use alias using system.windows.controls; using drawing = system.drawing; ... image img = ... //system.windows.controls.image drawing.image img2 = ... //system.drawing.image how to: use namespace alias qualifier (c#)

python - Is it pythonic for a function to return multiple values? -

in python, can have function return multiple values. here's contrived example: def divide(x, y): quotient = x/y remainder = x % y return quotient, remainder (q, r) = divide(22, 7) this seems useful, looks can abused ("well..function x computes need intermediate value. let's have x return value also"). when should draw line , define different method? absolutely (for example provided). tuples first class citizens in python there builtin function divmod() that. q, r = divmod(x, y) # ((x - x%y)/y, x%y) invariant: div*y + mod == x there other examples: zip , enumerate , dict.items . for i, e in enumerate([1, 3, 3]): print "index=%d, element=%s" % (i, e) # reverse keys , values in dictionary d = dict((v, k) k, v in adict.items()) # or d = dict(zip(adict.values(), adict.keys())) btw, parentheses not necessary of time. citation python library reference : tuples constructed comma operator (not within squ...

python - The best Django webcasts/videos -

i'm learning django though reading the django book , i'm huge fan of webcasts/screencasts/videos , haven't found ones far. there , ones recommend? check screencasts section @ this week in django . update: twid site appears down, condition permanent. list of screencasts still available @ archive.org , bulk of actual videos (eric florenzano's "django ground up" series) , hosted @ showmedo.com .

workflow - Flexible compiler pipeline definitions -

i'm developing compiler framework .net , want flexible way of defining pipelines. i've considered following options: wwf custom xml pipeline description custom pipeline description in code (using nemerle's macros define syntax it) other code-based description requirements: must not depend on functionality in later versions of .net (3+) since it's intended cross-platform , used on top of managed kernels, meaning semi-limited .net functionality. must allow conditional pipeline building, can specify command line options correspond elements , orders. wwf nice, doesn't meet first requirement. others work less optimal due work involved. does know of solution meet these goals little no modification? if know ruby solution write simple internal dsl can generate whatever pipeline data types , reader/writer code need. generating xml quick way started. can change dsl generate format later if required. you may want @ microsoft phoenix compiler ...

html - CSS: background-image not aligned anymore if I change zoom -

if change zoom in browser, background image (the logo of website) positioned differently respect other elements of website. i'm using: background-image:url('tbs-logo.png'); background-repeat:no-repeat; background-position: 92% 22%; i wondering if can keep aligned other elements, or should change html code instead add image tag. thanks. i think need specify elements width , height background image. have checked simple code: <html> <head><title>test</title> <style type="text/css"> #con{ width: 500px; margin: 0 auto; } #img{ width: 120px; height: 80px; background: url('ja2.jpg') 92% 22% no-repeat; float: left; border: 1px solid #000; } </style> </head> <body> <div id="con"> <div id="img"></div> <div>text tekst dfasdf saasdf dsaf dsa fas df sadf ...

java - tomcat5 fails to start on CentOS 5 with NoClassDefFoundError exception -

tomcat fails start if remove applications webapps directory leaving after os installation. the log (catalina.out) says: using catalina_base: /usr/share/tomcat5 using catalina_home: /usr/share/tomcat5 using catalina_tmpdir: /usr/share/tomcat5/temp using jre_home: created mbeanserver id: -dpv07y:fl4s82vl.0:hydrogenium.timberlinecolorado.com:1 java.lang.noclassdeffounderror: org.apache.catalina.core.standardservice @ java.lang.class.initializeclass(libgcj.so.7rh) @ java.lang.class.initializeclass(libgcj.so.7rh) @ java.lang.class.initializeclass(libgcj.so.7rh) @ java.lang.class.newinstance(libgcj.so.7rh) @ org.apache.catalina.startup.bootstrap.init(bootstrap.jar.so) @ org.apache.catalina.startup.bootstrap.main(bootstrap.jar.so) caused by: java.lang.classnotfoundexception: org.apache.commons.modeler.registry not found in org.apache.catalina.loader.standardclassloader{urls=[file:/var/lib/tomcat5/server/classes/,file:/usr/share/java/tomcat5/catalina-cluste...

operating system - Difference between binary semaphore and mutex -

is there difference between binary semaphore , mutex or same? they not same thing. used different purposes! while both types of semaphores have full/empty state , use same api, usage different. mutual exclusion semaphores mutual exclusion semaphores used protect shared resources (data structure, file, etc..). a mutex semaphore "owned" task takes it. if task b attempts semgive mutex held task a, task b's call return error , fail. mutexes use following sequence: - semtake - critical section - semgive here simple example: thread thread b take mutex access data ... take mutex <== block ... give mutex access data <== unblocks ... give mutex binary semaphore binary semaphore address totally different question: task b pended waiting happen (a sensor being tripped example). s...

ajax - ASP.NET WebService Returns Gibberish Characters When Throwing Exceptions -

i have web service (asmx) , in it, web method work , throws exception if input wasn't valid. [scriptmethod] [webmethod] public string mywebmethod(string input) { string l_returnval; if (!validinput(input)) { string l_errmsg = system.web.httputility.htmlencode(geterrormessage()); throw new exception(l_errmsg); } // work gets done... return system.web.httputility.htmlencode(l_returnval); } back in client-side javascript on web page, on error callback function, display error: function getinputerrorcallback(error) { $get('input_error_msg_div').innerhtml = error.get_message(); } this works great , when web method returns (a string), looks perfect. however, if 1 of error messages thrown exception contains special character, it's displayed incorrectly in browser. example, if error message contain following: that input isn’t valid! (that's ascii #146 in there) it displays this: that input isn’t valid! ...

java - How do I learn Java5 or Java6? -

i'm experienced java programmer has spent entire time working java 1.4 , earlier. can find quick reference give me need know new features in java5 , later in quick reference? java 5 new features java 6 new features the real meat in java 5. generics, autoboxing, annotations.

linux - C++ boost/asio client doesn't connect to server -

i learning boost/asio ad wrote 2 programs(client , server) e-book minor changes. should connect server. when try connect outside world(some random http server ) , works when change destination "localhost:40002" says invalid argument. client code: #include <boost/asio.hpp> #include <iostream> int main () { try { boost::asio::io_service io_service; boost::asio::ip::tcp::resolver::query query("localhost", 40002); boost::asio::ip::tcp::resolver resolver(io_service); boost::asio::ip::tcp::resolver::iterator destination = resolver.resolve(query); boost::asio::ip::tcp::resolver::iterator end ; boost::asio::ip::tcp::endpoint endpoint; while ( destination != end ) { endpoint = *destination++; std::cout<<endpoint<<std::endl; } boost::asio::ip::tcp::socket socket(io_service); socket.connect(endpoint); } catch (std::exception& e) { std::cerr ...

oop - Is it common/good practice to test for type values in Python? -

is common in python keep testing type values when working in oop fashion? class foo(): def __init__(self,barobject): self.bar = setbarobject(barobject) def setbarobject(barobject); if (isinstance(barobject,bar): self.bar = barobject else: # throw exception, log, etc. class bar(): pass or can use more loose approach, like: class foo(): def __init__(self,barobject): self.bar = barobject class bar(): pass nope, in fact it's overwhelmingly common not test type values, in second approach. idea client of code (i.e. other programmer uses class) should able pass kind of object has appropriate methods or properties. if doesn't happen instance of particular class, that's fine; code never needs know difference. called duck typing , because of adage "if quacks duck , flies duck, might duck" (well, that's not actual adage got gist of think) one place you'll see lot in s...

How to generate a random string in Ruby -

i'm generating 8-character pseudo-random uppercase string "a" .. "z": value = ""; 8.times{value << (65 + rand(25)).chr} but doesn't clean, , can't passed argument since isn't single statement. mixed-case string "a" .. "z" plus "a" .. "z", changed to: value = ""; 8.times{value << ((rand(2)==1?65:97) + rand(25)).chr} but looks trash. does have better method? (0...8).map { (65 + rand(26)).chr }.join i spend time golfing. (0...50).map { ('a'..'z').to_a[rand(26)] }.join and last 1 that's more confusing, more flexible , wastes fewer cycles: o = [('a'..'z'), ('a'..'z')].map(&:to_a).flatten string = (0...50).map { o[rand(o.length)] }.join

Understanding 3rd party iframes security? -

facebook , others offer little iframe snipplets can put in site. example: <iframe src="http://www.facebook.com/widgets/like.php?href=http://example.com" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe> what i'd know is, if put code inside side, code load page access dom of page? see security isssues if so. likewise facebook allows me put iframe site, how facebook applications work. mine data off page contains iframe? note used facebook example here, many companies same thing quesiton not specific facebook in way not tagging such. also can parent page access dom of iframe? actually there specific rules of inheritance iframes . apart of same-origin policy, , highly recommend reading entire google browser sec handbook.

What's problem on linq databinding -

<dx:aspxgridview id="aspxgridview1" runat="server" autogeneratecolumns="false" keyfieldname="categoryid"> <settingsediting mode="inline" /> <columns> <dx:gridviewcommandcolumn visibleindex="0"> <editbutton visible="true"></editbutton> <newbutton visible="true"></newbutton> <deletebutton visible="true"></deletebutton> </dx:gridviewcommandcolumn> <dx:gridviewdatatextcolumn caption="categoryid" fieldname="categoryid" visibleindex="1"> </dx:gridviewdatatextcolumn> <dx:gridviewdatatextcolumn caption="categoryname" fieldname="categoryname" visibleindex="2"> </dx:gridviewdatatextcolumn> <dx:gridviewdatatextcolumn caption=...

ruby on rails - How can I know whether a class is inherited from another one? Some methods like is_a? -

simple example: class end class b < end then, how can judge whether class b inherited class a? there method somehow is_a? or maybe called is_child_of? ? i can't find one. you can use < operator: b < a true, if b subclass of a.

tsql - Hidden Features of SQL Server -

what hidden features of sql server ? for example, undocumented system stored procedures, tricks things useful not documented enough? answers thanks great answers! stored procedures sp_msforeachtable: runs command '?' replaced each table name (v6.5 , up) sp_msforeachdb: runs command '?' replaced each database name (v7 , up) sp_who2: sp_who, lot more info troubleshooting blocks (v7 , up) sp_helptext: if want code of stored procedure, view & udf sp_tables: return list of tables , views of database in scope. sp_stored_procedures: return list of stored procedures xp_sscanf: reads data string argument locations specified each format argument. xp_fixeddrives: : find fixed drive largest free space sp_help: if want know table structure, indexes , constraints of table. views , udfs. shortcut alt+f1 snippets returning rows in random order all database user objects last modified date return date only find records date falls somewhere in...

Inline regex replacement in perl -

is there way replace text regex inline, rather taking text variable , storing in variable? i'm perl beginner. find myself writing my $foo = $bar; $foo =~ s/regex/replacement/; dostuff($foo) where i'd write dostuff($bar->replace(s/regex/replacement/)); or like, rather using temporary variable , 3 lines. is there way this? when regex sufficiently complicated makes sense split out can better explained, when it's s/\s//g feels wrong clutter code additional variables. starting perl 5.14 can use non-destructive substitution achieve desired behavior. use /r modifier so: dostuff($bar=~s/regex/replacement/r);

sql server 2005 - SQL sub-query problem with grouping, average -

in ms transact sql, let's have table (orders) this: order date order total customer # 09/30/2008 8.00 1 09/15/2008 6.00 1 09/01/2008 9.50 1 09/01/2008 1.45 2 09/16/2008 4.50 2 09/17/2008 8.75 3 09/18/2008 2.50 3 what need out of is: each customer average order amount recent 2 orders. customer #1, should 7.00 (and not 7.83). i've been staring @ hour (inside larger problem, i've solved) , think brain has frozen. simple problem? this should make it select avg(total), customer orders o1 orderdate in ( select top 2 date orders o2 o2.customer = o1.customer order date desc ) group customer

design - How would you balance between designing and (actually) implementing you application -

my question not programming language specific, more generic question see way of people thinking. usually in large development houses there specific roles each job, such programmers , architects. architects point of view have perfect architect , solution design, on other hand programmers dealing implementing application features , ui stuff. therefore if let architect example working on application out programmers application perfect frominside (design patterns, classes, db tables) nothing outside, applies vice versa. programmers focus on output without giving concern design principles (for instance solid principles). now working on small firm team composed of 8-10 people max, need take care of application design implementing features. question when need stop designing , implement solution? or should incremental work? what if reached point screwed because didn't design beginning ? i hope can have different ways of thinking can come-up multiple acceptable solutions ...

asp.net - Url Rewrite in IIS 7.5 causes Internal server error -

i have web application runs @ windows 2008 r2, asp.net v4.0. i installed url rewrite module, , started use shown in official examples. my problem starts when <rewrite> tag added web.config under <system.webserver> - when try browse page under current application, 500 - internal server error . this <rewrite> block i've been adding: <system.webserver> <rewrite> <rules> <rule name="test1"> <match url="^default/([0-9]+)/([_0-9a-z-]+)" /> <action type="rewrite" url="default.aspx?id={r:1}&amp;title={r:2}" /> </rule> </rules> </rewrite> </system.webserver> just had same error , found fix. need install module iis url rewrite. can dowload here: http://www.iis.net/download/urlrewrite cheers,

Do a "git export" (like "svn export")? -

i've been wondering whether there "git export" solution creates copy of tree without .git repository directory. there @ least 3 methods know of: git clone followed removing .git repository directory. git checkout-index alludes functionality starts "just read desired tree index..." i'm not entirely sure how do. git-export third party script git clone temporary location followed rsync --exclude='.git' final destination. none of these solutions strike me being satisfactory. closest 1 svn export might option 1, because both require target directory empty first. option 2 seems better, assuming can figure out means read tree index. probably simplest way achieve git archive . if need expanded tree can this. git archive master | tar -x -c /somewhere/else most of time need 'export' git, want compressed archive in case this. git archive master | bzip2 >source-tree.tar.bz2 zip archive: git archive --format zip -...

php - How do I write this array in simple method? -

i have function calculations lot. $arrleft , $arrright 2 different arrays. doing here combining 2 produce output current application. done simple method , eats lots of space , time. want if 1 can make code couple of lines shorter(i know can if in loop). cant myself putting here opinion. $arrleft = explode(',' , $data1); $arrright = explode(',' , $data2); if(isset($data1,$data2)){if(isset($arrleft[0],$arrright[0],$arrleft[1],$arrright[1],$arrleft[2],$arrright[2],$arrleft[3],$arrright[3],$arrleft[4],$arrright[4])) { $totalnumber = ($valueset+1)//calculate total number of variables set + 1 here $valueset = 4 $total number (4+1)=5 $value = (0, 0, $arrleft[0]); $value1 = (0, 1, $arrright[0]); $value2 = (1, 0, $arrleft[1]); $value3 = (1, 1, $arrright[1]); $value4 = (2, 0, $arrleft[2]); $value5 = (2, 1, $arrright[2]); $value6 = (3, 0, $arrleft[3]); $value7 = (3, 1, $arrright[3]); $value8 = (4, 0, $...

c# - Windows Forms - Enter keypress activates submit button? -

how can capture enter keypresses anywhere on form , force fire submit button event? if set form's acceptbutton property 1 of buttons on form, you'll behaviour default. otherwise, set keypreview property true on form , handle keydown event. can check enter key , take necessary action.

iphone - Application Loader: "No eligible applications were found." -

we have submitted application app store (and it's live). upload updates, trying "application loader". getting following error: "no eligible applications found." "to add application witg application loader, must first log in itunes connect , provide information application adding." not sure needs done. thanks in advance, sunil you need go itunes connect , go manage applications sections. there should select live app view it's details, , hit "add new version" button. you should fill out necessary meta data. @ point can change apps name appears in app store or change keywords, screenshots etc. then once done , submitted, should click ready upload binary button near top right of page. you'll asked usual questions adding or modifying encryption , new question regarding icloud , legal issues. answer according particular situation , carry on. app should in "waiting upload" state. once update in state, can...

java arraylist help needed -

have coded in many languages before new java. want create array members of type public class data { string date=""; string time=""; double price=0; int volume=0; }; data data1 = new data(); public arraylist ftsedata = new arraylist<data>(); i market data insert data1 followed by ftsedata.add(data1); i wait fresh data , when insert again data1 , add ftsedata. although ftsedata seems increasing in size correctly seems elements of ftsedata pointers data1 , hence elements of ftsedata seems have values equal last data1 values. i using arraylist because not know how many datapoint come in during day need expands. could please tell me if should using arraylist or else , if arraylist problem. many time. many everyone, i have 4 different functions each fill 1 part of data1. taking views on board, left data1 alone variable can seen in functions. in particular function adds data1 arraylist created ...

Why is there a private access modifier in an abstract class in Java, even though we cannot create an instance of an abstract class? -

i know not coding practice declare method private in abstract class. though cannot create instance of abstract class, why private access modifier available within abstract class, , scope of within abstract class? in scenario private access specifier used in abstract class? check out code vehicle class abstract , car extends vehicle. package com.vehicle; abstract class vehicle { // scope of private access modifier within abstract class, though method below cannot accessed?? private void onlights(){ system.out.println("switch on lights"); } public void startengine(){ system.out.println("start engine"); } } within same package creating car class package com.vehicle; /* * car class extends abstract class vehicle */ public class car extends vehicle { public static void main(string args[]){ car c = new car(); c.startengine(); // startengine() can accessed } } since abstract class can contain functionalit...

shell - Delete strings from an html file containing a pattern using unix commands -

i have messy html looks this: <div id=":0.page.0" class="page-element" style="width: 1620px;"> <div> <img src="viewer_files/viewer_004.png" class="page-image" style="width: 800px; height: 1131px; display: none;"> <img src="viewer_files/viewer_005.png" class="page-image" style="width: 1600px;"> </div> </div>// repeats 100+ times different 'src' attributes now 1 line actually (i have formatted in multiple lines easy readibility). trying remove <img> tags have display:none; set in inline css. possible use sed/awk or other unix command achieve this? think if indented html document, would've been easy. sed -e "s/<img[^>]*display: none;[^>]*>//g" filein a quick explanation sed : s stands substitution / delimiters s means first field pattern search, replaced second one. last 1 options. g means glob...

What is the best way to escape Python strings in PHP? -

i have php application needs output python script, more bunch of variable assignment statements, eg. subject_prefix = 'this string user input' msg_footer = """this 1 too.""" the contents of subject_prefix et al need written take user input; such, need escape contents of strings. writing following isn't going cut it; we're stuffed uses quote or newline or else i'm not aware of hazardous: echo "subject_prefix = '".$subject_prefix."'\n"; so. ideas? (rewriting app in python isn't possible due time constraints. :p ) edit, years later: this integration between web-app (written in php) , mailman (written in python). couldn't modify install of latter, needed come way talk in language manage configuration. this really bad idea. do not try write function in php. inevitably wrong , application inevitably have arbitrary remote execution exploit. first, consider problem solving. ...

ruby on rails - Application level filtering/data manipulation -

i have model many different children (has_many). my app needs lots of different manipulation on set of data. therefore getting data database pretty simple, won't need use scopes , finders, want things on data equivalent say: named_scope :red, :conditions => { :colour => 'red' } named_scope :since, lambda {|time| {:conditions => ["created_at > ?", time] }} should writing equivalent methods manipulate served data? or in helper? just need little things see relate querying actual database subset of data, when require children of 1 model, many different visualisations on it. so, if understand right, you'd query whole set of data once, select different sets of rows different uses. named scopes won't caching, building separate queries each variation. if want simple, can query rows (activerecord cache result same query), can use select filter rows: article.all.select{|a| a.colour == 'red'} or, 1 step further, can ...

windows - Copying file security permissions -

i'm copying file folder folder b , trying copy file permissions. here basic steps i'm using: copyfile(source, target) getnamedsecurityinfo(source, group_security_information | dacl_security_information) print source sd using convertsecuritydescriptortostringsecuritydescriptor setnamedsecurityinfo(target, group_security_information | dacl_security_information) getnamedsecurityinfo(target, group_security_information | dacl_security_information) print target sd using convertsecuritydescriptortostringsecuritydescriptor at #3 sd: g:s-1-5-21-1454471165-1482476501-839522115-513d:ai(a;id;0x1200a9;;;bu)(a;id;0x1301bf;;;pu)(a;id;fa;;;ba)(a;id;fa;;;sy)(a;id;fa;;;s-1-5-21-1454471165-1482476501-839522115-1004) at #6 get g:s-1-5-21-1454471165-1482476501-839522115-513d:ai(a;id;0x1301bf;;;pu)(a;id;fa;;;ba)(a;id;fa;;;sy) the call setnamedsecurityinfo returns error_success, yet results source , target file not have same sds. why that? doing wrong here? shfileopera...