Posts

Showing posts from August, 2013

directx - Phong Shading vs Tessellation -

i ran across phong shading while looking @ source engine. desription sounds tessellation . when looked up, didn't find directly comparing two. in directx tessellation isn't used phong shading in hlsl. what's difference? , 1 should use? phong shading not directly related dx11 tessellation, because both can smooth lighting details can see how confused. tessellation dynamically increases geometric detail based on parameters (often camera distance). can increase lighting quality (maybe relationship phong?) silhouette detail. shading advantages (not silhouette detail) can simulated entirely in pixel shaders without tessellation. phong shading pixel shading technique. not affect geometric detail. similar standard opengl gouraud shading , except instead of interpolating lighting value across pixels of surface, normal interpolated across surface , renormalized @ each pixel. gives more accurate lighting results called "per pixel lighting" opposed "pe...

ios - How to create a CATransform3D matching another made using setValue:forKey: -

Image
i tried create catransform3d, got wrong. following code do want , using key-values: [_transitionlayer setvalue:[nsnumber numberwithfloat:metrics.translationpointsx] forkeypath:@"sublayertransform.translation.x"]; [_transitionlayer setvalue:[nsnumber numberwithfloat:metrics.radians] forkeypath:@"sublayertransform.rotation.y"]; [_transitionlayer setvalue:[nsnumber numberwithfloat:metrics.translationpointsz] forkeypath:@"sublayertransform.translation.z"]; and here's how tried set doing catransform3d: sublayertransform.m34 = -0.000555; catransform3d sublayertransform = catransform3dmaketranslation(0, 0, 0); sublayertransform = catransform3dtranslate(sublayertransform, metrics.translationpointsx, 0, 0); sublayertransform = catransform3drotate(sublayertransform, metrics.radians, 0, 1, 0); sublayertransform = catransform3dtranslate(sublayertransform, 0, 0, metrics.translationpointsz); how can create matching trans...

Heroku support for Sqlite and Postgres -

why doesn't heroku support sqlite3? or why heroku support postgresql? in case wrong , heroku support either mysql or sqlite3 please tell me how? thx :) the filesystem read only, sqlite3 wouldn't work. heroku supports postgresql, it's chose. doesn't make business sense have deal tuning , supporting other rdbms mysql. there addons use mysql if like: https://addons.heroku.com/cleardb you can mysql via amazon rds https://addons.heroku.com/amazon_rds

replacing anchor text with jquery -

