Posts

Showing posts from March, 2013

sql - How to select parent ids -

i have table such structure. elementid | parentid ------------------- 1 | null 2 | 1 3 | 2 4 | 3 let current element has id 4. want select parent ids. result should be: 3, 2, 1 how can it? db mssql you can use recursive queries this: http://msdn.microsoft.com/en-us/library/aa175801(sql.80).aspx you can use this: with hierachy(elementid, parentid, level) ( select elementid, parentid, 0 level table t t.elementid = x -- insert parameter here union select t.elementid, t.parentid, th.level + 1 table t inner join hierachy th on t.parentid = th.elementid ) select elementid, parentid hierachy level > 0

audio - Gervill for Oracle Java? -

gervill said created opensource jdk compatible oracle java? yes. make sure have gervill.jar on classpath.

SQL Server 2008 - Add XML Declaration to XML Output -

i've been battling 1 few days now, i'm looking automate xml output below syntax select ( select convert(varchar(10),getdate(),103) xml path('dataversion'), type ), ( select conum, coname, convert(varchar(10),accounttodate,103) 'dla', lafilenet @xmloutput xml path('company'), type ) xml path(''), root('companies') which creates below output <companies> <dataversion>15/11/2010</dataversion> <company> <conum>111</conum> <coname>abclmt</coname> <dla>12/12/2010</dla> <lafilenet>1234</lafilenet> </company> <company> <conum>222</conum> <coname>deflmt</coname> <dla>12/12/2007</dla> <lafilenet>5678</lafilenet> </company> </companies> what i'm struggling how add xml declaration <?xml ver

Microsoft Ribbon for WPF (4.0.0.11019) -

i using latest wpf ribbon control downloaded http://www.microsoft.com/downloads/en/details.aspx?familyid=2bfc3187-74aa-4154-a670-76ef8bc2a0b4&displaylang=en in windows xp, ribbon application window’s title bar looks windows 98… or console window. how can improve appearance of tittle bar. answered microsoft consultant: ribbonwindow ships 3 templates of october 2010 release - classic, aero basic, , aero glass. on xp's luna theme, fall displaying classic ribbonwindow. should easy retemplate ribbonwindow achieve native xp - use our ribbonwindow templates in ribbon source , samples msi example. if feedback several customers luna theme top request, consider including our next release.

android - Save and restore expanded/collapsed state of an ExpandableListActivity -

i have expandablelistactivity (using simplecursortreeadapter) starts activity when user clicks on child-element. when pressing back-button in new activity list-items collapsed again. how save expanded state of expandablelistactivity , restore again. i tried implemented onsaveinstancestate() , onrestoreinstancestate() this... @override protected void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); parcelable liststate = getexpandablelistview().onsaveinstancestate(); outstate.putparcelable("liststate", liststate); } @override protected void onrestoreinstancestate(bundle state) { super.onrestoreinstancestate(state); parcelable liststate = state.getparcelable("liststate"); getexpandablelistview().onrestoreinstancestate(liststate); } ...but onrestoreinstancestate() gets never called. tried restore state in oncreate() method isn't called well: if (savedinstancestate != null) { parcelable liststate =

.net 4.0 - Error when creating an instance of Word in VB.net -

i getting error when run app in vs 2010 (it works fine in vs 2008) private sub generateinvoice() dim emptyobject object = system.reflection.missing.value dim wordapp new word.application wordapp.visible = true dim invoicedoc new word.document invoicedoc = wordapp.documents.add(invoicepath, emptyobject, emptyobject, emptyobject) dim totalfields integer = 0 each mergefield word.field in invoicedoc.fields the error occurs @ each line "object reference not set instance of object." am missing here? maybe invoicepath used in instance run via vs2010 invalid , call documents.add fails? are running both vs2010 , vs2008 on same machine? , invoicepath set exact same path in both instances?

How to get current time in ms in PHP? -

what want time() ,but should accurate in ms: 2010-11-15 21:21:00:987 is possible in php? function udate($format, $utimestamp = null) { if (is_null($utimestamp)) $utimestamp = microtime(true); $timestamp = floor($utimestamp); $milliseconds = round(($utimestamp - $timestamp) * 1000000); return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp); } echo udate('y-m-d h:i:s:u'); // 2010-11-15 21:21:00:987

java - Update contact info on Android < 2.0 -

i contact name, , after able check , update information in it. there example on matter, because couldn't find 1 shows in whole. tnx. have @ contactcontracts documentation , tutorial . check authenticatoractivity , 'contactmanager' example in api's.

css - Different position of div's containing text and divs containing images -

i got problem outlining of div elements. i got following structure. <div id="skillcontent"> <div id="skillname" class="inline"> <div class="skilllist"> <div><h3>[skill]</h3></div> <div><h3>[skill]</h3></div> </div> </div> <div id="skillstars" class="inline"> <div class="skilllist"> <div> <img src="img/star_active.png" alt="" /> <img src="img/star_active.png" alt="" /> <img src="img/star_inactive.png" alt="" /> <img src="img/star_inactive.png" alt="" /> <img src="img/star_inactive.png" alt="" /> </div> <div> <img src="img/star_active.png" alt="" /> <img src="img/star_active

