Posts

Showing posts from September, 2014

silverlight - Get ResponseHeaders from WebClient after OpenReadCompleted -

i filename out of content-disposition header when webclient openreadasync completed. can see header in response in fiddler, when try access silverlight system.notimplementedexception - property not implemented class. is there way these headers? response headers not supported in browser http handling. must specify client http handling before calling httphandler: bool httpresult = webrequest.registerprefix("http://", webrequestcreator.clienthttp); webclient wc = new webclient(); wc.openreadcompleted += new openreadcompletedeventhandler(wc_openreadcompleted); wc.openreadasync(...); the result headers available on webclient object in wc_openreadcompleted method. have at: http://msdn.microsoft.com/en-us/library/dd920295(v=vs.95).aspx

jquery - toggle divs, but only have one shown at once -

i have thumbnails slidetoggle hidden div. want 1 stay open @ once though. when next thumbnail clicked, open div closes , new 1 opens. i doing show , hide, looks bad because loose animation slidetoggle. so what's best way hide toggled divs , open new one? here html: <div id="maincontainer"> <div id="rowone"> <img src="illinoislottery_thumbnail_taller.jpg" id="rowoneleftimage" /> <img src="illinoislottery_thumbnail_taller.jpg" id="rowonemiddleimage" /> <img src="illinoislottery_thumbnail_taller.jpg" id="rowonerightimage"/> </div> <div id="rowoneleftimagehidden"> information left image in first row. </div> <div id="rowonemiddleimagehidden"> information middle image in first row. </div> <div id="rowonerightimagehidden"> information right image in first row.

PHP html generator class -

i use class create html content http://code.google.com/p/php-class-html-generator/ i try build table in way , html result wrong... $messalist = array(...); $html = htmltag::createelement('table')->id( $attr['id'] ); foreach($messagelist $message){ $html->addelement('tr') ->addelement('td')->settext($message['subject']) ->addelement('td')->settext($message['from']) ->addelement('td')->settext($message['date']) ->addelement('td')->settext($message['size']); } echo $html; how in right way? thanks this generated html: <table id="messagelist"> <tr> <td> <td> <td> <td>1.91kb</td>23 feb 11:56 am</td>to: me@me.com</td>re: helooo</td></tr> <tr> <td> <td&g

c# - Cache Entity Framework data and track its changes? -

what want pretty simple conceptually can't figure out how best implement such thing. in web application have services access repositories access ef interacts sql server database. of these instanced once per web request. i want have layer between repositories , ef (or services , repositories?) statically keeps track of objects being pulled , pushed database. the goal, assuming db-access accomplished through application, know fact unless repository access ef , commits change, object set didn't change. an example be: repository invokes method getallcarrots(); getallcarrots() performs query on sql server retrieving list<carrot> , if nothing else happens in between, prevent query being made on sql server each time (regardless of being on different web request, want able handle scenario) now, if call buycarrot() adds carrot table, want invalidate static cache carrot s, make getallcarrots(); require query database once again. what resources on database c

dowload file from shared drive to desktop C# -

i'm trying download file shared drive desktop keeps throwing error not virtual path. here code: if (directory.exists(server.mappath("m://shareddrive//" + username))) { file.copy("m://shareddrive//" + username, "c:\\documents , settings\\user\\desktop\\" + username, true); } are doing in asp.net application? (i'm guessing since using server.mappath ). have 2 problems: iis runs in service session, has no access users' mapped drives such m: . iis can access physical drives, or unc paths (the latter requires security set correctly). iis has no access user's desktop. please explain bit more detailed trying achieve if able help.

c# - How to abstract a static classes -

i have static class. can modify , make extends interface\abstract class. it contains lots of readonly , consts members. staic methods. in order make code testable, want to separate dto , manager. abstract each of them. how classes static? in opinion there 2 things static classes for: providing global functions/algorithms (that should not depend on state - a.k.a pure functions) hold global data if model methods in there pure can test right away. global data (your constants , read-only members) on other hand don't need testet should produced said methods. so if static methods use global data class refactor them include data parameters method, overload simple wrappers feeding global data , test new - pure - functions. take care include things database-data or system-times (datetime.now) , similar side-effect data methods well. if parameterlist gets big refactor method class some/most of parameters encapsulated new classes fields - remember s solid

pdf - asp.net, how do you separate a repeater using page break -

