Posts

Showing posts from March, 2015

regex - Javascript regular expression for URL -

can me building regular expression extract couple of urls using regular expressions below string '<a href="http://mydmncd.app.corp:8080/ag/ps?q=c~0~0~0~0~0~v2hgsds4-0ds43hg~94~0~~~1~0~0~~http%3a%2f%2fnghj.com" target="_blank"><img border=0 src="mydmncd.app.png" alt="" clickurl="http://mydmncd.app2.corp?q=1&f=4"/></a>' url starts http://mydmncd , remaining part may vary. have extract url until find double quotes. in above example have extract http://mydmncd.app.corp:8080/ag/ps?q=c~0~0~0~0~0~v2hgsds4-0ds43hg~94~0~~~1~0~0~~http%3a%2f%2fnghj.com i tried regex /[http://mydmncd].*"/g matching last double quotes. have tried /[http://mydmncd].*\s/g no luck. see jsfiddle the problem .* matches " . you should able replace .* [^\"]* match character except " . i don't have way test here, hope can you.

Sending inputs to email? WinForm C# -

i'm working on simple winform project have textbox user inputs name. when clicks on button want able send input email address or that. would possible? if how do it? the following code serves send email custom smtp client: using system; using system.net.mail; class program { static void main(string[] args) { try { mailmessage mail = new mailmessage(); smtpclient smtpserver = new smtpclient("smtp.customsmtp.com"); mail.from = new mailaddress("fromemail@fromemail.com"); mail.to.add("toemail@toemail.com"); mail.subject = "your subject"; mail.body = "your textbox here!"; smtpserver.send(mail); } catch (exception ex) { console.writeline("seems problem!"); } console.writeline(...

javascript - Backbone models and URL exceptions -

i have backbone model called user has urlroot of /api/users . thus, if create new model id of 5, url /api/users/5 . i have implemented endpoint individual user's twitter friends. endpoint /api/users/:id/twitter-friends do need create new collection url , , manually set id , or can somehow create method on model make request , return new collection instance (of user's twitter friends). example: var user = new user({ id: 5 }) user.findtwitterfriends() // returns collection of users or, make unique collection data of sort: var user = new user({ id: 5 }) var users = new users() users.url = user.url() + '/find-friends/twitter' // /api/users/5/find-friends/twitter users.fetch() what best practice dealing urls in way? there better way? have similar needs other uses, such api endpoint can users username @ /api/users/username/:username . having manually set urlroot: var user = new user({ username: username }) user.urlroot = user.urlroot + '/username/...

asp.net - Dynamic pages in MVC4 -

i'm building small mvc4 site, i've run in little problem :/ the site have admin area, , in area administrator of site, should able dynamicly create new pages. let's admin creates new page called "world" under page called "hello". when user navigates the.domain.com/hello/world newly created page should shown. it's basicly functionality of simple cms system. so, need way redirect calls not covered controller , action, 1 specific action on 1 specific controller. i've done before in webforms using urlrewriting. checked if aspx page existed on disk, , if didn't redirected page called pagehandler.aspx?pageid={some_page_id}, guess there way routing in mvc4? you can pass strings view() , should able catch route this: routes.maproute( name: "dynamicpageview", url: "page/{pagename}", defaults: new { controller = "page", action = "displaypage", pagename = "index" } );...

emacs - What does "extern" mean in JavaScript? -

i started use js2-mode in emacs, , found variables js2-global-externs , js2-additional-externs . doc string says "a list of extern names you'd consider declared." i don't understand "extern" means here. knew "extern" keyword in c, started discover "extern" means. searched javascript extern / ecma-262 extern / web browser extern didn't looked promising. can point me in right direction? the extern keyword has nothing javascript. it's configuration on js2-mode relies on define language. for instance, believe add own global variables js2-global-externs recognized. have @ file https://code.google.com/p/js2-mode/source/browse/trunk/js2-externs.el?r=57

c# - How do I check if a combobox in a datagridview equals a certain value? -

Image
i'm creating ordering system booking customers in, , want combobox in datagridview able mark job complete, , change colour of row green when yes selected, i'd please have no idea how it, have looked on internet , found nothing. this screenshot of database, , appreciated. i'm using winforms thanks in advance you have use cellvaluechanged event. private void gridcellvaluechanged(object sender, datagridviewcelleventargs e) { //just safe if (e.rowindex < 0 || e.columnindex < 0) { return; } var value = datagridview1[e.columnindex, e.rowindex].value; if (value != null && value.tostring() == "yes") // completed { datagridview1.rows[e.rowindex].defaultcellstyle.backcolor = color.green; } else { datagridview1.rows[e.rowindex].defaultcellstyle.backcolor = color.white; } } hope helps :)

javascript - large size of json response is truncated -