flash - Flex Spark Link Bar Background Color/Alpha -

i trying change background color , alpha of link bar in flex/flash 4 application. no matter properties define, background of said link bar white. please see image http://i.stack.imgur.com/pyhs2.png . <mx:linkbar id="lnkbar" backgroundalpha="0" backgroundcolor="black" bottom="0" itemclick="lnkbar_itemclickhandler(event)"> <mx:dataprovider> <s:arraycollection> <fx:string>resource management</fx:string> <fx:string>standard reports</fx:string> <fx:string>clear selected state</fx:string> </s:arraycollection> </mx:dataprovider> </mx:linkbar> instead of "backgroundalpha" or "backgroundcolor", use "contentbackgroundalpha" or "contentbackgroundcolor".

Pentaho kettle : how to execute "insert into ... select from" with the sql script step? -

Image
i discovering pentaho di , stuck problem : i want insert data csv file custom db, not support "insert table" step. use sql script step, 1 request : insert mytable select * myinput and transformation : i don't know how data csv injected in "myinput" field. could me ? thanks lot :) when first edit sql script step, click 'get fields' button. going load parameters(fields csv) box on bottom left corner. delete parameters(fields) don't want insert. in sql script write query question marks parameters in order. insert my_table (field1,field2,field3...) values ('?','?','?'...); mark checkboxes execute each row , execute single statement . that's it. let me know if have more questions , if provide sample data i'll make sample ktr file at.

c# - .NET Web Service receive HTTP POST request (500) Internal Server Error -

i writing c# web service has several methods, 1 of has receive http post requests. first thing have done alter web.config file in web service project below. <webservices> <protocols> <add name="httpsoap"/> <add name="httppost"/> <add name="httppostlocalhost"/> <add name="documentation"/> </protocols> </webservices> i can run web service locally , when click on method in browser, can see handles http post requests , accepts args=string, signature of web method accepts 1 string parameter named args. testing via test asp.net app using code below fire http post request. httpwebrequest request = (httpwebrequest)httpwebrequest.create(configurationmanager.appsettings["paymenthuburl"].tostring()); request.keepalive = false; request.contenttype = "application/x-www-form-urlencoded"; request.method = "post"; stringbuilder sb = new stringbuilder();

wpf controls - An integer value in WPF Resources? -

is possible set integer value in wpf control resources?! <usercontrol.resources> <solidcolorbrush x:key="mylinebrush" color="lightgreen" /> ??? <integer x:key="mystrokethickness" value="2" /> ??? <style targettype="local:myline" x:key="mylinestylekey"> <setter property="stroke" value="{dynamicresource mylinebrush}"/> <setter property="strokethickness" value="{dynamicresource mystrokethickness}"/> </style> in order modify dynamically mylinebrush , mystrokethickness values... to make declaration need import system namespace: xmlns:sys="clr-namespace:system;assembly=mscorlib" ... <sys:int32 x:key="myvalue">1234</sys:int32> note: need use double wpf properties instead of int32

global - Statistics on where Malicious Hackers / Spammers live -

does have ideas on worst global hackers live (from usa perspective). mean, warez, serialz, botnets, spammers have residence? in countries hackers live? how connect internet? banning home continent effective in curbing access? (or use unknown proxies?) i want block hackers based on ip address / contient (i.e. china / russia). don't care if alienate large group of users. also, freely available blocklists purpose? update: programming related because blacklisting common programming task. , programmers 1 of few groups care type of data. else ask? south america in general, brazil china , korea south eastern europe: hungary, czech, etc.

Hudson Shellscript for exporting Sourcecode from SVN repository into production folder -

i have 1 dedicated server has whole lamp-stack, svn , hudson installed. create freestyle hudson job, gets latest sourcecode out of svn-repository , puts /var/www/mywebapp folder. how shell script need like? edit when use svn export myrepourl mywebappfolder i erro, stating: started user anonymous reverting http://myipadress/repos updating http://myipadress/repos @ revision 2 no change http://myipadress/repos since previous build [workspace] $ /bin/sh -xe /tmp/hudson7864414135197533508.sh + svn export http://myipadress/repos/myrepo /var/www/mywebapp authentication realm: <http://myipadress> subversion repository password 'hudson': authentication realm: <http://myipadress> subversion repository username: svn: propfind request failed on '/repos/myrepo' svn: propfind of '/repos/myrepo': authorization failed (http://myipadress) finished: failure it should below svn export [your svn url] /var/www/mywebapp do let me know if

How to extract title from .pdf file using c# -

