Posts

Showing posts from August, 2013

node.js - Jade Templating engine error -

i trying pass values in jade template through node/express route nothing getting passed on. posting both server , template code. server.js: app.get('/note/:id',function(request,response) { var title=notes[request.params.id]['title'] var message=notes[request.params.id]['message'] console.log(title+' '+message) response.render('note', {locals:{title:title, message:message}}) }); note.jade: span #{locals.title} tried display locals array console throws error. i believe not need pass in locals key. if remember right used inside template. give try. response.render('note', {title:title, message:message}) and in template don't use #{locals.title} use #{title} did quick test , should work you.

c++ - Why does referencing an unique_ptr behave this way? -

vector<int> v1, v2; /*1*/ vector<int> &somereference=v1; //compiles /*2*/ somereference=v2; //compiles vector<unique_ptr<int>> vec1, vec2; /*3*/ vector<unique_ptr<int>> &otherreference=vec1; //compiles /*4*/ otherreference=vec2; //error i understand if neither line 3 nor 4 didn't compile, third 1 doesn't cause compilation errors - apparently there no problems initializing reference first time , passing around; problem appears when try assign second time. i can't understand going on behind scenes makes second assignment impossible. this has nothing references, it's unique_ptr cannot copied. unique_ptr<int> p1, p2; p1 = p2; // error consequently, vectors of unique_ptr cannot copied either. vector<unique_ptr<int>> vec1, vec2; vec1 = vec2; // error

Install nvidia-opengl headers in ubuntu -

i've been struggling setting opengl in ubuntu. my glxinfo: opengl vendor string: intel open source technology center opengl renderer string: mesa dri intel(r) ironlake mobile opengl version string: 2.1 mesa 9.1.3 opengl shading language version string: 1.20 opengl extensions: i have nvidia gt 520m card, how can use opengl library nvidia? installed nvidia-current , nvidia-current-dev , nothing happens. need newer version of opengl seems intel integrated card supports opengl 2.1. my laptop: acer 4743g; 2g ddr3 memory; gt 520m graphics card. system settings > software & updates > additional drivers tab select nvidia 1 , reboot

function - How to get Column Number(or index) from Excel Column Letter -

i have searched through site , googled formula. need calculate excel column number letter such as: a=1 b=2 .. aa=27 az=52 ... aaa=703 the code seems 1 digit off after random cycles of alphabet(az -> ba == off digit). seemingly randomly produce same integer 2 different inputs: getcolumnnumber(xlletter : text) : integer //start of function stringlength := strlen(xlletter); := 1 stringlength begin letter := xlletter[i]; if i>1 count += ((xlletter[i-1]-64) * (i-1) * 26) - 1; count += (letter - 64); end; exit(count); //return value my code example written in c/al used dynamics nav, can write c# or vb.net wouldn't mind if example in either of languages. in vba: public function getcol(c string) long dim long, t long c = ucase(c) = len(c) 1 step -1 t = t + ((asc(mid(c, i, 1)) - 64) * (26 ^ (len(c) - i))) next getcol = t end function

linux - Why use <VirtualHost> if you have only 1 domain name for the server ? But why can't "ServerAlias" be used w/o a <VirtualHost> -

okay so... tried using servername something.ooo serveralias www.something.ooo but appears.. you can not use serveralias unless used within <virtualhost *:80> </virtualhost> why that? what happens if server used 1 domain name , there no need "virtual" things. such "virtualhosts" ? virtualhost designed used multiple sites, however, when using alias, apache assuming have example.com , , wanting widget.example.com . said, because it's www , not mean apache doesn't see "separated" domains, needing virtualhost tag. this why can use servername, can't use serveralias without virtualhost . www , non-www separated domains.

jquery bug on navigation - any suggestions? -

