Posts

Showing posts from July, 2013

java - Thread is blocked when use restTemplate -

i encounter problem threads of app has locked/blocked when communicate remote server using spring's resttemplate. here jstack info of 1 blocked thread: "pool-1-thread-8" prio=10 tid=0x00007fbfd012d800 nid=0x27b1 runnable [0x00007fbfd7dfb000] java.lang.thread.state: runnable @ java.net.socketinputstream.socketread0(native method) @ java.net.socketinputstream.read(socketinputstream.java:129) @ java.io.bufferedinputstream.fill(bufferedinputstream.java:218) @ java.io.bufferedinputstream.read1(bufferedinputstream.java:258) @ java.io.bufferedinputstream.read(bufferedinputstream.java:317) - locked <0x00007fbfe40fe1f8> (a java.io.bufferedinputstream) @ sun.net.www.http.httpclient.parsehttpheader(httpclient.java:687) @ sun.net.www.http.httpclient.parsehttp(httpclient.java:632) @ sun.net.www.protocol.http.httpurlconnection.getinputstream(httpurlconnection.java:1072) - locked <0x00007

Connection time out installing mysql server in unix -

i trying install mysql server in aws ec2 instance. googled , executed below command in shell. sudo yum install mysql-server it throws below connection timed out exception loaded plugins: priorities, update-motd, upgrade-helper http://packages.us-west- 2.amazonaws.com/2014.03/main/201403504e47/x86_64/repodata/repomd.xml?instance_id=i-c82c93c3&region=us-west-2: [errno 12] timeout on http://packages.us-west-2.amazonaws.com/2014.03/main/201403504e47/x86_64/repodata/repomd.xml?instance_id=i-c82c93c3&region=us-west-2: (28, 'connection timed out after 10001 milliseconds') trying other mirror. is right way install mysql server? thanks. installing mysql from current aws ec2 documentation : to install , start lamp web server connect instance. to ensure of software packages date, perform quick software update on instance. process may take few minutes, important make sure have latest security updates , bug fixes. note -y option ins

Android Studio gradle doesn't compile the specified version -

i've been developing small project days today, android studio started give me error error:execution failed task ':app:processdebugmanifest'. > manifest merger failed : uses-sdk:minsdkversion 14 cannot smaller version 14 declared in library com.android.support:support-v4:21.0.0-rc1 i understood because it's trying compile library of android-l. version want compile old version won't. keeps giving me above error no matter version enter. here dependencies. dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:20.+' compile 'com.android.support:support-v4:20.+' } update i installed android studio beta , changed dependencies 1 eugen suggested below. syncing project gives same error no matter version of appcompat, support version specify. gives error every single time sync uses-sdk:minsdkversion 14 cannot smaller version l declared in library com.android.supp

c++ - Convert the contents of a UILabel to an image and save it to disk -