i have tried using html() , text() try change text of anchor - cant work :( here fiddle show - http://jsfiddle.net/kneidels/gzulh/ $('#contact-form-send').bind('click',function(e) { e.preventdefault(); $(".button").text('logging in...'); $("#mess").delay(2000).fadein(400); $("#mess").html('<p class="message">username/password not match. please contact our office assistance</p>'); $(".button").text("submit"); $("#mess").delay(2000).fadeout(400); }); thanks! you using .delay() lines following doesnt catch delay, need code when fadein done, write .fadein() code : $("#mess").delay(2000).fadein(400, function(){ $("#mess").html('<p class="message">username/password not match. please contact our office assistance</p>'); ...

c# - TypeScript and Generic MVC Model behavior -

i evaluating typescript see if save time in development requirements. lets define simple classes , set hidden fields main purpose of being generic , working mvc models. class baseobject { _name: string; constructor(public name) { this._name = name; } } interface baseform { savefields(): void; getfields(): void; toquerystring(): string; tojsonstring(): string; } class basereportform extends baseobject implements baseform { constructor(name) { super(name); } public pagenumber: number; public allowpaging: bool; public exportlink: string; ... savefields() {//write hidden fields form } getfields() { //get hidden fields form} toquerystring() { return "hidden fields query string"; } tojsonstring() { return "hidden fields json"; } } this works great, however, not seeing allow me work @models. nice able have ability magically following: var reportform=new reportform(@model.report); i aware achieve ...

Encrypting password in a MSBuild file -

i want encrypt password supplying in following code: <target name="default"> <!-- install service on remote machine --> <msbuild.extensionpack.computer.windowsservice taskaction="install" servicename="__testservice1" user="$(user)" password="$(password)" servicepath="c:\windows\system32\taskmgr.exe" remoteuser="$(remoteuser)" remoteuserpassword="$(remoteuserpassword)" machinename="$(remotemachine)" /> </target> i dont want hardcode password. how can encrypt it? please provide suggestion. googled not find solution work me. thank you. there many ways this. describe 2 simplest: have thought using feature of ntfs encrypting file system? store password in file plaintext , mark file encrypted. user created file (by default) has access file (if more paranoid can restrict access pr...

ios - JqueryMobile- event for page become active -

i using phonegap jquerymobile develop application. want refresh data when app running @ background , going visible. listen "pageshow" event fired when app initialize ( starting time). looked @ this can't find event page visibility. please help. got it. use "resume" event of phonegap handle case. http://docs.phonegap.com/en/2.5.0/cordova_events_events.md.html#resume

adapter - What is the ideal way to listen for messages from Hubot scripts? -

i want create hubot script captures messages within multiuser chat , record them including hubot. problem hubot not hear itself. doesn't appear adapters emit event whenever message sent, there recommended approach listening hubot messages? we're using hubot hipchat, , have resorted posting directly hipchat's api when want bot listen. not ideal, works.

.htaccess - handle error pages using PHP and htaccess -

i want put codes below in htaccess file: errordocument 403 /error/403 errordocument 404 /error/404 errordocument 500 /error/500 ... and have php file handles error pages me using ( file.php?a=404 ). now, need htaccess code rewrite "/error/404" "file.php?a=404" me. should ?! there's several other error documents might wish customise. 400 - bad request 401 - authorization required 403 - forbidden directory 404 - page not found 500 - internal server error for each 1 want use, add line .htaccess file , create corresponding page. errordocument 400 /errors/badrequest.html errordocument 401 /errors/authreqd.html errordocument 403 /errors/forbid.html errordocument 404 /errors/notfound.html errordocument 500 /errors/serverr.html

html - How to avoid the blinking of gradient background in IE8/9 when mouse hover -

when apply following css ie8/9, , mouse on empty area, background blinking. here html <div style="width: 100%;"> <ul> <li> <a class="content" href="javascript:;"> please mouse on after words </a> </li> <li> <a class="content" href="javascript:;"> please mouse on after words </a> </li> </ul> </div> here css setting ul { list-style: none; margin: 0px; padding: 0px; border: 0px; position: relative; } li { padding: 0px; position: relative; cursor: pointer; } .content { padding: 3px 6px; border-radius: 4px; text-decoration: none; display: block; } .content:hover { margin: 0; filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#e3f4fd', endcolorstr='#c7e9f9',gradienttype=0 ); ...

asp.net - How to show text on ImageButton on mouse over by css -

i have image button inside div. increasing image size , z-index on hover on div. want add text on image button when hover calling. how can ? my css: .hoverimageclass input[type=image]:hover { position: relative; z-index: 10000; height: 274px; width: 226px; margin-top: -67px; margin-left: -14px; padding-bottom: 13px; background-color: #f7f6eb; } my html: <div id="divimagedisplay" class="hoverimageclass" runat="server"> <asp:imagebutton runat="server" cssclass="course_img" id="imgbtncourse" alternatetext='<%#eval("levelname") %>' tooltip='<%#eval("levelname") %>' imageurl='<%#eval("courseimagepath") %>' causesvalidation="false" commandname="addtocart" commandargument='<%# string.format("{0},{1},{2},{3},{4},{5}",eval("id"),eval("levelid"),eval(...

php - Woocommerce how to edit address -

i having difficulties in editing new address type in woocommerce. added besides shipping , billing, type of address, personal. i want user change data on my account/edit address page. i can show data personal address, when user clicks on edit , should load form these fields. these files: my-account.php <?php /** * addresses * * @author woothemes * @package woocommerce/templates * @version 2.0.0 */ if ( ! defined( 'abspath' ) ) exit; // exit if accessed directly global $woocommerce; $customer_id = get_current_user_id(); if ( get_option('woocommerce_ship_to_billing_address_only') == 'no' ) { $page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'my addresses', 'woocommerce' ) ); $get_addresses = array( //added pd 'personal' => __( 'personal address', 'woocommerce' ), // 'billing' => __( 'billing...

How to resolve double tap on Button Issue in android? -

Image
mockup of application : problem : when click on button1 call intent of activitysecond button1.setonclicklistener(this); public void onclick(view v) { // todo auto-generated method stub switch (v.getid()) { case r.id.button1: intent intent = new intent(getapplicationcontext(), activitysecond.class); startactivity(intent); break; default: break; } } but, on double tap open twice activitysecond. how resolve it. please if solution share it. thank you. you can set launchmode of activitysecond singletop <activity android:name=".activitysecond" android:launchmode="singletop" > ... </activity>

c - UART blocks on read -

i have problem uart read (on raspberry pi). works ok stops in loop , waits on data... made option o_ndelay stops so. i use 2 terminal windows: one used uart program on second write: echo '123445' > /dev/ttyama0 (raspberry pi uart port) complete code below. #include <stdio.h> #include <unistd.h> //used uart #include <fcntl.h> //used uart #include <termios.h> //used uart int main(int argv, char * argc[]) { // setting uart //------------------------- //----- setup usart 0 ----- //------------------------- //at bootup, pins 8 , 10 set uart0_txd, uart0_rxd (ie alt0 function) respectively int uart0_filestream = -1; //open uart //the flags (defined in fcntl.h): // access modes (use 1 of these): // o_rdonly - open reading only. // o_rdwr - open reading , writing. // o_wronly - open writing only. // // o_ndelay / o_nonblock (sa...

php - Obtain form value from Drupal 6 module form while loop -

inside form hook: $count = 1; while($slice = db_fetch_array($fruit)){ $section = $slice['section']; $form[$section][$count] = array( '#type' => $slice['type'], '#title' => $slice['title'], '#value' =>$slice['value'], //'#default_value' => $slice['default_value'], '#disabled' => $true_statement, '#size' => $slice['size'], '#description' => $slice['description'], '#options' => unserialize($slice['options']), '#prefix' => $slice['prefix'], '#suffix' => $slice['suffix'], ); $count = $count+1; } inside save : function student_grant_save($form, &$form_state) { $vari = $form_state['values']['2']; //or question count # 3,4,5...etc... drupal_set_message(t('hi'...

audio - iOS 3D mixer works in iOS 5+ but not in iOS 4.3 -

i've set kaudiounitsubtype_au3dmixerembedded part of functional augraph . i've set output asbd of mixer following: sample rate: 44100 format id: lpcm format flags: c // (kaudioformatflagissignedinteger | kaudioformatflagsnativeendian | kaudioformatflagispacked) frames per packet: 1 channels per frame: 2 bits per channel: 16 bytes per packet: 4 bytes per frame: 4 this audio graph works great when running on ios 5+, on ios 4.3, outputs weird distorted sounds sound nothing inputs. better understand this, used 1 mixer input , compared input bytes versus output bytes. on ios 5+, input , output bytes identical, expect. however, on ios 4.3, output bytes different. when i'm inputting in 0s mixer (0x0000, 0x0000, ...) , output bytes printing out stream of 0x8000 0x8000. does have idea why 3d mixer behaves strangely on ios 4.3?

android - How to get the content of website in phonegap? -

i have design android,ios application website.i searched , find out phonegap can 1 that.please provide me info how content of website in phonegap?on first page have buttons home,contact etc.on click of home button,the home page website should shown. phonegap set of libraries jquery. write html pages , include javascript files phonegap. check out phonegap example project.

complexity theory - Step Count in Algorithm -

what step count algorithm in terms of n ? sequentialsearch(a,x,n) { i=n; [0]=x; while(a [i]!= x) = i-1 return } please mention count each step here.thanks! i hope looking for: while (a[i] != x) = i-1; worst case: scan whole array, a[n] a[0] = o(n) mean case: scan half array o(n/2) = o(n) complexity o(n)

c++ - Is there a safe way to use C++11 Smart Pointer and the Interface for Raw Pointer together? -

i want use c++11 smart pointers in new projects, , encounter problem. many current projects still use raw pointers parameters in interface , have no interface smart pointers, e.g. qmainwindow::setcentralwidget . to keep type consistent, have pass stored pointer get() segment: qmainwindow win; std::shared_ptr<qwidget> scrollarea{ std::make_shared<qscrollarea>() }; // qscrollarea derived class of qwidget. win.setcentralwidget(scrollarea.get()); but can't make sure whether other methods in qt execute operator delete on stored pointer of scrollarea . will cause memory leak or other problems if methods in qt that? i've checked latest c++ standard cd , found nothing on that. seems it's undefined behavior. if doing undefined behavior , dangerous, is there safe way use smart pointer(s) interface raw pointer(s)? there's no such way in general case. each "legacy" interface want use, must read documentation see how interacts owne...

camera - Android Image Not saving to sdcard -

after pressing capture button , image should save in sdcard, taking snapshot not saving image that, how can put capture button wherever want? have overlay in imageview , need put button on overlay. use 1 store image in sd card public void save(bitmap image) { file sdcard = environment.getexternalstoragedirectory(); file f = new file (sdcard, imagename); fileoutputstream out=null; try { out = new fileoutputstream(f); } catch (filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } image.compress(bitmap.compressformat.png, 90, out); try { out.flush(); out.close(); } catch (ioexception e) { e.printstacktrace(); } }

php - Insert a variable in javascript -

weel, i'm creating cicle javascript , php. this php while (($num_images > 0) && ($num_images < 5)) { echo '<a href="javascript: submitform' . $num_images . '()"><img id="myimgid" class="nomarge" alt="" src="image' . $num_images . '.jpeg" width="' . $ver . '" height="' . $hor . '"/></a>'; echo $num_images; $num_images--; } and now, want javascript like: <script type="text/javascript"> var img = 4; (img = 4, img > 0, img--) { function submitform() {document.myform.submit();} } </script> well... how make submitform1() myform1 .... instead of making new functions submit each form, make single function, submitform() , pass form index parameter (e.g. i parameter). like this, need write 1 function , function, submitform(i) submit corresp...

html - Issue with logo on Twitter Bootstrap site -

so, i'm working on first website twitter bootstrap. works great. i'm trying website responsive. when make screen smaller(too simulate mobile phone screen), logo gets bigger , bigger, until gets smallest page size(i geuss?), jumps smaller size , stays there. does have idea how fix this? want stay same size... html: <div id="header" class="container"> <img id="logo" class="span2 offset1" src="img/logo.png" title="hostellerie de hamert"> <h1 id="dehamert" class="text-center span6">hostellerie de hamert</h1> </div> css: #logo{ background-color: transparent; max-width: none; } , of course, bootstrap integrated. you set "span2" class on image element. when using bootstraps responsive library "spans" stack on top of each other instead of float screen width. suggest set width , height of #logo static value. h...

c# - I set the namespace but I I don't get the correct xml -

i have following code: xnamespace xsins = xnamespace.get("http://www.w3.org/2001/xmlschema-instance"); xnamespace ns = xnamespace.get("http://xyz.com/2006/"); xdocument doc = new xdocument( new xdeclaration("1.0", "utf-8", null), new xelement(ns + "node", new xattribute(xnamespace.xmlns + "xsi", xsins), new xattribute(xsins + "schemalocation", "http://aaa.com/bbb.xsd") )); xelement newelement = new xelement(ns + "principalnode", new xattribute(ns + "attributte01", "value attributte01"), new xattribute(ns + "attributte02", "value attributte02"), new xelement(ns + "subnode01", " value subnode01"), new xelement(ns + "subnode...

javascript - iframe - location - same origin policy -

as believing, iframe properties (if iframe loaded origin) can not set. tried little testcases, seems can properties. doing wrong in setting example? <iframe src="http://www.wikipedia.org" id="iframe"></iframe> <script> try { alert(document.getelementbyid("iframe").src); } catch(e) { alert(e); } </script> the above example alerts correct location in tests. regards you not accessing content elements/properties of contained document. getting src attribute of iframe set outer document. try this: iframeelement.contentdocument.body.style.backgroundcolor = "red";

c - How to ensure that UDP socket is closed? -

i have client server application. client sends commands server , receives data on udp socket channel. each time socket file created different id. executing command 10000 times using script , ebadf . problem suspecting close() not closes socket descriptor immediately. have read so_linger options think works tcp socket. is there way ensure close() closes socket descriptor. thanks the actual problem here aren't checking result of creating socket in first place, or you're closing socket , reusing it, or corrupting handle value, encountering ebadf later on. ebadf result of prior programming error. not failure close. find out actual error is. don't guess.

http - Content security policy not working -

i adding response header header: x-content-security-policy default-src 'none'; i expect no css or images loaded on page, loaded. doing wrong? for chrome , newer (v. 23 , newer) versions of firefox: content-security-policy: default-src 'none' for safari: x-webkit-csp: default-src 'none' for older versions of firefox (v. 23 , older): x-content-security-policy: default-src 'none' sorry - ie, sandbox policy recognized, , in ie 10 , newer.

Use REST API in Ruby on Rails Model -

i plan develop ruby on rails application uses instead of database application (in case vmware vcenter orchestrator). honest, orchestrator in turn uses database store , retrieve data, should masked portal application. have following code in controller: class workflowscontroller < applicationcontroller # /workflows # /workflows.json def index @workflows = workflow.list respond_to |format| format.html # index.html.erb format.json { render json: @workflows } end end and modified module models\workflow.rb implement list method: class workflow def initialize ( id, name, url ) @id = id @name = name @url = url end def list () ret = array.new wf = hash.new vco = vco.new vco.getall.each |link| link['attributes'].each |attr| wf[ attr['name'] ] = attr[ 'value' ] end ret.push( self.new( wf[ 'id' ], wf[ 'name' ], wf[ 'itemhref' ] ) ) end return re...

asp.net mvc 2 - A first chance exception of type 'System.DirectoryServices.Protocols.LdapException' occurred in System.DirectoryServices.Protocols.dll -

i have asp.net mvc 2 application windows authentication enabled. till yesterday, working fine. today when hit f5, i'm getting exception. googled nothing helped. help? i able actual exception setting "break when exception is:" - checking "thrown" system.directoryservices.protocols in debug -> exceptions menu in vs 2010. error was, ad server not reachable , credential invalid.

arrays - C how to modify memory of structs that are inside other structs -

if have 2 structs: typedef struct{ unsigned int time; double rate; }quote; typedef struct{ unsigned int freeslots; unsigned int end; unsigned int start; unsigned int currsize; unsigned int maxsize; unsigned int startat; //unsigned int currindex; quote quotebuffer[1]; }cbuf; and wanted make function modify size of quotebuffer array inside cbuf, how go doing that? have tried few approaches none have worked far. keep returning same format of: quote *newquotebuffer = malloc(sizeof(quote) * newsize); and if have existing cbuf somewhere (for example, call "a" pointer cbuf): a->quotebuffer = newquotebuffer; but doesn't work. hints? this: quote quotebuffer[1]; should be: quote *quotebuffer; then assignment work. dereferencing quote looks this: a->quotebuffer->time; if later have multiple elements of quote allocated malloc() can access them this: a->quotebuffer[i].time;

ios - How to get UIImage from pixels in memory -

i have point of picture in memory, how uiimage? i tried 2 methods below , use "uiimagewritetosavedphotosalbum(myimage, self, nil, nil);" save image album, didn't work. how solve this? first: nsdata *imagedata = [[nsdata alloc]initwithbytes:texture->data length:picsize]; uiimage* myimage = [ [ uiimage alloc ]initwithdata:imagedata ]; second: cgdataproviderref provider = cgdataprovidercreatewithdata(null, texture->data, texture->image_size.width * texture->image_size.height * texture->bytesperpixel, null); // prep ingredients int bitspercomponent = 8; int bitsperpixel = 32; int bytesperrow = 4 * 320; cgcolorspaceref colorspaceref = cgcolorspacecreatedevicergb(); cgbitmapinfo bitmapinfo = kcgbitmapbyteorderdefault; cgcolorrenderingintent renderingintent = kcgrenderingintentdefault; // make cgimage cgimageref imageref = cgimagecreate(320, 480, bitspercomponent, bitsperpixel, bytesperrow, colorspaceref, bitmapinfo, provider, null, no, renderingin...

sql - Join two tables on a column mix with ids and space -

how write sql statement in sql server 2008r2 join 2 tables on column has space? getting error "error converting data type varchar numeric." e.g. table1 [id | value | t2id] 1 | | 1 2 | b | 3 | c | 2 table2 [id | value] 1 | d 2 | e 3 | f result [id | value | t2id | id | value] 1 | | 1 | 1 | d 2 | b | |null| null 3 | c | 2 | 2 | e it left join show values table1, t2id column has ids table2 , spaces. joining 2 tables directly gave me above error. thank you you can use following query - select * table1, table2 table1.t2id = table2.id , table1.t2id not null union select table1.*, null, null table1 table1.t2id null

opengl - how to do customized stencil test in fragment shader -

in project, used 'discard' call perform customized stencil test, tries draw things on specified area defined stencil texture. here code fragment shader: //get stencil value texture float value=texture2d( stenciltexture, gl_fragcoord.xy/1024.0).x; //check if value equals desired value, if not draw nothing if(abs(value-desiredvalue)>0.1) { discard; } this code works, suffers performance problem because of 'discard' call. there alternative way through gpu shaders? tell me how. if access texture, must suffer performance penalties associated accessing texture. in same way, if want stop fragment being rendered, must suffer performance penalties associated stopping fragments being rendered. this true regardless of how stop fragment. whether it's true stencil test, shader-based discard , or alpha testing, of these encounter same general performance issues (for hardware discard leads significant performance problems, mobile hardware). exception d...

java - New user creation notification mails are not going in Alfresco -

when admin creates new user account, email should go created user's mail id. how can enable this? can in "alfresco-global.properties", if yes, how? i don't think possible out of box. implement functionality java behavior. sure not interfere emails sent out when inviting external users though otherwise double emails. update after doing research: well, made decision not make notification option configurable in create user gui. have followed calls made gui down repository , ends calling java method documented this: /** * create person optionally generated user name. * version doesn't notify them. * */ which means have coding implement notifications in scenario.

perl - How can I get the calling method which inherit from other package -

i want calling method's name. try caller, works fine in cases. result not expected when method inherit parent package. following example: package caller; sub output_caller { #output calling method's name @stacks = caller(1); print $stacks[3]; } package foo; sub foo { caller::output_caller(); } package bar; use base 'foo'; bar->foo(); the output foo::foo which expected bar::foo is possible bar::foo? use carp qw(confess) gets close. return at c:\src_test\perl\testmost\callertest.pl line 11. foo::foo('bar') called @ c:\src_test\perl\testmost\callertest.pl line 18 foo::foo from modified script package caller; sub output_caller { #output calling method's name @stacks = caller(1); print $stacks[3]; } package foo; use carp qw(cluck); sub foo { cluck(); caller::output_caller(); } package bar; use base 'foo'; bar->foo();

objective c - Resize content of CPScrollView -

i have cpwindow. in it, have cpscrollview set 284px of width , 434px of height. this code show how fill out cpscrollview: for(var = 0; < 50; i++) { var supplie = [cparray arraywitharray:[[supplies objectatindex:0] componentsseparatedbystring:@"/"]]; var suppliebutton = [[cpbutton alloc] initwithframe:cgrectmake(0, (i * 30), 160, 25)]; [suppliebutton settitle:[supplie objectatindex:0]]; [[_scrollviewsupplies documentview] addsubview:suppliebutton]; [_listbsup addobject:suppliebutton]; } so problem 50 buttons added, can see 22 of them because cpscrollview don't resize itself.. i searched , found cpscrollview class need subclass (i'm not sure if it's better way) don't know how this.. please me ! :) thank reading ! edit: sorry, said hello @ top of post string "hello !" disappears when save post.. try [[_scrollviewsupplies documentview] setframesize:cgsizemake(284, 30 * 50 + ...

php - PHPExcel memory still exhausted even with cell caching - other solutions -

<b>fatal error</b>: allowed memory size of 134217728 bytes exhausted (tried allocate 78 bytes) in <b>/var/www/leanne/api/classes/phpexcel/cachedobjectstorage/phptemp.php</b> on line <b>66</b><br /> hi, i asked this question few days ago , advised change code , use cell caching. while have changed code , attempted use cell caching, still getting memory error. desperate find solution this. can advise on caching method best writing excel files ranging between 1 100,000 rows of data? if cell caching doesn't work, may need use solution allows me append xls file in same way csv version. an example of current code below: if ($count_prods > 0) { $format = strtolower($export_data['output']); $temp_file_location = '../temp/exports/products/'; $filename = 'data_' + $shop->id . '_' . $export_id . '_test'; $separator = ','; $endrow = "\n"; $fh = f...

python - Django Querying By a Set Relationship (Reverse) -

i have class called toy, in toys either animals or fruits. some example database, |name|type|pk| |jerry|cat|33| |scoobie|dog|52| |leslie|dog|73| |helen|strawbery|86| |mark|banana|16| when user selects 'animals', should output jerry, scoobie, leslie , if selects 'fruits' should output helen, mark . i need below mydict={'animal':'cat' or 'dog', 'fruits':'strawberry' or 'banana'} toy.objects.filter(type = mydict[input]) or mydict={'animal':['cat' ,'dog'], 'fruits':['strawberry' , 'banana']} toy.objects.filter(type in mydict[input]) of course not work, ideas how can proceed? without knowing how model looks like: toy.objects.filter(type__in=["dog", "cat"]) or toy.objects.filter(type__in=["strawberry", "banana"]) and thirdly (with toy types fruit or animal) toy.objects.filter(type__in=["dog", ...

Android App that communicate whith Skype -

i try developp android app answer automatically call skype. visited link http://dev.skype.com/skype-uri , helped me initaite call application. probleme faces me is: can't know if skype mobile sends out public broadcast on such events (which usual way programmatically notified of incoming messages). because tried listen events broadcastreceveir , didn't receive things skype. can me? thanks.

backbone views - List editor and events of its items editors -

i have simple model: var listitem = backbone.model.extend({ schema: { name: 'text', } }); and simple model has list inside: var configuration = backbone.model.extend({ schema: { list: { type: 'list', itemtype: 'nestedmodel', model: listitem } } }); and form: var form = new backbone.form({ model: configuration }).render(); i need listen events on listitem's "name" editor. when use this: form.on('all', function() { console.log('print something') }); i did not "name" editor. i've tried lot of other events names non of them working in case. how can listen change events on listitem's "name" editor?

jquery - Two Different Datepickers in the same page -

Image
i have problem displaying 2 datepickers on same page. 1 should displayed hidden body and other 1 should regular datepicker. to achieve first functionality this: $('.date-picker').datepicker( { changemonth: true, changeyear: true, showbuttonpanel: true, dateformat: 'mm yy' }); and using css hide body: .ui-datepicker-calendar { display: none !important; } but when want display second datepicker cannot overwrite css style. i tried $('.ui-datepicker-calendar').css('display', ''); i tried removing style attribute still no luck. $('.ui-datepicker-calendar').removeattr('style'); does has idea on how achieve this? thanks update: this fiddle of have right now i have reached acceptable solution using code: $('#startdate').focusin(function() { $('.ui-datepicker-calendar').hide(); }); $('#startdate').focusout(f...

scroll - How to put multiple style attributes in jquery -

this question has answer here: how define multiple css attributes in jquery? 10 answers $('#header').css('left', 200 - $this.scrollleft()); i need put multiple style attributes in above line. start , end part needs intact. please help. in advance. as explained in documentation , can pass object .css() function set styles multiple properties in single call. key name of property , value value set. example: $('#header').css({ "left" : 200 - $this.scrollleft(), "top" : 600 }); would set left value of 200 - $this.scrollleft() , , top 600.

java - ireport plug-in for netbeans doesn't export PDF or XLS? -

i using netbeans7.3. ireports4.7.1 plug-in my program connects database , retrieves 1 record should shown in report generated. and here code generate it: try { connection con= drivermanager.getconnection(host, uname, pword); file f1 = new file("report1spring.jrxml"); string path = f1.getabsolutepath(); jasperdesign jd = jrxmlloader.load(path); string sql = "select arabic , english, nit, cnumber, (select mail emails id ="+ vars.pronum +") email allinfo inner join allaccounts on allinfo.id=allaccounts.id allinfo.id ="+vars.pronum; jrdesignquery newquery = new jrdesignquery(); newquery.settext(sql); jd.setquery(newquery); jasperreport jasrep = jaspercompilemanager.compilereport(jd); jasperprint jasprint = jasperfillmanager.fillreport(jasrep, null , con); jasperviewer.viewreport(jasprint,false); } catch (sqlexception |...

how to understand below vim script entries? -

question 1: know bash script let var = value , how understand mean of below grammar under vim? let g:counter += 1 return g:counter . '. ' question 2: what’s means '<c-\>^>' , key sequence in vim? map '<c-\>^>' i want append question, please forgive me, the vim key map map <c-\>^] :gtagscursor<cr> i press key ctrl-\ shift-. , press ] doesn't work, what's matter? question 1: the 2 lines should in function . otherwise return doesn't make sense. also global variable g:counter should defined. then first line, same as: let g:counter = g:counter+1 so increment variable g:counter 1 . the 2nd line: return g:counter . '. ' for example, after increment, variable value 10, line returns string 10. (space) the first dot concatenates 2 strings. first string variable value, converted string type automatically. , second string '. ' question 2: map <c-\>^...

wpf - Difference between KeyEventArgs.systemKey and KeyEventArgs.Key -

whats difference between keyeventargs.systemkey , keyeventargs.key ? fine trap key press event in wpf usercontrol class shown below. protected override void onkeydown(keyeventargs e) { base.onkeydown(e); if(e.systemkey == key.leftalt || e.systemkey == key.leftctrl || e.systemkey == key.rightalt) { this.focus(); closeanyopenpopups(); } } thanks because alt key handled system using e.systemkey possibility find out if alt pressed. property key return key.system . to make sure right key use expression: key key = (e.key == key.system ? e.systemkey : e.key);

c# - jquery ajax when again post clear data -

i have 2 script apart schedule. var kisi; $('#detaildatepickerend').datepicker({ dateformat: 'dd mm yy', defaultdate: "+1w", changemonth: true, onselect: function (selecteddate) { var dt = $("#detaildatepickerend").val(); $("#loadingimage").show(); var resultid = $('#resultid').val(); var datebegin = $('#detaildatepicker').val(); var price=$('#detailrates option:first').val(); var result = $('#detailmaxguest option:selected').val(); if (result != "select one") { kisi= parseint(result); } else { kisi = null; } $.ajax({ url: '/product/getreservation', type: 'get', data: { 'lastdate': dt,'kisi':kisi,'resultid':resultid,'datebegin':datebegin,'price':price }, contenttype: '...

elasticsearch - NEST: How to handle array fields which contains a single value (Newtonsoft Json Serialization error) -

during evaluation of elasticsearch in combination nest faced new problem. problem regarding fields array types plus fact array types automatically supported in es. have field productids can contain 1 or n values. mapping defined following: […] "productids" : { "type" : " integer", "store" : "yes" }, […] if field contains couple of ids query result in es looks this: productids: [ 1, 2 ] the fact array types automatically, field looks if contains single value: productids: 1 this circumstances leads following problem: have nest-query mapped class. in class attribute productids defined list<int> (i tried integer array). works fine long there more single value. if field contains single value in es it’s saved primitive data type. leads error in newtonsoft.json: connection error. @ newtonsoft.json.serialization.jsonserializerinternalreader.ensuretype(jsonreader reader, obje...

Highcharts Pie chart return slice animation on mouseout -

i implementing animated pie chart in highcharts slices pull out on mouseover , apart issue on mouseout want slice return 'closed' position. this code animation , have cleartimeout on mouseout not returning slice original position. is there easy way of chart original position. i have fiddle here... http://jsfiddle.net/rupertito/y3wvn/1/ pie: { allowpointselect: true, stickytracking: false, point: { events: { legenditemclick: function() { return false; }, mouseover: function(event) { var point = this; if (!point.selected) { timeout = settimeout(function ...

c# - Building online shop using signalr, asp.net mvc, backbone.js -

i'm looking complex example (book, article, video training) of how can combine these tools , create shop application. i started developing online shop using examples a. freeman, s. sanderson book . i way shopping cart implemented in book. i've read amazing article represents stack & capabilities: signalr (+ web api ) allows clients notified changes made on server! questions i'm interested in are: what best way implement shopping cart? of course implementations may vary! know that. i need authoritative reference on this . there's no need consider sophisticated registration, shipping details, e-payement service in case. @ least now. how deal shopping cart , backbone views, models, routing ? haven't found information on it. things i've made backbone.js failed in ie 8 . haven't examined thoroughly yet. these things compatible @ all? have developed production sites using jquery mobile? worth switching zurb foundation/twitter bootstrap fra...

java - Good architecture for detecting Android device shake event? -

i need start activity in case of device shake in android application . this feature should work in whole app , in activities. now sure how provide architecture it, because detecting shake , starting activity needs context instance. i don't want pass current activity instance shakelistener each time change activity . what suggest? thanks. you would have to keep around monitors sensor data, background service . service must continuously monitor sensor events , pass through noise filter, detect shake , send out broadcast . the activity on other hand can implement matching broadcastreciever . if don't want add broadcastrecievers activities, can register interested activities in init() code of library: public void init(context context){ sensortester st = new sensortester(context); st.registeractivity(mainactivity.class); st.registeractivity(otheractivity.class); } and start them library service using context received in init() code...

scheme - Records search function -

i have problem medical database in scheme. want write function takes x symptoms , searches through database match diagnose. this i've done far: (define helper-match (lambda (ls) (reverse (let loop ([ls ls] [found '()] [acc '()]) (cond [(null? ls) acc] [(memq (car ls) found) (loop (cdr ls) found (if (memq (car ls) acc) acc (cons (car ls) acc)))] [else (loop (cdr ls) (cons (car ls) found) acc)]))))) above function check duplicates don't know how write compares database. the structure of database looks this: (define *medical-db-2* '((1 (disease (meningit) (symptom (fever) (headache) (vertigo) (vomiting) (stiffness) (light sensitivity)))) (2 (disease (encefalit) (symptom (fever) (headache) (vertigo) (vomiting) (disorientation) (cramps))))

ruby on rails - Most of my assets suddenly return 404 after a push to heroku -

Image
i have deployed app (rails 3.2.11) million times, haven't messed settings, i'm greeted this: why did happen out of blue? conents of application.rb include config.assets.enabled = true - never had issues. in fact running locally on port 3000 seems not have issues whatsoever. after deploying heroku morning, seems loads nothing that's inside /assets/ interestingly, after copying files on try , make new app, git commit results in stuff you'd expect long list of these think might related: edit: interestingly enough of assets have loaded, logo , background, rest can see return 404. i had problem today rails 4 on heroku. article provided @jeff little bit old but, the gem repository has readme. summarizing, need add 2 gems gemfile: gem 'rails_serve_static_assets' (it solve static assets problem) and gem 'rails_stdout_logging' (which previous 1 depends on).

Ajax function with location.reload acting weird -

i have function sends values db, function works great until include success function location.reload() . sends empty values.. though... works fine, should able rely on it. any suggestions? $.ajax({ url: 'core/manage_articles.php', type: 'post', data: { blog:title, title:title, text:text, lat:lat, lng:lng, success: function() { location.reload(); } } }); well... didn't lib using i'll go on semiwild guess (might not right): $.ajax({ url: 'core/manage_articles.php', type: 'post', data: { blog:title, title:title, text:text, lat:lat, lng:lng }, success: function() { location.reload(); } } }); try this.

ssh - Dynamic application-level port forwarding with SOCKS using paramiko library in python -

i'm trying connect ssh server in following way: import paramiko import socks sock = socks.socksocket() sock.setproxy(socks.proxy_type_socks5, 'localhost', 22, true) sock.connect((**ip address of ssh server**, 22)) t = paramiko.transport(sock) t.connect( none, 'username', 'password') and following error > traceback (most recent call last): ... > sock.connect((**ip address of ssh server**, 22)) file "c:\python27\lib\site-packages\socks.py", line 368, in connect > _orgsocket.connect(self,(self.__proxy[1],portnum)) file "c:\python27\lib\socket.py", line 224, in meth > return getattr(self._sock,name)(*args) socket.error: [errno 10061] no connection made because target machi ne actively > refused my goal simulate putty's way in creating ssh socks proxy here: configure putty create ssh socks proxy secure browsing . or equivalent ssh -d [localhost]port for local dynamic application-level port...

uninitialized constant Rails (NameError) in Rails 3.213 -

when attempt visit rails site working or attempt run rake following error uninitialized constant rails (nameerror) /path/config/boot.rb:4:in `<top (required)>' /path/config/environment.rb:11:in `require' /path/config/environment.rb:11:in `<top (required)>' here line 4 of boot file rails.root = "#{file.dirname(__file__)}/.." unless defined?(rails.root) and line 11 of enviroment file require file.join(file.dirname(__file__), 'boot') the error seems that when call rails.root, perceives rails somehow uninitialized. ideas? if more info needed let me know. thank in advance try updating rubygems gem update --system . looks there issues , fixed in recent versions. if not works after adding: gem install bundler and after adding: gem 'bundler' in line 2 in config/boot.rb (just after require 'rubygems' ) please let me know

java - Validating numeric sequence -

i using java , need validate numeric sequence this: 9999/9999 . i tried using regex \\d{4}\\\\d{4} , getting false matches() . my code: pattern regex = pattern.compile("\\d{4}\\\\d{4}"); if (!regex.matcher(mysequence).matches()) { system.out.println("invalid"); } else { system.out.println("valid"); } can me, please? the regex pattern attempting match backslash rather forward slash character. need use: pattern regex = pattern.compile("\\d{4}/\\d{4}")

xml - XDocument.Save(string) not available -

i'm using vs 2012 express windows 8.i want load xml file, modify content , save disk. up now, i've been using linq xml , i've been able load file, change node information. i want save file disk using xdocument.save(string) method intellisense not include method though documented in online documentation. any idea why? thanks ---update--- here's i'm trying do string questionsxmlpath; xdocument xmldocquestions = null; storagefile file = null; public mainpage() { this.initializecomponent(); questionsxmlpath = path.combine(package.current.installedlocation.path, "assets/template.xml"); xmldocquestions = xdocument.load(questionsxmlpath); } private async void somecodeheretopopulatecontrols() { // code populates controls on window edit xml nodes. } private async void button_click_3(object sender, routedeventargs e) { xelement elequestion = (from el in xmldocquestions.descendants("question") (stri...

.net - FtpWebRequest/FtpWebResponse : connection is successful even if a bad password is provided after a successful connection -

i'm testing ftp connection user/password provided user. everything work fine if run unit tests independently. if try ordered test, running ftp_test_sucessful before ftp_test_unsuccessful , ftp_test_unsuccessful test fail : ftp connection successful if provide bad password after successful connection. passed unit test ftp_test_unsuccessful 00:00:02.3566157 passed unit test ftp_test_sucessful 00:00:00.3048244 failed unit test ftp_test_unsuccessful 00:00:00.2696941 not executed unit test ftp_test_sucessful 00:00:00 how "reset" ftp connection ftp_test_unsuccessful test connection correctly. here's unit tests : '''<summary> '''basic unsuccessful ftp test '''</summary> <testmethod()> public sub ftp_test_unsuccessful() _testsettings.ftpenabled = true _testsettings.changeftpcredentials("user", "badpasword") ...

asp.net mvc - Prevent MVC form submit using Javascript Function -

i have upload.ascx in project. loaded inside jquery popup. the upload.ascx contains file upload control. file upload control uploads .xlsx , .xls files. have added java script function validation (to prevent unnecessary files uploaded). onchange of fileupload control , onclick of submit button same validation function called. the file upload validation function working both calling. if user clicks submit button same function getting called , working fine. my problem is: in validation function have written return false . after displaying alert message, page getting redirected url ( localhost/admin/authorization/acceptfile.aspx ). acceptfile actionresult name. should not happen. function returning false. form getting redirected above url why.? i have kept debugger in action result not getting called if wrong file(its correct). if correct file index file loaded success message(action result getting called , working fine). . i suspect mvc form. if wrong file upload...

Unifying python dicts? -

does anone have fair algorithm unifying (almost) arbitrary dicts? is, given dicts a = {1: 1, 2: 2, 3: [1,2,3]} b = {4: 4, 3: [5], 5: {'a': 0, 'b': {}} c = {3: [{'a': '0'}], 5: {'b': {'b': 1}}} unify (a, b, c) yields {1: 1, 2: 2, 3: [1, 2, 3, 5, {'a': '0'}], 4: 4, 5: {'a': 0, 'b': {'b': 1}} } i keep wanting generic solution. wind searching generic solution couple of times year , not finding 1 ( no google, unify unification , unify union not same word! ), , keep putting off writing 1 myself. know programming prolog leads odd pespective on life, hey, how can 1 have recursive dict/key/value-store , not have unification? i have in past needed ordering, hence lists, , wound not going generic version hardcoding. time around don't need unification of sets/lists @ all, , fall once again hardcode know keys can ahead of time. but: if there generic solution out there, wouldn't...