Image
when large size of json response received ajax call, truncated (probably browser), stops me parsing it. when inspect in chrome developer tools, networks, shows trimmed response. copying , viewing on http://json.parser.online.fr/ shows following screenshot is there solution it? sorry!!! there no issue in response... issue populating response in grid large data(which fixed). chrome truncates response showing in networks, not actual response. sorry ur time guys...

windows - How can I stop and restart SQL Server from Perl? -

i want stop , restart mssql service programatically using perl. using net stop mssqlserver prompts stopping dependent services. easiest way as @joachim mentioned, can run net stop command stop service me question if stopping sql server service, going related services e.g. sql server agent ? because without sql server service others depending services not work. so me better solution stop depending service first, e.g. net stop sqlserveragent , net stop mssqlserver , when starting them start them in reverse order.

java - jSoup - Is it possible to match elements with a minimum attr() length? -

i can match elements in jsoup easily, then, after fact, need check these values see if @ least longer 1 character. i wondering if there way match elements specific attribute, if attribute's content length longer 1 character? hopefully allow me not have manually check lengths myself. document.select("img[src]") the above matches img tags src attribute, attributes may blank , i'd rather not have them match @ all. pseudo code explaining mean: document.select("img[src:length(1)]") i have looked through reference, cannot find suitable - except perhaps regex solution? http://jsoup.org/apidocs/org/jsoup/select/selector.html thanks, mikey. [attr~=regex] elements attribute named "attr", , value matching regular expression based on source link provided, this document.select("img[src~=.+]"); this should result in selection of img elements src attribute of 1 character or more.

webdriver - Robot Framework - Run Firefox with system proxy -

ok got code: ${server} http://www.google.pt/ ${browser} firefox ${delay} 0 *** keywords *** open browser google open browser ${server} ${browser} maximize browser window set selenium speed ${delay} after run keywords "open browser google", firefox opens , can't open url. figured i'm missing work office's proxy access external network. how can configure firefox webdriver open proxy (being system-default)? ty assuming using selenium2library (rather seleniumlibrary) easiest way of achieving creating firefox profile , passing in argument open browser keyword. 1-create firefox profile launch profile manager firefox.exe -p (windows) /applications/firefox.app/contents/macos/firefox-bin -profilemanager (osx) ./firefox -profilemanager (linux) create new profile (save known location). open profile , open options dialog, advanced tab. select "network" , set pro...

rebol - How does R3 use the Needs field of a script header? Is there any impact on namespaces? -

i'd know behaviour of r3 when processing needs field of script header , implications word binding has. background. i'm trying port r2 scripts r3 in order learn r3. in r2 needs field of script header documentation, though made use of custom function reference scripts required make script run. r3 appears call needs referenced scripts itself, binding seems different doing other scripts. for example when %test-parent.r is: rebol [ title: {test parent} needs: [%test-child.r] ] parent: ?? parent ?? child and %test-child is: rebol [ title: {test child} ] child: ?? child r3 alpha (saphiron build 22-feb-2013/11:09:25) returns: >> %test-parent.r script: "test parent" version: none date: none child: 9-may-2013/22:51:52+10:00 parent: 9-may-2013/22:51:52+10:00 ** script error: child has no value ** where: ajoin case ?? catch either either -apply- ** near: :name i don't understand why test-parent cannot access child set %test-child.r ...

c# - string.format(format,doubleValue) , precision lost -

i have double value: var value = 52.30298270000003 and when convert string , losses precision : var str = string.format("{0} text...", value); console.writeline(str); // output: 52.3029827 the number of precision on double value may changed @ run-time. how can force string.format method use precision ? you want use r format specifier from msdn result: string can round-trip identical number. supported by: single, double, , biginteger. precision specifier: ignored. more information: the round-trip ("r") format specifier . string.format("{0:r} text...", value) will give 52.30298270000003 text...

git-svn: preserving merges across two different git-svn repos -

we have been using workflow @ work several months svn developers create svn fix branches merged integration branch using git , committed svn, merge @ time, dcommit. in workflow, there has been single git-svn repo doing merge work. this workflow has worked pretty , git merges faithfully preserved in original git-svn repo. however, have decided spread merging workload across number of users, each of has own git-svn repo. unfortunately, finding merges performed 1 git-svn user (but not always) appear single parent commits in git-svn repo of other user instead of looking 2 parent merges. loss of merge history plays havoc history analysis , causes unnecessary merge conflicts since git can no longer identify correct merge-base, if merges parents had been preserved across repositories. does have practices avoid circumstances cause merge history corrupted in 1 or more git-svn repos sync common svn repo? i not sure causes problem, have found acceptable workaround recreate me...

android - Can we add Listener for custom ArrayAdpater class -

