Posts

Showing posts from July, 2014

sql server - In msdb.dbo.sp_send_dbmail, @profile_name is not valid -

i use sql server job execute sendemail stored procedure. job working fine when @recipients our specified email address. since couldn't log our specified email address check whether email has been received, want change @recipients email address the question when make changed, job history shows job not executed. error profile_name not valid does have idea this? here example. exec msdb.dbo.sp_send_email @profile_name = 'isss group', @recipients = 'isss@xxx.edu', @body = @mess,--@mess table @body_format = 'html', @subject = 'student information update', @from_address = 'administration@xxx.edu'; i want change @recipients = 'isss@xxx.edu' @recipients = 'myemail@xxx.edu' to check whether email has been received. once change it, sql server job failed. error shows profile name not valid. you must pass name of registered profile; can't make them on-the-fly. however, assume want different d

ios - WatchKit : error while communicating with the phone app -

i trying communicate iphone app. on watch controller have following code: func requestdatafromphone(messagetext: string) { var infodictionary = dictionary<string,string>() infodictionary["getappointmentstring"] = "message" wkinterfacecontroller.openparentapplication(infodictionary) { (replydictionary, error) -> void in println("we made it!") if let castedresponsedictionary = replydictionary as? [string: string], responsemessage = castedresponsedictionary["message"] { println(responsemessage) self.appointmentstring.settext(responsemessage) } } } on appdelegate of iphone app , have code : func application(application: uiapplication, handlewatchkitextensionrequest userinfo: [nsobject : anyobject]?, reply: (([nsobject : anyobject]!) -> void)!) { let response = "appointmen

ruby on rails - Testing Associations with rspec and Factory Girl -

my model; household has_many :neighbors , neighbor belongs_to :household each household must have neighbor: validates :neighbors, presence: {message: 'you must enter @ least 1 neighbor'] i trying create factory factory :household, class: "household" household_name "brooke" neighbor end factory :neighbor, class: "neighbor" first_name "tom" last_name "brooke" end "has valid factory" household = create(:household, neighbors: :neighbor) expect(household).to be_valid end this gives me: undefined method `neighbor=' #<household:0x007fd45ec85138> how set factory girl reflect association? i did this: i took neighbor out of household factory: factory :household, class: "household" household_name "brooke" end and test created association within test: "has valid factory"

java - The MVC pattern and SWING -

Image
one of design patterns find difficult real grasp of in "real swing life" mvc pattern. i've been through quite few of posts @ site discuss pattern, still not feel have clear understanding of how take advantage of pattern in (java swing) application. let's have jframe contains table, couple of text fields , few buttons. use tablemodel "bridge" jtable underlying data model. however, functions responsible clearing fields, validating fields, locking fields along button actions go directly in jframe. however, doesn't mix controller , view of pattern? as far can see, manage mvc pattern "correctly" implemented when looking @ jtable (and model), things muddy when @ entire jframe whole. i'd hear how others go regard this. how go when need display table, couple of fields , buttons user (using mvc pattern)? a book i'd highly recommend mvc in swing head first design patterns freeman , freeman. have highly comprehensive explanation

r - create one variable out of three and merge over rows -

so, i've been looking solution days. still not succeeding. maybe can me. # minimal example <- rep("a", 9) b <- rep("b", 4) schoolid <- c(a, b) dc <- c("a", "b", "c", "", "", "", "", "", "", "a", "b", "i", "j") mc <- c( "", "", "", "a", "b", "c", "", "", "", "a", "b", "i", "j") ec <- c( "", "", "", "", "", "", "a", "b", "c", "a", "b", "i", "j") dpoints <- c(20, 15, 17, "", "", "", "", "", "", 14, 13, 13, 12) mpoints <- c( "&qu

css - bootstrap: making table readable -

i use bootstrap style table , renders small fonts on device (galaxy s5). want render normal sized fonts , text wrap if required. real use case, must use table. https://jsfiddle.net/wcrrja2f/ for full screen: https://jsfiddle.net/wcrrja2f/embedded/result/ <div class="container-fluid"> <div class="row"> <table class="col-xs-12"> <tr> <td class="col-xs-5">lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore</td> <td class="col-xs-2">12</td> <td class="col-xs-5">lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore</td> </tr> </table> </div> </div> that's normal size of text inside table cell. if want increase font size on devices can use 17px

atlassian sourcetree - How do you stay up-to-date in your feature branch (Git)? -

say i've cloned develop branch of project. then, off of develop, branched , called feature/abc. as work on local feature/abc, point branched off of develop going more , more behind develop looks like. maybe fundamentally confused git process... does mean feature/abc branch fall more , more behind develop since branched off of old version of develop? part of git process , have resolve , conflicts may arise after complete work on local feature/abc, commit , push remote feature/abc, , merge develop? is there way pull in changes develop without merging work-in-progress changes on feature/abc? or whole point of should work on quick, easy changes can completed , merged feature branch doesn't fall behind? you can periodically pull in changes develop branch... git checkout develop git pull git checkout feature/abc git merge develop now feature/abc branch has latest stuff develop.

mongodb - Ruby gem 'mongo' insert number as long -

i'm using mongo gem in ruby , want insert record , want value stored numberlong via mongo ssh console can db.somecoll.insert({"key" : numberlong("123456789"}) and when i'll use find i'll field numberlong . how can same insert query via mongo ruby gem? thanks ahead

c++ - Cholesky with ScaLAPACK -

Image
i trying cholesky decomposition via pdpotrf() of mkl-intel's library, uses scalapack. reading whole matrix in master node , distribute in example . works fine when dimension of spd matrix even. however, when it's odd, pdpotrf() thinks matrix not positive definite. could because submatrices not spd? working matrix: and submatrices (with 4 processes , blocks of size 2x2): a_loc on node 0 4 1 2 1 0.5 0 2 0 16 nrows = 3, ncols = 2 a_loc on node 1 2 0.5 0 0 0 0 nrows = 2, ncols = 3 a_loc on node 2 2 0 0 0.5 0 0 nrows = 2, ncols = 2 a_loc on node 3 3 0 0 0.625 here, every submatrix not spd, however, overall matrix spd (have checked running 1 process). should do? or there nothing can , pdpotrf() not work matrices of odd size? here how call routine: int izero = 0; int desca[9]; // n, m dimensions of matrix. lda = n // nb, mb dimensions of block descinit_(desca, &n, &m, &nb, &mb, &izero, &izero, &a

css - Flexible 2nd and 3rd column system via CSS2 -

i have following setup 3 column layout: #column-menu { float: left; width: 25%; } #column-main { float: right; width: 55%; } #column-side { float: left; width: 20%; } this code works following html: <div id="column-side">my right side content</div> <div id="column-main">my main content</div> <div id="column-menu">my sub menu</div> i'm not committed using floats. happens works above structure, except when nothing in column-side. in case column-main cover additional width , not constrained 55%. there way build kind of flexibility css alone? if want floats, have reorder elements: .column-side { float: left; width: 20%; background: #00ffff; } .column-menu { float: left; width: 25%; background: #00ff00; } .column-main { overflow: hidden; background: #ffff00; } <div class="column-side">side</div> <div class="column-menu&qu

javascript - Ajax call to different website returns html instead of an array -

Image
i'm trying receive array using .ajax request url. here's controller, hosted locally on localhost:3000 def merchant_ids merchants = merchant.where(id: params[:id]).pluck(:merchant_name, :id, :merchant_city, :physical_address, :merchant_phone, :latitude, :longitude) render json: merchants end if make request following way: $.ajax('http://localhost:3000/dashboard/merchants/merchant_ids/1').done(function(data) { console.log(data); }); it logs array fine. but if try same thing app using localhost:3001 returns the whole html view instead of array. what doing wrong here? i have gem 'rack-cors' , config: config.middleware.insert_before actiondispatch::static, rack::cors allow origins '*' resource '/*', :headers => :any, :methods => [:get, :post] end end in ajax call try putting contenttype , datatype json try this- $.ajax({ url:"http://localhost:3000/dashboard/mer

android - Unregistering Broadcast Receiver when application goes to background -

i need check net connectivity in application. nothing should work if there no internet connectivity. have implemented using broadcastreceivers, want receivers unregistered (i.e. not getting called) when application in background. receiver should work when user using app. initially, had broadcast receiver registered in manifest, noticed got fired when app in background. so, chucked idea. then, registered receiver in onresume(), , unregistered in onpause(). but, problem if go activity activity b of application, receiver unregistered on onpause() of , again registered in onresume() of b. makes activity transition heavy. though, in such case unregister , register process shouldn't happen. i want receiver unregistered when user stops using app, not during activity transitions, should not keep running when app in background. thought of using services, want detect change in net connectivity, done best receivers. so, there way detect when app goes in background can unregist

c++ - how to avoid non-deterministic read caused by concurrent write -

non-deterministic read caused concurrent write can demonstrated following code: class bar { int val_; std::mutex m_; public: explicit bar(int v) : val_(v) {} int val() { std::lock_guard<std::mutex> l(m_); return val_; } void set(int v) { std::lock_guard<std::mutex> l(m_); val_ = v; } }; class foo { bar* bar_; public: explicit foo(bar* bar) : bar_(bar) {} int val() const { return bar_.val(); } }; bar bar(1); foo foo(&bar); cout << foo.val() << endl; // 1 bar.set(2); // executed in thread cout << foo.val() << endl; // 2 i interested know design patterns / coding practices avoid such problem. one solution can think of make "deep copy", i.e. foo have consistent snapshot of data depends on, reads same result. if foo owns bar, can make bar ref counted, , let foo maintain list of different versions of bar (all mutation bar go through foo), , client "snapshot view" of foo have ac

javascript - Access directive element from a controller -

on page have table custom directive shows row item's detailed view when user click on details button : <table ng-controller="mycontroller"> <tr ng-repeat="item in controller.items"> <td>{{item.name}}</td> <td> <a href="#" ng-click="controller.loaddetails(item.id)">details</a> </td> </tr> <tr ng-details details-colspan="2" ng-model="controller.details"></tr> </table> directive: .directive('ngdetails', function() { return { restrict: 'a', require: "^ngmodel", replace: true, template: '<tr class="detailstemplate {{ngmodel.cssclass}}"> \ <td colspan="{{detailscolspan}}" ng-bind-html="ngmodel.data"></td> \ </tr>', scope: {

c++ - It gives an error for big values -

i solving simple question of finding nth power of 2.it works lower power of n,but fails when try doing higher powers,also,the question have been asked has % 10^9+7 reduce size. if please tell me going wrong. #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; long long int pro=1; long long int func(int n) { if(n!=1) { pro=pro%1000000007; pro=(2*func(n-1)); return pro; } return 1; } int main() { pro=1; long long int n=555555; long long int x; if(n!=1) x=func(n); else x=1; cout<<x<<endl; } return 0; } if(n!=1){ x=func(n); }else{ x=1; //this incorrect, should return 2. } also long long int func(int n) { if(n!=1) { pro=(2*(func(n-1)%1000000007))%1000000007; return pro; } else return 2; }

c# - Select a file for renaming in SharpShell context menu -

Image
i'm using sharpshell write tiny new shell context menu item copies selected files new subfolder, prompts user directory's new name . searching stackoverflow, found this answer. however, i'd same in sharpshell. i somehow have fire svsi_edit @ it, can find buried deep in sharpshell.interop , i'm not sure how of works. can't find documentation or code samples whatsoever. (edit: think finding out how pidl file name start, maybe don't need @ all?) you can start creating project sharpshell register new shell context menu in tutorial . here, have define class implementing sharpcontextmenu . simplicity create menu filetype , show it: [comvisible(true)] [comserverassociation(associationtype.allfiles)] public class copyfilesextension : sharpcontextmenu { protected override bool canshowmenu() { return true; } protected override contextmenustrip createmenu() { var menu = new contextmenustrip(); var cop

jquery - Create a new row in bootstrap data table -

for me new row being created, values wrong. my jquery datatables list: $.ajax({ url: '@url.action("loadeventchargesbyutility", "vendor")', contenttype: "application/json; charset=utf-8", datatype: "json", data: "{'stayid':'" + stayi + "','datetime':'" + datetime + "','groupid':'" + groupid + "'}", type: "post", // 'get' or 'post' ('get' default) success: function (data) { data = json.parse(data); if (data != "no items") { $('#tblevent').datatable({ "spaginationtype": "full_numbers", "aadata": data, "bautowidth": false, "bdeferrender": true, "destroy": true, "aocolumns": [

bitbucket - One product ( server side / client side 1 / client side 2... ) in one repository git -

i have problem connected structure of git repository. working while svn, maybe change mindset little bit. our team developing 1 product, let's name "deep". "deep" has: server side (php/db) android app windows phone app ios app i'm android app developer don't need ios,windows phone , server side code. friend don't need code. there chance work part of master need , don't interact other parts @ all. why want have in 1 repository fact, these parts should on same stage of development, when make release. make more visible, there point in time when want make release, android app should support same amount of functionalities server side, windows phone, ios. and what's more in opinion looks cleaner have 1 repo = 1 product you looking submodules, each have own repository, stage commits in main repository of different modules. way can work stable copy of each others work, still work on code out affecting others.

understanding javascripts ( length - 1 ) in obj check to test for isArraylike (jquery) -

i going through source code of jquery , came across following function: function isarraylike( obj ) { // support: ios 8.2 (not reproducible in simulator) // `in` check used prevent jit error (gh-2145) // hasown isn't used here due false negatives // regarding nodelist length in ie var length = "length" in obj && obj.length, type = jquery.type( obj ); if ( type === "function" || jquery.iswindow( obj ) ) { return false; } if ( obj.nodetype === 1 && length ) { return true; } return type === "array" || length === 0 || typeof length === "number" && length > 0 && ( length - 1 ) in obj; } if go line line , see jquerys internal methods called such $.type , $.iswindow , part don't understand right @ end, following piece of code: ( length - 1 ) in obj; i see && used in end, question when check return true , when retur

deprecated - How to print the calling method name and line number for Deprecation Warning message in python? -

my deprecate warning message in function. print out module name , line number of calling function can locate them. take open() example: /path/to/file/group.py:180: deprecationwarning: 'u' mode deprecated open(tmpname, 'ru') csvfile however, own warning prints this: /path/to/file/models.py:735: deprecationwarning: deprecated. use course_id instead! warnings.warn("deprecated. use course_id instead!", deprecationwarning) on line 735 of models.py warnings.warn() call located. there way make warning output parent caller's name , line number? thanks. you can control caller want warning apply using stacklevel argument. for instance, following code: import warnings def hello(s): if isinstance(s, int): deprecation('use of integers deprecated.') else: print(s) def deprecation(msg): warnings.warn(msg, deprecationwarning, stacklevel=3) hello(1) will give following warning: warning_test.py:12: de

java - What is an alternative to escaped unicode localized property files in spring mvc? -

if want localized property file have character in native language such 嗨 instead of escaped unicode \u55e8 (obtained using native2ascii), currently reading property file using resourcebundle.getbundle passing in locale. if don't save propertyfiles in escaped unicode, shows in browser garbage. is there way make work without escaped unicode? instead of using resourcebundle, used messagesource. read value of string using messagesource.getmessage(string var1, object[] var2, locale var3) if that, don't need modify property files escaped unicode.

opencv - Not able to use std::sort with Android NDK -

ndk-build complains std::sort() has wrong arguments , in same message can't found. ndk use other function? candidate expects 2 arguments, 3 provided sort(centroids.begin() + * 10, centroids.begin() + (i + 1) * 10, pointxgreater); error: no matching function call 'sort(__gnu_cxx::__normal_iterator*, std::vector > >, __gnu_cxx::__normal_iterator*, std::vector > >, removeconvexity(cv::mat, cv::mat, cv::mat)::&)' for (int = 0; < 10; i++) { sort(centroids.begin() + * 10, centroids.begin() + (i + 1) * 10, pointxgreater); } thats function call. vector<cv::point> centroids; centroids.reserve(100); (int = 0; < contours.size(); i++) { vector<cv::point> contour = contours.at(i); moments mom = moments(contour); cv::point center = cv::point(int(mom.m10 / mom.m00), int(mom.m01 / mom.m00)); centroids.push_back(center); } std::reverse(centroids.begin(), centroids.end()); struct { bool operator()(c

java - Travis CI: config not read -

i'm building maven project travis ci. @ step in build, gpg plugin being called. no passphrase provided, fails. i've tried override build lifecycle phases prevent gpg plugin being activated. however, custom steps don't seem executed. the .travis.yml file in question here . however, viewing build log on travis, still see default build commands being called. in log of custom build lifecycle called. why travis not reading repository's .travis.yml file? i've used web linter, , checks out there. i've run of commands in build file locally, , execute correctly. can't see wrong travis configuration/setup. your file .travis.yml being read, execution breaking in this command : mvn install -dskiptests=true -dmaven.javadoc.skip=true -dsource.skip=true -dgpg.skip=true -b reading log... problem seems maven-gpg-plugin. check line 1498 of log post . the error: gpg secret key not avaiable. possible solution . since command breaking execution, bu

php - Create icon inside of input with bootstrap and cakePHP -

i have cakephp code: <?php echo $this->form->input('about_me', array('label' => __l('about me'), 'class' => 'form-control', 'before' => '<div class="form-group form-group-icon-left"><i class="fa fa-user input-icon input-icon-show"></i>', 'after' => '</div>', array('escape' => false) ) ); ?> i output (indented readability): <div class="col-md-6"> <div class="form-group form-group-icon-right"><i class="fa fa-map-marker input-icon"></i> <label>about me</label> <input class="form-control" placeholder="write something" type="text" /> </div> anyone can help? my solution this: <div class="form-group form-group-ic

android - .SQLiteException: near “00”: syntax error (code 1): , while compiling: -

i new android, , tried compare 2 date strings, this, don't know how solve.. here part of code have mistake int year=calendar.getinstance().get(calendar.year)+1900; int month=calendar.getinstance().get(calendar.month)+1; int day=calendar.getinstance().get(calendar.day_of_month); dbreminders bazadelete=new dbreminders(context); bazadelete.open(); bazadelete.deletereminder("date<"+year+"-"+month+"-"+day+" 00:00 am"); bazadelete.close(); podsetniciadapter.notifydatasetchanged();

xml - Java 8 default methods, JAXB, and JavaFX Property frustrations -

there way use jaxb annotations on default methods inherited java 8 interfaces? i created sample maven project @ https://github.com/ruckc/jaxb-java8-javafx highlighting shims required do. in dealing javafx properties, i've found can use default methods on interfaces remove annoying getters/setters data object. public interface named { @xmlattribute(name="name") default string getname() { return nameproperty().get(); } default void setname(string name) { nameproperty().set(name); } stringproperty nameproperty(); } this removes alot of redundant code inside implementations. issue now, when trying marshall objects using jaxb, still have implement methods (annotated @shim ) in implementations, annotations picked up. @xmlrootelement(name="business") public class business implements named { private final stringproperty nameproperty = new simplestringproperty(); @shim @override public void setn

java - How do I load a FileResource into a byte array? -

i have file called data.dat load byte[] in vaadin. data file need load , manipulate based on user's input. i tried: string basepath = vaadinservice.getcurrent().getbasedirectory().getabsolutepath(); fileresource resource = new fileresource(new file(basepath + my_data_file)); the problem don't know how manipulate resource extract byte[] . see lots of information how put images , on ui components , how stream user generated pdf , , on, can't seem find examples on how load own data file manipulate within code... from docs of vaadin have: java.io.file getsourcefile() gets source file. or downloadstream getstream() gets resource stream. and in downloadstream : java.io.inputstream getstream() gets downloadable stream. so can operate on file or inputstream read contents of fileresource for example in java 8: byte[] bytes = files.readallbytes(paths.get(resource.getsourcefile().getabsolutepath()));

Multi-dimensional arrays in Bash -

i planning script manage pieces of linux systems , @ point of deciding if want use bash or python . i prefer bash script because commands easier, real deciding factor configuration. need able store multi-dimensional array in configuration file tell script itself. storing simple key=value pairs in config files easy enough bash, way can think of multi-dimensional array 2 layer parsing engine, like array=&d1|v1;v2;v3&d2|v1;v2;v3 but marshall/unmarshall code bear , far user friendly next poor sap has administer this. if can't in bash write configs xml file , write script in python. is there easy way in bash? thanks everyone. bash not support multidimensional arrays, nor hashes, , seems want hash values arrays. solution not beautiful, solution xml file should better : array=('d1=(v1 v2 v3)' 'd2=(v1 v2 v3)') elt in "${array[@]}";do eval $elt;done echo "d1 ${#d1[@]} ${d1[@]}" echo "d2 ${#d2[@]} ${d2[@]}"

css - Hamburger Button in Bootstrap -

i want fix classic bootstrap style hamburger button on navbar, 1 appears toggle button when screen size gets sufficiently small. anyways, how can display button is, without having implement through navbar-toggle class? edit: here button have: <div> <div class="center"> <button type="button" class="btn">☰</button> </div> </div> body { background: #222; } .center { width: 100px; margin: 50px auto; } .btn { background-color: #222; border: 1px solid #3a3a3a; color: #d3d3d3; width: 42px; margin-left: 42px; font-size: 23px; height: 34px; transition: color 0.45s; transition: border 0.45s; } button.btn:hover { color: #2978e0; border: 1px solid #61a5ff; } https://jsfiddle.net/rstty1ye/ using utf-8 character mentioned on tutsplus.com it's not original finding or idea. nevermind, figured out. created custom button , used utf-8 character: trigram

swift - Why is retrieving data from JSON taking a lot of time? -

it takes @ least 15-35 second iphone go through these loops. learned json on stackoverflow , way people this. these arrays have 3 elements inside text , 1 small image per element if let parsejson = json{ let succes = parsejson["data"] let item = self.success["catalogue_products"] as! [[string: anyobject]] if item.isempty == false{ in item { var categoryname = i["category_name"] as! string if self.category == nil{ self.category = categoryname self.categories.append(self.category) self.categorycount = 1 } if self.category != categoryname{ self.categorycount += 1 self.category = categoryname self.categories.append(self.category) } var deep = i["products"] as! [[string: anyobject]] in deep{ var product = productcatalogue() product.categoryname = categoryname product.i

java - WAS 8.5 runtime jars are not shown in eclipse -

i'm using 8.5 in eclipse kepler our jsf 2.0 project , our project based on maven. somehow picking older j2ee jar , not taking j2ee jar lib folder. when expand in build path, it's not showing runtime jar. how can make eclipse show runtime jars in build path? web project -> configure build path -> libraries -> 8.5 (expand it) "no jars shown here" http://i.stack.imgur.com/eiali.jpg

perl - How to use LWP with client cert and CA -

i curenttly have perl code drops out shell call curl talk end point certificates. works fine feel cheating in perl when escape shell , take easy option. below curl command using , works fine. $soap_response = echo '$soap_request' | curl --cacert $self->{'server_cert'} --cert $self->{'client_cert'} -d '\@-' -h 'soapaction:urn:anonoutinop' $self->{'end_point'} -s | xmllint -format - ; i have ca file, , client file, both in pem format. i have tried use lwp , net::ssl make communication purely in perl , rid of reliance on curl cannot life of me work. i set enviroment net:ssl as #set ssl envrioment net::ssl $env{https_debug} = 1; $env{https_cert_file} = $client_cert; $env{https_ca_file} = $server_cert; $env{https_ca_dir} = $certificate_dir; then send request as my $ua = new lwp::useragent(); $request = http::request->new(post => $endpoint); $request->header(soapaction => '"query"');

jquery - javascript event conflict, but not sure how to identify the first event assignment -

i have element <div class='graph'> , try associate onclick event it. there dynamic loading process on top of element, not sure event handler process load exactly. for example, after open webpage, use highchart plot chart on <div class='graph'> , tried add event handler $('.graph').on('click',function(){//to show text when click <div>} , unfortunately, not work (the function never execute when click on element). think image highchart added 'click' event on '.graph' . when add 'click' event, not work expected. my question is: 1) how know what's first 'click' event (by console.log($('.graph').click()) seems not giving me useful info)? 2) how should make second click successful? thanks or hints! in source code can find line #9946 (for 4.1.7) - prevents default method, however, there won't find stoppropagation() call. i suggest use chart.events.click instead.

django - Running a local web server for testing and development -

i working on shared *nix sever not have root privileges. i trying build site using wordpress , development purposes need start local web server (something similar django runserver ). however, not sure how that. the server has instance of apache running however, can't make modifications config files don't have required privileges. any suggestions? just run server on port >1024 , won't need root credentials :)

python - How to fix ValueError: need more than 1 value to unpack? -

i following error when using below query,am giving variables when doing cursor.fetchall ,not sure why getting error,how overcome this? query:- query = """select metabuild,testbed gerrits.pw warehouse ='%s'"""%(warehouse_name) rows = cursor.execute(query) (metabuild,testbed)= cursor.fetchall() error:- (metabuild,testbed)= cursor.fetchall() valueerror: need more 1 value unpack fetchall returns list of tuples, 1 tuple per row. if query returns 1 row, do (metabuild,testbed)= cursor.fetchall()[0]

delphi - Not getting correct return value from Outlook -

i use following code send emails using outlook 2010 line result := mailitem.sent; returns error the item has been moved or deleted how can fix function gives me useable return value? function olsendmail(afrom, asubject, abody, ato, acc, abcc: string; amailfiles: tstringlist; areceipt: boolean = false; apreview: boolean = true): boolean; var outlook: olevariant; mailitem: olevariant; i: integer; mailinspector: variant; const olmailitem = $00000000; begin try try outlook := getactiveoleobject('outlook.application'); except outlook := createoleobject('outlook.application'); end; mailitem := outlook.createitem(olmailitem); if olaccountvalid(afrom) mailitem.sendusingaccount := outlook.session.accounts.item(afrom); mailitem.to := ato; mailitem.cc := acc; mailitem.bcc := abcc; mailitem.subject := asubject; mailitem.body := abody; := 0 amailfiles.count - 1 mailitem.attachments.add(

Composite design pattern PHP example -

in client code, , @ it's simplest should read like: <?php // client code $int1 = new _integer(2); $int2 = new _integer(3); $operator = new operator('+'); $op1 = new operands($int1); $op2 = new operands($int2); // $op1 + $operator + $op2 = solution === 5 ?> however, we're attempting using composite design pattern , things become non-trivial. have been working on following: <?php // use case: 2 + 3 = 5 // component interface solution { function f(); } // composite class operands implements solution { private $ints = []; function __construct(_integer $_integer = null ){ $this->_integer = $_integer; array_push($this->ints, $this->_integer); } function f(){ /* nothing */ } } // leaf class _integer implements solution { private $_int; function __construct($_int){ $this->_int = $_int; } function f(){ /* nothing */ }

python - Troposphere, passing output of a stack as input to another -

suppose i'm defined 2 stacks, , b. in stack a, define vpc , subnet , output subnet's id t = template() subnet = t.add_resource(subnet .....) subnetid = t.add_output(output('subnetid', value=ref(subnet)) in stack b, have these instances want live within subnet defined in stack a. how can achieve that? you'll need pass them in stack b parameters. decent example of in stacker , open source project maintain (i w/ troposphere). the bastion.py blueprint takes many parameters come vpc.py blueprint (both found here - sorry, tried post links each of blueprints, stackoverflow won't let me post more 2 links.). stacker handles passing parameters 1 stack you, biggest reason wrote it. let me know if have questions.

c++ - Create an object that contains another object -

i studying c++, , bit confused following situation: for example, class apple class apple { int kg; apple(); } class fruit class fruit { private: int count; apple one; public: fruit();//do need call constructor apple, //or default fruit constructor calls well? } in example default constructor gets called. if apple constructor example took int first param have set through initializer list: class apple { public: int kg; apple(int _kg) : kg(_kg) {} }; class fruit { private: int count; apple one; public: fruit() : one(5) //right here or you'll error { this->count = 5; //this->one(5) doesn't work. } };

javascript - Ionic: Why are my images not loading from my json file? -

i'm trying load images json file application cannot work: here's code: js: .controller('photoctrl', function($scope, $ionicmodal, $ionicbackdrop, $ionicscrolldelegate, $ionicslideboxdelegate, $http) { $scope.images = []; $scope.getimages = function() { $http.get('https://api.myjson.com/bins/37ia6') .success(function(data) { $scope.images = data.images; }) } html: <ion-view view-title="gallery" align-title="center" ng-controller="photoctrl" > <ion-content ng-init="getimages()" class="center" class="has-header padding"> <!-- start under6/7/8/9s photos --> <div class="item item-divider"> <i class="ion-images"></i> under6/7/8/9s photos </div> <a class="item item-list-detail"> <ion-scroll direction="x">

android - How do I save/load an object? I've done a lot of searching and can't figure out what's wrong -

i've been searching answer long time , know has been answered, none of "correct" answers have worked me. in mainactivity do: savedata save = savedata.load(getapplicationcontext()); and pull values out of it. in savedata have: public void save(context context) { try { fileoutputstream fos = context.openfileoutput("savedata", context.mode_private); objectoutputstream os = new objectoutputstream(fos); os.writeobject(this); os.close(); fos.close(); } catch (ioexception e) { e.printstacktrace(); } } public static savedata load(context context) { try { fileinputstream fis = context.openfileinput("savedata"); objectinputstream = new objectinputstream(fis); savedata save = (savedata) is.readobject(); is.close(); fis.close(); return save; } catch (exception e) { e.printstacktrace(); return null; }

linux - Script for selectively deleting directories by date -

i'm running sh script on debian machine. it's done nightly , uses rsync create incremental backups. saves each backup in directories named date. have: 2015-07-01 2015-07-02 2015-07-03 2015-07-04 , so-forth what able delete old copies list grows. preferably i'd keep daily backups past week, , weekly backups long have space. which means need 2 things: check date of each folder name. if date not saturday, , older 7 days, delete it. check amount of used space on partition (/dev/sdb1) , delete oldest folder if disk usage above 75%. i'm thinking step 2 need in loop perhaps. can delete 1 backup @ time. recheck space available, , delete folder if we're still above 75%. i'm assuming possible bash scripts. i'm still new them. i've found whilst googling around should pretty straight forward knows doing. i'm having trouble figuring out how piece elements together. here old script , not use after have migrated rsnapshot. have hardcoded

jquery - Fancybox trigger click not working online (after Ajax request) -

my jquery fancybox works on local computer, doesn't work on live website. locally, gallery starts single click when takes 2 clicks online. thanks help! here code: $(document).on('mousedown', '.photo', function(e){ if (e.which == 1) { var clicked = $(this); $.ajax({ url: 'gallery.php?title="' + encodeuricomponent($(this).attr("data-name")) + '"', datatype: 'json' }).done(function(data){ if(data != ''){ $('<div class="new-gallery hidden"></div>').insertafter(clicked); (var = 0; <= data.length ; i++) { (function(i) { $('<a class="fancybox" href="'+ data[i].dir +'" rel="gallery" title="'+ data[i].title +'"><img src="&

mysql local installation mysql_install_db error -

i working on *nix machine , don't have root privileges. i trying install mysql locally using blogpost: http://www.thedance.net/~roth/techblog/localmysql.html however, stuck @ scripts/mysql_install_db command. when run command following error: fatal error: neither host 'server.address.com' nor 'localhost' looked /usr/bin/resolveip please configure 'hostname' command return correct hostname. if want solve @ later stage, restart script --force option on further digging, found adding --basedir resolves issue. generates following errors: $scripts/mysql_install_db --basedir=. installing mysql system tables...2015-07-17 01:38:15 0 [warning] using unique option prefix key_buffer instead of key_buffer_size deprecated , removed in future release. please use full name instead. 2015-07-17 01:38:15 0 [warning] timestamp implicit default value deprecated. please use --explicit_defaults_for_timestamp server option (see documentation more details). 2015-0

How to not show pre-defined relationship types when double-clicking a node in neo4j Browser -

i have defined several relationship types between several nodes having common label. conceptually, relationship types can grouped in 2 different domains. problem facing when navigating through model in browser double-clicking nodes, relationship types show making confusing there kind of 2 conceptual domains overlapping. there way assign relationship types domains , instruct browser show relationships of 1 specific doman when double-clicking node? yup, think know mean. depends on version, believe if have latest (2.2.x) can unselect "auto-complete" in lower right of query graph visualization panes.

javascript - Issue with automatic reload of side menu -

so have side menu in ionic application present in templates. here how have set in app.js: .state('app', { url: "/app", abstract: true, templateurl: "templates/rubyonic/menu.html", controller: 'appctrl', }) .state('app.studies', { url: "/studies", views: { 'menucontent': { templateurl: "templates/rubyonic/studies.html", } } }) .state('app.study', { url: "/studies/:studynoderef", views: { 'menucontent': { templateurl: "templates/rubyonic/overview.html", } } }) here snippet of code controller: $scope.nodeid = $stateparams.studynoderef; $scope.collections = []; $scope.studies = []; studies.all().then(function(data) { $scope.x = angular.fromjson(data.allprojects); $scope.studies = angular.fromjson($scope.x.list); }); studies.fetchcolle

python - Beautiful Soup Not able to get_text after using extract() -

i working on web scrapping , want text website using beautiful soup . found get_text() method returning javascript code avoid come across should use extract() method have weird problem after extraction of script , style tag beautiful soup doesn't recognize body present in new `html. let me clear first doing this soup = beautifulsoup(htmlrawdata, 'html.parser') print(soup.body) here print statement printing html data when soup = beautifulsoup(rawdata, 'html.parser') script in soup(["script", "style"]): script.extract() # rip out print(soup.body) now printing none element not present debugging after did soup.prettify() print whole html including body tag , there no script , style tag :( confused why happening , if body present why saying none please thanks and using python 3 , bs4 , rawdata html extracted website . problem: using html example: <html> <style>just style</

How to instantiate an object which is in a different class in java -

i trying create program saves of data given user save file , read file when user wants know information back. now problem arises, when try call object instantiated in different method after call load() function. import java.io.fileinputstream; import java.io.serializable; import java.io.fileoutputstream; import java.io.objectinputstream; import java.io.objectoutputstream; import java.util.scanner; import java.util.arraylist; public class aibob { //array list of users public static arraylist<user> userlist = new arraylist<user>(); public static void main (string args[]){ scanner scanner = new scanner(system.in); system.out.println("hello! name bob, existing user or want make new account? "); string userquantifier = scanner.nextline(); string[] check = {"exist","new"}; if(userquantifier.contains(check[0])){ system.out.println("can tell me name please?");