Posts

Showing posts from August, 2012

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

WPF/MVVM - should view-models stay constant and just the model change? -

i'm bit in doubt 'the right way'. i have application concepts visual studio, i'll use explain: i have 'solution' view model , model behind. view model displayed in 'explorer'. i can change between situations 'no solution loaded' 'a solution loaded' , back. and question :-) : should keep view model object , let reflect have new 'solution object' loaded? or should create new view model object , let view bind new object? thanks comments! (and merry christmas all!) anders, denmark your viewmodel contains state of data associated ui not further back in model. one way answer questions such yours considering behaviour want in ui , needs binding state information. or, put different way, time feel writing code cause ui elements shown or hidden, think how maps boolean variable. so, take large chunks of ui visible when have model loaded. these might have visibility bound boolean property in viewmodel issolut

user agent - How to maintain web-politeness (avoid being banned) during web-crawl? -

a web-bot crawling site , using bandwdith resources. bots numerous , many purposes, starting homemade, university research, scrappers, new startups established search engines (and many more categories probably) apart large search engines can potentially send traffic site, why webmasters allow other bots purpose not know ? incentives webmasters allow these bots ? 2nd question is: should distributed crawler multiple crawlagent-nodes on internet, use different user-agent string each agent, because if use same ua, benefit of scaling via multiple agents highly reduced. because large websites high crawl-delay set, may take weeks or months crawl fully. 3rd question: since robots.txt (the defined crawl control method) @ domain level. should crawler have politeness policy per domain or per ip (sometimes many websites hosted on same ip) . how tackle such web poilteness problems ? other related things keep in mind ? there many useful bots besides search engine bots ,

macvim - how to change default color scheme without mess up vi's color -

hey guys moved macvim, it's great, when add theme: torth in .vimrc. found color vi totally changed, it's either way of rails plugin, or torth, mixed color. so how set startup color affect macvim, i'm familiar vi's color rails plug in, don't want mess up. btw how toggle off top tool bar in start up, great,if can show me find whole setup instruction. thanks macvim honors "gvim" settings. gvim being gnome vim gui variant rather prevalent on linux. this means should perhaps set overall settings specific user in "~/.vimrc", , override ones want in macvim defining them in "~/.gvimrc". it's decide organizational method suits best.

jruby - Warbler executable won't start -

i have trouble packing jruby-application warbler , running it. i've created simple sqlite3-app 1 model works fine when running via jruby -s rails s . however, if try packing jruby -s warble executable war packed winstone-server crashes with [winstone 2010/12/20 10:33:48] - beginning extraction war file [winstone 2010/12/20 10:33:50] - warning: servlet 2.4/2.5 spec xsd unavailable inside winstone classpath. retrieved web if required (slow) [winstone 2010/12/20 10:33:50] - no webapp classes folder found - c:\temp\winstone908137348044208817webroot\sqlite-test.war\web-inf\classes [webapp 2010/12/20 10:33:51] - warning: error application not initialized org.jruby.rack.rackinitializationexception: no such file load -- builtin/core_ext/symbol @ org.jruby.rack.defaultrackapplicationfactory.newruntime(defaultrackapplicationfactory.java:85) @ org.jruby.rack.defaultrackapplicationfactory.createapplication(defaultrackapplicationfactory.java:177) @ org.jruby.rack.default

java - RSA Decryption using PrivateKey in pem format -

i'm newbie cryptographic area. here problem: i need decrypt cipher text(encrpyted rsa-public key) using privatekey in "privatekey.pem" format. not know has been encrypted whether password based or anyother methods, rsa based encryption. there way decrypt cipher text? hope understand query if doubts pls post me explain clearly. request post ways possible using java ... assymmetric encryption works on principle need 1 of 2 keys encrypt data , other 1 decrypt it. in case how work: generate key pair: 1 private key, 1 public key give public key else, have him/her encrypt message it. 1 can read message private key (no password involved). so thing need private key. this means need store private key somewhere. security reasons, private key encrypted triple des (which symmetric). in case, encrypt private key triple des password. after have decrypted private key, can use decrypt message encoded encoded public key.password , need password decrypt private key

Parse Spanish characters in Objective-C using NSXmlParser -

i using nsxmlparser i fetch data server, parsing not end, because of spanish characters in data. how parse these spanish words? are sure encoding of document correct? encoding use? include encoding="utf-8" or such in <?xml ... ?> header? if xml parser doesn't know encoding, or encoding has been incorrectly specified, fail parse. if these encoded xml entities, entities hex-encoded, or named? if named, need included in dtd , you'll need call setshouldresolveexternalentities: yes .

c# add object to listbox and show string of object in it -

im using listbox , adding objects it. the object contains 2 variables, lets username , userid. how can add objects in list listbox.items.add(object); , show username of object? thnx! you can use displaymember , valuemember properties display username property of object , use userid property list item value: class youritem { public string username { get; set; } public string userid { get; set; } } yourlistbox.displaymember = "username"; yourlistbox.valuemember = "userid"; yourlistbox.items.add(new youritem { username = "fooname", userid = "fooid" });

asp.net - How to compare a session variable with a string in C#? -