i have custom arrayadapter class listview . i using custom adapter more listviews . all listview items have start same activity when clicked, how without adding individual itemlistener each listview item? i have done this: public view getview(int position, view convertview, viewgroup parent) { layoutinflater inflater = (layoutinflater)(context.getsystemservice(context.layout_inflater_service)); row = inflater.inflate(layoutresourceid, parent, false); imageview albumart = (imageview)(row.findviewbyid(r.id.album_art)); textview albumname = (textview)(row.findviewbyid(r.id.album_name)); final onclicklistener listener = new onclicklistener() { @override public void onclick(view v) { intent intent = new intent(v.getcontext(), playeractivity.class); intent.putextra("albumart", album.albumart); v.getcontext(...

web2py - Adding a nonce to a form that was manually created -

is there way add nonce manually created form? example, creating sqlform in controller , rendering {{=form}} in views automatically attach nonce form. but manually created this: <form> <input type="text"> <button type="submit">submit</button> </form> won't have nonce. you can construct , process form object in controller usual using form() or sqlform() . in case, can still create custom html form in view (as long input field names match) -- have include special hidden _formname , _formkey fields, can via form.custom.end . in controller: def myform(): return dict(form=sqlform(db.mytable).process()) in view: <form> <input type="text"> <button type="submit">submit</button> {{=form.custom.end}} note, form.custom.end includes closing </form> tag, no need add explicitly. if want html more explicit, can access _formname , _formkey values...

jquery - Fade Out/Fade In of List Items -

this "meet our staff" page there vertical unordered list of small images associated staff member (#staffdirectory). when user clicks different staff member 1 displayed, want current large listitem (which includes image , info member - , assigned class "staffselected" , displayed in div #staffmember) fadeout, lose class, take corresponding listitem (the 1 user clicked in #staffdirectory), fadein one, , add "staffselected" class. what happening there overlap , new listitem briefly displays right of old 1 (but happens second , subsequent times click #staffdirectory list - first time works beautifully). so, transitions not smooth. assume issue has deal declaration of newmember variable or use in fadein method. js , css below. in advance. js: $(document).ready(function() { $("#staffdirectory ul li").click(function() { var index = $("#staffdirectory ul li").index(this); var newmember = null; newmem...

javascript - Accessing a Java Map inside a scriptlet -

i've got java map object imported jsp file i'm working with. need take each entry of map , put table in jsp. i'm not going act i'm super knowledgeable scriptlets, can tell they're evaluated before running , placed code, makes accessing individual entries challenge. i've got working doing tostring on map , using regexs parse out info, want more safely. how achieved? i assuming map of map<integer,string>() type; <ul> <% for(integer key : yourmap.keyset()) { string value = data.get(key); system.out.printf("%s = %s%n", key, value); %> <li><%= value%></li> <% } %> </ul>

jquery - JavaScript object properties - connect them together? -

i have 3 objects in array. myarray = [ {name: "iphone", link: "www.apple.com"}, {name: "nokia", link: "www.nokia.com"}, {name: "google", link: "www.google.com"} ] how make loop , put properties display on page, this: iphone nokia google and have links when click on them thanks! with pure js, : for(var i=0;i<myarray.length;i++){ var = document.createelement('a'); a.href= myarray[i].link; a.text= myarray[i].name; document.body.appendchild(a); } but easier jquery: you can use jquery .each() . loop through array , can access object properties this . to make link, create a element , assing value .attr() , .text() $.each(myarray, function(){ var = $('<a/>'); //the element a.attr('href', this.link) //the href a.text(this.name) //the text $('body').append(a) //append body })

asp.net - Roles.IsUserInRole throwing a dataservicequeryexception -

what i'm trying test if role affected user or not, method (fig 1 ) test exposed wcf data service, , i'm trying call (fig 2 ) client side. call correct because tested simple test returns , got want send when change body of method send me wheter user in role or not, thows exception ( dataservicequeryexception ) fig1: [webget] public bool controler(string role, string user) { if(roles.isuserinrole(user,role)) { return true; } return false; } fig2: uri u = new uri(string.format(login.ctx.baseuri + "/controler?role='{0}'&user='{1}'", "serveur","oussama"), urikind.relativeorabsolute); ienumerable<bool> result = login.ctx.execute<bool>(u); bool res = result.single(); if (res == true) { response.redirect("index.aspx"); } else { response.redirect("error.aspx...

SQL query: have results into a table named the results name -

so have large db split tables. make when run distinct, make table every distinct name. name of table data in 1 of fields. ex: a --------- data 1 --------- data 2 b --------- data 3 b --------- data 4 would result in 2 tables, 1 named , named b. entire row of data copied field. select distinct [name] [maintable] -make table each name -select [name] [maintable] -copy table name -drop row [maintable] any great! i advise against this. one solution create indexes, can access data quickly. if have handful of names, though, might not particularly effective because index values have select records. another solution called partitioning. exact mechanism differs database database, underlying idea same. different portions of table (as defined name in case) stored in different places. when query looking values particular name, data gets read. generally, bad design have multiple tables same data columns. here reasons: adding column, changing...

rename image before saving via paperclip - rails 2.3.5 -

i using paperclip allow user upload images in rails application. i want rename images uploaded appending current time file names before saving them in database. here model. column 'data_file_name' used store image name in 'images' table. class image < activerecord::base set_table_name "images" set_primary_key "id" before_create : :rename_image_file def rename_image_file extension = file.extname(data_file_name).downcase self.data_file_name.instance_write(:data_file_name, "#{time.now.to_i.to_s}#{extension}") end belongs_to :book,:foreign_key => :book_id has_attached_file :data, :path => ":rails_root/public/book_images/:book_id/:style/:basename.:extension", :url => "http://www.test.org/book_test_editors/book_images/:book_id/:style/:basename.:extension", :styles => { :thumbnails => ["150x172#",:jpg], :large => ["100%", :jpg] ...

Vim cannot rebind Home/End keys -

i'd <home> perform g<home> , have tried map <home> g<home> noremap <home> g<home> map <home> g^ noremap <home> g^ map <home> g<home> noremap <home> g<home> map <home> g^ noremap <home> g^ nothing seems work, behavior stays same. @ point able type g + home right thing (go home/end of soft line in wrapped file) typing ctrl+v home yields ^[[1~ (and end yields ^[[4~ ). i bound this: noremap <esc>[1~ g^

php - Use Tidesdk to query mysql (external/localy) -

i've looked tidesdk , found no way query local or external mysql database. is there way connect mysql , query database/table, maybe via php? thx help currently there no native way of accessing mysql through tidesdk. welcome create native module tidesdk access mysql.

php - Complex SQL query JOIN and WHERE -

i have table, need contacts from. use complex query retrieve contacts "sms" table. however, should count records provided "imei" field, query keeps returning counts specific contact. below code use, advice? $sql = $this->db->query(' select t1.mnumber t1_number, t1.mcontent t1_content, t1.mcontact t1_contact, sum(t2.total) mtotal sms t1 join (select mcontent, mcontact, count(mnumber) total, mnumber, max(mid) mid sms group mcontact) t2 on t1.mcontact = t2.mcontact , t1.mid = t2.mid t1.mimei = ' . (imei) . ' group t1.mcontact order t1.mid desc'); return $sql->result(); thanks you!! better formatted, query is: select t1.mnumber t1_number, t1.mcontent t1_content, t1.mcontact t1_contact, sum(t2.total) mtotal sms t1 join (select mcontent, mcontact, count(mnumber) total, mnumber, max(mid) mid ...

gridview - Updating row directly in ASP.NET using databind() ! Please help me -

this difficult problem found how solve when cell on table don't receive input value user . please show me how retrieve value updated cell . please me . boring because of seeing problem protected void gridview1_rowupdating(object sender, gridviewupdateeventargs e) { int id; id = int.parse(gridview1.datakeys[e.rowindex].value.tostring()); foreach (gridviewrow row in gridview1.rows) { value1 = row.cells[2].text;//only receive lastest value . cann't receive value when updated } //response.write("check value" + value1); dataclassescheckdatacontext ctx = new dataclassescheckdatacontext(); ctx.editstudentproc(id, value1); gridview1.datasource = ctx.students; gridview1.editindex = -1; gridview1.databind(); } on rowupdating updated values in e.newvalues, ref http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewupdateeventargs.newvalues.aspx

sql - Order by the max value in the group -

i group results 1 column (name), order second column (note) each group, , order groups highest note have. so, if entities scrambled these: name note andrew 19 thomas 18 andrew 18 andrew 17 frank 16 frank 15 thomas 14 thomas 12 frank 5 i them ordered this: name note andrew 19 andrew 18 andrew 17 thomas 18 thomas 14 thomas 12 frank 16 frank 15 frank 5 grouped name, andrew appearing first because highest note 19, thomas (18) , frank (16). regards, val cte answer... create table namenotetable (name varchar(10), note int); insert namenotetable select 'andrew', 19 union select 'andrew', 18 union select 'andrew', 17 union select 'thomas', 18 union select 'thomas', 14 union select 'thomas', 12 union select 'frank', 16 union select 'frank', 15; ...

python - django-haystack - filter based on query along with query for search term -

i able search using ?q='search term'. requirement is, among searched terms, should able order them price etc. filter field etc. will provide more information if necessary. you should faceting enables search on other fields of model. comes down defining facets , enabling user search them, in addition textual search you're doing keywords.

python - Passing an object with an Exception? -

what correct way pass object custom exception? i'm pretty sure code used work, throwing error. class failedpostexception(exception): pass def post_request(request): session = requests.session() response = session.send(request.prepare(), timeout=5, verify=true) if response.status_code not requests.codes.ok: raise failedpostexception(response) session.close() return response try: ... except failedpostexception r: // type(r) - requests.response print r.text attributeerror: 'failedpostexception' object has no attribute 'text' the raising , catching of exception correct, issue here expect exception have text attribute not exist. when inheriting built-in exception type can use args attribute, tuple of arguments exception, example: try: ... except failedpostexception r: print r.args[0] in case use str(r) instead of r.args[0] . if there 1 argument exception str(r) equivalent str(r.args[0]) ,...

right to left - MFC query reading order (RTL) from loaded dll resource? -

we have old mfc app localized multiple languages. have language menu allows user select language (restart of app required). when rtl language such arabic selected, main window frame, , dialogs created in code via calls afxmessagebox, remain in ltr; when run on system runs windows in arabic. want set ws_ex_layoutrtl bit on windows create based on kind of resource loaded. there way use handle retrieved afxgetresourcehandle query if resources rtl? if not, there way this? edit: so clarify, problem main window frame, , dynamic dialogs remains in ltr layout when loaded resource dll rtl. load resource dll first thing in app initinstance function based on 3 letter code stored in registry user sets selecting language language menu drop down. resources dll work fine. have issue on main frame, , generic dialogs load such message boxes when error occurs. perhaps code snippet can explain i'm looking for: bool cwingfmainframe::precreatewindow( createstruct& cs ) { hi...

api - Twitter access token usage -

i want access twitter api on behalf of user. i'm bit confused twitter access token usage. compare github api easy integrate with, have accesstoken put query parameter access_token every http request. with github have access token (from test application), woundering should go - query string, headers? would happy if clarify. it should go in authorization header, word "bearer " (and space) before it. e.g. in android / java httpget call: httpget.setheader("authorization", "bearer " + access_token);

.net - How to prevent a borderless Windows Form from flickering when resizing (C#)? -

[c# .net 4.0] i'm learning c# , i'm trying build windows form using c# has formborderstyle = formborderstyle.none , can moved/resized using windows api. example, i'm using rounded corner or custom (moveable/resizable) border designs used google chrome , norton 360 basis form. i've made lot of progress far , gotten work, except when resize form, there black/white flicker along length of right , bottom borders when resize form quickly . i've tried adding this.doublebuffer = true in constructor , have tried this.setstyles(controlstyles.allpaintinwmpaint | controlstyles.optimizeddoublebuffer | controlstyles.resizeredraw | controlstyles.userpaint, true); . because i'm sucker graphics side of things, having control on full design of form, can see being forever bother me... so if can me resolve flicker doesn't occur anymore , incredibly useful toward learning process. i should mention i'm using windows xp, i'm not sure this post me since se...

c# - WCF, does the Client have to call the Server first? -

does client have contact service 1st? possible specify specific endpoint address on client, in service class, when each instance of service instantiated, begins calling address every x seconds whenever free, in order let client know how many servers available. maybe im missing seems though when create proxy, need know server there. when dealing alot of servers, im assuming above pretty handy? or usual hard code in list client of servers have access to? the typical approach problem hide servers behind virtual ip/load balancer, distribute requests across them according business needs. client makes request bank of servers, addressable through single endpoint, , load balancer determines server instance handle request.

Accept different types in python function? -

i have python function lot of major work on xml file. when using function, want 2 options: either pass name of xml file, or pass pre-parsed elementtree instance. i'd function able determine given in variable. example: def dolotsofxmlstuff(xmldata): if (xmldata != # if xmldata not et instance): xmldata = et.parse(xmldata) # bunch of stuff return stuff the app calling function may need call once, or may need call several times. calling several times , parsing xml each time hugely inefficient , unnecessary. creating whole class wrap 1 function seems bit overkill , end requiring code refactoring. example: ourresults = dolotsofxmlstuff(myobject) would have become: xmlobject = xmlprocessingobjectthathasonefunction("data.xml") ourresult = xmlobject.dolotsofxmlstuff() and if had run on lots of small files, class created each time, seems inefficient. is there simple way detect type of variable coming in? know lot of pythoners "you s...

c# - mapping complex object with automapper -

how can convert ienumerable<category> ienumerable<categoryviewmodel> definition public class category { public guid id { get; set; } public string name { get; set; } public datetime creationtime { get; set; } } public class categoryviewmodel { public guid categoryid { get; set; } public string name { get; set; } } i have done public static ienumerable<categoryviewmodel> converttocategoryviewmodellist(this ienumerable<category> category) { return mapper.map<ienumerable<category>, ienumerable<categoryviewmodel>>(category); but doesn't map id categoryid , don't want have creationtime in categoryveiwmodel either property names should match, or have override mapping id . have explicitly ignore creationtime : automapper.mapper.createmap<category, categoryviewmodel>() .formember(x => x.categoryid, src => src.mapfrom(y => y.id)) .forsourcemem...

c++ - Segfault when adding QwtPlot to the code -

i try use qwtplot, when add line mainwindow.cpp qwtplot *plot = new qwtplot(qwttext("demo"), this); the application compile , link without errors, when try run get program received signal sigsegv, segmentation fault. 0x00007ffff514227c in ?? () /usr/lib/libqtgui.so.4 without backtrace. .pro file: includepath += /usr/include/qwt config += qwt libs += -lqwt i'm using qwt 6.0.2, qt creator 2.7.0 , have qt 4.8.4 , 5.0.2 installed. the error occours when create "qt gui application" (without .ui file) , code: qwt-test.pro qt += core gui greaterthan(qt_major_version, 4): qt += widgets target = qwt-test template = app includepath += /usr/include/qwt config += qwt libs += -lqwt sources += main.cpp\ mainwindow.cpp headers += mainwindow.hpp main.cpp #include "mainwindow.hpp" #include <qapplication> #include <qdebug> int main(int argc, char *argv[]) { qdebug() << "main"; qapplicati...

javascript - Decouple backbone.js and jquery -

i evaluating whether should use backbone.js i interested in nice structure of backbone. hesitant use jquery backend (since have other js library used). is true use backbone "must" include jquery dependency..? pretty question i've asked myself lot. it's not problem exclude jquery or zepto , if don't need sync or backbone.view . backbone uses jquery.ajax syncing, hard create manually ( if want cross-browser support ), , dom events, heavily integrated in backbone.view . there jquery related backbone.history . the problem persist anywhere need backbone features, ground backbone functionality.

scroll - drag scrolling jquery for touch screen -

i searching jquery plugin scroll in touch screens (mobile , not mobile) i use in every touch screen, mobile , desktop wait suggestions jquery kinetic perfect http://the-taylors.org/jquery.kinetic/

ruby - Rails update_attributes always redirects -

i'm writing edit page record in database, want redirect if update successful , render edit page again errors. here code: def edit @list = list.find(params[:id]) if @list.update_attributes(params[:list]) redirect_to(root_path) else render('edit') end end the redirect fires launch edit page, before changes made or submit button clicked. any ideas appreciated. your edit action should this: def edit @list = list.find(params[:id]) end it renders edit view. form should point (and is) update action should so: def update @list = list.find(params[:id]) if @list.update_attributes(params[:list]) redirect_to(root_path) else render :edit end end

ios6 - Is there a way to force Webview to login to Facebook using the native iOS 6 Facebook Credentials -

i have question regarding facebook comments using social plugin on ios6. use social framework login app using facebook credentials set in phone settings. facebook loads comments on uiwebview inside 1 of screen in app. inorder post comments asks me login again whereas logged in using social framework. not want login again on webview. there way force webview login facebook using native ios 6 facebook credentials. after configuring facebook in phone setting ,use acaccount framework request access facebook account required permissions prams , either can use slcomposeviewcontroller: http://developer.apple.com/library/ios/#documentation/networkinginternet/reference/slcomposeviewcontroller_class/reference/reference.html#//apple_ref/doc/uid/tp40012205 class (to use default post ui view) or can use slrequest (using graph api url post) post on wall.

python - Error when calling datetime.date() -

i have 2 versions, both don't work reason can't tell. first version from datetime import datetime, date d = datetime.date(2011, 01, 01) print(d) which gives file "timesince.py", line 3 d = datetime.date(2011, 01, 01) ^ syntaxerror: invalid token second version from datetime import datetime, date d = datetime.date(2011, 1, 1) print(d) which gives traceback (most recent call last): file "timesince.py", line 3, in <module> d = datetime.date(2011, 1, 1) typeerror: descriptor 'date' requires 'datetime.datetime' object received 'int' running python 3.3 you imported date datetime, work: >>> d = date(2011, 1, 1) >>> d datetime.date(2011, 1, 1) no need put datetime infront when import method module, no longer use name of module call method because imported specific method! note: your first instance invalid syntax because can't have ...

refactoring - Refactor regular C++ code pattern -

summary : i'm trying see if can refactor c++ code has regular pattern make easier update , maintain. details : i have code creates thread local counters keep track of statistics during program execution. when statistic added source code there 5 things need updated: counter thread local declaration, counter total declaration, function reset thread counters, function add thread counters total, , print function. the code following: // adding statistic named 'counter' // declaration of counter __thread int counter = 0; int total_counter = 0; // in reset function counter = 0; // in add function total_counter += counter; // in print function printf("counter value is: %d\n", total_counter); i can see how macro created declaration of counter doing like: #define stat(name) __thread int name; \ int total_##name; but haven't thought of how extended update add , reset functions. ideally i'd type stat(counter) , have decla...

c++ - Inheritence over shared library boundaries -

i have 2 binaries, liba.so , exeb. liba exports many of it's functions, including few classes. consider following simplified example: from liba.so: #define export __attribute__((visibility("default"))) class export foo { public: export foo(); // implemented in cpp export virtual ~foo(); // implemented in cpp export virtual int func(int b); // implemented in cpp }; class export bar : public virtual foo { public: export bar(); // implemented in cpp export virtual ~bar(); //implemented in cpp export virtual char anotherfunc(char d); //implemented in cpp }; moving on executable b: class baz : public bar { public: void usefuncandanotherfunc(); //implemented in cpp }; in baz.cpp: foo *p = /* ... */; bar *q = dynamic_cast<bar *>( p ); // culprit during compilation stage, greeted following error: undefined reference `typeinfo foo' undefined reference `typeinfo bar' even though i'm exporting functionality of c...

wordpress - Landscape and portrait image sizes within css -

what best css display category images not squashed or display distorted. the images 1024 x 768 , wordpress/woocommerce settings being set @ 400 x 400 thumbnail , after regeneration of thumbnails there still same: live link i can change css not html. css: ul.products li.product .img-wrap { position: relative; margin: 0 0 1em; padding: 3px; background: #fff; border: 1px solid #e1e1e1; height: 150px; width: 150px; } ul.products li.product img { float: none; margin-right: 0; width: 100%; } one possible fix might be: ul.products li.product img { float: none; width: auto; margin: 0 auto; } this work portrait style thumbnails, not sure landscape style. what want here have thumbnails fit in 150x150 box regardless of aspect ratio of thumbnail image. on line 534 of woocommerce.css, following declaration: ul.products li.product img { display: block; height: 150px; width: 150px; } i remove height/width va...

css - overflow:hidden not working with translation in positive direction -

i came across weird thing lately overflow: hidden; . set element, , want transform elements in translate() , when translates in negative direction hidden, if translate in positive direction, won't hidden. in desktop browsers it's not showing, can reach little bit of mouse work. , on mobile it's scrolls, worst. here example showing it: http://cssizer.com/klhlpshw so i've been working similar day , realized while had html, body {overflow:hidden; } ...if add position:absolute or position:relative html , body, fixes issue.

How do I update or insert an sqlite row with multiple conditions -

i have 3 tables. a, b, , a_to_b. relationship between , b many-to-many. relationship information stored in table a_to_b. it's construction defined follows: create table (id integer primary key autoincrement not null, identifier_from_a text not null, identifier_from_b text not null); each relationship unique. i persist relationship data single statement per relationship. question is, how can achieve without inserting duplicates? the solution use multiple column unique definition in create table statement. for example: create table (id integer primary key autoincrement not null, identifier_from_a text not null, identifier_from_b text not null, unique (a,b) on conflict replace);

visual studio 2010 - Not able to build qt5 in release -

i'm buiding qt 5 visual studio 2010 because need have debug symbols. use following commands: configure -debug-and-release -force-debug-info -platform win32-msvc2010 -opensource -mp nmake but seems qt built in debug mode, because can see *d.dll files in qtbase/bin , qtbase/lib folders. when try build sample qt project, goes ok in debug. in release following error: 1>link : fatal error lnk1181: cannot open input file 'qtmain.lib' this file indeed absent in qt folder. i tried "-release" instead of "-debug-and-release" , created debug libraries instead of release. i build qt5.0.2 configure -developer-build -opensource -nomake examples -nomake tests in detail: install strawbey perl ( http://strawberryperl.com/ ) install windows sdk http://msdn.microsoft.com/en-us/windows/desktop/aa904949 when using windows 7. on older versions of microsoft windows directx sdk should installed. download qt 5.0.2 source code http://qt-projec...

firebird1.5 - Error SQLCODE -904 in firebird after installation -

i installed firebird database first time in life (version 1.5.6 on windows 7), after installation can not connect sample database (employee.fdb exists), or create database. gives following error in isql tool: c:\program files\firebird\firebird_1_5\bin>isql use connect or create database specify database sql> connect "c:\program files\firebird\firebird_1_5\examples\employee.fdb" con> user 'sysdba' password 'masterkey'; statement failed, sqlcode = -904 unavailable database sql> create database 'c:\test.fdb' con> user 'sysdba' password 'masterkey'; statement failed, sqlcode = -904 unavailable database firebird 1.5 written (long) before windows 7, , before things uac existed. may firebird 1.5 doesn't work correctly windows 7, or requires additional effort work. i'd suggest install firebird 2.5.2 (update 1) latest version , known work windows 7. another problem might local system connections don'...

twilio - Is there any form of sandboxing available to build and test functionality against? -

i'm indie developer , love platform have discovered can't buy phone numbers trial account . i've seen "sandboxing" deprecated feature , hoping similar has been created in it's place. me money tight , i'd basic app before having pay platform. is there anyway can test these platform features without incurring cost? twilio employee here. for development, don't charge until upgrade. said, started, 1 free phone number when sign up. 100% yours wish.. couple limitations: can send sms or place calls phone numbers you've verified us. also, once you've upgraded can still testing , development free our test credentials. full details on site - http://www.twilio.com/docs/api/rest/test-credentials - important bit you: you use these credentials in same way live credentials. however, when authenticate test credentials, not charge account, update state of account, or connect real phone numbers. can pretend buy phone number, or sen...

Handler: repeating code on android -

i got issue, have handler in activity use show message depending on message.what attribute, ok far, got second activity (activity b) started activity a, need same handler activity use on activity b (i tried many things , google , nothing) end copying code of handler on b, know wrong (not sure if necessary handlers), here post of solutions found , tried: static variable : accessing instance of parent activity? , works, static members go null since class not loaded anymore, since somes said bring leaks static member staying on memory did trick activity state (setting null when activity calls ondestroy, setting reference "static variable" = on methods onresume , oncreate of activity a, after this, still code comes expected nullpointerexception @ "static variable" when lose loaded class. another thing tried myownhandler (a class created me extending handler , implementing serializable trying pass through intent.putextra), noticed when think idea handler had of i...

c# - avoid page reload and controls' state setting to default on hitting back button -

i have 2 pages, page1 , page2. on page1, have checkbox below update panel , few controls in update panel such radio button , combo boxex. client side. <asp:checkbox><asp:checkbox> </br> <asp:updatepanel id="updatepanel1" runat="server"> <contenttemplate> <div id="div1" runat="server"> <asp:panel id="pnl1" runat="server" </div> </panel> </contenttemplate> </updatepanel> </br> <asp:button></button> when user checks checkbox(which outside update panel), pnl1 gets visble , when unchecked, pnl1 gets invisible. checkbox checked. when click button on page1, redirects page2. on page2 , hit button go on page1. when go on page1, want see checkbox checked. using mozilla. tell me please,how can achieve this. your input appreciated. thank you. if redirect page first called page_load function...

Issue with a variable in my batch script -

i want script to: accept variable create path using variable input display path display contents of directory what wrong following code? echo statement prints your directory set to ; dir statement works expected. @echo off set custompath = "c:\users\%1" echo directory set %custompath% dir %custompath% it's space around = . @echo off set custompath="c:\users\%1" echo directory set %custompath% dir %custompath% check this post .

javascript - How to make two select forms of different ids and names return their ids using $(this)? -

i have html form 2 select dropdown lists. each 1 has same sites leave from/go to. i'm trying grab id of each 1 , store them separate variables, each time select new option, variables reset undefined . code looks this: $('select[name=depart], select[name=return]').change(function(){ var id = $(this).attr('id'); var depart_id; var return_id; // grabs place left var dep = $('select[name=depart] option:selected').val(); // grabs place traveled var ret = $('select[name=return] option:selected').val(); // grabs day in log string var day_id_raw = $(this).closest('tr').attr('id'); // creates jquery object string above var day_id = $('#' + day_id_raw); // creates substring of string above cutting off @ day number in log. e.g. "day 1" in log becomes number "1". var day_num = day_id_raw.substring(3, day_id_raw.length); //creates jquery object mil...

payflowpro - PayPal (Payflow Pro) Error 52 -

i trying set test process authorizations completed. managed response other invalid vendor (i had set account wrong), response: result=52&pnref=xxxxxxxxxxxx&respmsg=insufficient permissions perform transaction any thoughts on how correct this? request string: trxtype[1]=a &verbosity[4]=high &acct[16]=411111xxxxxx1111 &tender[1]=c &amt[4]=1.99 &currency[3]=usd &user[8]=mypayflowuser &vendor[8]=mypayflowuser &partner[6]=paypal &pwd[10]=xxxxxxxxxx &origid[13]=xxxxxxxxxxxxx you should have api_full_transactions. result code 52 means trying make payflow api call when have payflow link account. payflow link accounts allowed make api call securetoken.

Progressbar (ttk.Progressbar) with python in tkinter not showing -

using ttk.progressbar in python (in tkinter gui), i'm trying have progressbar appear when press button. clicking "analyse" button on gui calls function analyze in script, i've meant three-stage rocket of sorts: grid() progressbar-widget add mainframe, , start() it. do actual computing (which takes 3 seconds in test-runs) stop() progressbar , grid_remove() hide user again, job complete. if comment out step 3 , progressbar shown , started expected, while step 2 executed. if step 3 remains, progressbar never shown in first place. now, since work in step 2 being executed either way, i'm assuming might have gridding , removing of progressbar-widget in same function-call, since first real gui project in python, i'm bit @ loss on how work around (if indeed problem). there way around this, or way of more elegantly accomplishing same task? function button calls follows: def analyze(): # --step 1-- progressbar.grid() progressbar.start() ...

c# - Best way to have single View/ViewModel/Xaml link to multiple Json resource files in MvvmCross -

inside application have many pages, have similar layout - header , bodytext. the way have structured @ moment, every single page have view, viewmodel, .xaml , .json file. the trouble app has bloated point have 20 pages (don't ask) , copy , pasting these each file inefficient , error prone. i'd have single helpviewmodel, helpview, page_help.xml, , every page different .json file relevant textual resources. i cannot figure out how achieve despite looking through existing mvvmcross topics. so xaml has heading looks this: <textview style="@style/helptexttitle" local:mvxbind="{'text':'path':'textsource','converter':'language','converterparameter':'heading1'}}" /> the json file has same name viewmodel (and gets linked automagic) looks this: { "heading1":"sample heading", } and have helpviewmodel can accept argument - name of json file public string headerf...