i'm trying create batch of letters using repeater far when convert letters pdf contents of letters written 1 after other on same page. want split repeater each letter has own page. how do this? please me!! :) usually when convert pdf, page breaks controlled standard css styles page-break-before:always , page-break-after:always applied html object. these styles can used either in css class applied element or inline in element style attribute. so in repeater should (pardon pseudo code): <asp:repeater> <itemelement> <div style="page-break-after:always;"> <asp:label id="lblletter"> </div> </item> </asp:repeater> where lblletter set letter in server-side event.

html - Split a <td> table element into LEFT and RIGHT justified -

whats best way split table element <td> ? don't want use nested tables. need internal element have 2 elements 1 left justified , other right justified no border. for example: <table> <tr> <td>left, right</td> </tr> </table> any other ways besides following? <table> <tr> <td>left</td> <td>right</td> </tr> </table> i want internal element <span> or whatever best this. <table> <tr> <td> <div style="float:left">left</div><div style="float:right">right</div> </td> </tr> </table>

What is the relationship between Perl PAR::Packer's pp, par.pl, parl scripts? -

i'm trying learn par , par::packer. understand par module allows loading modules .par archives. don't understand 3 scripts pp , par.pl , parl in par::packer. (note: in question parl includes parl.exe windows). what par.pl supposed be? perl script contains perl interpreter (the same 1 on development machine) , par module? what parl ? binary contains same thing par.pl? if i'm not mistaken in par.pl , parl are, why want par.pl ? parl seems strictly superior since can run without pre-existing perl. is parl safe distribute end users no perl ever? example, if have several scripts want distribute, both sharing many modules, can distribute parl , pars scripts , modules, , simple wrapper scripts launch par'd scripts parl ? parl , par.pl can both produce standalone scripts/exectubles -b , -b options, respectively. mean pp frontend/wrapper? what par.pl supposed be? perl script contains perl interpreter (the same 1 on development machi

wpf - ComboBox does not reflect its ItemsCount -

i trying build small application combobox , issue items not getting updated in properly, 2 items sometime 4 items getting visible items count getting updated properly. following xaml code: <combobox name="numberscombo" width="118"> <combobox.itemtemplate> <datatemplate> <textblock text="{binding title}" /> </datatemplate> </combobox.itemtemplate> </combobox> following code itemssource on page load, con.numbers dictionary of string , numbers class, hence values sent attachment: numberscombo.itemssource = con.numbers.values following code adding new items combobox: dim temp new bsplib.contactlib.contactcon(con.prime.conid, false) con.numbers.add(temp.conrowid, temp) numberscombo.itemssource = con.numbers.values testlabel1.content = numberscombo.items.count

Different behavior in Visual C++ compared to MingW -

i have wrapper class int, named intwrapper , , function addn adds 2 numbers, defined follows: intwrapper* addn(intwrapper *first, intwrapper *second) { intwrapper c; c.setdata(first->getdata() + second->getdata()); return &c; } then, in main() function this: intwrapper first(20), second(40); intwrapper* t = addn(&first, &second); cout << (*t).getdata() << endl; in dev-c++(mingw32) executes intended, , print value 60 , in visual c++ value -858993460 . however, if use new keyword create new object inside addn function outputs 60 in visual c++. intrigued why happens. thoughts? full code here: #include <iostream> using namespace std; template<typename t, t defaultvalue> class wrapper { private: t n_; public: wrapper(t n = defaultvalue) : n_(n) {} t getdata() { return n_; } void setdata(t n) {

php - Is it possible to echo any variable inside JText::_ if so how -

is possible print variable inside jtext ie:- need print $email test whether nil or has value in it... $this->setmessage(jtext::_('com_users_registration_activate_success')); the jtext class has static method '_' converts string argument passed into string, using language files , settings appropriate context. if want see being passed setmessage try: echo 'debug setmessage argument: "'.jtext::_('com_users_registration_activate_success').'"'; if find reveals _ returning nothing, indication there not entry 'com_users_registration_activate_success' in language file(s) being used. edit: if need append $email this: $this->setmessage(jtext::_('com_users_registration_activate_success').$email);

javascript - Passing data from my razor view to my js file -

i'm searching best way pass data razor view js file . example, lets have jquery dialog configured in js file. buttons text on dialog, localize (through resource files fr/nl/uk). translations available @userresource.buttondelete + @userresource.buttoncancel below different solutions see: using nice razorjs nuget package allows razor code inside javascript file. works pretty well. question is: is bad practice compile js files in order use razor syntax inside scripts? declaring global variables in js script file , assign value view this: in view: <script> var labelbuttondelete = @userresource.buttondelete; </script> in js file: alert('the text button ' + labelbuttondelete); what best way pass data razor js file? have alternative? thanks anyway. i've been using second approach time without issues. difference i'm using singleton in js file avoid polluting global javascript namespace. but if doing more serious client

Griffon checkbox binding won't work -

i trying following griffon code on model: @bindable boolean hello1=false on view: checkbox(id:1,text: 'hello1', constraints:'wrap',selected:bind(target: model, targetproperty:'hello1')) but error org.codehaus.griffon.runtime.builder.uberbuilder - error occurred while building test.testview@1132e76 groovy.lang.missingmethodexception: no signature of method: java.lang.object.setvariable() applicable argument types: (java.util.collections$emptymap, java.util.arrays$arraylist) values: [[:], [1, javax.swing.jcheckbox[,0,0,0x0,invalid,alignmentx=0.0,alignmenty=0.5,border=javax.swing.plaf.synth.synthborder@b101cf,flags=288,maximumsize=,minimumsize=,preferredsize=,defaulticon=,disabledicon=,disabledselectedicon=,margin=javax.swing.plaf.insetsuiresource[top=0,left=0,bottom=0,right=0],paintborder=false,paintfocus=true,pressedicon=,rolloverenabled=true,rollovericon=,rolloverselectedicon=,selectedicon=,text=]]]8-mar-2012 12.03.41 groovy.util.factorybuildersu

c# - How can I change the way my data shows up on GridView after I pulled it from SQL DB -

i pull data out of database , put in dataset through sqladapted , databind it. my question how can change way data presented in table? example: should have 2 digits after decimal , should have 3 etc. example: should right justified whereas should centered? when build gridview, can assign items <asp:boundfields> , instead of using "autogeneratecolumns". gives more control, example: <asp:boundfield datafield="datelastcontacted" headertext="contacted" sortexpression="datelastcontacted" itemstyle-cssclass="resultscell" headerstyle-cssclass="resultsheader" itemstyle-horizontalalign="center" dataformatstring="{0:dd mmm yyy}" nulldisplaytext="n/a" /> you can use itemstyle-horizontalalign="center" alignment, , use dataformatstring="{0:n2}" specify decimals, see here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataf

java - Lucene Wildcard Search doesn't seem to rewrite the query like it does for Fuzzy Search -

when @ at explain of fuzzy query can see has replaced existing search term artist:republica~0.5 with terms in documents matched (artist:republic^0.78 artist:republica^1.04 artist:republice^0.80888885) but wildcard query doesnt seem to artist:republica* gives constantscore(artist:republica*^1.04)^1.04 why ? never mind thought multi-term queries used same rewrite method reading of javadocs realise fuzzy query uses different rewrite method wildcard , prefix queries. fuzzyquery: multitermquery.toptermsscoringbooleanqueryrewrite wildcardquery: multitermquery.constantscoreautorewrite

javascript - jQuery change html on clone -

on click copying div. wish alter of html , append. i have tried following, clone , append cant seem alter html. not sure best way handle it, sure have wrong. thanks var htmlstr = $(this).parents(".listingcontainer").first(); $htmlstr.find(".savecompareshow").remove() $(htmlstr).clone().appendto('.comparewrapper'); once have cloned dom element should treat though wanted change dom element isn't being cloned. use variable instead of selector. assuming have html this: ​<div class='listingcontainer'> <div class='listing'> </div> <div class='listing'> </div> </div> you can clone contents of listingcontainer div , change contents before appending them comparewrapper div. following javascript shows simple example: $(document).ready(function() { $('.listing').click(function() { var $htmlstr = $(th

dynamic - Can we import and export a function from a dll -

i have dll "a.dll" exports function "int foo()". have dll "b.dll" consumes a.dll , uses function foo() , exports other functions. possible export function "int foo()" (imported a.dll) b.dll can consumed in third dll "c.dll". i want know whether possible or not, dont want workarounds making a.dll available third dll. also, not concerned if bad design or not. thanks patience read through. kapil. as a.dll exports 1 function, function available application (like b.dll uses it). c.dll capable import exported functions a.dll. additionally, might take called "export forwarding" (see url ) mechanism enables 1 export functions b.dll , implemented these in a.dll (like \system32\sfc.dll exports functions forwarded \system32\sfc_os.dll)

html5 - Download Binary Data as a File Via Javascript -

i'm making ajax call api returns binary data. i'm wondering if possible take binary data , display client in new window? i'm doing right now. problem is, document opens up, blank. $.ajax({ type: "post", url: apiurl, data: xmlrequest, complete: function(xhr, status) { var bb = new window.webkitblobbuilder(); // append binary data blob bb.append(xhr.responsetext); var bloburl = window.webkiturl.createobjecturl(bb.getblob('application/pdf')); window.open(bloburl); } }); any ideas? okay, figured out. had specify responsetype 'array buffer': function downloadpdf() { var xhr = new xmlhttprequest(); xhr.open('post', api_url, true); xhr.responsetype = 'arraybuffer'; xhr.onload = function(e) { if (this.status == 200) { var bb = new window.webkitblobbuilder(); bb.append(this.response); // note: not xhr.responsetex

c++ - vector sort and erase won't work -

when using code remove duplicates invalid operands binary expression errors. think down using vector of struct not sure have googled question , code on , on again suggests code right isn't working me. std::sort(vec.begin(), vec.end()); vec.erase(std::unique(vec.begin(), vec.end()), vec.end()); any appreciated. edit: filesize = textfile.size(); vector<wordfrequency> words (filesize); int index = 0; for(int = 0; <= filesize - 1; i++) { for(int j = 0; j < filesize - 1; j++) { if(string::npos != textfile[i].find(textfile[j])) { words[i].word = textfile[i]; words[i].times = index++; } } index = 0; } sort(words.begin(), words.end()); words.erase(unique(words.begin(), words.end(), words.end())); first problem. unique used wrongly unique(words.begin(), words.end(), words.end())); you calling 3 operand form of unique , takes start, end, , predicate. compiler pass words.end() predicate,

c# - Can not get MSMQ Com to find my Queue -

i trying count of messages in msmq. have found code on internet (many times): // setup queue management com stuff msmqmanagement _queuemanager = new msmqmanagement(); object machine = "mylaptopcomputer"; object path = @"direct=os:mylaptopcomputer\private$\myqueue"; _queuemanager.init(ref machine, ref path); console.writeline(_queuemanager.messagecount); marshal.releasecomobject(_queuemanager); every time _queuemanager.init fails error: the queue path name specified invalid. i have checked (and double checked) queue name see if wrong. have tried different queues, different machines, running remote, running local... nothing works. i have tried variations on code above. example have tried: _queuemanager.init("mylaptopcomputer", @"direct=os:mylaptopcomputer\private$\myqueue"); the queues used nservicebus , function fine when use nservicebus access them. does have idea on how can work? i think problem error you

c# - Generic ServiceFactory<T> for WCF Channel Factory and StructureMap with MVC 3 -

so interesting post because must include code , attempt explain how have setup architecture. i have placed service , datacontracts in central assembly (dmt.wcf.contracts). done distributed pieces of application can reference same type of service interfaces , contracts nice. i have setup structuremap container inject dependencies in following manner, specifying servicecontext, house of service interface properties can referenced int application later. public interface iservicecontext { } public class servicecontext: iservicecontext { public iauthenticationservice authenticationservice { get; set; } public servicecontext(iauthenticationservice authenticationservice) { authenticationservice = authenticationservice; } } then, have structuremapcontrollerfactory looks following: public class structuremapcontrollerfactory:defaultcontrollerfactory { protected override icontroller getcontrollerinstance(requestcontext requestcontext, type controllerty

c# - How to view collapsed elements while designing a WPF control? -

i set datagrid collapse when there no items <datagrid name="datagrid" visibility="{binding hasitems, elementname=datagrid, converter={staticresource booleantovisibilityconverter}}"> </datagrid> the problem is, appear on design mode. how it? should create fake data? i tried private void usercontrol_loaded(object sender, routedeventargs e) { if (designerproperties.getisindesignmode(this)) { this.datagrid.itemssource = new list<table> { new table() }; } } but didn't work if understand trying do, works me: <window x:class="wpfscratch.mainwindow" xmlns:local="clr-namespace:wpfscratch" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x="http://schemas.microsoft.com/win

php - Select random row per distinct field value? -

i have mysql query results in this: person | some_info ================== bob | pphsmbf24 bob | rz72nixdy bob | rbqqarywk john | kif9adxxn john | 77tp431p4 john | hx4t0e76j john | 4yiomqv4i alex | n25pz8z83 alex | orq9w7c24 alex | beuz1p133 etc... (this simplified example. in reality there 5000 rows in results). what need go through each person in list (bob, john, alex, etc...) , pull out row set of results. row pull out sort of random sort of based on loose set of conditions. it's not important specify conditions here i'll it's random row example. anyways, using php, solution pretty simple. make query , 5000 rows , iterate through them pulling out random row each person. easy. however, i'm wondering if it's possible mysql query don't have use php iterate through results , pull out random rows. i have feeling might involve bunch of subselects, 1 each person, in case solution more time, resource , bandwidth intensive cur

using MonoTouch / Mono for Android with Eclipse IDE -

currently doing first steps monotouch , continue mono android soon. far using monodevelop ide, lacking lots of features got used when using eclipse. how difficult integrate monotouch / mono android eclipse? this solve lot of problems me :) it's likely easy mono android uses msbuild system (tasks) mono provides compatible tool, called xbuild won't easy monotouch. monotouch provides tool, mtouch most (but not all) of work build ios applications. can see how it's used if @ build output inside monodevelop (inside error list pad). there few steps done monodevelop iphone addin. of them can done using mtouch - not of them (it depends on project). the following questions talks similar subject (using msbuild drive monotouch builds). monotouch: custom msbuild task error what complete set of steps build monotouch app bundle command line?

c# - IoC / DI containers, factories and runtime type creation -

i learned di frameworks guice , ninject , wanted use them in of new projects. while familiar general dependency injection concepts , know how use frameworks construct object graphs, struggle apply ioc when comes dynamic application behavior. consider example: when application starts, main window shown. when user clicks main panel, context menu opens. depending on user' selection, new user control created , shown @ mouse position. should user decide close application, confirmation box shown , - upon confirmation - main window closed. while easy wire main window's view presenter/viewmodel , bind domain logic, don't understand how cleanly (in sense of ioc) achieve following tasks: dynamically instantiate concrete ui control (e.g. igreenboxview , iredimageview <-- jconcretegreenboxview , jconcreteredimageview ) without using kind of service locator pattern (e.g. requesting ioc again) depending on that, create new model, presenter , view instance

ios - Master Table Application -

i using basic ipad master table application uses portrait orientation only. wish stop masterviewcontroller appearing when swipe right (making accessible button). solution simple unfortunately self taught newbie. this new feature of uisplitviewcontroller introduced in ios 5.1. in order disable feature, implemented new property called presentswithgesture turn on , off. apple highly recommends leave on people grow expect work way, if must disable it, somewhere in code need add this: self.splitviewcontroller.presentswithgesture = no; or, if creating splitviewcontroller manually set presentswithgesture no.

php - Using a string path to set nested array data -

i have unusual use-case i'm trying code for. goal this: want customer able provide string, such as: "cars.honda.civic = on" using string, code set value follows: $data['cars']['honda']['civic'] = 'on'; it's easy enough tokenize customer input such: $token = explode("=",$input); $value = trim($token[1]); $path = trim($token[0]); $exploded_path = explode(".",$path); but now, how use $exploded path set array without doing nasty eval? use reference operator successive existing arrays: $temp = &$data; foreach($exploded $key) { $temp = &$temp[$key]; } $temp = $value; unset($temp);

c++ - pg:172-176.PartA.Interface Design Alternatives, Stroustrup-CPL-3E -

on page 172, stroustrup doing so: namespace parser { //interface users double expr(bool); } namespace parser { //interface implementers double prim(bool); double term(bool); double expr(bool); using lexer::get_token; <snip> } q1. imply first namespace being inserted (as example) user.h , included main.cpp - driver; second namespace implementer.h , included parse.cpp? why says: "compiler doesn't have sufficient information check consistency of 2 definitions of namespace" because both implementer.h , user.h can't included "parser implementation"(parse.cpp)? 172.png 173.png on page 174, has: namespace parser { //interface implementers // ... double expr(bool); // ... } namespace parser_interface { //interface users using parser::expr; } is upper namespace going implementer.h , lower 1 user.h in " dependency graph " restating obvious: when make run, chan

android - Launch another intent from AndEngine activity -

i have 2 activities, mainmenuactivity , gameactivity, each inherit andengine's basegameactivity. i'm trying launch game main menu: startactivity(new intent(getapplication(), gameactivity.class)); finish(); this being called within onscenetouchevent. causes application crash in poolupdatehandler::onupdate, on line says "synchronized (scheduledpoolitems)". i feel should simple. clues? try suggestion swapping out getappliction() this . want pass in reference current activity's context rather passing in application reference.

c++ - Overload reference conversions -

the following class seems compile , conversion operators never called: class { public: operator a() const { std::cout << "a() called" << std::endl; return *this; } operator a&() { std::cout << "a&() called" << std::endl; return *this; } operator const a&() const { std::cout << "const a&() called" << std::endl; return *this; } }; is function specifying conversion reference ignored? here's quote 12.3.2 a conversion function never used convert (possibly cv-qualified) object (possibly cv-qualified) same object type (or reference it) also, using -wall -wextra -pedantic -ansi on gcc gave me: warning: statement has no effect static cast. (also, try clang online give nice compiler error messages).

iphone - How to set Parser Delegate to Self in ARC environment? -

hey have used parsers in past never in arc environment. when try , set parser self gives me error message , doesn't parse data. know problem , how solve it? here warning when try set parser delegate self: semantic issue: sending 'charitycontroller *const __strong' parameter of incompatible type 'id<nsxmlparserdelegate>' here code: - (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { if (connection == theconnection) { // data object. //nslog(@"data server is: %@",data); nsstring *test = [[nsstring alloc]initwithdata:data encoding:nsstringencodingconversionallowlossy]; nslog(@"data server is: %@",test); parser = [[nsxmlparser alloc] initwithdata: data]; [parser setdelegate:self]; [parser parse]; } } - (void)parser:(nsxmlparser *)parser didstartelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsst

c# - Why does this LINQ grouping have a count of 3 instead of 2? -

given following classes: public class weekofyear : iequatable<weekofyear>, icomparable<weekofyear> { private readonly datetime datetime; private readonly dayofweek firstdayofweek; public weekofyear(datetime datetime) : this(datetime, dayofweek.sunday) { } public weekofyear(datetime datetime, dayofweek firstdayofweek) { this.datetime = datetime; this.firstdayofweek = firstdayofweek; } public int year { { return datetime.year; } } public int week { { return cultureinfo.currentculture.calendar.getweekofyear(datetime, calendarweekrule.firstday, firstdayofweek); } } public bool equals(weekofyear other) { return year == other.year && week == other.week; } public int compareto(weekofyear other) { if (year > other.year || year == other.year && week > other.week)

c++ fstream - creating own formatting flags -

i need create new flags format of output file. have class class foo{ bar* members; ofstream& operator<<(ofstream&); ifstream& operator>>(ifstream&); }; and want use like: fstream os('filename.xml'); foo f; os << xml << f; os.close(); this save xml file. fstream os('filename.json'); foo f; os << json << f; os.close(); and json file. how can this? you can create yor own manipulators, either hijacking existing flag or using std::ios_base::xalloc obtain new stream specific memory, e.g. (in implementation file of foo : static int const manipflagid = std::ios_base::xalloc(); enum { fmt_xml, // becomes default. fmt_json }; std::ostream& xml( std::ostream& stream ) { stream.iword( manipflagid ) = fmt_xml; return stream; } std::ostream& json( std::ostream& stream ) { stream.iword( manipflagid ) = fmt_json; return stream; } std::ostre

php - How to insert md5 hash value in MS sql server? -

i have table user have password field. here want input md5 hash value directly database since haven't prepare registration apps. there function or attributes column. search option , couldn't found options in sql server database , using md5 function in php select password of user table does mean passwords in database aren't hashed @ all? i know isn't answer looking but: md5 wrong hash use passwords. quick. need use hashing algorithm takes lot more time. salt . or better yet, use proven library handle you.

bash - How to grep for new folders which don't match folders from the pattern -

i need following in bash: go folder , recursively check new files in current folder, new files last update time >=d - 7 days, remember name of every new files i this: find ./ -type f -ctime -7 -exec ls {} \; > new.files then need go previous directory cd ../ , find new folders created not white list (the list of folders) , updated during last 7 days. if find directory need go directory , check new files did before ( find ./ -type f -ctime -7 -exec ls {} \; > new.files.from.new.dir ) as result should send list of new files , list of new directories (not white list) new files. thank in advance help! here's finished, refined script! note cool use of redirection. :) #!/bin/bash ##################### # # file change finder # #################### #export use in shells! export curr_dir=`pwd` results_loc=$curr_dir whitelists_loc=$curr_dir period=0.1 #before x number of days... can fractional #also, needed shells, hence source export ftime=-$period #m

What are the best deployment Tools & Best Practices for Drupal Sites Databases -

i've been asked developpement team of information/news centric website based on drupal 7 goal of automating deployment staging production, done manually , lots of mistakes made, delaying official launch of website. i'm aquainted tools phing deploy php applications developed zend framework or symfony , have small knowledge capistrano. after research here , there, have stumbled upon certains tools combination formula automated deployment: drush + capistrano migraine i'm looking best practices first launch date close , tools later implementation presume take times before master capistrano/drush automate deployment of both files , settings stored in drupal's db. one current trend in drupal development move site configuration out of database , code using features module . nuvole made excellent presentation on (although regards making drupal distributions, concerns large-scale sites similar. moving site configuration code, many errors can eliminated c

ios5 - Videos have no sound on iOS 5.0.1 -

i got several reports sound of videos played in iphone app not playing anymore. not able reproduce problem on iphone though. obvious solution, "mute" turned on considered. sound playing on other apps, e.g. youtube. the devices running ios 5.0.1 , videos delivered through .m3u8 file contains references several other .m3u8 files contain references .ts video files. not invention, if source of problem, open other suggestions streaming videos. unfortunately, neither knowledgable streaming videos or video formats. any suggestions might shed light on situation appreciated. i found answer question in thread: http://forums.macrumors.com/showthread.php?t=1247982 it doesn't have video encoding or may app. problem "rotation lock" switch can used "mute" switch. quote: if select "use side switch to:" lock rotation when set mute, , side switch in mute position when switch toggle mute rotation, thinks it's still on mute.

java - problems invoking a method with a generic type argument -

i have problem generics, let me explain. i have class wraps linkedlist: public class idnlist<t extends numerable> extends idnelement implements list<t> { private linkedlist<t> linkedlist; @override public boolean add(t e){ return linkedlist.add(e); } //stuff } please note generic type t of class extends numerable interface. ok, inside different class want invoke method follows: if(childtoadd instanceof numerable) ((idnlist<?>)this).add((numerable)childtoadd); but eclipse says: the method add(capture#1-of ?) in type idnlist<capture#1-of ?> not applicable arguments (numerable) , , can't figure out why can't work. why can't add numerable object list? missing? edit: it's classic. ask, , find clue. seems workaround is: ((idnlist<numerable>)this).add((numerable)childtoadd); but don't know how elegant is. appreciate further comments. say have classes a , b both ext

php - replace trailing zeros regex with dot(.) and comma(,) including delimiter , -

i use regular expression remove trailing zeros numbers dot( . ) delimiter: (?:(\.\d*[1-9])|\.)0*$ and i'm replacing $1 . example: 9.50 2.00 3.06 3.000 it give me: 9.5 2 3.06 3 but doesn't seem work same way comma( , ). tried no luck: (?:(\,\d*[1-9])|\,)0*$ i'm new php , first question here. thank in advance. if these separate strings, numbers only, use: [.,]?0*$ , replace empty string.

php - Converting City&Country to Coordinate points -

is there fast php code convert city + country latitude , longitude coordinates. have list of locations , need convert them coordinates. tried doing in javascript, encountered problems trying results php store in json file. there efficient php code this? thanks. in app, i'm using following function geo-code locations using google service. function takes 1 parameter - location geo-code (e.g. "boston, usa" or "sw1 1aa, united kingdom") , returns associative array lat/lon. if error occurs or location cannot determined, returns false. note in many cases city + country not able determine location uniquely. example, there 100 cities named springfield in usa alone. also, when passing country geo-coding service, make sure put full country name , not 2-letter code. found hard way: passing 'ca' "canada" , getting strange results. apparently, google assumed 'ca' means "california". function getgeolocationgoogle($lo

Best way in PHP to ensure in a class that all the class functions are called only if a given condition is true -

i have class in each function of class have check exact same condition before executing code: class myobject { public function function1($argument) { if($condition === true) { //do } } public function function2($argument) { if($condition === true) { //do } } public function function3($argument) { if($condition === true) { //do } } public function function4($argument) { if($condition === true) { //do } } } we can see function1, function2, function3, function4 execute code if $condition === true . if in future add function called function5, have duplicate condition. so question is, best way ensure before call function in class, condition true, , if condition false, not call function. my method use magic function __call , make functions of class private: class myobject { publi

c# - How set a object datasource to a subReport in reportviewer -

i configured report add show respective values, in 1 point decide set subreport principal report. reading found need bind subreport event passing datasource this this.reportviewer1.localreport.subreportprocessing += new subreportprocessingeventhandler(mysubreporteventhandler); void mysubreporteventhandler(object sender, subreportprocessingeventargs e) { e.datasources.add(new reportdatasource("objectdatasource3")); } and defined in aspx follow object datasource asp:objectdatasource id="objectdatasource3" runat="server" selectmethod="obtenerdetallesgestion" typename="sodexosat.reports.datasets.camposgestion"> <selectparameters> <asp:parameter name="idgestion" type="int32" /> </selectparameters> the value of first parameters setting in first report. problem it's reportviewer say's follow an error occurred during

Avoiding Polymorphic Associations in Rails -

(sorry bad english) let's suppose have models a, b, c. each model have 1 address. in book "sql antipatterns: avoiding pitfalls of database programming" (chapter 7 - polymorphic associations) there recipe avoid such associations through use of "common super table" (also called base table or ancestor table). polymorphically, be: table addresses: id: integer parent_type:string # 'a', 'b' or 'c' parent_id: integer i know can use intersection tables, following solution looks more polished: instead of polymorphically associating a, b, c address, recipe suggests create super table (addressing) have id field (surrogate key or pseudo key). then, other tables references addressing. way, says author, "you can rely on enforcement of database’s data integrity foreign keys". so, be: table addressing id: integer table addresses id: integer addressing_id: integer (foreign_key) zip: string table

Type casting in haskell, Fractional and Int -

i've written function (should) takes infinite list of booleans , calculate ratio of true false values on first n elements: prob n list = foldr (+) 0 (map booltoint (take n list)) / n booltoint b | b == true = 1 | otherwise = 0 unfortunately that's not working: no instance (fractional int) arising use of `/' possible fix: add instance declaration (fractional int) in expression: foldr (+) 0 (map booltoint (take n list)) / n in equation `prob': prob n list = foldr (+) 0 (map booltoint (take n list)) / n booltoint b | b == true = 1 | otherwise = 0 failed, modules loaded: none. i tried make conversion, isn't working either: prob n list = foldr (+) 0 (map booltoint (take (fromintegral (tointeger n)) list)) / n booltoint b | b == true = 1 | otherwise = 0 it's compiling, try call function error: *main> prob 50 tocoin1 <interactive>:1:6: ambiguous type v

SVG linear gradient definition -

Image
i confused svg linear gradient specification. suppose, want fill 100x100 rectangle linear gradient slanted @ 45 deg. straightforward way specify gradient points x1 = 0, y1 = 0, x2 = 100 , y2 =100. but, not clear happens when provide points x1 = 86, y1 = 0, x2 = 100 , y2 = 14. note, gradient vector still parallel previous one, gradient vector length not cover entire bounding box. so, having following doubts: are these 2 gradient definitions equivalent? in second case, svg standard specify happens points 100, 100, use extrapolated colors gradient vector? i know svg gradient has attribute spreadmethod , according documentation plays role when gradient starts or ends inside bounds of target rectangle. since second definition not same case (the start , end points lie on bounding box edge), spreadmethod still play role here? the sentence spec : "indicates happens if gradient starts or ends inside bounds of target rectangle" merely emphasizes fact there no visibl

c# - RichTextBox contents are not updated while saving -

i have list box control in form contains paths of files of particular type folder. on item double click adding page dynamically tab control , loading contents of file object of rich text box. want edit contents , save again . when open saved file edited contents not saved has earlier contents there while loading file rich text box.how update rich text box object text , save. private void lsterrorlist_mousedoubleclick(object sender, mouseeventargs e) { arraylist errortype = new arraylist(); richtextbox myrich = new richtextbox(); string[] list; tabpage selectedtab; if (lsterrorlist.items.count > 0) { string error = lsterrorlist.selecteditem.tostring(); int result = error.lastindexof('\\'); string filename = error.substring(result + 1, error.length - (result + 1)); list = error.split(new char[] { '\t' });

java - Creating a set of uniformly distributed random numbers -

i have list of n objects. insert x dummy objects randomly placed between real n objects, spaced between (0, n). so tried following code. int[] dummyindexes = new int[x]; int randomstep = n/x * 2; // *2 because mean n/x/2 random random = new random(); int randidx = 0; (int i=0; < x; i++) { randidx += random.nextint(randomstep); dummyindexes[i] = randidx; } this works alright, although i'm not getting distribution way end of domain n . what's better way ? this ensure have 1 random value between each n/x randidx = n * / x + random.nextint(n / x) + 1;

vb.net -- winforms -- datagridview -- new row with data filled into some cells -- disappears -

when add new row datagridview, able add data cell, when go row mouse data disappears out of cell. code needed data stay? private sub bindingnavigatoraddnewitem_click(sender system.object, e system.eventargs) handles bindingnavigatoraddnewitem.click ' when new row entered add site id. dim rrow integer = 0 rrow = dgvestimator2.newrowindex '' set job site id if isdbnull(me.dgvestimator2(1, rrow).value) or isnothing(me.dgvestimator2(1, rrow).value) me.dgvestimator2(1, rrow).value = rjobsiteid ' .rows(dgvrow).cells(1).value = objsheet.cells(excelrow, 1).value me.dgvestimator2.rows(rrow).cells(1).value = rjobsiteid ' me.dgvestimator2.rows(rrow).cells(1).selected = true 'datagridview1.rows[rowindex].selected = true me.dgvestimator2.rows(rrow).selected = true ' dgvestimator2.rows(rrow).setvalues() dgvestimator2.commitedit(datagridviewdataerrorcontexts.commit) end