i edited question it still not work, user writes appendix press ok in login, nothing happens here login (vb.net) partial class login inherits system.web.ui.page protected sub button1_click(byval sender object, byval e system.eventargs) handles button1.click session("passcode") = textbox1.text response.redirect("default.aspx") end sub end class and here default page c# public partial class _default : system.web.ui.page { protected void page_load(object sender, eventargs e) { if (session["passcode"] == "appendix") { response.write("ok !"); } else { response.redirect("login.aspx"); } } } you mean session["passcode"] == "appendix" in c# (unlike vb), == equality operator , = assignment operator.

java - Creating a fancy search bar with Swing components -

i'm trying come elegant recreation of search bar component in thunderbird . clear button doesn't appear until there text in box, screen-shot bit inaccurate. should use layered pane , buttons float above box? (but getting text not appear below buttons hacky) maybe put buttons @ ends of search bar , have somehow blend in? any ideas or maybe style reconsideration welcome, thank you. what white panel border , jtextfield without borders inside. 2 buttons (or more) in west , east. button appear/hide depending on text field content.

php - Easy way of handling different user / pass for DB on dev. machine vs production server -

i have config-file global variables database connectivity settings (such db host, db name, user, pass). i able drag , drop files dev machine production server. however, development db host etc may different 1 on production server. is there easy way of, in php, saying "if i'm on dev-machine, use these values" ? (i'd prefer avoid hacks based on host ip / name.) i'm thinking of perhaps setting in php.ini or httpd.conf instance $dev_machine , set true on dev machine. you can set apache variable setenv , , query php's apache_getenv() .

javascript - VBScript slow byte array copy -

i using following code read in binary file in vbscript , store in byte array access javascript , copy js array, sneaky way (the way!) i've found of reading binary data in js. function readbinaryfile(filename) dim instream,buff set instream=createobject("adodb.stream") instream.open instream.type=1 instream.loadfromfile filename buff=instream.read() instream.close dim bytearray() dim dim len len = lenb(buff) redim bytearray(len) = 1 len bytearray(i-1) = ascb(midb(buff, i, 1)) next readbinaryfile=bytearray end function it appears work expected, problem being seems extremely slow. example, reading in 300kb file can take on 2 minutes. expecting read files around 2meg. could explain why such slow operation , if there's can speed up? thanks. the problem loop. try using disconnected recordset conversion: function rsbinarytostring(xbinary) 'antonin foller, http://www.mot

c# - Where is EntitySet<T>'s "Results View"? -

Image
when looking @ linked entityset<t> of linq sql mapped entity, see following: i'd see following (achieved using .asqueryable() extension method) can click little refresh icon , see content: why can't see results view on regular plain entityset<t> ? also, i've noticed on this msdn page says: in linq sql, entityset<tentity> class implements iqueryable interface. from can see, entityset<tentity> doesn't inherit either iqueryable nor iqueryable<t> . what's claim? you'll find answer question the results view works collections meet following conditions implement ienumerable or ienumerable (vb.net works ienumerable) do not implement ilist, ilist, icollection or icollection (c# restriction only) do not have debuggertypeproxy attribute system.core.dll loaded in debugee process in particular #2, entityset<t> implement's ilist<t> therefore debugger won&

image processing - Hough Circle in c# , dynamic memory -

i have problem in dynamic memory allocation getting data matrix image image_gray = new image("im1.jpg"); matrix circles = new matrix(100, 1, 3); question 1: how can locate dynamic memory because don't know number of circles? emgu.cv.cvinvoke.cvhoughcircles(image_gray, circles, hough_type.cv_hough_gradient, 2, 100, 200, 100, 10, 500); question 2: circle matrix [100 ,3], how can get point center= round (circle[i][1], circle[i][1]) how can int radius= circle[i][2]; what should loop data matrix , casting should point , int. i tried (not working / error) for (int i=0; < circles.rows; i++) { matrix entry = circles.getrow(i); float x = entry[0]; float y = entry[1]; float r = entry[2];} // not working because instead of copying (required) (i) row copies whole matrix( circles) , float x=......gives errors no overload method 'this' takes '1' arguments please me in regard regards sorry answer question. please give hin

.net - Real world experiences with the ADO.NET Entity Framework and unit testing -

i investigating ado.net entity framework in combination unit testing. recommended way described scott allan: testability , entity framework 4.0 the article involves code generation pocos . my first impression: manual effort introduce , maintain architecture high. before deep dive interested in real world experience. using poco objects makes unit testing easier, doesn't in making code uses linq queries on poco objects testable. take @ this article . describes how hide ef behind abstraction, while still allowing use linq queries on it.

optimization - Retrieving the most significant features gained from SIFT / SURF -

i'm using surf extract features images , match them others. problem images have in excess of 20000 features slows down matching crawl. is there way can extract n significant features set? i tried computing mser image , use features within regions. gives me reduction anywhere 5% 40% without affecting matching quality negatively, that's unreliable , still not enough. additionally size image down, seems affect quality of features severely in cases. surf offers few parameters (hessian threshold, octaves , layers per octave) couldn't find on how changing these affect feature significance. after researching , testing have found hessian value each feature rough estimate of it's strength, using top n features sorted hessian not optimal. achieved better results when doing following until number of features below target of n: size image down, if overly large only features lie in mser regions considered for features lie close each other, feature higher hes

ASP.NET validators validate on mouse up -

i have compare validator on password field compared password repeat field. if there validation error error doesn't disappear until lost focus event fired. client wants changed key event. what best way of going this? it doable below: <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.js"></script> <script type="text/javascript"> $(function () { $('#textbox1').keyup(function () { if (typeof (page_clientvalidate) == 'function') { page_clientvalidate(); } }); }); </script> edited: changed mouseup keyup.

php - FullCalendar jquery plugin: Move events between 2 calendars on the same page -

edit: fullcalendar jquery plugin( http://arshaw.com/fullcalendar/ ). is there way move event 1 calendar(in month mode) calendar(in month mode) both on same page? know there demo on fullcalendar home page shows dragging events onto calendar, when try drag event off calendar onto calendar, not work. event gets hidden behind calendar container element. ideas on how work? thanks. this issue http://code.google.com/p/fullcalendar/issues/detail?id=550 , though not yet implemented, handle this.

PowerPoint 2010 Macro only works under Windows 7, not Windows XP, (Copy, Paste Shapes error/bug) -

i migrated vba macro powerpoint 2007 2010 , after debugging , testing found out copying shapes 1 presentation works under windows 7 , not under windows xp. when close presentation copied shape from, in windows xp, new object emptied. in windows 7 object still exists. i made example: public sub test() dim handlerapplication new handlerapplication dim slide slide handlerapplication.create application set slide = activewindow.selection.sliderange(1) dim ppt presentation dim shapetocopy shape dim copiedshape shape dim strtemplatefile string strtemplatefile = "slidetemplate.pptx" set ppt = application.presentations.open(buildpath(componentspath, strtemplatefile), msotrue, msofalse, msofalse) set shapetocopy = ppt.slides(7).shapes(1) shapetocopy.copy set copiedshape = slide.shapes.pastespecial(pppasteshape)(1) ppt.close copiedshape.name = "testname" end sub i appreciate help/workaround. the problem bug in office 2010

security - Securing a RESTful API -

for current side project, modular web management system (which contain modules database management, cms, project management, resource management, time tracking, etc…), want expose entire system restful api think make system more usable. system going coded in asp.met mvc3 if make data/actions available through restful api, should make system easy use php, ruby, python, etc… (they make there own interface manage data if wanted). however, 1 thing seems hard (from user's using restful api point of view) restful api security ajax functionality. if wanted complex setup , use, create soap services whole drive using restful api is easy. common way of securing restful api with key associated user. works fine when calls done on server side once start doing ajax functionality, changes. want restful api able called directly javascript firebug able access key user using allow person access system. there better way secure restful api not make user of restful api complex things set up

flex4 - Flex 4 spark tabbar. How do I Reduce space between tabbar button and bordercontainer -

how remove space between tab button , border container. the code <s:tabbar dataprovider="{vsapplication}" > <s:layout> <!--<s:buttonbarhorizontallayout gap="7" />--> <s:horizontallayout gap="7" paddingbottom="0"/> </s:layout> </s:tabbar> <mx:viewstack id="vsapplication" width="100%"> <s:navigatorcontent id="ncconfiguration" label="configuration" width="100%"> <s:bordercontainer width="100%"> </s:bordercontainer> </s:navigatorcontent> <s:navigatorcontent id="ncproject" label="project" width="100%"> <s:bordercontainer width="100%"> <mx:datagrid id="dgproject" dataprovider="{projectdata}" doubleclickenabled="true" itemdoubleclick="dgproject_itemdoubleclickhandler(event)"> <mx:c

How to return warnings from server side to silverlight -

we have business case need return both validation errors , warings server side , display on silverlight. see silverlight using system.componentmodel.dataannotations.validationresult process errors. not contain , fields "warnings". i wondering if has idea handle problem. thanks. i think validationresult used validationexception thrown subclasses of validationattribute. mecanism used blocking validation errors because throwing exception stops execution of code. if happens in service, exception can sent client , processessed, not wanted scenario. you extend model (those classes validationattribute, subclasses, validationexception not sealed) add warning flag you'd have trap exception continue processing , rethrow in case of warning. another alternative add business logic validation errors , warnings response client. approach because can include whatever info want way want/need it.

asp.net mvc - MVC 1 IsValid property equivalent of ModelState.IsValid on the view side -

i trying display div when error occur. i'm adding errors on controller side , tried call isvalid property of viewpage , came error: page.isvalid cannot called before validation has taken place. should queried in event handler control has causesvalidation=true , initiated postback, or after call page.validate. is there way verify easily? alright... forget it. i found under: viewdata.modelstate.isvalid

licensing - Software License Web Application -

we in process of building web application client , have inquired owning code site. issue license agreement client use of code if reason no longer working on project. have ownership of code allow them use wherever see fit, limitation have sale of code. company several employees , using application within company. thanks in advance -jn sounds me need attorney. try this: http://www.google.com/search?btng=1&pws=0&q=software+licensing+attorney

c# - Finding Class Elements in a List of Classes -

i trying use "list.find" method find match element in class. here example... class myclass { string item1; string item2; } list<myclass> myclasslist = new list<myclass>(); // trying find instances of "myclass" in list "myclasslist" // element "item1" equal "abc" // myclasslist.find(item => .item1 == "abc"); ????? anyway, hope explains bit better. confused last part, question is: how can use list.find find matches of element in list of classes. thanks , please let me know if i'm not being clear. your example there. should using findall method: list<myclass> results = myclasslist.findall(x => x.item1 == "abc"); or, if prefer results typed ienumerable<t> rather list<t> , can use linq's where method: ienumerable<myclass> results = myclasslist.where(x => x.item1 == "abc");

windows - Is there a way to set HttpExpires on a sub-directory of a virtual directory programmatically on IIS 6? -

i have web application: w3svc/1/root/myapp i can set httpexpires value via adsutil: cscript c:\inetpub\adminscripts\adsutil.vbs set w3svc/1/root/myapp/httpexpires "d,86400" however, don't want caching whole application, images subdirectory: w3svc/1/root/myapp/images keep in mind images isn't it's web directory, sub-directory. when try thru adsutil this: the path requested not found. errnumber: -2147024893 (0x80070003) error trying object: w3svc/1/root/myapp/images i under impression creating web directory create virtual directory,but when @ metabase set web directory;so, set vdir = getobject("iis://localhost/w3svc/1/root/myapp") if err.number <> 0 set objroot = getobject("iis://localhost/w3svc/1/root/myapp") set vdir = objroot.create("iiswebdirectory", "images") end if vdir.put "httpexpires", "d,2419200" vdir.setinfo

symlink - C# CreateSymbolicLink doesn't follow through share access -

i'm not sure if c# problem or windows limitation. i have server running program makes symbolic links in shared folder. can access through link form server normal disk path , share path. if try access same share other pc can't access linked files. can delete rename... links can't follow links. i checked acl of link , target files. should able access. i use following function: [dllimport("kernel32.dll")] static extern bool createsymboliclink(string lpsymlinkfilename, string lptargetfilename, int dwflags); maybe have set additional things? or have change windows settings on server? sorry if solution not programming thing think here have best chances this. edit 1: i have share: c:\share a link: c:\share\file.txt to destination: d:\file.txt if access share different pc can't access data of file.txt. this page tuxera has description of reason the similar concept of symbolic link available in windows vista. symbolic links c

.net - Constraining time with LINQ -

i'm having difficulty constraining time in linq statement. still pretty new linq. sql want emulate this: select id, token, starttime tokens token = '050' , starttime > dateadd(mi, -30, current_timestamp) this sql statement gets rows time in starttime column less 30 minutes current time. how linq? far best guess datetime cutoff = datetime.now - new timespan(0, 30, 0); ienumerable<tokens> token = datacontext.tokens.where(row => row.token == "050" && row.starttime > cutoff); but doesn't seem working. advise? you may add 30 days token's starttime , compare current date. should compare token text string (double quotes), possibly might varchar2 type. var token = datacontext.tokens.where(r => r.token == "5" && r.starttime.adddays(30).date >= datetime.now.date ); edit: want show last 30 days of operation, date , time should

php - Dwoo template search path -

can somehow add paths dwoo looking templates from? have 2 folders store templates, , use extends -function across these 2 directories without having stuff "../templates/template.tpl" or using absolute paths. so, if in template {extends "base.htm"} i'd dwoo look, example, directories "/www/site/templates" , "/www/site/static" file. you can use includepaths function of dwoo_template_file class, example: $tpl = new dwoo_template_file('foo.html'); $tpl->setincludepath(array('/www/site/templates', '/www/site/static')); echo $dwoo->get($tpl, $data); then should automatically relative paths dirs , take first found.

reporting services - SSRS - configure email server for basic authentication -

i tried suggested here , ssrs still returns error. failure sending mail: transport failed connect server. for ssrs configuration, have following in config file: <extension name="report server email" type="microsoft.reportingservices.emaildeliveryprovider.emailprovider, reportingservicesemaildeliveryprovider"> <maxretries>3</maxretries> <secondsbeforeretry>900</secondsbeforeretry> <configuration> <rsemaildpconfiguration> <smtpserver>myservername</smtpserver> <smtpserverport></smtpserverport> <smtpaccountname></smtpaccountname> <smtpconnectiontimeout></smtpconnectiontimeout> <smtpserverpickupdirectory></smtpserverpickupdirectory> <smtpusessl></smtpusessl>

Field problem in Crystal Reports -

i dragged field details section, shows 1 row , repeats there in details section , shows next row. want courseid2 should come below courseid1 , nothing else should repeated. the way have tables joined causing "extra" records. if you're not understanding join , you're looking quick-fix/hack problem, can add group on courseid field , move "detail" fields new group header section. after that, suppress detail section , group footer section. leave group header section showing on report, , it's impossible duplicate records group header section. you need develop better understanding of data though, , how joins affect outcome of query.

php - Can't use preg_replace inside a static function, why? -

is there reason why can't use preg_replace inside static function? when move code out of it, works perfectly. ideas? funny, because works fine: class obnoxiousweasel { public static function callmedoitidareya($omgudid) { return preg_replace("/(, don\'t listen)/", '...', $omgudid); } } $pieceofmymind = "ok, what's point, don't listen"; $reply = obnoxiousweasel::callmedoitidareya($pieceofmymind); echo $reply; returns: "ok, what's point..." we need see code before can tell wrong. using preg_replace inside static function not problem. edit: edited above useless function improve it. might face it, i'm addicted refactoring.

c# - RegEx to close an unclosed tag -

i have received invalid xml data poll provider , clean several unclosed tags before processing. the data looks this: <questions> <question number="1"> <title>what name?</title> <answer>john doe<answer> <!-- problem --> </question> <question number="2"> ... </question> is there way regular expressions clean , go ahead , close <answer> tag? i have this: "<answer>.*?(?<closingtag><answer>)" find occurrences, how do specific replacement on <closingtag> named group? sorry basic question, struggling bit regex expression. thanks, hal programatic repair of human error in xml validation asking trouble. in extreme, might undo xml validation. take 1 example: <questions> <question number="1"> <title>what name?</title> <answer>john doe<answer> <!-- problem --> </question> <question n

php - Problems with match against -

im trying make search engine php , mysql , im using match agains. however im having problem (probably syntax) driving me crazy. here code: <?php $busqueda= $_get["words"]; require("conectdb.php"); if ($busqueda<>''){ $trozos=explode(" ",$busqueda); $numero=count($trozos); if ($numero==1) { $cadbusca="select * post contenido '%$busqueda%' or titulo '%$busqueda%'"; } elseif ($numero>1) { $cadbusca="select * , match ( 'titulo', 'contenido' ) against ( '$busqueda' ) score post match ( 'titulo', 'contenido' ) against ( '$busqueda' ) order score desc"; } $result=(mysql_query($cadbusca)); while($info = mysql_fetch_array($result)) { echo $info["id"]." ".$info["titulo"]." ".$info["contenido"]; } } ?> here error after more 1 word search: warning: mysql_fetch_a

python - Django: standard location/conventions for data import scripts? -

i'm working on number of django projects, , in of them, have initial data import. this data isn't neat json, shown in fixture examples in django docs - tends messy excel or csv files. scripts tend following snippet, , run them standalone python, because don't know better: import sys django.core.management import setup_environ sys.path.append(location of django projects, ex: 'c:\django') mysite import settings setup_environ(settings) project_name.app_name.models import model_name import csv reader = csv.reader(open(complete path data, ex: "c:/django/mysite/restaurants.csv"), dialect='excel') row in reader: column_one_title = row[0] column_two_title = row[1] model_name.objects.get_or_create(my_first_column=column_one_title, my_second_column=column_two_title) i feel when commit these projects github or send them client or whatever, should include import scripts. they're important part of project. is there standard way, in

c# - How to create instance of an object? -

i using json.net library convert objects json , objects. i have interface: public interface igoods { list<ipen> pens { get; set; } list<ipencil> pencils{ get; set; } void deserialize(string json); } implementation: new public void deserialize(string json) { jsonconvert.deserializeobject<goods>(json); } the obvious error got is: not create instance of type project.ipen. type interface or abstract class , cannot instantated. how overcome error? thanks! see using json.net converters deserialize properties

android loading and saving images on the device -

i building application load list of news website. each news/headline has image. want save/cash images user not has download them again. q: in opinion, better/more sufficient way: loading images , saving them on device or use cachemanager? @ moment using first solution , works fine. however, website has many categories , more news per category therefore there lot of images saved on device. normal in type of applications save images on device? thanks help, marqs i don't think should save images on device, because of many reasons: why wasting device space on news images? user wants read news , thats it. (in case maybe open later, still - not forever) you can save on device , make app. delete files after lets 24 hours.. the main issue privacy issue, when user deleting cache files thinks webs visited has wiped device, in case aren't.. maybe can add "clean cache" button in app. after wrote think using cache-manager best way - because meant things ex

How do I install django-ckeditor? -

in stack overflow there's 2 questions this editor , , nobody answers!!! so i'm asking how install django package project?? i've followed these steps already, have no errors, nothing, , still form stays same. why?? edit: heres model from datetime import datetime django.db import models django.utils.translation import ugettext_lazy _, ugettext ckeditor.fields import richtextfield class newsletter(models.model): title = models.charfield( _(u'title'), max_length=200, help_text=_(u'newsletter title'), ) body = richtextfield() date = models.datefield( _(u'date'), help_text=_(u'set date when newsletter should send') ) class meta: ordering = ['title',] forms.py from models import newsletter, mail class newsletterform(forms.modelform): class meta: model = newsletter view: from newsletter.models import n

regex - Python filter list to remove certain links from html source code -

i have html source code want filter out 1 or more links , keep others. i have set filter "*" wildcard: <a*>link1</a>‚ <a*>link2</a>‚ or <a*>link3</a> <a*>a bad link*</a> text* <a*>update*</a> other text right before link <a*>click here</a> i filter out every instance of link html source code using python. i'm ok loading list array. need filter. each line break signify separate filter , want remove link(s) , not text i still new python , regex/beautifulsoup. if point me in right direction, appreciated. to remove <a> tags , keep text not contained within tags: >>> beautifulsoup import beautifulsoup bs >>> markup = """<a*>link1</a> <a*>link2</a> or <a*>link3</a> ... <a*>a bad link*</a> ... text* <a*>update*</a> ... other text right before link <a*>click here</a>"

asp.net mvc - jquery post behaviour help -

it's meant call action method called logon. depending on logic want either redirect url, or set error text. its getting right information json data, doing displaying json result in new tab when click submit button. what wrong here? $("#submit").click(function () { $.post({ url: "account/logon", datatype: "json", success: function (data) { if (data.redirect) { // data.redirect contains string url redirect window.location.href = data.redirect; } else { // data.form contains html replacement form $("#error").replacewith(data.error); } } }); you need cancel default action ... return false; @ end of click handl

Can I change the double click event handler (ondblClickRow) for a jQuery jqGrid plug-in after it has been rendered in ASP.NET MVC? -

i have been using jqgrid success; however, i've hit can't seem working. returning grid definition partialviewresult via ajax , appending the results div. i change double click event said grid. i'm using firebug , can seem grid element using $('#my-grid')[0] when attempt call methods on below tells me jqgrid "not defined". i'm pretty sure i've got jqgrid stuff referenced correctly or wouldn't have gotten far (i have been displaying , editting data in grids already). here's code gets , attempts modify grid definition: $(document).ready(function() { //add grid pulling via ajax $.get('<%=url.action("grid","entity", new {id = "customeraccount"}) %>', function(htmlresult) { //append grid definition div $('#customer-list').append(htmlresult); var mygrid = $($('#customeraccount-grid')[0]); $(mygrid).jqgri

How to make your c# app work as windows service? -

Image
how make c# app work windows service? (matereals, todos wanted) from visual studio "new project window, select windows service. set template can use turn app service.

sql server - sql query for by periods -

Image
i have 2 fields in table, nexttime , endtime, table name visit. i value page 00:05:00 or sth that. minimum 5 minute. i have query database based on value. i earliest nexttime , time + 00:05:00. let's earlist nexttime 06:44. my query 06:45, 06:50, , on.. i have input value interval time. nvm that. i wanna know how query interval. the result looked this. nexttime : endtime 06:55:00 ~ 06:58:00 07:25:00 ~ 07:28:00 07:35:00 ~ 08:52:00 08:38:00 ~ 08:48:00 08:40:00 ~ 08:54:00 08:43:00 ~ 09:36:00 09:12:00 ~ 09:30:00 here's based on information provided , understanding of question solution i'm proposing. in order meet chart periods, change periods within both select statements , clauses each unioned query. use master go create database tests go use tests go create table visits ( nexttime datetime not null , endtime datetime not null ) go begin transaction insert visits (nexttime, endtime) select n'06:55:00&

objective c - IKImageView redraw problem on image change -

i have 1 large ikimageview in window. image changes when user clicks something. when change happens, ikimageview first draws background colour, draws image on top of it, looks pretty crappy. there way switch images more smoothly? it contains garbage when window loads split second until image loads - related? problem solved - stop using ikimageview , never bother again because poorly documented , buggy. trusty nsimageview. nsimageview refreshes in better way ikimageview - ikimageview draws whole background unbuffered, draws image unbuffered. nsimageview whole thing 1 operation. never darken door again, ikimageview.

mysql automatically prevent redundant inserts -

i have table like create table adjacencies( relationid int not null primary key auto_increment, parent int not null, child int not null, pathlen int not null ) ; i'm inserting large amounts of entries like insert adjacencies( parent, child, pathlen ) select a, b, c condition ; so when run insert query, possible (parent,child) relation exist , duplicated. bad news. i don't want create primary key on ( parent, child ) because results in hard fail (query failure). what want soft fail if there attempt insert (parent, child) pair exists in table (i.e pair gets ignored , , rest of query proceeds normally). what's best way in mysql? (* wondering why there relationid member in table? ) create composite unique key around parent , child columns. issue query instead: insert ignore adjacencies( parent, child, pathlen ) select a, b, c condition ; the ignore clause turn duplicate key errors warnings.

asp.net - Can Math.Round in C# be used for whole integer values? -

i have integer 363 example. any method make 360 or 365? there's nothing built-in, you're going have code logic yourself. here's 1 such method. (going down clearer, going manageable.) int number = 363; int roundeddown = number - number % 5; int roundedup = number + (number % 5 > 0 ? (5 - number % 5) : 0); edit negative numbers, logic gets reversed. static int rounduptofive(int number) { if (number >= 0) return number + (number % 5 > 0 ? (5 - number % 5) : 0); else return number - (number % 5); } static int rounddowntofive(int number) { if (number >= 0) return number - number % 5; else return number + (number % 5 < 0 ? (-5 - number % 5) : 0); }

php - Check all $_POST Variable at once -

instead of checking post variables form 1 @ time there way run 1 check atleast verify not empty like if(!isset(all $_post)){ echo "one of fields not completed."; } you can create array of required fields , loop through that $required_fields = array("name", "address", "phone", "email"); foreach ($require_fields $field) { if (!strlen($_post[$field])) { echo "$field cannot empty"; } }

autofill - What are the benefits of using emacs auto-fill-mode? -

i wondering whether should disable emacs auto-fill-mode or keep it. why want disable it? why want keep it? are there factors other personal preference, or may influence personal preference? i guess rule of thumb whether else looking @ file, , whether have reasonable expectation text filled. if it's going filled text, might use auto-fill. i'm not sure there single answer, use auto-fill in modes , not in others. on things commonly understood have column limit: code [comments], commit logs. off free form text notes, org-mode, etc. there's no reason has used globally.

html - how to iterate elements in reverse order in jquery? -

this question has answer here: jquery .each() backwards 12 answers i'm new jquery.i'd know how iterate form elements in reverse order in jquery using each()? appreciated:) try $($("input").get().reverse()).each(function() { /* ... */ });

Error while trying to parse a website url using python . how to debug it? -

#!/usr/bin/python import json import urllib beautifulsoup import beautifulsoup beautifulsoup import beautifulstonesoup import beautifulsoup def showsome(searchfor): query = urllib.urlencode({'q': searchfor}) url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s' % query search_response = urllib.urlopen(url) search_results = search_response.read() results = json.loads(search_results) data = results['responsedata'] print 'total results: %s' % data['cursor']['estimatedresultcount'] hits = data['results'] print 'top %d hits:' % len(hits) h in hits: print ' ', h['url'] resp = urllib.urlopen(h['url']) res = resp.read() soup = beautifulsoup(res) print soup.prettify() print 'for more results, see %s' % data['cursor']['moreresultsurl'] showsome('sachin') what wrong in code ? note 4 links getting

image - Using pngcrush with git export filter -

i’d optimize png files when export them (using git archive) repository, using smudge filter. however, if understand correctly, these filters work via stdin , stdout, while pngcrush needs “real” file. is there workaround? use temporary files. eg: in=$(mktemp) out=$(mktemp) # save stdin temp file cat > "$in" # crush image , ignore regular output. # die if pngcrush fails. pngcrush "$in" "$out" > /dev/null || exit $? # write temp file stdout cat "$out" # clean rm "$in" "$out" &

ios - Website which can make a call to a given phone number -

is there website/server through can tie-up doing following: i pass user id , phone number. using user id, know , phone number. 3.1 make call phone number have passed , me , both of connected? 3.2 make call phone number have passed , should display number in mobile. please let me know whether of these 3.1 or 3.2 possible? i'm not sure if you're looking for, have @ ribbit api .

Runtime splash screen iPhone -

i made iphone application supports french , english languages. when application loading there black screen appears initially. instead of want add splash screens french , english. both splash screens different. when language french load french splash screen , when language english, load english splash screen. in simple words, how add default.png english , french? please let me know if there way implement this. you can dynamically load universal screen, switch 1 of language specific screens. can play code: add appdelegate.m @interface switchdefault : uiviewcontroller {} @end @implementation switchdefault - (void)viewdidload { [super viewdidload]; /* use if statement here display specific french / english spash */ uiimageview *switch = @"english.png"; self.view = switch; [uiview beginanimations:nil context:nil]; [uiview setanimationduration:2.0]; [uiview setanimationdelegate:self]; [uiview setanimationdidstopselecto

visual studio 2010 - Ways to make it easier to work with shared pointers in C++ -

i busy designing new c++ application. in application want minimize potential errors pointers, , since application should plain c++ (no .net or other fancy things), investigating shared pointers , considering using shared pointers everywhere (instead of normal pointers). i worked out tricks make easier work shared pointers, e.g.: using typedef within class, this: class x { public: ... typedef std::shared_ptr<x> ptr; }; that way can write x::ptr, easier write "std::shared_ptr" everywhere. i noticed disadvantages shared pointers: everywhere use shared pointer need include <memory> i can't use forward declaration anymore if want use pointer are there other tricks make shared pointers easier work with? don't! the way minimize pointer errors use the right pointer types. , that's types , plural. shared pointers not silver bullet. become memory leaks when have cyclical references (and if plan use them ever

javascript - replaceing innerHTML of div with some html code -

i have div id xyz.now have avariable has html code follows var mycode = "<br>jajaj<b>jjja</b> "; now want replace content of div html code using following document.getelementbyid("xyz").innerhtml = mycode this doenot work.i not getting why.mycode dynamicallly created in code. if simple document.getelementbyid("xyz").innerhtml ="some text" works getelementbyid() is case sensitive .

keeping the one view on the front and doing another activity in Android -

i want play audio file in application condition want play selected sound file in background means when timer countdown(i have created 1 separate view timer countdown) gets on audio file should play same timer countdown view is. the timer countdown layout view should maintained , audio file should played. can please me here because able play selected file finely, want play timer countdown view maintained. how playing audio file? mediaplayer should able achieve want. this question helpful.

Reporting Services Expression -

i'm trying set hidden-property of textbox based on expression: =iif(isnothing(parameters!customer_numbers.value) , isnothing(parameters!country_codes.value),false,true) error: "argument not specified parameter 'falsepart' of public function iif(expression boolean, truepart object, falsepart object) object" i'm jscript/c# guy , not used pseudo-vb language. wrong? regards alex my answer nothing wrong! i created test report (rs 2008) 2 parameters: customer_numbers , country_codes. set parameters text fields , nullable. i added textbox text "both parameters null". set visibility expression via copy , paste question. the report starts fine, , if set both parameters null see textbox. rdl of textbox turns out this: <visibility> <hidden>=iif(isnothing(parameters!customer_numbers.value) , isnothing(parameters!country_codes.value),false,true)</hidden> </visibility>

using the same webpart logic with different look in Sharepoint 2010 -

i have custom developed webpart in visual studio, , want use same functionality in sharepoint site multiple times different looks every time. what's best practice achieve this? i suggest used xslt based custom webpart can apply different xslt on each instance different , feel example same sharepoint coreresult webpart. you have inherit webpart dataformwebpart

c# - WCF - maxReceivedMessageSize -

i have problem setting maxreceivedmessagesize larger files. i'm getting: the maximum message size quota incoming messages (65536) has been exceeded. increase quota, use maxreceivedmessagesize property on appropriate binding element. here server side configuration: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appsettings> <add key="httpbaseaddress" value="http://localhost:8080/welcomemessage/"/> <add key="httpfiletransferaddress" value="http://localhost:8080/filetransfer/"/> </appsettings> <system.web> <compilation debug="false" /> </system.web> <system.webserver> <modules runallmanagedmodulesforallrequests="true"/> </system.webserver> <system.servicemodel> <services> <service name="fs.services.messageservice" behaviorconfiguration=&

Is there concept of panel in BlackBerry -

as have concepts of panel in swings , awt can add controls.do have concept of panel in blackberry. .can 1 please tell me it.i have create icons in bb , place @ bottom of screen give of toolbar.i know have toolbar package in bb 6.0 simulators(like 8520 curve) doesnt support dont want use that. please me understand there concept of panel in bb in awt , swings thanks in advance yogesh chaudhari we have managers in blackberry. implement toolbar on blackberry screen can use verticalfieldmanager , horizontalfieldmanager. if want toolbar show @ bottom can use verticalfieldmanager contains 1 fixed size verticalfieldmanager , 1 horizontalfieldmanager. can have toolbar buttons in horizontalfieldmanager , add parent manager.. this. verticalfieldmanager parent = new verticalfieldmanager(manager.use_all_height|manager.use_all_width); verticalfieldmanager vfm = new verticalfieldmanager(){ public void sublayout(int width, int height) { super.sublayout(display.getwi

c# - Cannot implicitly convert type 'string' to 'System.DateTime' -

i trying convert string datatime an error occurs. using vs 2003, .net framework 1.1 datetime dt = convert.todatetime("11/23/2010"); string s2 = dt.tostring("dd-mm-yyyy"); datetime dtnew = convert.tostring(s2); cannot implicitly convert type 'string' 'system.datetime' can 1 me me syntax how solve error. string input = "21-12-2010"; // dd-mm-yyyy datetime d; if (datetime.tryparseexact(input, "dd-mm-yyyy", system.globalization.cultureinfo.invariantculture, system.globalization.datetimestyles.none, out d)) { // use d }

puzzle - expected `;' before "pennies"? C++ Debugging (Code Completed) -

can tell me why error on last cout ? #include <iostream> #include <cmath> #include <stdio.h> #include <cstring> #include <conio.h> using namespace std; inline void keep_window_open() { char ch; cin>>ch; } int main() { cout << "how many pennies have?\n"; int pennies; cin >> pennies; double total_pen; total_pen = (0.01 * pennies); if (pennies >= 1) { string penn = " pennies."; }else { string penn = " penny."; } cout << "how many nickles have?\n"; int nickles; cin >> nickles; double total_nic; total_nic = (0.05 * nickles); if (nickles >= 1) { string 5 = " nickels."; }else { string 5 = " nickel."; } cout << "how many dimes have?\n"; int dimes; cin >&

flex4 - Pen tool in Flex/Flash Builder 4 -

is there way drawing lines/curves in flex/fb4 -like pen tool? because not practical method drawing <s:line/> 's. maybe external tool lets draw , code flex/fb4? i want draw in ide part of application, application not going drawing application. draw interface in illustrator. run through catalyst, , make custom component. or can export flash components( swf's no code ) illustrator directly iirc.

security - changing background data state in Android -

allow me start little rant: while background data enabled on galaxy s (froyo) battery drains in few hours! cant figure out why when both exchange , gmail accounts set push. in case, leads need turn bg data off conserve battery , turn on browsing marketplace. dont understand why market app cant turn thing on when open app , not bother me , dont why everytime turn bg data off dialog telling me save me battery, know that! thats why im turning if off!!! eurghhhh... with out of way, wanted write little widget allow me turn background data on , off whenever want without going through menus , seeing annoying dialog. found out setting 1 of "secured settings" apps cant change. what wanted ask, whether there way change secure setting in android through code? has found way around this? or have live it? thanks! what wanted ask, whether there way change secure setting in android through code? only modifying firmware.