can figure out why code effecting other jquery scripts. navigation toogles left right when implemented breaks other toogles. <script type="text/javascript"> var $fee = jquery.noconflict(); $fee('.left-nav-links').css({"width":"60px"}); var already_open = 0; $fee(document).on("mouseover",".left-nav-links > li",function(){ if(already_open==0){ already_open = 1; $fee('.left-nav-links').stop(); $fee('.left-nav-links').animate({"width":"192px"}, 1000); } }).on("mouseout", ".left-nav-links > li",function(){ if(already_open==1){ already_open = 0; $fee('.left-nav-links').stop(); $fee('.left-nav-links').animate({"width":"60px"}, 1000); } ...

c# - "Method must have a return type" and "return must not be followed by an object expression" -

im adding method public static class public static logmessage(exception ex) { trace.writeline(ex.tostring()); return ex; } when this, message says "method must have return type" and in return message says "since 'util.logmessage(system.exception)' returns void, return keyword must not followed object expression" how correct this? you need change declaration return exception: public static exception logmessage(exception ex) { trace.writeline(ex.tostring()); return ex; } note that, depending on usage, might make sense allow generic method: public static t logmessage<t>(t ex) t : exception { trace.writeline(ex.tostring()); return ex; } this allow use resulting exception in typed manner. alternatively, not return exception, since logging shouldn't need return exception in case: public static void logmessage(exception ex) { trace.writeline(ex.tostring()); }

c# - Can't serialize an object with Json.Net -

i have following object , trying serialize json json.net [serializable] public class flightselection : iequatable<flightselection> { public static readonly datetime initialdate; public flightselection(); public flightweekselectiontype flightweekselectiontype { get; set; } public bool isvalidproposallineweeksexists { get; } public int play { get; set; } public list<proposallineweek> proposallineweeks { get; set; } public int selectedcount { get; } public int skip { get; set; } public void applypattern(); public bool equals(flightselection other); public override bool equals(object obj); public bool[] toboolarray(); public override string tostring(); } i try serialize following code: var jssettings = new jsonserializersettings(); var fs = new flightselection(); string json = jsonconvert.serializeobject(fs, formatting.none, jssettings); i following error: the 'obj' argument not flightselection object. ...

java - JButtons acting up in paintComponent() -

i sorry non-descriptive title not sure how communicate problems. starters jbuttons every , again creating multiple times in same order loop should create them. issue having when reposition them using setlocation() method creates new jbuttons want them leaves old ones are. don't know if have refresh graphics or going on. help. the array playerhand()is defined in player class , 5 in length. public void paintcomponent(java.awt.graphics g){ setbackground(color.green); // create graphics2d object graphics object drawing shape graphics2d gr=(graphics2d) g; for(int x=0;x<player.hand.size();x++){ card c = player.hand.get(x); //c = current element in array c.xcenter = 30 + 140*x; c.xcord = c.xcenter - 30; c.ycord = 0; //5 pixel thick pen gr.setstroke(new java.awt.basicstroke(3)); gr.setcolor(color.black); //sets pen color black ...

Git authentication as root from Python script doesn't work even when demoted -

i have python script needs run in sudo mode , should run git commands (among them clone , push). these commands can't connect server, because run root , such don't use normal-user ssh key. so far it's common problem, thing trying demote user before calling these commands. used: def bash_background_demoted(cmd_list): def _demote(): if getuid() == 0: user = getenv('sudo_user') else: user = getenv('user') uid, gid = pwd.getpwnam(user)[2:4] setegid(gid) seteuid(uid) process = popen(cmd_list, stdout = pipe, stderr = pipe, preexec_fn = _demote) outp, err = process.communicate() print outp + err this method seems work on other commands, not on git: bash_background_demoted(['whoami']) # mark bash_background_demoted(['git', 'clone', 'ssh://git@bitbucket.org/stuff', '/repo/dir/']) # permission denied (publickey). # fatal: remote end hung...

ajax - How is a json file read? extjs -

say have fields here user in "json" format: { "users": [ { "id": 1, "name": "ed spencer", "email": "ed@sencha.com" }, { "id": 2, "name": "abe elias", "email": "abe@sencha.com" } ] } i assume root here "users". save text users.json file? and there, how read file (in case, ext.js) ext.define('am.model.user', { extend: 'ext.data.model', fields: ['name', 'email'] }); var store = ext.create('ext.data.store', { model: 'user', proxy: { type: 'ajax', url : 'users.json', reader: { type: 'json', root: 'users' } } }); what url? absolute path? work??? help! in html page, javascript file served...

windows 8 - Source file 'obj\ARM\Release\TemporaryGeneratedFile_<GUID>cs' could not be found -

so, windows metro app not build because number of errors source file 'obj\arm\release\temporarygeneratedfile_<guid>.cs' not found. <guid> variety of long alphanumeric strings. this accompanied number of other warnings state source file 'obj\release\\temporarygeneratedfile_<guid>.cs' specified multiple times guids match errors. here's piece of info. if run app right right developing, have no issues. still warnings, none of errors. app runs without problem. however, when push code git , download code, either computer or same computer, errors above , app not run, leads me believe crucial file not getting pushed. however, don't know don't understand meaning of message. have insight these temporarygeneratedfiles are? try checking length of path temporarygeneratedfile_[guid] are. in our case, these files deep in folder hierarchy , compiler couldn't find them. moving intermediary folder closer drive's root solved issu...

How to get correct SHA1 hash of BLOB using CryptoJS? -

cryptojs v3.1.2, sha1.js rollup in js want calculate sha1 of blob before sending server. on server want calculate sha1 of resulting file , compare sha1 received js. problem hash generated cryptojs.sha1() incorrect (always 9844f81e1408f6ecb932137d33bed7cfdcf518a3) js code: function uploadfileslice (slice) { // slice blob var filereader = new filereader() filereader.onload = function(event){ var arraybuffer = event.target.result var wordarray = cryptojs.lib.wordarray.create(arraybuffer) var sha1crc = cryptojs.sha1(wordarray).tostring(cryptojs.enc.hex) //etc requestparams.append('fileslice', slice) requestparams.append('sha1crc', sha1crc) //etc } filereader.readasarraybuffer(slice) } php code: $file_crc = sha1_file($_files['fileslice']['tmp_name']); if ($_request['sha1crc'] !== $file_crc) { echo "invalid crc: {$_request['sha1crc']} (expected $file_...

ruby on rails - Strategy for prioritizing data updates and maintenance in a data-heavy app? -

i've got rails app tens of thousands of records poll api updates on. i'm wondering what's best practices in terms of creating system (more involved cron job) tracks how record should updated...some records more important/timely others...so regular maintenance, want more important records polled , updated twice day , compared once day non-important records. so assuming these records have method returns "importance"...should create type of maintenance_record model belongs_to each record , keeps track of record's staleness (a combination of record's updated_at , importance)? record log whether latest attempt successful or not, , perhaps have foreign key table of log records. the purpose have maintenance_record quick index , sort cron-like job can scan list jobs do, rather hitting records database (which may contain records lots of blobs, etc. , may grow orders of magnitude). , of course, have more 1 kind of record-like model...so having polymorphic...

Accessing an osgi declarative service in a java project -

im trying access osgi ds in java project. found example on internet: bundlecontext context = frameworkutil.getbundle(this.getclass()).getbundlecontext(); servicereference servicereference = context.getservicereference(myclass.class.getname()); myclass blah = (myclass) new servicetracker(context, servicereference, null).getservice(); blah.dostuff(); the problem here if run in java class "context" variable null. guess thats because not in osgi bundle. i tried chaning things , works if change this: bundlecontext context = frameworkutil.getbundle(myclass.class).getbundlecontext(); but honest dont understand bundle context. what , can same class reference class is? manual states following: context - bundlecontext against tracking done. ... doesent make things clearer me. thanks! frameworkutil.getbundle(class) returns non-null if class pass in loaded osgi bundle classloader. means need in osgi bundle. you need clearer you're trying do. "access...

c++ - How to rotate text for drawText? -

i rotate text 45 degrees? qfont font; font.setpixelsize(12); //grid for(int = 0; < 10; i++){ painter->drawline(100, 100 + * 800/9, 900, 100 + * 800/9); str = qstring::number((double)9 - i, 'd', 1); painter->setfont(font); painter->drawtext(75, 100 + * 800/9 - 6, 40, 40, 1, str); } insert painter->rotate(45); before painter->drawtext(75, 100 + * 800/9 - 6, 40, 40, 1, str); , painter->rotate(-45); after (to restore rotation angle of coordinate system): painter->rotate(45); painter->drawtext(75, 100 + * 800/9 - 6, 40, 40, 1, str); painter->rotate(-45); depending on if mean 45 degrees clockwise or anti-clockwise may need negate rotation angles. after rotate coordinate system, paint painted rotated until restore painter. convenient way of saving , restoring state of painter using qpainter::save() , qpainter::restore() .

database - In MySQL, does the designated size of TEXT or BLOB affect performance or table size? -

i have table of data consists of foreign_key fields , blob column, other tables need not retrieve large blobs on regular basis. so data-blob on own, matter length is? example, if want store cached webpages...for pages, 65kb limitation of blob it...but inevitably, there pages 100kb of data, next size of blob, mediumblob, 16mb: http://dev.mysql.com/doc/refman/5.0/en/blob.html how changing datablob field blob mediumblob affect kind of retrieval operations, whether it's several records @ row or large batch operations? don't mean, "how retrieving records of 16mb in size different records of 64kb?"...i mean ask, there difference if blob sparsely populated? is, 90% of fields have 60k of data, , rest may past 65k limit. another way ask this: if data i'm working may consist of 50% blobs of blob size, , 50% of mediumblob...should create 2 tables , separate data way? or of little difference making 1 mediumblob table , storing small blobs in there? (which simplify...

java - Getting Error using Jersey client -

this question has answer here: how produce json output jersey 1.6 using jaxb 6 answers i using jersey client push data localhost. here code - public cloudconnection(jsonobject jsonpush) throws clientprotocolexception, ioexception, jsonexception { clientconfig config = new defaultclientconfig(); client client = client.create(config); webresource webresource = client.resource(uribuilder.fromuri("http://localhost/visual/savedata.php").build()); clientresponse response = webresource.path("restpath").path("resourcepath").type(mediatype.application_json).accept(mediatype.application_json).post(clientresponse.class, jsonpush); } when execute in eclipse works fine , db on localhost inserted recoord using savedata.php. make runnable jar of project , run jar throws error - message body writer java type, class org.codehaus.je...

sql server - Foreign Key off of a UNIONed View -

i have view looks this: create view reference.test schemabinding select reference.highleveltestid testid, name, isactive, cast(1 bit) ishighleveltest reference.highleveltest union select lowleveltestid testid, name, isactive, cast(0 bit) ishighleveltest reference.lowleveltest go note: highleveltestid , lowleveltestid guaranteed never have same values (no conflicts). i have table looks this: create table [reference].[testaddition]( [testid] [bigint] not null, [otherstuff] [bit] not null, .... ) i fk testaddition table test view on testid column (for referential integrity , ease of use odata). is there way that? foreign keys cannot applied views. angle: cannot apply referential integrity results returned select statement, because not stored permanently, non-persistent output of query. to manage referential integrity, apply foreign keys or other s...

Defining relationship for symbolic variable in MATLAB -

let's have symbolic variable "q" depends on symbolic variable "t". how define each symbolic variables. t= sym('t'); q = sym('q(t)'); and have expression contains (when use pretty(expression)) result = blah1* diff(q(t),t) *blah2 i want make particular part new variable. let's "qdot" in end, want this. result2 = blah1*qdot*blah2 i'm in process of figuring out. thank in advance. you should use subs function. here how use particular question function rewrite() t = sym('t'); q = sym('q(t)'); = sym('a'); blah1 = a^2; blah2 = t^3; result1 = blah1*diff(q,t)*blah2; qdot = sym('qdot'); result2 = subs(result1, diff(q,t), qdot) % result2 = a^2*qdot*t^3; end note result2 = subs(result1, 'diff(q(t),t)', qdot) and newmiddle = sym('qdot'); result2 = subs(result1, diff(q,t), newmiddle) also give desired result.

C++ SFML Sprite.setColor(sf::Color) Details -

i'm attempting replicate effect of having translucent color layer on solid image in sfml. have base image renders fine in sfml. in image editor, have numerous layers on image create various colored instances of image. example, first red layer i've used has rgba value of 222, 14, 14, 128. when use sfml's setcolor method (using same rgba code) on base image's sprite, color of end image not same, , appearing less vibrant. misunderstanding method's usage, or bug? there way can same color image editor gives me? sfml's setcolor function uses multiplication. if use color of pure white (255,255,255) sprite same. you're describing color in image editor less "vibrant" suspect layer using color add, rather multiply.

javascript - Change Twitter Tweet Button Text -

i've looked around can't seem find way this. below twitter tweet button code: <a href="https://twitter.com/share" class="twitter-share-button" data-url="{$post- >permalink}" data-text="{$themeoptions->directory->sharetext} {$post->permalink}" data-lang="en" style="background:#000000;">want new text here</a> regardless of enter link text, above, changes tweet. i'm assuming twitter js script. there way around this? here's need know, if mean creating own tweet button example uses jquery.. http://www.ejhansel.com/create-a-custom-twitter-tweet-button/ or question personalizing existing generic tweet button?

java - Android - how to programmatically add and populate spinners? -

i have been looking quite time on web efficient , clean way of programmatically adding elements views in general in android i've never quite found way trying do. as want use recommended ways of working (defining layouts in xml files) there limitations explain in next part. here's trying achieve. have activity displays default view (setcontentview called in overwritten oncreate method). i need able display several "pop-up" style messages, i've read, there 2 ways that, popups , dialogfragments . latter seems more appropriate me have specific customization in dialogfragment (which class separated activity extending dialogfragment). now, defined simple linear layout in xml document dialog fragment catch is, need add spinners it, , never know in advance how many need add (hence, can't define spinners manually in xml file). i've read bit inflation understand, merely instantiates view becomes "visible" , "manipulable" @ runtime co...

html - Transfer Search Box From Old Website to New Website -

i working company has hired me turn new home page design of theirs html , css. in design gave me there search box in header same 1 on current webpage ( http://shop.manorfinewares.com/intro.html ). unsure how navigate current page's source code in order transfer search box new page designing them. here header code have far... css: #header{ position:absolute; width:100%; top:0; height:107px; min-width:600px; border-bottom: 1px dotted #86beca; } #headercontainer{ position:relative; width:100%; margin:0 auto; top:0; height:107px; max-width:1280px; min-width:600px; border-bottom: 1px dotted #86beca; } .headerutilitycontainer{ float:left; padding-top:4px; margin-left:8%; width:22%; height:103px; } .headerutilitycontai...

php - Login Background Change -

i have login system changes login boxes account info once logged in. have background , boarder around account info , not log in boxes. tried add <div class> around if($session->logged_in) didn't seem work. has ever done before? in advanced, josh here code logged in stuff. need adding div class around it. <?php /** * user has logged in, display relavent links, including * link admin center if user administrator. */ if ($session->logged_in) { echo "<div class='welcome'><b>" . $session->username . "</b></div>" . "<div class='account'><a href=\"userinfo.php?user=$session->username\">my account</a></div> &nbsp;&nbsp;" . "<div class='account'><a href=\"useredit.php\">edit account</a></div> &nbsp;&nbsp;"; if ($session->isadmin()) { echo "<div class='accou...

jquery - Bootstrap typeahead not working with my following code -

i have code search places. server returning data in json format correctly typeahead not showing results. <script type="text/javascript"> $(document).ready(function(e) { $('#txt_ser').typeahead({ minlength:1, source: function (query, process) { var places = []; var map = {}; $.ajax({ datatype: "json", url: "<?php echo base_url() . "ajax/ser";?>", data: 'q='+query, type: 'post', success: function (data) { $.each(data, function(i, place){ map[place.yt_center_state] = place; places.push(place.yt_center_state); }); return process(places); } }) } }); }); </script> server returning data in json format example shown below when keyword pune typed 0: {yt_center...

<link rel="stylesheet" type="text/css" href="style.css"> isn't work -

it's in folder called "website" css file has body { background-color: #d0e4fe; } h1 { color: orange; text-align: center; } p { font-family: "times new roman"; font-size: 22px; } why isn't working? i think have wrong quotes. instead of “ quotes, try " with stylesheet named style.css placed @ same level web page, following line works me: <link rel="stylesheet" type="text/css" href="style.css">

jQuery UI Dialog with iFRAME -

i'm implementing jquery ui dialog iframe. dialog has iframe has file upload page. fine, closing dialog iframe page got problem. the below code: parent page <!-- upload file form --> <div id="dialog-upload" class="dialog" title="upload file" style="display:none"> <div class="message error"></div> <iframe id="upload-form" src="file_upload.php" width="276" height="195" frameborder="0"></iframe> </div> <!-- button launch dialog --> <button id="btnupload">upload</button> <script type="text/javascript"> function _finishupload(){ console.log($('#dialog-upload')); // element outputed in console $('#dialog-upload').dialog( 'close' ); // dialog not closed. //$('#dialog-upload').hide() // code executed. } function _fil...

What is this error message in C# programming? -

i received error: 'moveball.game' not contain definition 'ballspeedaxis1' , no extension method 'ballspeedaxis1' accepting first argument of type 'moveball.game' found (are missing using directive or assembly reference?) in beginning, there no error when tried insert value 1 one. int ballspeedaxis1 = 1; int ballspeedaxis2 = 1; ... int ballspeedaxis10 = 1; however, after changed loop shown below. var ballspeedxaxis = new int[10]; (int = 0; < ballspeedxaxis.length; i++) { ballspeedxaxis[i] = 1; } the error occurs on following lines: private void onupdate(object sender, object e) { canvas.setleft(this.ball1, this.ballspeedxaxis + canvas.getleft(this.ball1)); } may know how can solved it? because variable scope wrong. ballspeedxaxis should defined inside class instead of inside method initializes it. also, cannot use var if define class-scoped variable. , weird don't use index inside onupdate method. class ...

python - Replace a substring in a string -

i'm having issue program in python. i'm trying read content html file, removing html tags , removing stop words. actually, remove tags can't remove stop words. program gets text file , stores them in list. format of file following: a ... yours if test code step step in python interpreter, works, when 'python main.py' doesn't work my code is: from htmlparser import htmlparser class mlstripper(htmlparser): def __init__(self): self.reset() self.fed = [] def handle_data(self, d): self.fed.append(d) def get_data(self): return ''.join(self.fed) def strip_tags(html): s = mlstripper() s.feed(html) return s.get_data() def remove_stop_words(textcontent, stopwords): stopword in stopwords: word = stopword.replace('\n','') + ' ' textcontent.replace(word, '') return textcontent def main(): stopwords = open("stopwords.txt", ...

Android Push Notifications in China -

i have been given challenge create cross platform push notification service. technology choice not question, merely if android (or other mobile) devices located in china can receive push notifications. the reason wouldn't work (in eyes) if google blocked in china; i've seen wikipedia article seems no google services in china blocked see no reason why push notifications won't work. the reason asking valued architect proclaims push notifications won't work (at all) in china on android. since don't know persons in china wondering if me this. please :) in china, please use other push service, like: pushy igetui jpush baidu google push not work in china. chinese. may message me if need help.

Incoming call blocking in android 4.0 -

i want block incoming calls android 4.0 devices.i tried itelephony working upto 2.2.but found apps in market working in ics too.then came know modify phoine state has beed removed , can apply system apps tried older android sdk there kept modify phone state permission in manifest file did not show me error after running app not working in ics. used below code if (this.checkcallingorselfpermission(manifest.permission.modify_phone_state) == packagemanager.permission_granted) { but not going inside if clause in ics permission present in manifest file, suspect is not reading modify_phone_state permission manifest file. please suggest me thank in advance

php - parent transaction id in refund in authorize.net -

i'm using authorize.net aim , silent post. purchase done via aim, , it's working fine. if user wants refund it's tracked via silent post url. there no parent transaction id refund transaction. couldn't understand of transaction refund for. have idea on one? or how it. keep test mode turned off, transaction id each payment transaction. refund call (credit or void) pass particular transaction id can identify payment. in test mode authorize.net returns 0 transaction id. more test refunds on authorize.net using test account?

oop - What is difference between functional and imperative programming languages? -

most of mainstream languages, including object-oriented programming (oop) languages such c#, visual basic, c++, , java designed support imperative (procedural) programming, whereas haskell/gofer languages purely functional. can elaborate on difference between these 2 ways of programming? i know depends on user requirements choose way of programming why recommended learn functional programming languages? definition: imperative language uses sequence of statements determine how reach goal. these statements said change state of program each 1 executed in turn. examples: java imperative language. example, program can created add series of numbers: int total = 0; int number1 = 5; int number2 = 10; int number3 = 15; total = number1 + number2 + number3; each statement changes state of program, assigning values each variable final addition of values. using sequence of 5 statements program explicitly told how add numbers 5, 10 , 15 together. functional languages: ...

asp.net - FormsAuthenticationTicket disappeared after Response.Redirect operation -

i developed website asp.net. make authentification. authorization made web service. if answer web-service success, create ticket: var ticket = new formsauthenticationticket(1, param.login, datetime.now, datetime.now.adddays(1), false, string.empty, formsauthentication.formscookiepath); var encticket = formsauthentication.encrypt(ticket); var authcookie = new httpcookie(formsauthentication.formscookiename) { value = encticket, expires = datetime.now.adddays(1) }; response.cookies.set(authcookie); this code added authentification cookie. if add next string after previous code: response.redirect("<redirect address>"); cookie disappeared after redirect. why it's happened? web.config part of authentification here: <authentication mode="forms"> <forms name=".aspxformsauth" loginurl="~/login.ashx" /> ...

Which HTTP and WebDav status **MUST NOT** include message body? -

i know 204 , 205 must not include message body. any others? the exceptions 1xx, 204 , 304 (and head responses). see http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p1-messaging-23.html#message.body.length . also: need aware of difference between "does not have message body" , "message body must empty".

ios - Sort an NSArray of strings with custom comparator -

i have following array of numbers in strings. 08, 03, 11, 06, 01, 09, 12, 07, 02, 10 and want be: 06, 07, 08, 09, 10, 11, 12, 01, 02, 03 how can this? thinking of using custom comparator this: nscomparisonresult compare(nsstring *numberone, nsstring *numbertwo, void *context) but never used before. any help? kind regards edit oké @ moment did this. nsarray *unsortedkeys = [self.sectionedkalender allkeys]; nsmutablearray *sortedkeys = [[nsmutablearray alloc]initwitharray:[unsortedkeys sortedarrayusingselector:@selector(localizedcompare:)]]; this sorts array 01 --> 12. these numbers represent months in tableview. @ moment starts in januari , stops in december. want is starts in june , ends in march. hope clears question little bit. first, write simple comparison function; nsinteger mysort(id num1, id num2, void *context) { int v1 = ([num1 intvalue]+6)%1...

c# - Query related to getting number of days in between of two days -

i need number of days between 2 given dates. i used "(enddate-startdate).days" senior advised may incur memory leaks, told me may result in different values if used on 32 bit system vs on 64 bit system , advised me use timespan instead , days. i couldn't point. can please explain how may incur memory management issue? datetime dt1 = datetime.now; datetime dt2 = datetime.now.adddays(-10); int daysdiff = (dt2-dt1).days; // i'm doing this. timespan ts = dt2-dt1; // senior- int daysdiff = ts.days. // advised me. please correct me if i'm wrong i'm not proficient on point. in advance, appreciate help. c# code: int yourversion() { datetime dt1 = datetime.now; datetime dt2 = datetime.now.adddays(-10); int daysdiff = (dt2 - dt1).days; return daysdiff; } int seniorversion() { datetime dt1 = datetime.now; datetime dt2 = datetime.now.adddays(-10); timespan ts = dt2 - dt1...

Why jQuery("html body div table") returns null, whereas jQuery("html body div") not? -

Image
for following example: http://jsfiddle.net/mhbty/ why jquery("html body div table") returns null and, of course when check length of object, zero. however, jquery("html body div") returns correct thing after. sure "table" exist in html source code, want know why returns null? thanks. this working fine : nothing change in alert(jquery("html body div table ").html()); http://jsfiddle.net/m2sdy/ you forgot choose jquery option left hand side panel

jquery - Mousenter cancel mouseleave on cursor re-enter -

in example if move mouse in, out, in, out mouseleave event still fire twice http://jsfiddle.net/4bslm/1/ how can make fadeout event stop firing if cursor moved in? $(document).on("mouseenter","div",function() { $(this).find("span").fadein(400);}).on("mouseleave","div",function() {$(this).find("span").delay(700).fadeout(400);}); (note .on required) use stop() method stop playing animation. jsfiddle $(document).on("mouseenter", "div", function () { $(this).find("span").stop().fadein(400); }).on("mouseleave", "div", function () { $(this).find("span").stop().delay(700).fadeout(400); });

perl - Different ways to test for $1 after regex? -

normally when check if regex succeeded do if ($var =~ /aaa(\d+)bbb(\d+)/) { # $1 , $2 should defined } but recall seeing variation of seamed shorter. perhaps 1 buffer. can think or other ways test if $1 after successful regex? you can avoid $1 , similar altogether: if (my ($anum, $bnum) = $var =~ /aaa(\d+)bbb(\d+)/) { # work $anum , $bnum }

javascript - Is it possible to construct a link, navigate to it and print the response in C# programmatically? How? -

i have webpage written in c#/razor. printing values database on page : <div style="min-height: 150px; font-size: 1.25em"> <div style="margin-bottom: .5em"> <table> <thead> <tr> <th>name</th> <th>branch</th> <th>phone no.</th> <th>extension</th> <th>email</th> </tr> </thead> <tbody> @foreach (var prod in model) { <tr> <td>@prod.fullname</td> <td>@prod.branch</td> <td>@prod.phoneno</td> <td>@prod.extension</td> <td>@prod.email</td> ...

sql - MySQL assertion -

i'm mysql , sql newbie, discovered mysql doesn't support assertions. i've tables: create table stagione ( nome varchar(20), biennio char(9), teatro varchar(20), primary key(nome, biennio), foreign key (teatro) references teatro(nome) on update cascade on delete set null ) engine=innodb; create table produzione ( produttore varchar(20), spettacolo varchar(40), primary key(produttore, spettacolo), foreign key (produttore) references produttore(nome) on update cascade on delete cascade, foreign key (spettacolo) references spettacolo(titolo) on update cascade on delete cascade ) engine=innodb; create table proposta ( nomestagione varchar(20), bienniostagione char(9), spettacolo varchar(40), primary key(nomestagione, bienniostagione, spettacolo), foreign key (nomestagione, bienniostagione) references stagione(nome, biennio) on update...

ODP.NET in Microsoft Enterprise Library 6.0 -

there couple of questions floating around this, none have been answered. basically - there implementation of odp.net enlib (6.0) being used? or have go down route of writing mapping / custom dao odp.net? the generic database can me far, falls flat oracle stored procedures (the dreaded 'parameter discovery not supported connections using genericdatabase. must specify parameters explicitly, or configure connection use type deriving database supports parameter discovery' error) i aware of entlibcontrib project - seems on hold/dead has not had new realease since 2011/entlib 5.0. any pointers, or advice custom dao development entlib, appreciated. here's our official stand on this: if working oracle database, can use oracle provider included enterprise library , ado.net oracle provider, requires reference or add assembly system.data.oracleclient.dll . however, keep in mind oracleclient provider deprecated in version 4.0 of .net framework, , support provi...

php - How to display a certain details from database -

i have code search in mysql , working when run , entered account number display accounts in database want display details account number inquire on. what should change or add? don't know <?php echo "<h2>search results:</h2><p>"; //if did not enter search term give them error if ($find == "account_number") { echo "<p>you forgot enter search term!!!"; exit; } // otherwise connect our database mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); // perform bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //now search our search term, in field user specified $data = mysql_query("select account_number, name, balance memaccounts id like'%$find%'"); //and display results while($result = mysql_fetch_array( $data )) { echo $result['account_nu...

ssh - Putty Configuration GUI - remote command from script -

i can call remote command local file console(-m option) in putty. is possible same putty gui(connection->ssh->remote command, or elsewhere)? so, put more clearly, question can set file source of remote command in gui. not directly, no - explicitly takes string. possibly 1 of various putty forks has added (although can confirm kitty not). the way can think of wrap putty in script reads content of file (whatever is) , puts value windows registry @ hkey_current_user/software/simontatham/putty/sessions/nameofsession/remotecommand before executing putty.

c# - Randomly seeing System.NotSupportedException: http in WebRequest.GetCreator(string prefix) -

on our asp mvc application running on mono, notsupportedexception: http when creating webrequests. here stacktrace: 979: message: system.notsupportedexception: http 980: @ system.net.webrequest.getcreator (system.string prefix) [0x00000] in <filename unknown>:0 981: @ system.net.webrequest.createdefault (system.uri requesturi) [0x00000] in <filename unknown>:0 version information: 3.0.12 (master/b39c829 tue jun 18 11:23:32 cest 2013); asp.net version: 4.0.30319.17020 https://github.com/mono/mono/blob/master/mcs/class/system/system.net/webrequest.cs#l479 sometimes works , doesnt. couldnt figure out why. did solve issue? i saw in of earlier versions of mono 2.10 (a couple of years ago actually), , helped tracking down (but haven't seen time now). if memory doesn't fail me race condition in either asp.net's startup path or bug in synchronization primitives asp.net using. it tricky track down, happened on production server (of course) , ...

jquery - tablesorter to sort by number of facebook likes? -

i working on table jquery tablesorter , have 1 of columns displaying facebook likes buttons (the 1 counter next "like"). want sort number of "likes" displayed. how can this? you can see unfinished table here: http://fx-bar.com/brokers.html here i've done until (i added tabber script had issue before): <!doctype html> <html> <head> <script type="text/javascript" src="/table/jquery-latest.js"></script> <script type="text/javascript" src="/table/jquery.tablesorter.js"></script> <script type="text/javascript" src="/tabber/tabber.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#mytable").tablesorter(); } ); </script> <script type="text/javascript"> $(document).ready(function() { $("#mytable").tablesorter( {sortlist: [[1,0]]...