Posts

Showing posts from July, 2011

jQuery disable enable click event with fade -

how can disable click event before fadein , enable after fadeout? my js code: $('a').click(function(){ // disable click $('div').fadeout(400, function(){ $(this) .css('background','yellow') .fadein(1800, function(){} // enable click );}); }); i coulda use stop() need disable/enable plz modify http://jsfiddle.net/wbwrm/1/ thx add class element, , don't run event when class there. $('a').click(function () { var $this = $(this); if ($this.hasclass('noclick')) return; // disable click $this.addclass('noclick'); $('div').fadeout(400, function () { $(this).css('background', 'yellow').fadein(1800, function () { // enable click $this.removeclass('noclick'); }); }); });

How to programmatically determine when a rollover happened in log4j? -

i attempting use log4j write csv files. csv header must written top of log file every time created. example, of these rolled files must have following first line in log file: log.0 timestamp, name, min, max log.1 timestamp, name, min, max log.2 timestamp, name, min, max is possible determine when rollover has occurred can append header? thanks. p.s: know there lots of open source csv writers prefer not use them because use existing log functionality in our software. if @ log4j documentation rollingfileappender, has method called rollover. http://logging.apache.org/log4j/1.2/apidocs/index.html you need implement custom file appender inherits rollingfileappender, , override rollover method. imagine call super.rollover, , write whatever want header new file before gets logged it.

objective c - NSSortDescriptor Not Working to Organize TableView -

i working on sorting tableview cells , not working reason. had earlier revision of exact same code , exact same plist have sworn worked several months. refuses sort. sorting code inside numberofrowsinsection method: nsstring *date = [self.months objectatindex:sectionnumber]; nsdictionary *monthdata = [self.sportdictionary objectforkey:date]; nssortdescriptor *sortdescriptor2 = [[nssortdescriptor alloc] initwithkey: nil ascending: yes]; nsarray *days = (nsarray *)[[monthdata allkeys]sortedarrayusingdescriptors:[nsarray arraywithobject:sortdescriptor2]]; for(int x = 0; x < [days count]; x++) { nslog(@"day: %@", [days objectatindex:x]); } when @ output of nslog, not right. getting 15, 22, 29, 3, 8 the part of plist it's sorting shown: <dict> <key>1 september 2012</key> <dict> <key>3</key> <array> <string>georgia tech (orange effect)</string> <string>8:00 pm </string> <string>home</string> ...

asp.net - MVC4 Mobile environment on xp -

i trying develop simple sample mobile web app using mvc4, provide small demo team. following machine config os: windows xp vs: vs 2010 express emulator: android (i couldn't find windows7 emulator xp) problem: android emulator needs (as far know) application hosted iis application when create virtual directory mvc4 , try access, simple throws 403 error, thats because (again far know) iis 5.1 doesn't know mvc4 request handling question: how proceed in situation test application on latest mobile (of kind windows7, android or apple) emulator browser ? i tried iis express, android emulator didn't it. have tried mapping requests aspnet_isapi.dll? see blog post instructions: http://itscommonsensestupid.blogspot.in/2008/11/deploy-aspnet-mvc-app-on-windows-xp-iis.html?m=1

python - Making a sprite character jump naturally with pyglet and pymunk -

this code displays image assassin1.png on black screen. image has pymunk body , shape associated it. there invisible static pymunk object called floor present beneath it. gravity induced on image , resting on invisible floor. i make image jump naturally when press up key. how can implement this? import pyglet import pymunk def assassin_space(space): mass = 91 radius = 14 inertia = pymunk.moment_for_circle(mass, 0, radius) body = pymunk.body(mass, inertia) body.position = 50, 80 shape = pymunk.circle(body, radius) space.add(body, shape) return shape def add_static_line(space): body = pymunk.body() body.position = (0,0) floor = pymunk.segment(body, (0, 20), (300, 20), 0) space.add_static(floor) return floor class assassin(pyglet.sprite.sprite): def __init__(self, batch, img, space): self.space = space pyglet.sprite.sprite.__init__(self, img, self.space.body.position.x, self.space.body.position.y) def update(self): self.x = self.space.body.position.x self.y = self.space.body.positio...

python - set axis limits in loglog plot with matplotlib -

Image
how create space around points i've plotted matplotlib? for example, in plot, bottom left point cutoff axis, little more space between point , axis. import matplotlib.pyplot plt x = [2**i in xrange(4,14)] y = [i**2 in x] plt.loglog(x,y,'ro',basex=2,basey=2) plt.xlim([0, 2**14]) # <--- line nothing plt.show() in interactive mode, xlim line returns (16.0, 16384) , old values instead of new values i'm trying set. zero can not plotted on loglog graph (log(0) = -inf). silently failing because can not use 0 limit. try plt.xlim([1,2**14]) instead.

php - want to display the download link whenever there is a file to download -

my problem is, title say, want display download link file when file available is... i dont know error is: <?php $doc = get_post_meta(get_the_id(), 'wp_custom_attachment', true); ?> <div id="custom_pdf"> <a href="<?php echo $doc['url']; ?> "> download pdf here </a> </div><!-- #custom_pdf --> this normal code.. work fine, here displayed unconditionally... , code conditionally is: <?php $doc = get_post_meta(get_the_id(), 'wp_custom_attachment', true); ?> <? if(strlen(trim(<?php $doc['url'] ?>)) > 0) { <div id="custom_pdf"> <a href="<?php echo $doc['url']; ?> "> download pdf here </a> </div><!-- #custom_pdf --> } ; ?> // end if and here somewhere error, dont know where. can please me. thanks. your php tags not correctly placed in html code: <?php $doc = get_post_meta(get_the_id(), 'wp_custom_att...

Annoying Facebook popup (?) in browsers for a particular site -

Image
i not know call these elements. please see attached image. every time open particular site ( http://www.bdnews24.com/bangla/ ), window appears @ lower left. irrespective of firefox or chromium browser. blocking popups did not help. i can close pest clicking on cross, appear again in 5 minutes. news site , refresh after particular time. since read news regularly site, auto refresh necessary feature me. please tell me how stop these popups. thanks in advance. try http://adblockplus.org/en/ . not stop popup, stop content within popup.

objective c - How to specify Restkit object manager to perform a POST -

i trying send post request using ios restkit. can perform get, cannot find how send post. my current code looks following: rkurl *url = [rkurl urlwithbaseurl:[objectmanager baseurl] resourcepath:@"/users/sign_in.json" queryparameters:params]; [objectmanager loadobjectsatresourcepath:[nsstring stringwithformat:@"%@?%@", [url resourcepath], [url query]] delegate:self]; apparently, performs get. idea should add make post? thanks! to answer question (regardless of above discussion) can following: [objectmanager loadobjectsatresourcepath: @"path" usingblock: ^(rkobjectloader *loader) { loader.httpmethod = rkrequestmethodpost; }];

java - CXF, XMLStreamWriter and Encoding -

i have spring web project should implemented cxf , web services. one function output xml file. using xmlstreamwriter task. works fine. but when add cxf dependencies pom-file, output xml file gets "ibm1252" encoding. xml file can not read afterwards. exception: "invalid encoding name ibm1252" thrown. i have added following dependencies: <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-core</artifactid> <version>${cxf.version}</version> </dependency> <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-frontend-jaxws</artifactid> <version>${cxf.version}</version> </dependency> <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-transports-http</artifactid> <version>${cxf.version}</version> </dependency> i didn't change in code. , have tried this: xmlstreamwriter writer =...

knockout.js - KnockoutJS validation plugin on viewmodel components -

my viewmodel has ko.observable members store dialog state objects. each dialog object has sorts of members corresponding input fields in dialog. add validation dialogs using knockoutjs validation plugin. i don't, however, want add validation entire view model, rather dialogs. when tried extending dialogs this: this.dialog = ko.observable(new registrationdialog(self)).extend({validatable: true}); things didn't work right: isvalid() , errors() methods not defined, , validation wasn't working properly. i've created jsfiddle illustrate this. when press start button, dialog opens (pardon lack of css), pressing enter doesn't generate error messages. email validation fails work, showing message 'true not proper email address.' i go documentation : this.dialog = ko.validatedobservable(new registrationdialog(this)); then fix bugs in fiddle: data-blind click handler on form (instead of submit, assume) on register button have enable: isvalid should en...

objective c - How do I compare a constant value to a continuously-updated Accelerometer value each time round a loop? -

as suggested me in a previous post of mine, following code takes data coming accelerometer "minute" assignment : cmaccelerometerdata* data = [manager accelerometerdata]; performed, , then extracts data acceleration exercised on x-axis , stores value in double (double x) : cmmotionmanager* manager = [[cmmotionmanager alloc] init]; cmaccelerometerdata* data = [manager accelerometerdata]; double x = [data acceleration].x; suppose value stored 0.03 , suppose want use in while loop follows : while (x > 0) { // } the above loop run forever however , if used following code instead : cmmotionmanager* manager = [[cmmotionmanager alloc] init]; while([[manager accelerometerdata] acceleration].x > 0) { // } wouldn't comparing 0 different value each time round loop? (which i'm going in project anyway..) any thoughts? the reason i'm asking following : i want check values coming x-axis on period of time, rather keep checking them @ regular intervals, want w...

python - django integrity error, many to many relationship -

that's models.py: class user(models.model): email = models.emailfield() def __unicode__(self): return str(self.email) class link(models.model): link = models.urlfield() users = models.manytomanyfield(user, through='shorturl') class shorturl(models.model): link = models.foreignkey(link) user = models.foreignkey(user) short_end = models.charfield(max_length=20) counter = models.integerfield() adding users works fine: >>> user = user.objects.create("john_doe@planetearth.com") i integrity error when try add link: >>> link = link.objects.create("stackoverflow.com") integrityerror: shortener_link.short_end may not null what missing? you need create link this: link.objects.create(link="stackoverflow.com", user = request.user, short_end = 'stack', counter = 0) since of fields required.

parsing - PHP XPath Table elements disapearing -

i have learned xpath , wanting read data columns in table. my current code looks this: <?php $file_contents = file_get_contents('test.html'); $dom_document = new domdocument(); $dom_document->loadhtml($file_contents); //use domxpath navigate html dom $dom_xpath = new domxpath($dom_document); $elements = $dom_xpath->query("//tr[@class='rowstyle']"); if (!is_null($elements)) { foreach ($elements $element) { echo $element->nodevalue . '<br />'; } } else { echo 'none'; } ?> also variation in query because through research have seen lots of issues nest table elements produces same result: $elements = $dom_xpath->query("//table[@class='tablestyle']/tbody/tr[@class='rowstyle']"); it grab row of data makes single string, combining of cells 1 string , making tags disappear. what want separate cells , grab row number. i curious on how find out version of xpath have... php version 5.3.5 its not...

apache - Does WordPress preload pages? -

while surfing site , reviewing server access logs, appears 'next' page in site served along page navigated (one click, 2 pages). in order, other times appears random, grabbing unlisted pages , serving those. that is, click on 'about' page, , logs report serving 'about' , 'contact'. there's nothing visibly wrong on front end, , validates. i'm using highslidejs gallery uses preloaders images, , looked potential bugs wp-supercache haven't found answer. this doesn't seem normal behavior since it's polluting logs. leads follow appreciated. that's web browser pre-fetching next page. wordpress letting browser know page next, using link rel='next' element . if want prevent this, add functions.php file in theme: remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

MongoDB: How do I update a single subelement in an array, referenced by the index within the array? -

i'm trying update single subelement contained within array in mongodb document. want reference field using array index. (elements within array don't have fields can guarantee unique identifiers.) seems should easy do, can't figure out syntax. here's want in pseudo-json. before: { _id : ..., other_stuff ... , my_array : [ { ... old content ... }, { ... old content b ... }, { ... old content c ... } ] } after: { _id : ..., other_stuff ... , my_array : [ { ... old content ... }, { ... new content b ... }, { ... old content c ... } ] } seems query should this: (again, pseudocode) db.my_collection.update( {_id: objectid(document_id), my_array.1 : 1 }, {my_array.$.content: new content b } ) but doesn't work. i've spent way long searching mongodb docs, , trying different variations on syntax (e.g. using $slice, etc.) can't find clear explanation of how accomplish kind of update in mongodb. please help! as expected, query easy once know how. here's ...

html - Freeze Screen w/ Overlay if JavaScript isn't enabled -

i'd darken , lock page (prevent clicking / scrolling) , have white text saying user doesn't have javascript enabled. i know proper thing have gracefully degrade when there isn't javascript- don't want go route right now. <noscript> <div id="nojs-overlay"> please enable javascript view site<br> <a href="instructions.html">instructions on how enable javascript</a> </div> </noscript> the above example loads overlway div in case javascript not enabled. selected answer cause flicker or delay on slow devices. make sure style nojs-overlay div (or series of divs) overlay complete screen.

database - magento upgrade from 1.6.2 to 1.7.0.2 - Will the db base be changed? -

i looking upgrading magento community 1.6.2 1.7.0.2. first on test server, there errors during updating in magento connect, have upload files self ... but when going put these data live environment, can copy data ftp live website? or there new/changed settings in database? and if yes on last question, lines changed? avoid upload core library changes via ftp. the fastest , more secure way patch application using diff files patch -p0 -f < 1.6.2.0-1.7.0.0.diff then when first visit site magento automatically upgrade db

Design: Selling content on 3rd party site -

just need advice i'm new territory , not sure best approach is. i have site sell online courses udemy or appsumo or lynda. people pay on site , can access/stream videos , quizzes online. now i'm partnering 3rd party site sell our courses custom making courses site , these courses not available on site users. courses available on site should not visible users come 3rd party site. the idea - on 3rd party site - user going view course details, register , pay online after user redirected site. user should not indication has come site - , feel should similar 3rd party site , url masked well. goes without saying while on site - should not able access of current pages "view courses", "about us" "contact us" etc etc basically idea user never know site. next time when wants access course - login on 3rd party site , redirected here. so tech team on other end suggesting should make new build main course pages , new layout , deploy on separate server poi...

php - How to insert data in the nested set model(MySQL); -

Image
in nested set model have left , right columns the first time when table empty, need insert right column, if don't know how many children have left 1 - forever right ? - value goes here?? how make dynamic? not static. ps: using php i'm assuming tags , title looking solution works mysql . yes, right unless know number of elements in advance value right needs calculated dynamically. there 2 approaches can use: you start least value works (2 in case) , increase later needed. you make guess 10000000 , hope that's enough, need prepared possibility wasn't enough , may need adjusting again later. in both cases need implement left , right values multiple rows may need adjusted when inserting new rows, in second case need perform updates if guesses wrong. second solution more complex, can give better performance. note of 4 common ways store heirarchical data, nested sets approach hardest perform inserts , updates. see slide 69 of bill karwin's models heir...

python - Generating Discrete random variables with specified weights using SciPy or NumPy -

i looking simple function can generate array of specified random values based on corresponding (also specified) probabilities. need generate float values, don't see why shouldn't able generate scalar. can think of many ways of building existing functions, think missed obvious scipy or numpy function. e.g.: >>> values = [1.1, 2.2, 3.3] >>> probabilities = [0.2, 0.5, 0.3] >>> print some_function(values, probabilities, size=10) (2.2, 1.1, 3.3, 3.3, 2.2, 2.2, 1.1, 2.2, 3.3, 2.2) note: found scipy.stats.rv_discrete don't understand how works. specifically, not understand (below) means nor should do: numargs = generic.numargs [ <shape(s)> ] = ['replace resonable value', ]*numargs if rv_discrete should using, please provide me simple example , explanation of above "shape" statement? drawing discrete distribution directly build numpy. function called random.choice (difficult find without reference discrete distributions...

flash - How can I parse data from .swf file? -

i'm trying develop application parse data .swf (i want able read fields flash file) how can achieve this? or impossible ? you can use swf::parser ex: use swf::parser; $parser = swf::parser->new( 'header-callback' => \&header, 'tag-callback' => \&tag); # parse binary data $parser->parse( $data ); # or parse swf file $parser->parse_file( 'flash.swf' ); check here: http://search.cpan.org/~ysas/swf-file-0.42/lib/swf/parser.pm

Using spaceless in django template -

i have following code: {% item in profile.jobs.all %} {% if not forloop.first %}, {% endif %}{{ item }} {% endfor %} which produces following: "programmer , plumber , philosopher" i not want leading space before comma, way i've been able rid of compress onto 1 line, reduces readability: {% item in profile.jobs.all %}{% if not forloop.first %}, {% endif %}{{ item }}{% endfor %} is there better way deal this? {% spaceless %} strips spaces between html tags. you can either use {{ value|join:", " }} or believe work: {% item in profile.jobs.all %} {% if not forloop.first %}, {% endif %} {{ item }} {% endfor %}

php - Session array with productids -

i'm adding product ids session array with: if (isset($_get["add"]) && (int)$_get["add"]>0) { $_session['products'][] = $_get["add"]; } how loop array , add class products ids in array? what this: ... $_session['products'][$_get["add"]] = true ; ... then ask if ($_session['products']) { ... } or in loop foreach ($_session['products'] $id=>$isset) { // ... } btw shorter cond: if (($_get["add"]*1)>0)

http - Using Pastebin API in Node.js -

i've been trying post paste pastebin in node.js, appears i'm doing wrong. i'm getting bad api request, invalid api_option , i'm setting api_option paste documentation asks for. var http = require('http'); var qs = require('qs'); var query = qs.stringify({ api_option: 'paste', api_dev_key: 'xxxxxxxxxxxx', api_paste_code: 'awesome paste content', api_paste_name: 'awesome paste name', api_paste_private: 1, api_paste_expire_date: '1d' }); var req = http.request({ host: 'pastebin.com', port: 80, path: '/api/api_post.php', method: 'post', headers: { 'content-type': 'multipart/form-data', 'content-length': query.length } }, function(res) { var data = ''; res.on('data', function(chunk) { data += chunk; }); res.on('end', function() { console.log(data); }); }); req.write(query); req.end(); console.log(query) confirms string encoded , api_option t...

html - How to change the form data into json and pass to api using post method? -

Image
id:<input type="text" id="id" required="required"></br> name:<input type="text" id="name" required="required"></br> <input type="submit" id="submit"> i have form, have placed above code. , can give values. need is, have send value give in text box api in specific format shown below. { "entry": { "id":"", "name":"" } } i have using ruby. not using rails or other framework. how can this? if possible give me code examples. html - how change form data json , pass api using post method? - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company blog tour start here quick ove...