i know python such solution exist (http://pybrary.net/pypdf/). hope suggest library c# issue. a commonly used library manipulating pdf files in .net itextsharp port of itext library. here's example: class program { static void main() { pdfreader reader = new pdfreader("test.pdf"); var title = reader.info["title"]; console.writeline(title); } }

c++ - Effective data structure for both deleteMin and search by key operations -

i have 100 sets of objects, each set corresponding query point qi, 1 <= <= 100 . class { int id; int distance; float x; float y; } in each iteration of algorithm, select 1 query point qi , extract corresponding set object having minimum distance value. then, have find specific object in 100 sets, searching id, , remove objects. if use heap each set of objects, cheap extract object min(distance) . however, not able find same object in other heaps searching id, because heap organized distance value. further, updating heap expensive. another option have considered using map<id, (distance, x, y)> each set. way searching (find operation) id cheap. however, extracting element minimum value takes linear time (it has examine every element in map). is there data structure use efficient both operations need? extract_min(distance) find(id) thanks in advance! std::map or boost::multi_index

Android MapView: how to show grouped annotations? -

i create android app shows map of united states annotations in different cities; when zoom in zone see annotations in single places (e.g. see newyork:10 pictures, zoom in ny , see 6 annotations in central park , 4 in 5th.avenue, example). has made similar thing (like in iphone photo application and/or earthquake sample shown on web using js googlemaps ?) thanks in advance , greetings ! c.

WPF: Binding to readonly property in code -

i'm doing rescaling on data in valueconverter whenever panel redrawn. want move of processing viewmodel of processing occurs if control size or few other properties change. to ensure rescaled data looks acceptable need actualwidth of container in viewmodel. want bind property of viewmodel 1 way when changes can trigger rescaling processing. all examples find bind clr or dependency property element rather other way , i'm missing in understanding work out how should it. have have tried few different things setting binding not getting right. any hints? thanks. in myview xaml: <myitemscontrol/> in myview code behind, like: binding b = new binding(mywidthproperty); b.mode = bindingmode.oneway; b.source = myitemscontrol.name; .........? and public static readonly dependencyproperty mywidthproperty = dependencyproperty.register( "mywidth", typeof(double), typeof(myviewmodel)); in myviewmodel: public double mywidth{ { return _mywi

scheme - Hosting for Racket web app? -

hi wonder if have free or paid hosting racket web app? racket looks fun me if way run web-app have own server - that's bad. is there google app engine racket? superb! i host blog (written in racket) ultrahosting. wrote blog post experience them. far i've been happy it.

text - SmsManager causes com.android.phone force closes randomly -

i using smsmanager send text messages application. code snippet is smsmanager.sendtextmessage(number, null, content, null, null); for messages less 160 characters. , multipart messages use, arraylist<string> parts = smsmanager.dividemessage(content); sman.sendmultiparttextmessage(number, null, parts, null, null); these statements cause process com.android.phone has stopped unexpectedly please try again in random fashion. don't understand what's going on. this stack trace got: java.lang.nullpointerexception e/androidruntime( 1143): @ com.android.internal.telephony.smsdispatcher.handlesendcomplete(smsdispatcher.java:741) e/androidruntime( 1143): @ com.android.internal.telephony.smsdispatcher.handlemessage(smsdispatcher.java:407) e/androidruntime( 1143): @ android.os.handler.dispatchmessage(handler.java:99) e/androidruntime( 1143): @ android.os.looper.loop(looper.java:123) e/androidruntime( 1143): @ android.app.activitythread.main(activitythrea

asp.net - How to make the boxes in a checkboxlist unchecked by default? -

i've tried looking @ properties asp.net checkboxlist on msdn , searching google , can't seem find way of setting checkboxes unchecked default. missing glaringly obvious solution? thanks, by default listitem in checkboxlist should not checked. if have selected property set true checked: <asp:listitem selected="true">item 1</asp:listitem> by default false , should suffice. if need clear checked items on demand can use clearselection method : checkboxlist.clearselection() .

date - Problem with getDay() method javascript -

i'm trying day name in javascript. every time search usage of function getday() , explained method returns day of week, example: 0 sunday, 1 monday etc. so 1st janauary 2010 friday, can explain why i'm getting 1 instead of 5? same 2nd janauary 2010, i'm getting 2 instead of 5. i've tried ways without success. here's code : theday = new date(2010,01,01); alert(theday.getday()); thank !!! the month in js zero-based, day of week. date(2010,01,01) 1 february, 2010. january month zero. sure enough, 1 february 2010 monday (i remember well). try this: var theday = new date(2010,00,01); alert(theday.getday());

Auto width and height with imagemagick? -

i'm creating image of string of text imagemagick , need both width , height of image conform size of text. currently, use "caption" command , specify width of 300px, image 300px wide, , text wraps if longer 300px. i guess need still specify maxwidth somewhere in imagemagick code, text still wraps @ 300px.. width of image fit longest line of wrapped text , not 300px. possible?

lisp - Performance difference between functions and pattern matching in Mathematica -

so mathematica different other dialects of lisp because blurs lines between functions , macros. in mathematica if user wanted write mathematical function use pattern matching f[x_]:= x*x instead of f=function[{x},x*x] though both return same result when called f[x] . understanding first approach equivalent lisp macro , in experience favored because of more concise syntax. so have 2 questions, there performance difference between executing functions versus pattern matching/macro approach? though part of me wouldn't surprised if functions transformed version of macros allow features listable implemented. the reason care question because of recent set of questions (1) (2) trying catch mathematica errors in large programs. if of computations defined in terms of functions, seems me keeping track of order of evaluation , error originated easier trying catch error after input has been rewritten successive application of macros/patterns. the way understand mathematica

jquery - Listen for my Flash event in Javascript -

i'm trying build basic video player playlist using ovp player. far have figured out how feed in new video source using externalinterface, can not figure out how listen flash event "event_end_of_item". how listen flash events in javascript (and jquery)? ovp has lot of events defined, don't know how listen them. example, here event_end_of_item: public function endofitem():void { sendevent(event_end_of_item); } the ovp documentation non-existent , support forum bad. in model.as file find add line in other imports (at start of file): import flash.external.*; then in end event, add line: externalinterface.call("stopedplaying"); so event this: public function endofitem():void { sendevent(event_end_of_item); // inform javascript flv has stopped playing externalinterface.call("stoppedplaying"); } then in html document, add between script tags: function stoppedplayin

regex - PHP preg_match_all() not capturing subgroups -

i'm trying parse twitter atom feed in php running strange issue. i'm calling preg_match_all regexp string: "|<entry>.*<title>(.*)</title>.*<published>(.*)</published>.*</entry>|xsu" it matches entries ok, captured subgroups title/published not show in results (no arrays captured subgroups created in result object). now strange part, try capture last bit well: "|<entry>.*<title>(.*)</title>.*<published>(.*)</published>(.*)</entry>|xsu" and capturing works. title , published date , large chunk of final data don't want. i tried add non capturing string "?:" last subgroup capturing stopped working alltogether again. so how capture data want, without having capture large chunk of unwanted data @ end? i recommend use dom (or simplexml ) parsing rss/atom feeds. way better results regular expressions. here's example (using simplexml): $rss_feed

php 5.3 - Non-deterministic object reference bug in PHP 5.3.X -

as of yesterday (perhaps after recent php update?), i'm getting strange non-deterministic bugs in php 5.3.3. these appear in our production server in php 5.3.2 well. the errors amount fatal error: uncaught exception 'errorexception' message 'attempt assign property of non-object' in various parts of code base. generally, error line like: $this->foo = $bar in __construct() call. $this not found in constructor?! i have no idea going on. ideas? possibly regression of bug?: http://bugs.php.net/31525 edit : should mention, refreshing script after little while, absolutely no changes code, makes work again. hence non-deterministic. edit 2 : furthermore, while php set log tiniest of errors, , is logging other errors occur, error not logged in log file. brings me think looking @ php engine dependency error. well, looks bug... an instance of happening zend_config a possibly related issue symfony and few others (searching pretty useless sin

Accessing LDA parameters from Apache Mahout LDA package -

i have tested using apache mahout building latent dirichlet allocation model on corpus of 30 documents. did not have hadoop installed on system thats why local execution of mahout yielded resulting model. access model parameters, in estimated \alpha, \beta, \phi, \theta how can access these? /mahout lda -i /tf-vectors -o -k 4-v 27 i can see has folder each iteration(i presume) of learning algorithm. each has single file part-r-0000 not know how access. any appreciated. i can't off-hand except people can read mahout-user mailing list , answer questions there. suggest repeat question there. see here more information how subscribe: https://cwiki.apache.org/mahout/mailing-lists.html

iphone - Set root ViewController in a UISplitViewController from the detail view -

i have uisplitviewcontroller, , i'd change root view controller (on left side of screen) when click button in detail view (the right side of screen). if in detail view: nextgameviewcontroller *newtableviewcontroller = [[nextgameviewcontroller alloc] init]; nsarray *newvcs = [nsarray arraywithobjects:newtableviewcontroller, self, nil]; splitviewcontroller.viewcontrollers = newvcs; it crashes error: -[nextgameviewcontroller setparentviewcontroller:]: unrecognized selector sent instance 0x4938a50 nextgameviewcontroller subclass of uitableviewcontroller, why happening? if push onto view controller stack root view works fine. uitableviewcontroller's parentviewcontroller read property. see this question more discussion. sounds want push new table view on left side of detail view, still under root view, not replace root view controller itself, describing. you use array trying replace @ information. see this link viewcontrollers property more information.

entity framework - EDMX and stored procedures; I can't see a method to call my SPROC in the context -

i added sproc edmx using update model option. did function import , assigned null return type. problem when try call sproc mycontext.current, there no sign of it. missing something? are using ef v4? not possible in ef v1, see, example, this question .

php - Help w/ Codeigniter session expiration time -

i dynamically set session expiration time in codeigniter. i'm autoload session class. have view contains checkbox users click (remember me). right if click check box or not expiration time stays same :/ // config.php $config['sess_expiration'] = 7200; // controller if ($this->input->post('remember_me') == 'true') { $this->session->remember_me(); } $newdata = array( 'failed_login' => 0, 'user_name' => $this->input->post('user_name'), 'logged_in' => true ); $this->session->set_userdata($newdata); // my_session.php class my_session extends ci_session { function remember_me() { $this->sess_expiration = 172800; } } if need implement "remember me" feature - you've started in wrong way. you need create 1 more database table fields user_id | token . then, after user

salesforce - How to refer html element id specified in visualforce and pass onto javascript function? -

i have apex tag generate input text field. <apex:page id="my_page"> <apex:inputtext id="foo" id="c_txt"></apex:inputtext> </apex:page> when clicks field, want execute javascript. but when check html source, apex tag becomes input tag has (i think) dynamically generated part. <input type="text" size="50" value="tue nov 16 00:00:00 gmt 2010" name="j_id0:j_id3:j_id4:c_txt" id="j_id0:j_id3:j_id4:c_txt"> as can see id has junk part :( id="j_id0:j_id3:j_id4:c_txt" in javascript i'm trying getelementbyid('c_txt') not work of course. how deal this??? update seems can not working... <apex:includescript value="{!urlfor($resource.datepickerjs)}"></apex:includescript> <apex:inputtext id="foo" id="c_txt" onclick="javascript:displaydatepicker()" /> datepickerjs var elem = get

Group resource translation files in folder in VS2010 for C#/WPF app -

i'm using resource files strings internationalization support in c# wpf application. i have files under folder strings , access in code strings.mainwindow.somestringid . problem translation files start grow, folder beings contain huge number of files , gets easier screw pooch making changes wrong file, ending german sentences on russian files. i'd set strings folder have sub folder each locale. tried changing "custom tool namespace" option under properties no avail. basically how it's laid out: http://d.pr/viwi , how i'd laid out: http://d.pr/7wsu try approach. instead of resources/locale/bunch_of_resources use resources/bunch_of_folders_one_for_each_context/resources(pt-pt, en-en) it not perfect. organize.

c++ - Good starting cross platform ide -

i'm hoping write open source ide programming language i'm designing. wondering if knew of lightweight ide's written in c++, use starting place. ideally want use bsd licensed, i'm willing consider other licenses if required. thank in advance can provide. edit: want develop custom interface each platform. example, use objective-c create mac os x specific interface it. eclipse best way go. might want check code::blocks or kdevelop

dbus - gnome: how to execute commands upon screensaver activation? -

is there way run specific command every time gnome-screensaver activated? thanks found there : http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html#gs-intro gnome screensaver has dbus signal named : activechanged in org.gnome.screensaver then call getactive() and if returns true call method

Getting list of solutions in Prolog -

i learning prolog , reading book called programming prolog artificial intelligence. practice want learn how extend 1 of examples in book. can please help? say have these facts: parent(pam, bob). %pam parent of bob parent(george, bob). %george parent of bob how write prolog predicate give me list of bobs parents? example: list_parents(bob, l). l = [pam, george] ; l = [george, pam] ; true. an all-solutions predicate findall/3 might trick: list_parents(p, l) :- findall(parent, parent(parent, p), l). simply put, findall/3 finds bindings parent in 'backtrack-able' goal parent(parent, p) , , puts bindings of parent list l . note won't remove duplicates, can sort/2 l before returning create set. executing this: ?- list_parents(bob, l). l = [pam, george]. if don't have findall/3 in prolog implementation, manually this: list_parents(p, l) :- list_parents(p, [], l). list_parents(p, acc, l) :- parent(parent, p), \+ member(par

c# - Why should graphics needs to be disposed? -

why should graphics needs disposed? pen , solidbrush ? well simple answer implement 'idisposable' need disposed. the longer answer consume unmanaged resources need released. calling dispose directly (or using 'using' statement) can release resources rather waiting gc you.

javascript - (jQuery/JS) How to *set* a list item to be 1st in a UL or OL regardless of its original order? -

i have working code here: function portfolio() { $('#main-projects').children().toggle(function () { $(this).css('cursor', 'pointer'); var projectname = $(this).attr('id'); //alert(projectname); projectname = projectname.replace("li-", "main-"); $('.main-details').hide(); $('.main-stage').fadeout(300); $('#' + projectname).delay(300).fadein(900); }, function () { //haven't written callback yet, no worries. }); } works great already: when click li (child of ul#main-projects ) finds name of hidden slideshow div replacing name of li's id, replaces "li-(name of project)" "main-(name of project)" shows div. what want (and can't seem find solution to) take li that's been selected , move first in list curate in way slideshow that's been shown above it. i know how grab item number eq(index) h

php - How To Remove All DtDdWrappers and Labels on Zend Form Elements -

i know can remove stuff each element individually so $button ->removedecorator('dtddwrapper') ->removedecorator('htmltag') ->removedecorator('label'); i wondering if can achieve same elements in zend form? , how 1 remove dl wrapping form? markus, here solution use seems work well, suitable you. first, in order render form no <dl> tag, need set decorators on form object itself. inside class extending zend_form, call zend_form->setdecorators() passing array of form decorators. from reference guide: the default decorators zend_form formelements, htmltag (wraps in definition list), , form; equivalent code creating them follows: $form->setdecorators(array( 'formelements', array('htmltag', array('tag' => 'dl')), 'form' )); to wrap form in other dl, use above decorators change dl whatever tag use, typically use div of class form see later.

Append new entries from bash array to a txt file -

here's situation, wrote small script generate list of ip addresses e-mail rejected: msgid_array=($(grep ' sendmail\[' /var/log/maillog | egrep -v 'stat=(sent|queued|please try again later)' | egrep dsn='5\.[0-9]\.[0-9]' | awk '{print $6}')) z in ${msgid_array[@]}; ip_array[x++]=$(grep $z /var/log/maillog | egrep -m 1 -o 'relay=.*' | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}') done so looks message id's of rejected e-mails , stores them in msgid_array. then using loop grep's maillog each message id , filters out senders ip address , stores ip's in ip_array. now intend run each day , let parse log entries yesterday store results in separate txt file. if have "rejected_ip_addresses=" entry in txt file, how add new ip addresses existing list? so today run , entry looks this: rejected_ip_adresses=1.1.1.1 2.2.2.2 tomorrow whe

socialengine - social engine upgrade theme -

i have project in social engine 3.x . have upgraded social engine 4.x. want upgrade social engine 3.x old theme social engine 4.x theme. social engine 4 uses new way of handling templates, , lot of stuff got used in se 3.x - smarty parts , stuff, handled differently. copy existing theme, rename , start editing css , layout files of modules/widgets.

c# - How to use the update method for a generic LINQ to SQL repository -

i have implemented following generic methods: public iqueryable<t> query(expression<func<t, bool>> filter) { return context.gettable<t>().where(filter); } public virtual void update(t entity) { context.gettable<t>().attach(entity); } i not sure how implement in consumer class? ideally, pass in userref , update user accordingly? change to: public iqueryable<t> query<t>(expression<func<t, bool>> filter) { return context.gettable<t>().where(filter); } public virtual void update<t>(t entity) { context.gettable<t>().attach(entity); } var user=something.query<user>(x=>x.name=="bla bla").first; user.name="alb alb"; something.update(user); but consider avoiding writing generic repositories. don't gain them. if it's generic, exposes iqueryable, takes in expression filters, it's quite useless abstraction layer , adds complexity.

xmpp - ejabberd server mod_archive module -

i trying set message archiving ejabberd server. tried add new module mod_archive following link http://lboynton.com/2009/11/25/ejabberd-mod_archive-with-mysql-on-ubuntu/ . after not able restart ejabberd server , gives me following error in ejabberd.log =error report==== 2010-11-16 12:44:41 === e(<0.38.0>:ejabberd_rdbms:67) : start of supervisor ejabberd_odbc_sup_localhost failed: {error,{shutdown,{child,undefined,ejabberd_odbc_sup_localhost, {ejabberd_odbc_sup,start_link,["localhost"]}, transient,infinity,supervisor, [ejabberd_odbc_sup]}}} thanks, sathi. all internet tutorials mod_archive in ejabberd incomplete or caotics. or maybe old. problem using ubuntu 12.04 server lts mysql. , did things explained in blogs. so install mod_archive need this: the typical: svn co https://svn.process-one.net/ejabberd-modules cd ejabberd-modules/mod_archive/trunk ./build.sh cp ebin/*modules in ejabberd and configure /etc/ejabberd.cfg but methods ejabberd

Objective-C multiple inheritance -

i have 2 classes 1 includes methoda , other include methodb. in new class need override methods methoda , methodb. how achieve multiple inheritance in objective c? little bit confused syntax. objective-c doesn't support multiple inheritance, , don't need it. use composition: @interface classa : nsobject { } -(void)methoda; @end @interface classb : nsobject { } -(void)methodb; @end @interface myclass : nsobject { classa *a; classb *b; } -(id)initwitha:(classa *)ana b:(classb *)ab; -(void)methoda; -(void)methodb; @end now need invoke method on relevant ivar. it's more code, there isn't multiple inheritance language feature in objective-c.

objective c - Where's the memory leak? -

i'm adding custom view tableheaderview following code: imagebutton = [uibutton buttonwithtype:uibuttontyperoundedrect]; imagebutton.frame = cgrectmake(120, 12, 64, 64); imagebutton.titlelabel.font = [uifont systemfontofsize:10]; imagebutton.titlelabel.linebreakmode = uilinebreakmodewordwrap; imagebutton.titlelabel.textalignment = uitextalignmentcenter; [imagebutton settitle:nslocalizedstring(@"choose\nphoto", @"choose\nphoto") forstate:uicontrolstatenormal]; [imagebutton addtarget:self action:@selector(photobuttonpressed) forcontrolevents:uicontroleventtouchupinside]; // add existing image, if any, button if (child.thumbnailimage != nil) { [imagebutton setbackgroundimage:child.thumbnailimage forstate:uicontrolstatenormal]; } // add button view self.headerview = [[uiview alloc] initwithframe:cgrectmake(22, 12, 70, 70)]; [headerview addsubview:imagebutton]; // add view table header self.table

c++ - Prettiness of ternary operator vs. if statement -

i'm browsing through code , found few ternary operators in it. code library use, , it's supposed quite fast. i'm thinking if we're saving except space there. what's experience? performance the ternary operator shouldn't differ in performance well-written equivalent if / else statement... may resolve same representation in abstract syntax tree, undergo same optimisations etc.. things can ? : if you're initialising constant or reference, or working out value use inside member initialisation list, if / else statements can't used ? : can be: const int x = f() ? 10 : 2; x::x() : n_(n > 0 ? 2 * n : 0) { } factoring concise code keys reasons use ? : include localisation, , avoiding redundantly repeating other parts of same statements/function-calls, example: if (condition) return x; else return y; ...is preferable to... return condition ? x : y; ...on readability grounds if dealing inexperienced programmers

Is there any difference between 1U and 1 in c? -

while ((1u << i) < nsize) { i++; } any particular reason use 1u instead of 1 ? on compliers, both give result same representation. however, according c specification, result of bit shift operation on signed argument gives implementation-defined results, in theory 1u << i more portable 1 << i . in practice c compilers you'll ever encounter treat signed left shifts same unsigned left shifts. the other reason if nsize unsigned, comparing against signed 1 << i generate compiler warning. changing 1 1u gets rid of warning message, , don't have worry happens if i 31 or 63. the compiler warning reason why 1u appears in code. suggest compiling c warnings turned on, , eliminating warning messages changing code.

python - How to pass UTF-8 string from wx.TextCtrl to wx.ListCtrl -

if enter baltic characters in textctrl , click button test1 have error "inicodeencodeerror: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)" button test2 works fine. #!/usr/bin/python # -*- coding: utf-8 -*- import wx class myframe(wx.frame): def __init__(self, parent, id, title): wx.frame.__init__(self, parent, id, title, (-1, -1), wx.size(450, 300)) self.panel = wx.panel(self) self.input_area = wx.textctrl(self.panel, -1, '',(5,5),(200,200), style=wx.te_multiline) self.output_list = wx.listctrl(self.panel, -1, (210,5), (200,200), style=wx.lc_report) self.output_list.insertcolumn(0, 'column') self.output_list.setcolumnwidth(0, 100) self.btn1 = wx.button(self.panel, -1, 'test1', (5,220)) self.btn1.bind(wx.evt_button, self.ontest1) self.btn2 = wx.button(self.panel, -1, 'test2', (100,220

asp.net - Binding Programatically Vs. Object Data Source for Performance -

i used bind gridviews , detailviews etc. on page using objectdatasource (unless wasn't possible so). recently, i've started binding contols programatically. find lot cleaner , easier, though may disagree. binding objectdatasource has advantages , disadvantages, doing programatically. say bind gridview programatically (e.g. gridview1.datasource = somelist ), when change page on gridview, have code this. each time page changes have call gridview1.datasource = somelist again. objectdatasource don't need this. stick somelist object viewstate when change page don't need hit database each , every time. my question is: how objectdatasource works? store it's data in viewstate , not hit database again unless call .select method? try , best performance out of applications , hit database few times possible don't idea of storing huge list in viewstate. there better way of doing this? caching per user idea (or possible)? shall hit database everytime instead

Android UI Design Principles -

im writing program going type of scheduler backed database. we'll call database items, b c , each relies on each other. can't add b without a, , can't add c without b (relies on row ids). they're simple list of items, want little more b hold, extend, , view c items. initially figured use context menu reading through android design guidelines, understand while desirable, should not way of navigating items. so listview a, can add button delete item or allow press on item listview b. but how recommend design listview b? after b record added, don't need edit it, have options hold , extend. wouldn't want allow click on list item b go straight listview c bypass options needed b. im guessing either: 1) ignore guidelines , stick context menus 2) have greyed out edit form b, clickable button go c 3) have greyed out edit form b, include c listview on edit form b the last 2 options raises own issues, in c relies on b, either need have "save , con

android - Ksoap Library and Request Time out? -

i using ksoap library call webservice in android. dont see request timeout property here in case of internet not available in middle of call important have it. some 1 suggested me use socket class has sotimeout dont know how implement here 1 suggest me should do? public void callwebservice() { try { soapobject request = new soapobject(namespace, method_name); request.addproperty("passonstring", "anything"); soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11); envelope.dotnet=true; envelope.setoutputsoapobject(request); httptransportse androidhttptransport = new httptransportse(url); androidhttptransport.call(soap_action, envelope); .. ... }catch(exception ex) {} } you have modify httptransportse class take timeout parameter passes through socket. pretty simple implement, looking @ httpstransportse class this. then catch sockettimeoutexception , whatever necessary. feel free create issue on project , or cont

symfony1 - how to increase performance of mysql query if we have more than 1 million records? -

in user table have more 1 million records how can manage using mysql, symfony 1.4. make performance better. so can give quick output. to improve performance of designed system can increase resources. typically, these days, cheapest way distribute task. for example slow thing in rdbm system reading , writing storage (typically rdbms systems start i/o bound, is, wait data read or written storage). so, offset, commonly rdbms allow split table across multiple hdds, multiplying i/o performance (approach similar raid0). adding more hard disks increases performance. goes on maximum i/o system support (either because system can not push more data through circuits or because need crunch numbers bit when fetches them becomes cpu bound; optimally utilising both) after have start multiplying systems distributing data across database nodes. work either rdbms must support or there should application layer coordinate distributing tasks , merging results, things still scale. i

flash - Flex ActionScript Project Error in Object Declaration.(project.mxml file) -

i have flex actionscript application, need draw simple rectangle in stage. using firstapp.mxml , class called book.as ; here complete code have done. firstapp.mxml <?xml version="1.0" encoding="utf-8"?> <mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:script> <![cdata[ import com.books.book; import flash.display.*; var n:book = new book; //n.var1 = "another string"; addchild(n); ]]> </mx:script> </mx:application> book.as package com.books { import flash.display.*; public class book extends sprite { public var var1:string = "test var"; public var var2:number = 1000; public function book() { var b = new sprite; b.graphics.beginfill(0xff0000, 1); b.graphics.drawrect(0, 0,

javascript - Cross Frame Script Reuse -

i have application running in hta (msft html application) uses same script file on , on again throughout frames; hits 9 in places , application setup within various servers caching set immediate expire i'm trying carve out sort of performance in ball of mud. is there 'good' way load main script file in top frame excuting within frames i.e. --- top window ---- var mainscript = function(){ return (function(){ current functions etc here })(); }; --- sub frames ---- var framescript = top.mainscript; framescript(); and how affected window scope (would keep top window scope or in scope of frame-window) the simplest method appears to give subframe id dynamically populate script loaded in master frame (using eval make js run); i.e. |> parent (aka top frame) <script>top.windows = [];</script> <script id="myscript"> var test = function(){ top.windows.push(window); } </script> |>> subframe loads subsubfr

c# - n-dimensional Array -

i want create n-dimensional array of doubles. @ compile-time, number of dimensions n not known. i ended defining array dictionary, key being array of ints corresponding different axes (so in 3-dimensional array, i'd supply [5, 2, 3] double @ (5, 2, 3) in array. however, need populate dictionary doubles (0, 0, ... 0) (m1, m2, ... mn), m1 mn length of each axis. my initial idea create nested for-loops, still don't know how many i'd need (1 each dimension), can't @ compile-time. i hope i've formulated question in understandable manner, feel free ask me elaborate parts. to create n-dimensional array, can use array.createinstance method: array array = array.createinstance(typeof(double), 5, 3, 2, 8, 7, 32)); array.setvalue(0.5d, 0, 0, 0, 0, 0, 0); double val1 = (double)array.getvalue(0, 0, 0, 0, 0, 0); array.setvalue(1.5d, 1, 2, 1, 6, 0, 30); double val2 = (double)array.getvalue(1, 2, 1, 6, 0, 30); to populate arrays, can use rank property ,

ASP.NET MVC 2: Where is ModelState.AddUnhandledError Defined? -

i've seen modelstate.addunhandlederror in few code samples, doesn't seem part of modelstatedictionary class. presumably it's extension method? is standard part of mvc? know defined? no, not part of standard mvc. presumably it's custom defined extension method.

php - How to store url in database and generate unque id -

i want create application using php , mysql. assume making api call , getting list of urls. want store urls , each url should have 1 uniqe id( ie. number) can pass id page , can url db. assume made api call got 5 urls keyword "xyz" , got following urls , respective titles google.com/abc1.html title1 google.com/abc2.html title2 google.com/abc3.html title3 google.com/abc4.html title4 so want generate unique id of each url id1 google.com/abc1.html title1 id2 google.com/abc2.html title2 id3 google.com/abc3.html title3 id4 google.com/abc4.html title4 constraints url should unique database can hold around 12lacs urls. can please guide me how implement that? give optimization guide lines thanks 12lacs = 1.2 million, right? for can use regular unsigned integer auto increment; create table urls ( id int unsigned not null auto_increment, url varchar(255) not null unique, title varchar(255) not null, primary key(id) ); an unsigned int

jquery search problem. all forms are showing -

all forms showing.. want #google-search active on page load. thank you $(".header-search-input").keyup(function() { $(".header-search-input").val($(this).val()); }); var $searchbylinks = $("#search-by > a"); $searchbylinks.click(function() { var $el = $(this) $(".header-search-form").hide(); $($el.attr("href")).show(); $searchbylinks.removeclass("cur-search"); $el.addclass("cur-search"); return false; }); <div id="search-by"> <a class="cur-search" href="#google-search">google</a> <a href="#image-search">images</a> <a href="#youtube-search">youtube</a> <a href="#maps-search">maps</a> </div> i think should work hide links aren't represented class-name 'cur-search': $(document).ready( functi

Creating a Javascript API for a GWT application -

all gwt examples/tutorials talk gwt client-side code being activated events such onpageload(). want use gwt create library can invoked user-written javascript function calls. can point me information needed this? gwt-exporter helpful.

c++ - Address already in use with boost asio acceptor -

i wrote server listening incomming tcp connections , clients connecting it. when shut down server , restart on same port, error message eaddrinuse when calling bind(...) (error code: 98 on linux). happens though setting option reuse socket. the error not happen time, seems happens more when clients connected server , sending data while shuts down. guess problem there still pending connections while server shut down (related topic: https://stackoverflow.com/questions/41602/how-to-forcibly-close-a-socket-in-time-wait ). on server side, using boost::asio::ip::tcp::acceptor. initialize option "reuse_address" (see http://beta.boost.org/doc/libs/1_38_0/doc/html/boost_asio/reference/basic_socket_acceptor.html ). here code snippet: using boost::asio::ip::tcp; acceptor acceptor::acceptor(io_service); endpoint ep(ip::tcp::v4(), port); acceptor.open(ep.protocol()); acceptor.set_option(acceptor::reuse_address(true)); acceptor.bind(ep); acceptor.listen(); the acceptor closed w