i have project need lot of individual words , phrases converted graphic format - preferably transparent png. my thought load each word/phrase text file 1 @ time, put uilabel , grab contents of uilabel graphic , write png file. problem i'm not sure how graphic part. ideally, uilabel resize right fit contents, don't end clipped words or lots of blank space. can point me in right direction? don't objective-c i've got 25 years of c++. thanks, lindsay just add label on self.view , call method. method save image in photoalbum, , wil return image created, can use it. hope have searched for. - (uiimage *)createimagewithlabel { uigraphicsbeginimagecontextwithoptions(self.view.frame.size, self.view.opaque, 0); [self.view.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *image = uigraphicsgetimagefromcurrentimagecontext(); uiimagewritetosavedphotosalbum(image, nil, nil, nil); uigraphicsendimagecontext(); // _iv.ima

javascript - Apache Cordova multiple activity -

i new apache cordova.we planning build hybrid html5 application . know network current user using (3g / 2g / wifi) . have tried javascript api code mentioned in apache cordova site seems not working ( https://cordova.apache.org/docs/en/3.0.0/cordova_connection_connection.md.html ). looking @ creating activity cordova support multiple activity ? . regards aravind

java - EasyMock: How to test this method -

i new development environment in java , want understand how write ut kind of method in java using easymock. public class myclass{ public classb classbobj; public int mymethod(someclass someclassobj){ classa obja = new classa(); obja.addparam(classbobj); classc classcobj = obja.getclasscobj(classbobj); return someclassobj.getresult(classcobj); } } i can create mocks of someclass, classb how mock behavior of classa , classc ? want define behaviour of classa i.e., "addparam" , " getclasscobj" . how can ? i need test "mymethod" of "myclass" thanks. because classa object instantiated within method, you're not going able mock easymock. if you're happy not mock classa object, can add expectations needed mocked instance of classb , use capture check classc object has been built expected. so test this: import static org.hamcrest.corematchers.is; import static org.junit.assert.assertthat;

ios - PhoneGap iPhone app installer -

i'm developing cross-platform iphone (ios) application using phonegap . one of clients, want test it, not living in town, , i'd give him installer can test program. i've added phone in apple dev center, don't know how create installer. is possible? i have been developing cross platform app using appcelerator , have been sharing test builds client using tesflight. the method of sharing simple creating account, uploading ipa, selecting device id of client he/she may install on device. once done, can either invite client sign , download app or share download link.. hope helps.

bash - Testing empty variables -

i have large number of variables in script, , want script error out if 1 of variables empty. i know can: if [[ -z "$var_1" ]] || [[ -z "$var_2" ]] || ... [[ -z "$var_n" ]]; # failure message fi however, cannot inform user variable empty if in way. there alternative approach above can inform user empty variable? #!/bin/sh foo=(var_1 var_2 var_n) bar in ${foo[*]} if [[ ! ${!bar} ]] echo $bar empty fi done

hadoop - Read default block size of HDFS using Java API -

i want read default block size value hdfs-site.xml using java program ? can in ? <property> <name>dfs.blocksize</name> <value>134217728</value> </property> you can try using get method of configuration parameter (or other). first need add resource, did in comment posted, , parameter: configuration conf = getconf(); conf.addresource(new path("/etc/hadoop/conf/hdfs-site.xml")); system.out.println(conf.get("dfs.blocksize")); hope helps.

ios - How to conform to an objective c protocol in an existing .h file in Swift? -

i trying recreate ray wenderlich tutorial in swift, using both swift , objective c. main part (i.e. view controllers , models) done in swift , using bridging header existing .h , .m classes. i having trouble trying swift view controller conform obj-c delegate. in .h file have: @class rwtrateview; @protocol rwtrateviewdelegate - (void)rateview:(rwtrateview *)rateview ratingdidchange:(float)rating; @end @interface rwtrateview : uiview ... @property (assign) id <rwtrateviewdelegate> delegate; @end in swift file have: class detailviewcontroller: uiviewcontroller, uitextfielddelegate, rwtrateviewdelegate, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate { @iboutlet var rateview : rwtrateview ... func configureview() { // update user interface detail item. if let detail:rwtscarybugdoc = self.detailitem as? rwtscarybugdoc { if let rv = self.rateview { rv.notselectedimage = uiimage(named: &qu

javascript - Where is "by" declared in the protractor source? -

in following code snippet: element(by.id('mydiv')); the element declared in line 740 in this source. couldn't identify by declared. variable declared? if not declared anywhere, how variable resolved? reading source, by "locator" , this source maybe related it. couldn't see source declaration of by variable. by defined webdriver.js , extended in protractor specific angular locators by.model . locators in webdriver.js defined in this file . the extension in protractor defined here .

c++ - Blocking signals on disabled widgets in Qt -

i have combo disabled, adding element emit currentindexchanged(int) signal. i expected signals naturally turned off when widget disabled, it's not case. know there blocksignals(bool) , if there many widgets signals must "blocked when disabled", blocksignals require boolean state each widget. how can disable signals sent widget when disabled (and not alter blocksignals state)? edit clarify: since widget, user cannot interact when it's disabled, but signals emitted when altering widget programmatically. in case there 2 interesting signals: currentindexchanged(int) , activated(int) the problem in code alter combo programmatically , wish emit signal, , it's user alters combo interacting. that's why using currentindexchanged , not activated . in both cases, anyway, don't want signals emitted when widget disabled. the qcombobox signals user interaction based end user point of view if have qcombobox , nothing else question seems imp

php - How to include a file in shortcode function in wordpress -

i want make shortcode , in shortcode want require file. when user write shortcode in editor. output show required file layout. i make shortcode not working, here shortdoe code: <?php function inner_page( $atts, $content = null ){ $return_string = require 'foo/foo_artilces_list.php'; return $return_string; } add_action('init', 'register_section_shortcodes'); function register_section_shortcodes(){ add_shortcode('inner_page', 'inner_page'); } ?> here require file code <?php /*========= template name: kbe =========*/ get_header(); ?> <div id="foo_container"> <h1><?php the_title(); ?></h1> <!--breadcrum--> <?php if(foo_breadcrumbs_setting == 1){ ?> <div class="foo_breadcrum"> <?php echo foo_breadcrumbs(); ?> </div> <?php } ?>

font awesome - Where is the .htaccess on OVH server? -

so, have website hosted on ovh , icons of font awesome not displaying on firefox. upon research, have found there simple way solve this . however, here's problem : site hosted on ovh server, , not able find .htaccess file. went through files cyberduck (on mac) in www directory on server, , have not been able find file add code.

Meteor - Iron Router : {{>yield}} is not working -

my problem that: 1- "{{>yield}}" not working properly. when remove "{{>yield}}" template, template shows properly. if place "{{>yield}}" in template, empty body tag displayed. 2- if remove "{{>adlayout}}" body tag, empty body tag displayed. i have following template code : <head> <title>my metronic</title> <meta charset="utf-8"/> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta content="width=device-width, initial-scale=1.0" name="viewport"/> <meta content="good description" name="description"/> <meta content="dave alex" name="author"/> <!-- begin global mandatory styles --> <link href="http://fonts.googleapis.com/css?family=open+sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css"/&g

ios - Streaming multiple music with AVPlayer -

Image
i have app want make requires streaming audio files web server. use avplayer player. problem is, responses receiving server has 2 audio files on it. , makes streaming hard. audio player ui way this: i have slider streamed time ranges (the black one) , slider avplayer.currenttime . have 2 audio music streamed , music durations added 8:46. first music has 6 minutes duration , second music has 1:46. can see in above photo, streamed time ranges slider indicates avasset has streamed first music. problem is, can't continue streaming , playing next music when first 1 has reached it's end. stop , slider value gets 0. what want accomplish when first item has reached end, avplayer load player item , second music. continue play , slider continue move. is possible? suggestions? experts. to load audio files 1 after other, can use avqueueplayer. nsurl *song1 = [nsurl urlwithstring:@"audio url1"]; nsurl *song2 = [nsurl urlwithstring:@"audio url2&quo

java - JMS Message Selector doesn't work in Multi-Server Environment -

i've implemented spring jms hornetq. works if 1 app-server hornetq. if 2 app servers accessing hornetq. doesn't work. inorder identify different server i've introduced clientid, still doesn't work. here flow. prepare message send clientid(unique serverid sending message) correlation id , send horentq quename 'q1' producercallback , wait response. request.setstringproperty("clientid", clientid); request.setjmscorrelationid(correlationid); in consumder side i've defaultmessagelistenercontainer listening queue q1. once message received process , set correlaionid , clientid in response object , send q 'q2' final string clientid = request.getstringproperty("clientid"); final string correlationid = request.getjmscorrelationid(); response.setjmscorrelationid(correlationid); response.setstringproperty("clientid", clientid); in sender side i've defaultmessagelistenercontainer listening q2. message selector se

c# - Struct parameters in attributes -

i have got following sample code: public struct testdata { public readonly string element; public readonly bool mandatoryind; public testdata( string element, bool mandatoryind ) { element = element; mandatoryind = mandatoryind; } } [attributeusage( attributetargets.class, allowmultiple = false )] public class test : attribute { public testdata[] values { get; set; } public test( params testdata[] values ) { this.values = values; } } what want this: [test( "3477", true, "3286", true, "3286", false )] public class testclass { } basically, i'd pair of parameters (string, bool) captured in testdata() struct, not sure if it's possible this. have tried following, compile error "an attribute argument must constant expression, typeof expression or array creation expression of attribute parameter type". [test( new testdata("3477", true), new testdata("3

android - GCC_PHAT output -

i trying develop gcc_phat algorithm on android devices. fft used this library . idea correlate 2 audio files (16-bit pcm mono) find delay between them. matlab works perfectly. first problem fft output, gives numbers higher 32768 . example: fft re -20830.895138576154 fft re -30639.569794501647 fft re -49850.48597621472 fft re -49335.28275604235 fft re -96060.94916529073 fft re -91409.17426504416 fft re -226903.051428709 is there way normalize these numbers interval of [-1,1]? the library's forward transform definition match matlab 's, should matching values after forward transform (not critical since g_phat normalized [-1,1]). however, same cannot said of inverse transform . indeed code comments on inversetransform : this transform not perform scaling, inverse not true inverse. and library webpage: this fft not perform scaling. vector of length n , after performing transform , inverse transform on it, result original vector multi

c# - How to set and get tag in xaml dynamically? -

while creating gui using xaml, created textbox tag this: <textbox name="textbox" horizontalalignment="center" verticalalignment="center" margin="216,178,143,120" width="158" tag="mytag"/> now want let user able change tag. that, looking kind of function of form: textbox.settag( "user provided tag" ) so tag can changed one: <textbox name="textbox" horizontalalignment="center" verticalalignment="center" margin="216,178,143,120" width="158" tag="user provided tag"/> after searching internet quite while, didn't come practical solution. help? thanks. you can use binding between 2 controls. user allowed enter tag value textbox . bind tag of second textbox text property of first textbox : <textbox name="entertagtextbox" /> <textbox name="gettagtextbox" tag="{

objective c - Doing math with NSExpression using parenthsis -

i haven nsstring @"200 * (1 + (5 / 100))" , when put nsexpression *expression = [nsexpression expressionwithformat:mystring]; and nslog expression returns string. when call [[expression expressionvaluewithobject:nil context:nil] doublevalue] result of 200 . can nsexpression not handle 2 sets of parenthesis? solution using nsexpression - don't want use of mathlibraries, because have simple math equations. thanks of course can handle 2 sets of brackets, problem in types of values. when write 200 * (1 + (5 / 100)) these values treated integers, , integer arithmetic used. means 5 / 100 evaluates 0 , that's why 200 result. if 5.0 / 100 (notice decimal point), you'd getting right result, division treated float division.

android - ADT wont update to 23 because of dependency conflict -

i starting android dev , launching adt first time after installing past apis sdk manager (down 2.2 froyo) , error telling me update, when checks update says no new updates. moreover when try manually install new adt https://dl-ssl.google.com/android/eclipse/ dependency conflict error. also when download fresh adt google seems regular juno eclipse no adroid stuff set up, no adt splash screen or anything... i can't proceed learn android if cant use ide because needs update adt version wont install. i have tried manually downloading adt v23 , same error occurs, deleted adt 22 related stuff in plugins of eclipse directory , somehow still occurs came across same issue. hence, deleted old eclipse cum android sdk bundle , installed new bundle (eclipse juno & android) click here download. working fine now. workspace in different directory, noting happens project.

Android EditText : How to avoid user enter smileys? -

Image
i avoid user put smiley keyboard edittext . possible ? you can define input type , accept letters or change keyboard type: https://developer.android.com/training/keyboard-input/style.html or can accept specific digits: how create edittext accepts alphabets in android?

php - Laravel 4.2 : File in a form not working -

i have problem getting file form laravel 4.2. have form declared : {{ form::open(array('url' => 'app/add-file', 'files' => true)) }} {{ form::file('file')}} <button type="submit">confirmer</button> {{ form::close() }} and try show result in controller @ moment. array empty. return var_dump(input::file()); when analyzed post request in chrome, see content type in headers content-type:application/x-www-form-urlencoded; charset=utf-8 maybe problem, form declared enctype multipart/form-data any idea ? thanks i found problem. using jquery mobile , there problem. ajax must disabled form otherwise not working files. did that {{ form::open(array('url' => 'app/add-expense', 'files' => true, 'data-ajax' => 'false')) }}

c - When terminating a process is it possible to delete a file? -

i need write windows c application creates file, , file needs deleted when application terminated(both in case of graceful termination or forced kill). one more requirement user should able open file in read-only mode(may using notepad). read in java(i.e documentbuilder::parse) i have written following code handle hfile = createfile("d:\\test.xml", generic_write, file_share_read, null, create_always, file_flag_delete_on_close, null); when open file(i.e test.xml) in notepad.exe, error saying "the process cannot access file because being used process". however, following code works fine handle hfile = createfile("d:\\test.xml", generic_write, file_share_read,

java - JSON validation is not happening -

i facing problem in json validation. code using import net.sf.json.jsonexception; import net.sf.json.jsonobject; string stringtovalidate="{'customer':[{'condition':'matches','value':'nordstrom,nordstromrack,neimanmarcus,neimanmarcuslastcall,tjmaxx,macys,dsw,saksfifthavenue,off5th,bananarepublic,jcrew,bloomingdales'}],'notcustomer':[{'condition':'matches','value':'neimanmarcuslastcall'}],'daterange':[{'condition':'in last','value':'6 months'}]}"; try { system.out.println(stringtovalidate); jsonobject.fromobject(stringtovalidate); /* try { map<string, object> tsmap = new json2java().getmap(stringtovalidate); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); return fals

ctypes - How to correctly load a Windows COM DLL in Python -

i trying load windows com dll in python exposed interfaces. using dependency walker tool can list functions in dll. see 4 functions: dllcanunloadnow dllgetclassobject dllregisterserver dllunregisterserver if understood correctly, need object of class using dllgetclassobject() , use exposed interfaces. i using pythoncom , win32com.client extract object (got recipe stackoverflow post ) import pythoncom import win32com.client def createinstancefromdll(dll, clsid_class, iid_interface=pythoncom.iid_idispatch, punkouter=none, dwclscontext=pythoncom.clsctx_server): uuid import uuid ctypes import oledll, c_long, byref e = oledll(dll) print (e) #print (e.dllregisterserver()) clsid_class = uuid(clsid_class).bytes_le iclassfactory = uuid(str(pythoncom.iid_iclassfactory)).bytes_le com_classfactory = c_long(0) hr = e.dllgetclassobject(clsid_class, iclassfactory, byref(com_classfactory)) myfactory = pythoncom.objectfromaddress(com_classfactory.value, pythoncom.iid_iclassfactor

javascript - In JQuery, what's the best way to get a data attribute of a set of nodes into an array? -

in jquery, what's best way data attribute of set of nodes array? i got syntax working: var ids = $("a.some_class").map(function(index, item) {return item.getattribute('data-id');}); is there simpler syntax this? thank you there nothing easier map approach but, data method get things in cross browser way , return pure javascript array: var data = $('a.some_class').map(function() { return $(this).data('id'); }).get();

twitter bootstrap - How to close popovers on modal close? -

i want close popovers in modal, not displayed if reopen modal. the problem if try close @ $("#modal").on("hidden", function() { [...] }); , targets unavailable. same goes if @ .on("shown", ... . i cannot delete using : $(".buttonpopover").popover("hide"); because .buttonpopover never available @ time want delete popovers. how can close them without accessing parent ? bootply the problem if try close @ .on("hidden") , targets unavailable that's because hidden.bs.modal event fires: "when modal has finished being hidden user (will wait css transitions complete)." instead, use hide.bs.modal event which: " fired when hide instance method has been called" like this: $('.modal').on('hide.bs.modal', function() { $("#openpopover").popover("hide") }); demo in bootply update i'm curious if you're hidden event f

delphi - How to enumerate MSSQL Servers from a 64-bit client app? -

i'm looking way of enumerating ms sql servers on local network 64-bit delphi application. method i've used far on 32-bit works fine contains assembly code won't compile on 32-bit. can't seem find way of enumerating servers 64-bit client. the code cannot compile this: function ptcreateadoobject(const classid: tguid): iunknown; var status: hresult; fpucontrolword: word; begin asm fnstcw fpucontrolword end; status := cocreateinstance( class_recordset, nil, clsctx_inproc_server or clsctx_local_server, iunknown, result); asm fnclex fldcw fpucontrolword end; olecheck(status); end; example here adopted x64, compatible both, x32/x64 systems. uses activex, comobj, oledb, db, adoint, adodb; function createadoobject(const classid: tguid): iunknown; var status: hresult; {$ifdef cpux86} fpucontrolword: word; {$endif cpux86} begin {$ifdef cpux86} asm f

java - SXSSF generated corrupted report in Z/OS on applying cell Style -

i trying execute program in z-os machine write excel report. due size of report, using sxssfworkbook write report. one of cells in report grey in color. have apply color cell. used following code set color. xssfcellstyle cellstyle = (xssfcellstyle) wb.createcellstyle(); xssfcolor mycolor = new xssfcolor(datatypeconverter .parsehexbinary("ffbfbfbf")); //also tried java.awt.color cellstyle.setfillforegroundcolor(mycolor); cell.setcellstyle(cellstyle); but report generated, cell dark in color. out of curiosity, checked styles.xml inside excel document. following found. <fill><patternfill patterntype="solid"><fgcolor rgb="ããâãâãâã"/></patternfill></fill> i tried generate same report in windows machine, , gave me correct result. <fill><patternfill patterntype="solid"><fgcolor rgb="ffbfbfbf"/></patternfill> can me resolve issue? ---------------------- edited ---

visual studio 2010 to follow strict OOP rules -

i trying learn coding follow strict oop concepts , best practices while writing program. there feature/option in vs2010 can allow best programing practice else give error?? thanks in advance not helps there can do. in solution explorer right click project , select properties, there tab named "compile". there can edit warning , errors options. there "option strict" property, make sure change "on". , below there list can specify warning configurations. change of them "warning" or "error" i hope you. luck learning.

Split row into Multiple Rows in stored procedure in sql server 2008 -

i want split rows multiple rows based on value of column.for example if have working hrs 1 8 in 1 row want split in 2 rows 1 one 4 , other 4 8 table follows- hrs end name class 1 8 s 3 i want divide like hrs end name class 1 4 s 1 4 8 s 2 please reply you can use following concept split 1 row 2 rows select 1 hrs, 4 end , name, 1 class thetable class=3 union select 4 hrs, 8 end, name, 2 class thetable class=3 of course need parameterize class , other values.

Android - How to add footer from xml layout to a custom activity to display it in all activities? -

i want create custom activity display footer activities extend it. have created xml layout called footer.xml how add custom activity ? public class customactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //what should add footer there ? } } include footer.xml in other activities above other items in layout . or create main activity , hold footer.xml , view , added fragments (replace activities fragments )

unity3d - 2D camera positioning in Unity -

i'm writing 2d game in unity , force orthogonal camera's view frustum altered on right-hand side according device's aspect ratio, left/bottom being set 0,0 i.e.: i'd bounds of camera's y frustum to 0 @ bottom , 10 @ top. easy , i've done moving camera's position 5 , setting camera size 5 (i'm presuming has worked). (also, there's no real reason why i've gone 10, seems round number...) when scene starts i'd move camera's x frustum left 0 , right whatever aspect ratio demands: somewhere between 4:3 , 16:9 depending on device. pretty mean setting camera's x translation presume, i'm touch lost on how aspect ratio, , calculate should be? ...and here's answer: vector3 pos = new vector3(5.0f * camera.main.aspect, 5.0f, -10.0f); camera.main.gameobject.transform.position = pos; which popped main.cs script, under start() function. 5.0f half height of 2d camera'a othrogonalsize (as mentioned in question abov

JAVA - Active directory and ldap password properties -

i'm using program adds correctly user ad using ldap protocol. noticed there properties password. there userpassoword stores password in clear , unicodepwd accepts encoded pwd. i'm working in project lot of users created admin in ad, using windows server administration tool. suprise me more, these users have password , app workws fine login...but both properties empty! so, password? java have add passwords in same way, cannot figure out how approach problem, because don't know users' password stored. ideas? you cannot read password ad. there special logic in directory handle writes attributes, but, there no read capability. appear null.

python - Django form to update an object doesn't keep files -

so i'm working on portfolio site, , i've got form called work represents works in portfolio. work has m2m field normal images, , 1 imagefield main image used thumbnails etc. my problem following, when go update view created work, old image (that in database) listed in form, no in field itself. says current: [name of image], , regular filefield label edit . i don't want user able update work if upload image again. how pass current image form? #models.py class work(models.model): name = models.charfield(max_length=255) image = models.imagefield( upload_to="images" ) #forms.py class meta: model = work exclude = ('slug',) #views.py def workedit(request, pk): if request.method == "post": form = workform(request.post, request.files) if form.is_valid(): new_work = form.save(commit=true) return redirect("/portfolio/beheer/werk") else: print(form) prin

How to get desired results in mysql query? -

i use query fetch: customername tblcustomers sum of transactionamount tbltransactions against each customer select a.customerid, sum(transactionamount) transactionamount ,b.customername tbltransactions join tblcustomers b using (customerid) group a.customerid order b.customername the coloumn transactionamount in tbltransactions contains positive values customer purchases , negative values customer payments. how expression in query min(transactionamount) < 0 each customer ? edit: min(transactionamount) < 0 gives me maximum amount paid far each customer you can using conditional aggregation: select a.customerid, sum(transactionamount) transactionamount, b.customername, min(case when transactionamount < 0 transactionamount end) biggestpayment tbltransactions join tblcustomers b using (customerid) group a.customerid order b.customername; note smallest value less 0 minimum not maximum. edit: in case, find latest payment date using

node.js - sails js and postgres database with few diffrent schemas and same table names in diffrent schemas -

i've encountered huge problem sails , sails-postgresql. im using sails v 0.10.0-rc8 , sails-postgresql v 0.10.0-rc4 i have postgres database few diffrent schemas diffrent applications. these schemas contains tables same name example: schema test has table uzytkownicy (users) , schema webapp has table uzytkownicy diffrent attributes. somehow sails sails-postgresql join tables same name schemas 1 huge table (which dont exists in database) , throw errors when im trying data table defined in model. example: my model definition: module.exports = { adapter: 'postgresql_app', tablename: 'uzytkownicy', migrate: 'safe', autopk: false, autocreatedat: false, autoupdatedat: false, meta: { schemaname: 'webapp' }, attributes: { id_uzytkownicy: { type: 'integer', index: true, primarykey: true }, id_role: { model: 'role' }, imie: { type: 's

javascript - When hovered over the Foundation Jquery menu (without dropdowns) a white patch appears -

Image
i used foundation top bar create menu. none of elements have drop downs. if hover on item leave behind white patch : this happens in google chrome. when tried in firefox works fine! how rid of patch? here's link live website : http://secret-temple-3539.herokuapp.com/ the css file : @import "compass"; $top-bar-color: rgba(17, 17, 17, 0.2); body{ font-family: 'comfortaa', cursive !important; } .top-bar-section{ a{ font-family: 'comfortaa', cursive !important; background: transparent !important; @include transition-property(all); @include transition-duration(0.3s); @include transition-timing-function(ease-in); &:hover{ background: none repeat scroll 0 0 rgba(17, 17, 17, 0.2) !important; @include border-radius(50px); color: #ffffff !important; } } } .top-bar{

How does polymer react to internal content -

i experimenting polymer see if can build mobile version of application have developed in php/mootools what want achieve single page application, when starts puts single image splash screen, whilst in background validates user logged in member of smf forum. if fails validate, redirect login url. thinking body of index.html page contain this <body> <forum-auth forumurl="/forum/authorize.php" login_url="/login" splash="background.png"> ... lots of content further polymer elements access global variables {{token}} , {{user}} gets returned successful logon. token jwt , user object application specific. </forum-auth> the polymer element definition go this <template> <div id="splash" class="show-splash-screen"> <img src="{{splash}} /> </div> <core-ajax url="{{forumurl}} handleas="json" on-core-response={{handlere

c# - How to make DateTime field nullable in Local SQL db -

Image
i'm working on asp.net mvc 4 project , i'm facing problem caused local data base. have few tables in there, in 1 of them have "datetime" type field. want field not required, have set "allow nulls" option in table's designer view "true". added data in table, in fact didn't enter values in "datetime" field. when run app , try open view data table should appear error: "the 'datefrom' property on 'person' not set 'null' value. must set property non-null value of type 'datetime'" could me issue? ps: i'm using visualstudio 2012 ultimate , programming in c# i created db code-first method: here class of person: using system; using system.collections.generic; using system.linq; using system.web; using system.componentmodel.dataannotations; namespace personuregistrs.models { public class persona { [key] [required] public i

activerecord - Rails 3: has_many and where -

i have following models class city < activerecord::base has_many :dealers end class dealer < activerecord::base belongs_to :city end i need find cities have dealers. how go writing where() desired results? to find cities have dealers: city.joins(:dealers) if city has no dealers not returned in results.

c# - Merge and Renumber Pages with ITextSharp -

we trying merge 2 page numbered pdfs new pdf. want have new pdf start page number 1 e.g. pdf pages sorted 1,2,3,4,5 pdf pages sorted 1,2,3,4,5 merged pdf should have page number 1,2,3,4,5,6,7,8,9,10 , other old page labels should not seen on newly merged pdf. this our sample code labels not showing on page. string output_file = "~/output/output.pdf"; document document = new document(); using (var inputpdfstream = new filestream(@"c:\test.pdf", filemode.open)) { pdfreader reader = new pdfreader(inputpdfstream); pdfreader.unethicalreading = true; using (pdfwriter writer = pdfwriter.getinstance(document, new filestream(server.mappath(output_file), filemode.create))) { document.open(); pdfcontentbyte cb = writer.directcontent; pdfimportedpage page; (int = 1; <= reader.numberofpages; i++) { page =writer.getimportedpage(reader, i); document.newpage(); cb.addtemp

linux - Fail2Ban Will Not Start -

i running centos 6.5 (kernel linux jspring 2.6.32-431.el6.x86_64 #1 smp fri nov 22 03:15:09 utc 2013 x86_64 x86_64 x86_64 gnu/linux) , wondering if assist - im installing fail2ban through yum when go run getting following error; service fail2ban start starting fail2ban: error directory /var/run/fail2ban exists not accessible writing [failed] if advise me how fix great. thanks! you need set appropriate rights on mentioned directory: drwxr-xr-x root:root

c# - access variable a method from another method -

i have 1 small issue variable: public class ini { private float euhh; public void receivevalues(del ludel, int kont) { dell[kont] = ludel; euhh = dell[kont].euh; } public string pafa(int kont) { console.writeline(euhh); return euhh; } } i want send value of dell[kont].euh (member of struct) receivevalues pafa. tried private variable euhh when print value in console value of euhh 0. any advice please? or maybe did wrong. you assuming calling order of 2 method. why not returning value future use: public class ini { public float receivevalues(del ludel, int kont) { dell[kont] = ludel; return dell[kont].euh; } public string pafa(int kont, float euhh) { euhh; console.writeline(euhh); return hhh; } } and use as: float euhh = re

sonarqube - Is there Sonar properties to add custom dictionary in the Fxcop -

currently executing fxcop rules part of sonar scan. we’ve got couple of wordings need add custom dictionary fxcop don’t raised fxcop violations. i have committed codeanalysisdictionary.xml in repository developer can changer whenever required , versioned. i know can use /dictionary: argument using fxcopcmd.exe. is there way can achieve similar result using sonar properties. i using below mentioned sonar properties. sonar.fxcop.mode= sonar.fxcop.installdirectory=c:\\program files (x86)\\microsoft fxcop 10.0 sonar.fxcop.assemblydependencydirectories=c:\\lib*** any little here appreciated. thanks, santhosh it seems there has been feature request @ sonar jira state set "closed" "won't fix". https://jira.codehaus.org/browse/sonarcs-350 on other hand, if add "customdictionary.xml" file solution root folder, works automatically. sample customdictionary.xml <dictionary> <words> <recognized> <w

ms access - Checking network connection using vba -

is there way check network connection in vba? i using command: if dir("o:\") = "" msgbox "you have network connection" else msgbox "no connection" end if but doesnt work , getting run time error what doing correct except flip if , else parts, i.e. when dir("o:\") = "" = you not connected and when returns means have connection. the dir function used return first filename specified directory, , list of attributes. sub test_connection() if (len(dir("o:\"))) msgbox "connected" else msgbox "no connection" end if end sub

Error in opening of file. Python -

i trying open file , met problem: typeerror: coercing unicode: need string or buffer, nonetype found here code example: a = open(fname, "rb").read(255) whats wrong code? fname none , not string: >>> open(none) traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: coercing unicode: need string or buffer, nonetype found you'll have fix how set fname or explicitly guard against being none .

How to connect to MySQL on 3307 port in ruby dbi -

in ruby db = dbi.connect("dbi:mysql:database=db1:host=dbhostname:port=3307", "username", "password") isn't working me using same details in direct mysql connection in command line does...? what missing connection on port 3307 ??? i error: access denied user 'username'@'localhost' (using password: yes) (dbi::databaseerror) changed order dbi:mysql:host=hostname;database=dbname;port=3307 worked reason don't know.

php - count occurences in preg_replace regex -

i know can find of occurrences preg_match_all i.e. <?php $text = 'here juice. juice...'; $counted = preg_match_all('/juice/',$text,$empt); echo $counted; ?> but how can count occurrences preg_replace? as per the manual , there optional 5th parameter $count , set number of replacements performed: preg_replace($pattern, $replacement, $subject, -1, $count) the 4th parameter $limit on number of replacements. -1 means no limit.

Injecting key events and motion events in android -

can tell me on injecting key , motion events same application other applications in android. please note should work in market devices(non rooted phones) well. in advance can tell me on injecting key , motion events... other applications in android. please note should work in market devices(non rooted phones) well. this not possible, sorry.

r - Package installation failed when trying to install from GitHub -

Image
i trying run following command in rstudio (version 3.1.0 on windows 7 64-bit): devtools::install_github("data.table", "rdatatable") i following output: installing github repo data.table/master rdatatable downloading master.zip https://github.com/rdatatable/data.table/archive/master.zip installing package c:\users\cle1394\appdata\local\temp\rtmpcrtx8y/master.zip installing data.table "c:/progra~1/r/r-31~1.0/bin/x64/r" --vanilla cmd build \ "c:\users\cle1394\appdata\local\temp\rtmpcrtx8y\devtoolsd343a7c2b57\data.table-master" --no-manual \ --no-resave-data * checking file 'c:\users\cle1394\appdata\local\temp\rtmpcrtx8y\devtoolsd343a7c2b57\data.table-master/description' ... ok * preparing 'data.table': * checking description meta-information ... ok * cleaning src * installing package build vignettes warning: running command '"c:/progra~1/r/r-31~1.0/bin/x64/rcmd.exe" install -l "c:\users\cle1394\ap

ember.js - Trigger REST adapter to push records to store -

i have following setup: the ember frontend connected websocket server the backend pushes records (real-time data) via websocket clients, stringified json the client receives data, , must update store new data received the problem have not know process raw json data make compatible in store. can of course parse json ( json.parse ), part of rest adapter doing. when doing normal rest request, more or less happens that: server generates reply -> rest adapter converts -> gets pushed store but now, since not using rest adapter process data (because not request triggered in client side, notification coming server side), not know how trigger normal processing rest adapter performs. how can trigger rest adapter programmatically? can pass stringified json coming websockets server? is possible hook rest adapter generic websockets callback, thing have stringified json coming websockets server? this code have (inspired in web2py ) function connect_websocket() {

java - How to handle null pointer exception in wicket form submit -

i have 2 textboxes , 1 submit button in program.when provide inputs , hit submit button works fine. when not entering in textboxes , hit submit button , not working. throwed null pointer exception when form submit. error below. wicketmessage: method onformsubmitted of interface org.apache.wicket.markup.html.form.iformsubmitlistener targeted @ component [markupcontainer [component id = form1]] threw exception root cause: java.lang.nullpointerexception @ com.usaa.application.pages.homepage$3.onsubmit(homepage.java:158) @ org.apache.wicket.markup.html.form.form.delegatesubmit(form.java:1518) @ org.apache.wicket.markup.html.form.form.process(form.java:914) @ org.apache.wicket.markup.html.form.form.onformsubmitted(form.java:876) how handle error , please me ... thanks, kumar do this: textfield<string> tf1 = new textfield<string>("tf1"); tf1.setconvertemptyinputstringtonull(false); form.add(tf1); the value textfield emp