Posts

Showing posts from August, 2011

asp.net - Cant open a closed file -

i using code below try , open pdf file , getting error cannot open closed file? not sure missing here. dim filename string dim folderlocation string = nothing dim fileformat string = "application/pdf" dim tfilenamearray array = nothing dim tfilename string = nothing filename = "\\server\files\45144584.pdf" dim fs new filestream(filename, filemode.open, fileaccess.read) using (fs) end using dim data() byte = new byte(fs.length) {} dim br binaryreader = new binaryreader(fs) br.read(data, 0, data.length) br.close() response.clear() response.contenttype = fileformat response.appendheader("content-disposition", "attachment; filename=" & tfilename.split("\")(tfilename.split("\").length - 1)) response.bufferoutput = true response.binarywrite(data) response.end() you need have code references fs inside of using, otherwise attempting acce

Deploying android applications Qt 5.1 -

i have been trying deploy simple qt application android no luck. details follows qt version : qt 5.1.0 android (windows 32-bit) downloaded here qt creator version : qt creator 2.7.2 i have set following options in qt creator android configurations android sdk location : c:\adt-bundle-windows-x86-20130717\adt-bundle-windows-x86-20130717\sdk android ndk location : c:\android-ndk-r8e ant location : c:\program files\java\jdk1.7.0_25 avd name : androidavd (api level 17,armeabi-v7a) kit configuration name of kit : android arm(gcc 4.4.3,qt 5.1.0)(default) device type : android device : run on android sysroot : empty compiler : gcc (arm 4.4.3 ) android gdb server : c:\android-ndk-r8e\prebuilt\android-arm\gdbserver debugger : c:\android-ndk-r8e\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-gdb.exe qt version : 5.1.0 (android_armv7)(c:\qt\qt5.1.0\5.1.0\android_armv7\bin\qmake.exe) deploy configuration of kit(for both release ,

c++ - CMAKE use environment variables without passing them as commandline arguments? -

i use modules on rhel5 , have various versions of compilers/binutils located on machine. such end defining environment variables point tools , update paths accordingly old tools shipped rhel5 out of picture. is there simple method have cmake load corresponding environment variable? for example in environment: cmake_cxx_compiler=/some/other/compiler cmake_linker=/some/other/linker is there way have cmake grab these without passing them arguments via commandline? the following didnt work me in cmakelists.txt set(cmake_cxx_compiler, $env{cmake_cxx_compiler}) and not surprisingly following didnt work: if($env{cmake_cxx_compiler}) set(cmake_cxx_compiler, $env{cmake_cxx_compiler}) message("cmake_cxx_compiler ${cmake_cxx_compiler}") endif() maybe syntax issue or not correct place update such cmake variable? work when pass via commandline (e.g. -dcmake_cxx_compiler=${cmake_cxx_compiler}), dont want way. thanks never mind. syntax error: set(cm

javascript - JSON.parse causes "Uncaught SyntaxError: Unexpected token u" -

i have: <input type="hidden" id="notifications" value="@viewbag.notifications" /> when put breakpoint on line , check value, see value is: [{"id":"42647","isread":0,"messagetype":3},{"id":"fsh3hg","isread":0,"messagetype":2}] i want parse value in javascript when page loads, wrote: var notifications = document.getelementbyid('notifications').value; alert(notifications); // prints undefined alert(document.getelementbyid('notifications')); // prints: object htmlspanelement var parsednotifications; if (notifications != '') { parsednotifications = json.parse(notifications); } but error "uncaught syntaxerror: unexpected token u" on following line: parsednotifications = json.parse(notifications); why error occur? you wrote: alert(document.getelementbyid('notifications')); // prints: object htmlspanel

python - Receiving error: Reverse for with arguments '()' and keyword arguments not found -

i getting error creating link in django template. my template looks this: <a href="{% url 'location_detail' pk=location.id %}">{{ location.name }}</a> my urls.py looks like: url(r'^location(?p<pk>\d+)/$', views.location_detail, name="location_detail"), my view looks like: def location_detail(request, pk=none): i error: reverse views.location_detail arguments '()' , keyword arguments '{u'pk': 1l}' not found. i'm using django 1.5 , python 2.7.2 thanks! the problem had name space on primary project urls.py: url(r'^com/', include('com.urls', namespace="com")), changing url to: {% url 'com:location_detail' pk=location.id %} that did trick

c# - WCF Service + Entity Framework Class Customization -

i'm developing project sql server + entity framework + wcf service. the main goal map sql server database class objects entity framework, customize them , build wcf service uses objects. so first part done. i've created database , mapped object entity framework. for customization part of process, i've done implement new objects inherit entity framework created objects in order provide them custom functionality. far good. when try send 1 of objects created entity framework wcf service wcf client works ok, when same own object (that inherits ef object) gives me error: consider marking datacontractattribute attribute, , marking of members want serialized datamemberattribute attribute. if try include [datacontract] on custom class, says should same base class (created ef). point is: can't change ef classes because lose changes on next update. can body point me in right direction? best regards, josé pedro silva

php - why isn't my AJAX get request working -

in js page want variables php page using ajax(); triggered html page load. i've tried use both , post, nothing alerts or logs console supposed to, not error. html: <!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> <script src="http://xxxxxx/bn/sample.js"></script> </head> <body> <div>welcome! </div> </body> </html> js: (sample.js) $(function(){ $.ajax({ url : "http://xxxxxx/bn/sample.php", type : 'get', data : data, datatype : 'json', success : function (result) { alert(result.ajax); // "hello world!" should alerted console.log(result.advert); }, error : function ()

osx - Identify directories that are packages in Mac OS X with Python -

the mac os x finder uses concept of "packages" make contents of folders opaque user. i'm using os.walk() enumerate directory tree , want skip enumeration on packages such application bundles. the mdls commandline utility can used check whether com.apple.package in kmditemcontenttypetree attribute. only/best way detect whether folder package drop os.system , use mdls after detecting os indeed darwin? as aside, solution seems depend on spotlight metadata understand populated from files/directories themselves. makes me wonder whether there method check whether directory package outside of mdls . perhaps i'm missing something. os x packages (and bundles) defined extension. create directory .app extension see presented (broken) application in finder. the official documentation lists following ways define bundles: the finder considers directory package if of following conditions true: the directory has known filename extension:

Rspec: How to I refactor tests that are similar? (example given) -

i have 2 examples, feel majority of code inside of them same. however, bit different (the records different, , additional assertion in 2nd 1 too). i'm still beginner @ testing, looking tips go forward. i'm testing rake task. here's code: it 'leaves 1 billing info each order' order = factorygirl.create(:order) factorygirl.create_list(:billing_info, 2, order_id: order.id) expect(billinginfo.all.count).to eq(2) run_rake_task expect(billinginfo.all.count).to eq(1) end 'keeps billing info trevance information' order = factorygirl.create(:order) factorygirl.create(:billing_info, order_id: order.id, complete_trevance_message: nil, trevance_attempts: nil) factorygirl.create(:billing_info, order_id: order.id, complete_trevance_message: "303 -- processor decline", trevance_attempts: 1) expect(billinginfo.all.count).to eq(2) run_rake_task expect(billinginfo.all.count).to eq(1) expect(billinginfo.first.complete_trevance_mes

unit testing - Mocking mixin classes in Grails -

i having difficulty unit testing controller. i have following objects: class user { string username } class securitymixin { user userdetails(session) { user user = new user() user.username = 'somename' return user } } @mixin(securitymixin) class mycontroller { def index() { def username = userdetails(session).username } } how mock userdetails method? i've never done mixin, maybe can test out. in *controllertests @before void setup() { .. controller.metaclass.userdetails = { new user(username: 'somename') } }

python - SQLAlchemy custom field with default value for file uploads in Flask -

i'm trying create custom field in sqlalchemy managing uploaded files in flask application. i'm trying achieve similar django's filefield. so want able is, given model: class testmodel(base): __tablename__ = "testmodel" id = column(integer(), primary_key=true) profile_photo = column(filefield(upload_set, 100)) i want able like: m = testmodel() m.profile_photo.save(request.files["profile_photo"]) models.db.session.add(m) models.db.session.commit() what have based on built in string type , works this: class filefield(types.typedecorator): impl = string def __init__(self, upload_set, *args, **kwargs): super(filefield, self).__init__(*args, **kwargs) self.upload_set = upload_set def process_bind_param(self, value, dialect): if value not none: return value.filename return value def process_result_value(self, value, dialect): return filenamestring(self.upload_set,

c# - XAML UI updates not visible in code-behind -

having same project opened in both, visual studio , blend , use former write code while edit xaml in latter. when add ui element .xaml file , save in blend, if have file opened in visual studio too, see message external changes have been done , asking if want them take effect in opened file*. accept it, , can see changes take effect in .xaml file in visual studio. the problem is, although new elements have been added .xaml file, i'm not able access them throug intellisense in code-behind .cs file. for example if add following element mainpage.xaml using blend: <button x:name="mybutton" content="button"/> i can see same line added page in visual studio, cannot access using name mybutton in mainpage.xaml.cs file. intellisense not working it. if write, example mybutton.content = "hello!"; red underlined, can build , run project. rebuilding project doesn't trick, , intellisense doesn't work until save file "again&quo

c# - Change array element name without flattening with XmlSerializer -

i have following code: [serializable] [xmlroot("database")] public class sqldatabase { public list<sqltable> tables { get; private set; } } if use xmlserializer without custom attribute, generated xml persists list hierarchy: <database> <tables> <sqltable name="table1" /> <sqltable name="table2" /> </tables> </database> however, i want change element name "sqltable" "table". tried use xmlelement attribute on list [serializable] [xmlroot("database")] public class sqldatabase { [xmlelement("table")] public list<sqltable> tables { get; private set; } } the name changed hierarchy flattened: <database> <table name="table1" /> <table name="table2" /> </database> then tried xmlarray attribute, changes name of list not elements within: [serializable] [xmlroot("database")]

facebook - How to get fb like buttons to load last? -

i have page bunch of imgs, these imgs link own page. each img, have button, url individual page. in ff, imgs load first, in chrome, seems buttons load first. how can buttons load after page otherwise loaded? since, didn't posted code, can give link jquery command .ready(): http://api.jquery.com/ready/ if put function within command, executed after every image or other content of page (or element) loaded. for example can add facebook button jquery after images loaded this: $(document).ready( function() { $("#fbpages").children("li").each( function(key, val) { $(val).html($(val).html() + '...fblikebutton...'); } ); } );

sql - Stored Procedure Error Handling when parameter left out -

i have stored procedure here executes fine, custom error messages aren't working when leave out parameter. instead getting default error message. does know doing wrong? using sql server 2012 so instance when call exec sp_getclienttransactioninfo '2001-01-01' should printing 'this error msg= date required. please enter date' but isn't. alter procedure sp_getclienttransactioninfo @fromdate datetime, @todate datetime, @active int set nocount on set transaction isolation level read uncommitted -- variables handle error msg declare @error int, @errormessage varchar(200) set @error = 0; set @errormessage = ''; if (@fromdate null) begin set @error = -1 set @errormessage = 'from date required. please enter date' goto final_process end if (@todate null) begin set @error = -1 set @errormessage = 'to date required. please enter date' goto final_process end if (@active null) begin set @error = -1 set @errormessage = 'acti

asp.net - Correct way to handle date in querying db -

i want know correct way handle date parameter in querying db. database hosted in windows azure, , have table job field modified datetime data type. datetime stored in database utc. i want query list of jobs based on modified date. user enter start , end date, based in different time zones. how handle dates match data when querying database? i'm using asp.net mvc. need ensure daylight saving time considered. i know cannot write query like: var data = _context.jobs .where(c => c.modified >= startdate && c.modified <= enddate); this hard problem since user's browser might not report correct time or timezone, assuming can trust ... ... it's still hard problem since need convert time entered in local time zone utc , involves knowing not timezone's offset (which easy browser) actual timezone in can apply appropriate offset daylight savings or not datetime entered , not 'now'. this link might determine

ios - Created UItextfield programmatically, how to get text later? -

i've created uitextfield programmatically when view loaded. if button pressed after loads, though, how text uitextfield in later void? -(void)viewdidload { uitextfield *fldcard= [[uitextfield alloc] initwithframe:cgrectmake(12, 45, 293, 25)]; fldcard.placeholder = @"card"; fldcard.keyboardtype = uikeyboardtypenumberpad; [fldcard setbackgroundcolor:[uicolor colorwithred:0.22 green:0.53 blue:0.23 alpha:1.0]]; [fldcard.layer setcornerradius:5.0f]; [fldcard.layer setmaskstobounds:yes]; [self.view addsubview:fldcard]; [fldcard release]; } -(void)myaction:(id)sender { [self.view endediting:yes]; nslog(@"fldcard %@", fldcard.text); } in .m file under: @interface yourviewcontroller () { uitextfield *fldcard; } @end then take out uitextfield when init fldcard. able uitextfield method in class.

AngularJS promise doesn't retrieve a deeply wrapped jquery $.post call -

i developing both javascript library , angularjs front-end. javascript library needs portable cannot rely on angularjs. use pretty standard servlet query pattern: queryservice = function(url, method, params, resulthandler, queryid) { var request = { jsonrpc: "2.0", id: queryid || "no_id", method: method, params: params }; $.post(url, json.stringify(request), handleresponse, "json"); function handleresponse(response) { if (response.error) console.log(json.stringify(response, null, 3)); else if (resulthandler) resulthandler(response.result, queryid); } }; this queryservice function called other functions in our library. can see that queryservice returns nothing. expects callback function perform needed actions. can't figure out callback function needed return result promise object's then() function. here's angular service code: angular.module("app").service("data&q

php - HTML_Table returns an incorrect output -

i'm trying use pear::html_table package generate table multi-dimensional array, $data. this dump of $data: array ( [0] => array ( [0] => office [1] => canvasser [2] => fundraising hrs [3] => pac/hr no pfu [4] => pac $ no pfu ) [1] => array ( [0] => tbs1 [1] => vatcher, georgia [2] => 29 [3] => 8.295 [4] => 481 ) ) edit: first array row of thead tags , additional arrays rows in tbody tags. and code: $data = $worksheet->toarray('', true, false, false); // phpexcel // build table $table = new html_table(array('class' => 'dt'), 0, true); $thead =& $table->getheader(); $tbody =& $table->getbody(); // loop through rows ($r = 0, $lr = count($data); $r < $lr; $r++) { // loop through columns ($c = 0, $lc = count($data[$r]); $c

javascript - $.AJAX to $.POST -

can me convert code $.post,any code replace not functioning. thank $.ajax({ type: "post", url: "http://192.168.254.107/webs/main/ajax/validatelogin.php", data: senddata, success: function(data) { $("#info").html(data); var returnmessage = data; var mes = returnmessage.tostring().trim(); if (mes != "" && mes != "invalid login!") { localstorage.setitem("message", returnmessage); window.localstorage.setitem("username", username); window.localstorage.setitem("data", data); document.location.href = "trackme.html"; } else { alert(mes); } } }); how this: $.post('http://192.168.254.107/webs/main/ajax/validatelogin.php', senddata, function(data) { $("#info").html(data); var returnmessage = dat

php - Wordpress issue -

my site www.sinteag.com,i have tried making changes in siteurl , home url in database not able solve it.site generating own url on every anchor...like if visit site , click on read more buttons or social icons in footer show own site url first designated url, stuck due issue. this text metting requirments lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut thanks in advance. you have absolute links (which include site domain) without http:// . html requires prefix website names explicitly state domain http:// or whatever applies site. so <a href="http://sinteag.com">lorem ipsum</a> , similar.

java - How to return a HTML page from struts.xml itself without going to an action? -

if request made html page, how return directly struts.xml without going action? create action has result in struts.xml doesn't have class , i.e. <package name="default" extends="struts-default"> <action name="index"> <result name="mypage">/path/to/page.html</result> </action> you create global result, found action, i.e <global-results> <result name="mypage">/path/to/page.html</result> </global-results> <action name="index"/> you create interceptor returns result while intercepting , action. these essential elements of configuration invoke dispatcher forward requested page.

asp.net mvc - Same link in menu and in footer are in different languages -

my asp.net mvc 4 website urls looks "/language/controller/action". html code of link in menu , in footer same. <li><a href="@url.action("websitedevelopment", "service", new { area = "" })">website development</a></li> when site opened in "en-gb" culture link in menu pinting to /en-gb/service/websitedevelopment but link in footer is /hy-am/service/websitedevelopment how possible? how can fix this? you don't specify "language" in url.action, takes default language. asp.net links absolute ones, without specifying language, it's /default-language/controller/action if want language taken current url, need write own url.action function, or extend it.

sencha touch 2 - Nesting in css3 -

i new css , sencha touch 2. while working on tutorial on sencha touch 2,i see css file having code /* increase height of list item title , narrative fit */ .x-list .x-list-item { min-height: 10.5em!important; height:7.5em; } /* move disclosure button account list item height increase */ .x-list .x-list-disclosure { position: absolute; bottom: 4.0em; right: 0.10em; } is .x-list .x-list-item css nesting concept , x-list class name? , concept purely css concept or sencha touch concept? it's pure css concept, syntax means .x-list .x-list-item select element class x-list-item nested under element having class x-list the same goes second syntax. if want make more stricter, can use element.class selector select if matches element.class combination, if taken example.. using like div.x-list span.x-list-item { /* select span having class x-list-item nested under div element having class x-list */ }

Overloading for optional array support - Java -

is there way make code more concise not have many overloaded methods? public void method(string[] args1, string[] args2){} public void method(string[] args1, string args2){} public void method(string args1, string[] args2){} public void method(string args1, string args2){} the number of overloaded methods increases exponentially number of arguments increases. problem, , know there has easier way this. the goal find best way pass number of objects of same type argument without using array single-object input. why? it's simplicity end programmer. maybe if have great number of arguments - besides - can increased in future, it's better wrap them in separate class, i.e. inputparams , pass 1 instance of class method. consider next code: inputparam ip = new inputparam(); ip.setfield1(field1); //... // usage this.method(ip); // declaration public void method(inputparams arg){} p.s. but, other guys mentioned, depends on many conditions , trying achieve.

html - Using bootstrap with web.py's form -

i using web.py in backed generate form. wanting use bootstraps form class. snippet html <form name="test" method="post"> $:form.render() <input type="submit" name="button" value="login" /> </form> which, when generated web.py, turns <form name="login" method="post" class = "register"> <table> <tr><th><label for="username">username:</label></th><td><input type="text" id="username" name="username"/></td></tr> <tr><th><label for="password">password:</label></th><td><input type="password" id="password" name="password"/></td></tr> <tr><th><label for="password_again">repeat password:</label></th><td><input type="pa

VB.NET/XAML Memory Leak on Data change of path (Windows Store App) -

i changing xaml path object's data vb.net code achieve effect in ui. code using is: do while somecondition await task.delay(somevalue) dim geom pathgeometry = new pathgeometry dim figr pathfigure = new pathfigure dim mycurve quadraticbeziersegment = new quadraticbeziersegment figr.startpoint = new point(somevalue, somevalue) mycurve.point1 = new point(somevalue, somevalue) mycurve.point2 = new point(somevalue, somevalue) figr.segments.add(mycurve) geom.figures.add(figr) mypath.data = geom loop everything results wanted. noticed there huge memory leak freeze system after 3 minutes. tests show leak in last line of iteration, i.e. mypath.data = geom i don't have experience in handling memory leaks. please guide me. thank you.

wordpress - Single.php template for Taxonomy Term -

i have custom post type - films. has taxonomy of film_cat, in turn has 2 terms/categories - term1 & term2. for each single post within term1, display specific single.php template. each single post within term2 should have it's own single.php template. i utilising taxonomy-film_cat-term1.php taxonomy archives templates, can't find info on how create different single.php templates based on taxonomy term. you can create single.php page renaming according custom post type name. example: custom post type name: films single.php be: single-films.php so can find posts of film on single-films.php .hope have cleared self

ruby on rails - Decimal being stored as BigDecimal:4a58c60,'0.7484999999 999999E2',27(27) instead of 74.85 -

i have table created , 1 of columns created as: t.decimal price i created new record doing this: prices.create(:price => 74.85) and record created shows this: #<price id: 10, price: #<bigdecimal:4925c58,'0.7484999999 999999e2',27(27)>> why happen? set 74.85 not 74.849999... thanks this floating point error. can use string instead: prices.create(:price => "74.85") note not rails bug, it's way floating point values , bigdecimal work: bigdecimal.new(74.85, 0) #=> #<bigdecimal:7fc37cb7c068,'0.7484999999 9999994315 6581139191 98513031e2',45(54)> bigdecimal.new("74.85") #=> #<bigdecimal:7fc37ce69d48,'0.7485e2',18(18)>

spring - Enter in to a particular page through the browser after I login to the system -

need idea on process land in page after login web portal. requirement enter url of particular page in browser, system check user login system, if yes land on page have entered if not system take me login page , after successful login landed in page have entered in browser. so, please tell me how in plain servlet/jsp model, spring , struts 1 , struts 2. any post helpful i know basic jsp/servlet model. write servlet filter intercept every request brwoser, there check user logged in or not. if logged in normal flow continue if not redirect login page. when redirecting login page, make sure send url hit browser in response. in client side hold url send in response , after eneter credentials in login page when user submit record send url (hold in client side response) in request , after successful login use servelet request dispatcher land in url. i not sure spring-security has feature , struts 2. implementation process can share others familiar on technologies. in str

c++ - OSGViewer in Qt's TabWidget -

i using openscenegraph 3.0.1 , having problem qt integration using the osgqt::glwidget when adding tab control during startup (inside constructor of main window. mainwindow::mainwindow(qwidget* parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); qwidget* viewerwidget = new myviewerwidget(new osgviewer::viewer()); ui->tabwidget->addtab(viewerwidget, "my osg view"); // tab entry added nothing see empty osg window } it works, when calling code menu after displaying main window: void gcdrp::mainwindow::on_actioncreate_simulation_view_triggered() { qwidget* viewerwidget = new myviewerwidget(new osgviewer::viewer()); ui->tabwidget->addtab(viewerwidget, "my osg view"); // tab content visible (as expected) } it seems scene graph screwed up. ideas? works setminimumsize: qwidget* viewerwidget = new myviewerwidget(new osgviewer::viewer()); viewerwidget->setminimumsize( ui-

excel - Jquery html to xls code doesn't work on IE and FireFox -

hi trying implement jquery code html work on chrome, ie , firefox doesen't work, havent got enough javascript experience find please help. i tried change quotation marks on javascript doesent work too. <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js></script> <script> $(document).ready(function() { $("#btnexport").click(function(e) { //getting values of current time generating file name var dt = new date(); var day = dt.getdate(); var month = dt.getmonth() + 1; var year = dt.getfullyear(); var hour = dt.gethours(); var mins = dt.getminutes(); var postfix = day + "." + month + "." + year + "_" + hour + "." + mins; //creating temporary html link element (they support setting file names) var = document.createelement('a'); //getting data our div contains html table var data_type = &#

AngularJS: Setting a variable in a ng-repeat generated scope -

how access set of scopes generated ng-repeat? i suppose @ heart of fact don't understand quite how relationship works between a) collection of objects pass ng-repeat directive , b) collection of scopes generates. can play around (a), ng-repeat scope watches , picks up, how set variables on scope (b)? my use case have set of elements repeating using ng-repeat, each of has edit view gets toggled using ng-show/ng-hide; state each element held in variable in local scope. want able trigger ng-show on particular element, want trigger called outside ng-repeat, need able access local scope variable. can point me in right direction (or tell me if i'm barking wrong tree)? thanks update: link below helpful thankful. in end created directive each of repeating elements, , used directive's link function add scope collection on root scope. when working within hierarchy of scopes find useful dispatch events $emit , $broadcast. $emit dispatches event upwards ch

iphone - Send attachments to salesforce native rest sdk through ios -

i need send image salesforce through iphone app.i have tried things converted image--> bytes-->base64 encoding store sfdc (rich data field), it's done perfectly, need save image .here codes given below (it's not working) guides me how achieve nsdata *imagedata = uiimagepngrepresentation(imageview.image); nsstring *boundary = @"---------------------------14737809831466499882746641449"; sfrestrequest *request = [[sfrestrequest alloc] init]; [request setdelegate:self]; [request setendpoint:ksfdefaultrestendpoint]; [request setmethod:sfrestmethodpost]; nsmutabledata *body = [nsmutabledata data]; [body appenddata:[[nsstring stringwithformat:@"rn--%@rn",boundary] datausingencoding:nsutf8stringencoding]]; [body appenddata:[[nsstring stringwithstring:[nsstring stringwithformat:@"content- disposition: form-data; name=\"entity_document\"; filename=\"%@\"\r\n",@"test.png&qu

nsbundle - Objective-C / Load cell from xib / Need explanation -

ok, know how load custom cell xib, via code: nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"custpmcellview" owner:self options:nil]; cell = (customcell *)[nib objectatindex:0]; but can explain first row do? i feel stupid typing every time , not knowing how works. nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"custpmcellview" owner:self options:nil]; loadnibnamed returns views under xib. holding in array. here view under custpmcellview fetched , saved in array nib . cell = (customcell *)[nib objectatindex:0]; we getting first view array, our desired view, , casting , assigning cell object. we need assign new view each cell in uitableview , purpose every time new cell needed, , using above code snippet. edit [nsbundle mainbundle] , explained @ what meaning of [nsbundle mainbundle] in iphone?

python - alembic will allow sql files under versions? -

in sqlalchemy-migrate repos, can place .sql files instead of .py files under versions folder upgrading/downgrading database schema. 001_mysql_downgrade.sql 001_mysql_upgrade.sql is same feature exist in alembic? if yes can plz explain how do? thanks you call upon files in migration .py files, inside upgrade() , downgrade() callables. can customize how callables render editing script.py.mako file. however, .py file not there @ all, you'd need override scriptdirectory , script right now, unless made more of hook implement extensions this. overriding classes possible require monkeypatching @ moment. it's alembic support.

excel - How can I find sum of highlighted cells? -

Image
i've been asked excel question @ work, i'm not excel person, use it. is possible sum() of highlighted boxes? i've looked online found plugins or vba scripts. as vba script solution, have: function sumclr(rcolor range, rrange range) dim rcell range dim lcol long dim vresult lcol = rcolor.interior.colorindex each rcell in rrange if rcell.interior.colorindex = lcol vresult = worksheetfunction.sum(rcell, vresult) end if next rcell sumclr = vresult end function it works if there inbuilt function, that'd great. if in excel 2007 or later sort column colour, , sum coloured boxes (which grouped @ top or bottom). else mean; getting people make mark next number "interesting" require vba - per post. if colours have been created using conditional formatting (check selecting home tab, , conditional formatting while 1 of highlighted cells selected) can use same formula , sumproduct or si

ios - Change customer's name in app store -

Image
this question has answer here: change company name 1 answer i uploaded app in hurry, , somehow messed , chosen wrong name our customer. there quick way change string (in red circle in pic) itunes account? i've been searching time now, without success. edit: app approved , on appstore you should contact apple support, see https://discussions.apple.com/thread/1657353?start=0&tstart=0

What's the new before_create in Rails 4? -

i tried using before_create: class star < activerecord::base before_create :add_to_total_stars post load (9.7ms) select "posts".* "posts" "posts"."id" = ? order "posts"."id" asc limit 1 [["id", 1]] (1.0ms) rollback transaction nomethoderror: undefined method `+' nil:nilclass but can see i'm getting error. what's new before_create in rails 4? edit: class star < activerecord::base before_create :add_to_total_stars belongs_to :starable, :polymorphic => true protected def add_to_total_stars if [post].include?(starable.class) self.starable.update_column(:total_stars, starable.total_stars + self.number) end end end nomethoderror: undefined method `+' nil:nilclass /home/alex/rails/rating/app/models/star.rb:10:in `add_to_total_stars' /home/alex/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:377:i

c# - Multiple websites sharing content from one central location? -

at moment have 3 umbraco websites each have own content trees, have 1 page in common. @ moment, since 3 sites independent, data copied each site. however our client asking pages can managed one site. ie. data updated in 1 umbraco installation , somehow mirrored across other sites. bear in mind page password protected , contains sensitive data. how can achieve this? my first thought maybe expose xml feed contained of relevant data have no idea how i'd keep data secure. case of encrypting , setting on https? literally have no idea begin here.. can point me in correct direction? i'm looking simplest solution here. thanks if have 3 separate web sites implied saying coping data 1 site another, set web service on main site data edited. put macros on other sites display data. if sensitive data add login , password web service , have https.

jquery - javascript setInterval timer issue -

the code : function starttimer() { var = 0; var timeinterval = setinterval(function () { $("#time").html(i++); }, 1000); settimeout(function () { clearinterval(timeinterval); }, 2000); } my problem $("#time").html(i++) 0 , not incrementing <!doctype html> <html> <head> <script type = 'text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'></script> <script> (function starttimer() {//selef executing function var = 0; var timeinterval = setinterval(function () { $("#button").html(i++); }, 1000); })()//end of function </script> </head> <body> <p id='button'></p> </body> </html> set time out should removed code work.see above code.it works

facebook - Getting details of likes and comments of a particular post id in ios -

i doing native ios application in making post on facebook programmatically depending on user inputs. able post , able post id. want details of likes, comments , shares post have got future manipulations. using me/feed method post in facebook. in issue 3days. little useful. if want count can use following code may you. simple url request graph api: http://graph.facebook.com/[full url] example: http://graph.facebook.com/http://www.stackoverflow.com edit: (an example "likes") http://graph.facebook.com/http://www.imdb.com/title/tt0117500/ example : http://graph.facebook.com/http://www.imdb.com/title/tt0117500/ or call new request fb object: [facebook requestwithgraphpath:@"photo_id/likes"]; replace photo_id facebook id of photo you're interested in. call return array information photo. in -facebook requestdidload: method, count of array return number of likes. nsinteger likecount = [result count];

Custom Option File download from Sales/Orders page in admin, not working in magento -

the link custom option file sales/order page in admin is: index.php/admin/sales/download/downloadcustomoption/id//key/ the link same file website (not admin), accessing account : index.php/default/sales/download/downloadcustomoption/id//key/ the same file has above 2 links when accessing admin or website. link working index.php/default/sales/download/downloadcustomoption/id//key/ i.e. 1 has default in link , not admin in link. does know how working? changes needed? using magento 1.7. thanks, neet the way fixed use base url of default store generate url. rewrite following function in app/code/core/mage/catalog/model/product/option/type/file.php below: /** * return url option file download * * @return string */ protected function _getoptiondownloadurl($route, $params) { $websites = mage::app()->getwebsites(); $code = $websites[1]->getdefaultstore()->getcode(); $params['_store'] = $code; return mage::geturl($route,

shell - How can I prepend a default value to all echo calls in a bash script -

i have bash script containing multiple echo calls: #!bin/bash echo 'a' echo 'b' echo 'c' i want prepend default text of these echo calls output this: default_text: default_text: b default_text: c is there way globally inside script without adding default text each 1 of echo calls? note: below there 2 answers question. 1 accepted resolves problem echo commands. second 1 resolves problem globally inside script any command outputs stdout. define function: function echo { builtin echo 'default_text: ' "$@" ; } the builtin needed, otherwise function recursive.

linux - Beaglebone am335x accessing GPIO by mmap, set and clear pin -

i'm writing simple program set , clear pin (the purpose use pin custom spi_cs). i'm able export pin (gpio1_17, port 9 pin 23 bb white) , use trough filesystem have drive faster. this code: uint32_t *gpio; int fd = open("/dev/mem", o_rdwr|o_sync); if (fd < 0){ fprintf(stderr, "unable open port\n\r"); exit(fd); } gpio =(uint32_t *) mmap(null, getpagesize(), prot_read|prot_write, map_shared, fd, gpio1_offset); // start of gpioa if(gpio == (void *) -1) { printf("memory map failed.\n"); exit(0); } else { printf("memory mapped @ address %p.\n", gpio); } printf("\ngpio_oe:%x\n",gpio[gpio_oe/4]); gpio[gpio_oe/4]=usr1; printf("\ngpio_oe:%x\n",gpio[gpio_oe/4]); printf("\ngpio_cleardataout:%x\n",gpio[gpio_cleardataout/4]); gpio[gpio_cleardataout/4]=usr1; printf("\ngpio_cleardataout:%x\n",gpio[gpio_cleardataout/4]); sleep(1); printf("\ngpio_setdataout%x\n",gpio[g

iphone - filter data from mediawiki api ios -

i used "action=query&prop=revisions&rvprop=content&titles=%@&format=json&redirects" api getting details anil_ambani. in response got following dictionary <i> query = { normalized = ( { = "anil_ambani"; = "anil ambani"; } ); pages = { 1222313 = { ns = 0; pageid = 1222313; revisions = ( { "*" = "{{blp sources|date=june 2012}}\n{{infobox person\n| name = anil ambani \n| image =anilambani.jpg\n| image_size = \n| caption = ambani in 2009\n| birth_date = {{birth date , age|1959|6|4|df=y}}\n| birth_place = [[mumbai]], [[maharashtra]], [[india]]\n| nationality = indian\n| occupation = chairman of [[anil dhirubhai ambani group]] \n| networt

joomla, change alias in com_menus -

can pinpoint me alias in com_menus changed because need add url few values , joomla striping & , % etc i have : mysite.com/going?3dpa%26tt%3df%26sd%3d*3%26ed%3d*20%26drf%3d6%26drt%3d15%26a%3d2%26at%3d33554432%26st%3dpa%26sp%3d2 and joomla creating this: mysite.com/going-3dpa-26tt-3df-26sd-3d-3-26ed-3d-20-26drf-3d6-26drt-3d15-26a-3d2-26at-3d33554432-26st-3dpa-26sp-3d2 how prevent changing anything? the menu alias determined joomla , component's router.php. best guess out of issue base64encode param joomla sees single param. add view default.xml string value, way joomla should able build sef route; check router.php , debug if it's not behaving expected. in order have sef routing correctly, need create menu item pointing view; if don't need it, hide in hidden menu.

Windows Phone 8 don't added pdf files at build -

Image
comparing source , console log saw pdf files aren't adding. reason (obviously) app crash when call pdf file. files (.png, .xml, .html, ...) don't have problems. what reason? need add location? thx you should try set build action *.pdf files "content". works in project.

ggplot2 - r - Add significance level to correlation heatmap -

Image
this question has answer here: significance level added matrix correlation heatmap using ggplot2 1 answer i have following data frame df (appended) i have written short script plot correlation heatmap library(ggplot2) library(plyr) library(reshape2) library(gridextra) #load data frame df <- data.frame(read.csv("~/documents/wig_cor.csv",sep="\t")) c = cor(df[sapply(df,is.numeric)]) #plot data plots <- dlply(df, .(method), function (x1) { ggplot(melt(cor(x1[sapply(x1,is.numeric)])), aes(x=var1,y=var2,fill=value)) + geom_tile(aes(fill = value),colour = "white") + geom_text(aes(label = sprintf("%1.2f",value)), vjust = 1) + theme_bw() + theme(legend.position = 'none') + scale_fill_gradient2(midpoint=0.8,low = "white", high = "steelblue")}) #plot ef analysis method plots <- dlply(df, .(me

httprequest - Simple escaped http request via CMD or Browser from within a batch -

i need automate opening program, making simple http request batch file. i can't install curl or wget or other handler. if possible i'd make request in cmd, normal browser work. the below batch file have... echo start "" "c:\program files\spacialaudio\simplecast\simplecast.exe" ping localhost -n 5 > nul start http://localhost:8181/?artist=myartist&title=mytitle&songtype=s&duration=240000 question 1: have use default browser? question 2: above batch minces url, how escape correctly? the browser ends requesting http://localhost:8181/?artist=myartist even if encode url first http://localhost:8181/?artist=myartist&amp;title=mytitle&amp;songtype=s&amp;duration=240000 i same result double quote url. start "" "http://blah.blah.com&text"

c - Error in string initialisation -

here trying out following thing in code , got following error---"prog.c:10:8: error: incompatible types when assigning type ‘char[100]’ type ‘char *’" . please , tell me how can modify initialisation char str[100] right answer #include <stdio.h> #include <stdlib.h> int main() { char str[100]; str = "a"; str = str + 1; str = "b"; str = str + 1; str = "c"; str = str + 1; printf("%s", str - 2); return 0; } you have declared array char str[100]; by specifying name of array base address of array same address of first element. str="a"; in above statement, trying assign "a"s (note "a" string here) address array base. compiler not allow this. cos, if so, lose 100 elements. if want assign first element value 'a', do str[0] = 'a'; note have used single quote. remember "single quote single char" .

accessibility - How to prevent Windows Narrator from reading hidden HTML tags? -

i have html page, multiple hidden elements become visible under circumstances. when set focus on page wrapper (to read content), windows narrator reads elements, hidden ones. i have tried using aria-hidden="true", css display: none, html5 hidden attribute, ignored. far, mechanism found works remove elements dom, before setting focus on wrapper. it's not ideal solution. apply role="presentation" tabindex="-1" elements have aria-hidden applied.

virticle space between components in sencha touch -

Image
i trying give space between components here screen shot , want give vertical space between lables , textfields , button dont find way here code ext.define('test.view.main', { extend: 'ext.panel', xtype: 'main', requires: [ 'ext.titlebar', 'ext.label' ], config: { items: [ { docked: 'top', title: 'test', ui: 'dark', xtype: 'titlebar' }, { xtype:'panel', style:'padding:10%', items:[ { xtype: 'label', html: 'user name/mobile number', }, { xtype: 'textfield', },{ xtype: 'label&

c# - Default right-click context menu in WPF GridView -

i'm working on project uses wpf gridview. i've been charged altering right-click context menu. currently right-click context menu brings menu checklist of columns in it. default behaviour? i'm unable find such context menu in code. need somehow persist these column selections survive restart of application. i hope can help. i've not been able find information on menu anywhere! mark that's not default behaviour , have had coded.

java - How to hardcode private key which can be used to encrypt once and decrypt many times? -

in application want use private key encrypt password once , decrypt many times tool run. application run like: user encrypt password using tool. then user paste password in properties file. when next time tool run read password , decrypt login. here facing problem like, when encrypt password doing using tool encryption perpose. when try decrypt key different key generated. how can share private key between these 2 tools.. thanks.. i think confusing symetric , asymetric encryption. when doing symetric encryption can use same key. in asymetric encryption have 2 keys. public key can encrypt passwords, can't decrypt them key. possible private key . therefore don't need share key between tools. name suggests private key should never leave system.

read from .txt the third coordinate using c++ -

i have .txt file real coordinates of points. scenario camera facing wall; between them have box. want in .txt points refering box, want read third component coordinates, meaning depth value , if it's bigger distance supprime line. file.txt 0.005545 0.06564 1.6354 0.235443 0.35464 2.6575 if(value>2.5) { delete line .txt } all coordinates separated white space , lines intro. thanks i think work: #include <fstream> #include <vector> #include <iterator> #include <algorithm> #define thresh 2.5f using namespace std; int main() { vector<float> dataarray; ifstream myfile("test.txt"); copy(istream_iterator<float>(myfile), istream_iterator<float>(), back_inserter(dataarray)); myfile.close(); ofstream newfile("test.txt"); for(int = 2; < dataarray.size(); += 3) { if(dataarray[i] < thresh) { (int j = i-2; j <= i;

java - Jfreechart:displaying multiple charts -

i new java , jfreecharts , using jfreechart create many charts(barcharts , piecharts). display charts , when created. charts generated gets stacked upon other , last chart on top. if close last 1 charts gets closed. want know if possible have 1 frame , charts can navigated using 'next' , 'previous'button. if has experience in this, please share. in advance the following more started. better use gui editor of netbeans ide. mind following typed, without seeing compiler. fields: private static final int charts = 6; private int currentchartno = 0; private jbutton previousbutton = new jbutton("<"); private jbutton nextbutton = new jbutton(">"); private jpanel currentchartpanel = new jpanel(); private jpanel[] chartpanels = new jpanel[charts]; initialisation in frame: // getcontentpane(), having per default borderlayout. add(currentchartpanel , borderlayout.center); add(previousbutton, borderlayout.west); add(nextbutton, borderla

"'WinJS' is not defined." and "Windows' is not defined." -

sorry english. started learning develope windows store app. , found tutorial here . follow it, create new javascript windows store app. when build app, no code added, jshint show error that: 'winjs' not defined. 'windows' not defined there default.html <!doctype html> <html> <head> <meta charset="utf-8" /> <title>simplechanel9reader</title> <!-- winjs references --> <link href="//microsoft.winjs.1.0/css/ui-dark.css" rel="stylesheet" /> <script src="//microsoft.winjs.1.0/js/base.js"></script> <script src="//microsoft.winjs.1.0/js/ui.js"></script> <!-- simplechanel9reader references --> <link href="/css/default.css" rel="stylesheet" /> <script src="/js/default.js"></script> </head> <body> <div id="main"> <hea