Posts

Showing posts from September, 2014

php - Trying to get property of a non-object -

i thought had resolved error when added if block below, i'm still erroring out. line of code causing following errror: fatal php error on line 95 of /xxxxx/getcontactvaluesosvc.php: trying property of non-object line 95 if condition here: if($contact->customfields->c->ask_again->lookupname){ $contactname=$contact->customfields->c->ask_again->lookupname; } anyone know why merely checking existence (what line should doing think) causing error im getting?

Multiplying by an Integer by a Float/Double in Java -

Image
i'm trying simple: multiply integer float/double: private final static int = 100; ... double d = 0.5; // although dividing 2, decimal. int x = (int) (a * d); however, although you'd expect return x = 50 , instead x = 100 ! same thing happens when use float d = 0.5f . know going on , why isn't working? jls §4.2.4. floating-point operations tell rules governing floating point operation, per if of operand floating point number other operand widened floating point (if not already) , final result floating point number. so, int 100 widened 100.0 before arithmetic operation, , result of operation 50.0 . now, since casting result in int , jsl §5.1.3. narrowing primitive conversion applicable, , double 50.0 narrowed int 50 . 100 impossible result, given code have provided. my guess when got 100, have done else.

excel - Run-time Error 424 Object Required UserForm doesnt exist -

i'm attempting things written on site www.excel-easy.com when click commandbutton (from activex controls) in worksheet website instructed, nothing happens. tried use button form controls, says error in ---> dinnerplanneruserform.show my code: sub button2_click() dinnerplanneruserform.show end sub when used f8, said error here --> private sub userform_initialize() private sub userform_initialize() 'empty nametextbox nametextbox.value = "" 'empty phonetextbox phonetextbox.value = "" 'empty citylistbox citylistbox.clear 'fill citylistbox citylistbox .additem "san francisco" .additem "oakland" .additem "richmond" end 'empty dinnercombobox dinnercombobox.clear 'fill dinnercombobox dinnercombobox .additem "italian" .additem "chinese" .additem "frites , meat&quo

cordova - What's the right place for a hook to delete my typescript files? -

my cordova app code written in typescript there no reason these files should end in apk file. but should put script delete these files in: before_build, before_clean, before_compile, before_prepare, before_run? or in respective 'after_' versions? the github cordova-cli repo points here: apache.org hooks guide page doesn't describe each stage. there few answers question, guess depends on how / when converting typescript files javascript (as process done hooks before_prepare hook.) short answer either after_prepare or before_compile. let @ cli commands prepare, compile , build ( source ): prepare [platform...] copies files specified platforms, or platforms. ready building eclipse, xcode, etc. compile [platform...] compiles app binary each targetted platform. no parameters, builds platforms, otherwise builds specified platforms. build [<platform> [<platform> [...]]] alias cordova prepare followed cordova compile befor

jquery - Add dash in auto complete phone number -

question: is possible automatically add dash "-" in auto complete? let have phone number field , if type phone number in browser auto complete show. ex. this browser auto complete value 1234567890 once select want automatically format this 123-456-7890 because there site dont have validation format phone field can input 10 digit number continuesly , once have in browser cache display other phone field. thanks in advance. $('#phone-number-field').keyup(function(){ $(this).val($(this).val().replace(/(\d{3})\-?(\d{3})\-?(\d{4})/,'$1-$2-$3')) });

c# - Finally is not executed when in a Thread running in a Windows Service -

can explain why block not executed? have read posts when expect block not executed, seems case. code needs topshelf , log4net. running .net 4.5 i guess must windows service engine kicks in on unhandled exceptions, why running before block has finished? using log4net; using log4net.config; using system; using system.threading; using topshelf; namespace consoleapplication1 { public class hostmain { static void main(string[] args) { hostfactory.run(x => { x.service<hostmain>(s => { s.constructusing(name => new hostmain()); s.whenstarted(tc => tc.start()); s.whenstopped(tc => tc.stop()); }); x.runaslocalsystem(); x.setservicename("timertest"); }); } public void stop() { logmanager.getlogger("mylog").info(&q

nested attributes - Retrieving form params in Rails 4 controller using fields_for and accepts_nested_attributes_for -

i positive dumbest question cannot wrap head around it. i have 2 models in simple has_one/belongs_to relationship registration_code.rb class registrationcode < activerecord::base has_one :billing_transaction accepts_nested_attributes_for :billing_transaction billing_transaction.rb class billingtransaction < activerecord::base belongs_to :registration_code in form collecting information both models using fields_for. _form.html.erb (truncated example) <%= form_for @registration_code, :html => {:class => "form", role: "form"} |f| %> <%= f.label :registration_code, "registration code", :class => "control-label" %> <%= f.text_field :registration_code %> <%= f.fields_for @billing_transaction |bt| %> <%= bt.label :transaction_amount, "transaction amount", :class => "control-label" %> <%= bt.number_field :transaction_amount %> <% end

java - STS 3.6.4 on Mac OS X Crashes on Launch -

i have fresh download of spring-tool-suite-3.6.4.release-e4.4.2-macosx-cocoa-x86_64.tar.gz & jdk 8u45 on either mac os x 10.9.5 or 10.10.3 crashes after launch. sts loads, asks me create workspace, interface loads, crashes 15 seconds later. due security policies, have use java 8, downgrading jdk lower version not option. does have suggestions on how troubleshot/fix issue? note, i'm system admin preparing package deployment, not developer. don't have previous workspaces or old versions of software installed on machines. thanks! did let load previous workspace, example sts 3.6.2 or something? if so, please make sure create new workspace , give shot. i have been using sts 3.6.2. after saw post, decided give tried. downloaded it, unarchived , ran it.it has been running 5-10 mins far. so, don't believe wrong pack. os: macosx 10.10.3

c# - Accessing current Microsoft account from Visual Studio extension -

i writing vs extension need communicate server , identify user, , figured if possible, since extension client connecting server, using visual studio's built-in support microsoft accounts make more sense implementing own account management infrastructure. at first, because of variety of useful apis available visual studio developer, 1 might think getting info on current user easy. however, there don't seem obvious apis can used access accounts; checked here , there weren't related services listed (the "profile" services allow read/write settings stored current user). does know of (relatively) simple way access microsoft account visual studio extension? edit i tried hadi brais's suggestion, , @ first appeared work (i retrieved information); however, each time, visual studio crash 30s afterward. commented out lines interacted registry , replaced them static values variables, , crashes stopped. clearly, accessing visual studio's registry keys caus

ios - Not receiving push notifications in background, only foreground (no alerts) -

i've set app push notifications , , past few days of development i've received 0 notifications when app in background. no alert, badges, sounds -- nada . nothing shows in notifications area when swipe down screen above. but when app in foreground, application:didreceiveremotenotification: indeed fire off. when first started messing around notifications, getting them, @ point stopped working. i've verified phone has notifications enabled app. i'm using quickblox send cross-platform push notifications, , have control panel on website can send notifications. when sent 1 through there, receive in background. on foreground, see log output ones sent control panel: 2015-07-11 00:11:26.755 viewerapp[6671:2177549] didreceiveremotenotification userinfo={ aps = { alert = "testing push notification"; sound = default; }; } and receive when client app uses quickblox api send push notification: 2015-07-11 00:14:14.907 viewerapp[66

java - JPanel in JComboBox dropdown but not in the editor -

Image
what want seems relatively simple, , i'm there. used extend tablecelleditor , size important. want this: with combination of custom comboboxeditor s , listcellrenderer s i've been able this: which has inconveniences of: cutting off components beyond original width of jcombobox forcing height of jcombobox height of jpanel in drop-down allowing 1 (1) click modification of form before drop-down disappears. i'd have drop-down stay visible until user clicks editor or jcombobox looses focus control, , have value in editor update. there ever 1 (1) jpanel in drop-down , don't want editor able edit string displayed. my question similar @erkanhaspalut 's question here neither response satisfying. i'd made similar attempt embedding jpanel in jpopupmenu , adding jtextfield had similar issues popup disappearing prematurely. i've tried forcing size of jcombobox both setting setmaximumsize height value (which has no effect) , with

doctrine - Entity alias in new symfony 2.7 directory structure -

after adapting new recommended structure in symfony 2.7 i'm not able access entity alias through $em->getrepository('bundle:entity') . this directory structure: mybundle - component - catalog - model product.php and mapping definitition in config.yml : mappings: mybundle: type: annotation dir: %kernel.root_dir%/../src/mybundle/component/product/model prefix: mybundle\component\product\model alias: ??? # tried different things what should write in $em->getrepository('mybundle:product') instead of mybundle:product succesfully accesing entity? if possible use default symfony alias, don't need specify alias every entity in config.yml actually didn't need generate:bundle it's not real bundle namespace , logical organization of files. the solution specify complete namespace in getrespository() : $em->getrepository('mybundle

ios - Change a UIButton's text (padding) programmatically in Swift -

still learning swift , don't know objective-c. saw in order changing button's text programmatically requires use of titleedgeinsets not sure how use it. i change text in button (padding) in bottom , both left , right. thanks responses and/or examples! ios 9.1/xcode 7.1/swift 2.1/osx 10.10.5 : the method titleedgeinsets didn't work me. button's frame tightly hugs text (i didn't specify frame size), , frame has red background color. after doing: mybutton.titleedgeinsets = uiedgeinsetsmake(10,10,10,10) the red background shrunk inwards 10 pixels on each side, meant of text outside red background. using negative values had no effect on original frame size. i able padding around text, making frame bigger, doing: mybutton.contentedgeinsets = uiedgeinsetsmake(5,5,5,5)

android - Keyboard hiding EditTexts in Fragments -

Image
edit: need use keyboard, hides edittext , need scroll keyboard not hiding it. i using samsung tablet. my style: parent="android:theme.holo.noactionbar.fullscreen" the edittext fields in scrollable view, so: the fragment layout: <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin"> <scrollview android:layout_height="wrap_content" android:layout_width="match_parent"> <linearlayout android:layout_height="match_parent" android:layout_marginbottom="20dp

ios - fatal error when reloading table data: unwraps to nil: need assistance -

the app developing has table view. seems made mistake when printing table view cell values, because whenever reload table data when app running, fatal error, unexpectedly found nil in unwrapping. happening because there's error in table code. appreciated, thanks. entire code: import uikit class viewcontroller: uiviewcontroller, uitableviewdelegate { var arr = [int]() var timer = nstimer() var countdowntimer = nstimer() var count = 0 var countdown = int(arc4random_uniform(4000) + 1000) var highscore:int! var buttontapcounter = 0 let dateformatter = nsdateformatter() @iboutlet weak var beginbutton: uibutton! @iboutlet weak var table: uitableview! @iboutlet weak var resetdatabutton: uibutton! @iboutlet weak var averagelabel: uilabel! @iboutlet weak var bestlabel: uilabel! @iboutlet weak var startbutton: uilabel! @iboutlet weak var highscorebutton: uilabel! @iboutlet weak var timerlabel: uilabel! @iboutlet weak var backgroundimage: uiimageview! func updatetime() {

Expression is not an integer constant expression in iOS objective c -

Image
i want use following expression -(void)switchcondn{ int expression; int match1=0; int match2=1; switch (expression) { case match1: //statements break; case match2: //statements break; default: // statements break; } but got when research found in order work in objective-c, should define constant either this: #define txt_name 1 or better, this: enum {txt_name = 1}; i have been using methods since long time . variable value change in run time need define in others way , didn't want use if else there way of declaration variable others way i have had study following why can not use constant in switch - case statement in objective-c ? [error = expression not integer constant expression] objective c switch statements , named integer constants objective c global constants case/switch integer constant 'not reduce integer'

javascript - Change span on click Jquery -

i've code $('a').click(function() { $('a span').first().addclass('hide'); $('a span:nth-child(2)').removeclass('hide'); $('a span:nth-child(2)').addclass('display'); }); .hide { display:none; } .display { display:block; } <a href="#"> <span>hello</span> <br> <span class="hide">world</span> </a> when click on link want first span hide , 2nd span appears. i want multiple times (click on link multiples times , have same result). i try jquery code i toggle classes , have prevent default on link doesn't try leave page. $('a').click(function(e) { e.preventdefault(); $('a span').toggleclass('hide show'); }); here work demo

c++ - Universal reference deduction if the argument is address -

quick query regarding universal references: let's have code int q = 10; auto && wtf = &q; this 1 compiles fine, have no idea what's happening behind hood. it's taking reference address? isn't pointer's job? i trying deduce auto&& 's type , did by: int & test = &q //error int && test = &q //error so become? need clarification on what's happening , what's purpose of taking & universal reference? doing because trying understand std::bind since can take address or pointers(which address of being pointed aka pointer's value). when write &q create temporary value. an rvalue [...] xvalue, temporary object (12.2) or subobject thereof, or value not associated object. [§ 3.10] those best bound rvalue references, so auto && wtf = &q; becomes rvalue reference ( && , && stays && ) type of &q . isn't int , it's int * . that'

Why does Python's copy.copy() return a object not equal to the original? -

in python, if copy list or dictionary, copied instance equal original: >>> = [1, 2, 3] >>> b = copy.copy(a) >>> == b true >>> = {"a":1, "b":2} >>> b = copy.copy(a) >>> == b true but if copy object, result not equal original: >>> class myclass(): ... def __init__(self, name): ... self._name= name ... >>> = myclass('a') >>> b = copy.copy(a) >>> == b false why? equality in python objects checked calling __eq__() function. example: >>> class ca: ... def __eq__(self, other): ... print("equals") ... return true ... >>> c = ca() >>> b = ca() >>> c == b equals true that because list equality dependent on elements , not actual memory location (reference) list stored, is, can 2 different list references, if have same elements in same order, lists equal. example

Combinations between elements in two tuples in Python -

this question has answer here: all combinations of list of lists 5 answers is there math ncr function in python? [duplicate] 2 answers i have 2 tuples: t1 = ('a', 'b') t2 = ('c', 'd', 'e') i wonder how create combinations between tuples, result should be: ac, ad, ae, bc, bd, edit using list(itertools.combinations('abcd',2)) i generate list of combinations given string: [('a', 'b'), ('a', 'c'), ('a', 'd'), ('b', 'c'), ('b', 'd'), ('c', 'd')] if insert tuple instead of string following error occurs: typeerror: sequence item 0: expected string, tuple found any suggestion how proceed? itertools.product lookin

php - Create 2 dimensional merged array based value -

i have array in following format, array ( [0] => array ( [expense_id] => 7 [type] => frfrf [mode] => rfr [amount] => 100 [tran_type] => expense [date] => 2015-06-29 ) [1] => array ( [expense_id] => 8 [type] => frfrf [mode] => rfr [amount] => 100 [tran_type] => expense [date] => 2015-06-29 ) [2] => array ( [expense_id] => 9 [type] => frfrf [mode] => rfr [amount] => 444 [tran_type] => expense [date] => 2015-06-29 ) [3] => array ( [expense_id] => 10 [type] => frfrf [mode] => rfr [amount] => 1000 [tran_type] => income [date] => 2015-06-29

detection - Emgucv library currentFrame.Copy -

now working face detecting using emgucv library. beginner that. have not idea line result = currentframe.copy(f.rect).convert<gray, byte>().resize(100, 100, emgu.cv.cvenum.inter.cv_inter_cubic); can please tell me? currentframe.copy(f.rect) image represents image bounded rectangle(f.rect), obtained var f represents result of actual detection want implement; convert() converts grayscale; resize resizes image 100,100 interpolation type emgu.cv.cvenum.inter.cv_inter_cubic. you should read more this.

css - JQuery UI: resizable div with scrollbar -

Image
i made resizable div , want scrollbar (y-axis) when user resized much. when there enough space rows of text, scrollbar should disappear. thought done overflow-y: auto didn't. what should like what looks like https://jsfiddle.net/1wk4mevo/4/ as can see, there scrollbar if there enough space content in div. how can fix this? (code can seen in fiddle) change css handle. if drop height 7px 0px scrollbar goes away. element within box, 'extra' height causing scrollbar appear @ times. so, tried removing bottom:-5px; see below new fiddle. https://jsfiddle.net/1wk4mevo/8/ overriding css works: .ui-resizable-s { bottom:0px; } and produces result you're looking for.

node.js - Deploying Sails.js project to Google cloud: "Fatal error: Unable to find local grunt." -

i trying deploy sails.js project google cloud. after running gcloud preview app deploy app.yaml --set-default , deploy seems successful when browse project, see error: server error the service requested not available yet. please try again in 30 seconds. the logs console.developers.google.com show " fatal error: unable find local grunt. " should configure on google cloud have grunt available? or should configure in project allow cloud find grunt? i have been able deploy demo projects https://cloud.google.com/nodejs/ not projects using sails.js. update: solved the problem sorted installing grunt , grunt-cli locally bunch of other dependencies. same issue can this: make sure package.json file contains following dependencies: "dependencies": { "express": "^4.12.0", "gcloud": "^0.15.0", "grunt": "^0.4.5", "grunt-cli": "^0.1.13", "grunt-contrib-clean"

php - Sendemail using json -

this question has answer here: php mail function doesn't complete sending of e-mail 24 answers i using template having trouble sending email using sendemail.php. not figure out problem. here codes <?php header('content-type: application/json'); $status = array( 'type'=>'success', 'message'=>'mesajınız gönderildi!' ); $name = @trim(stripslashes($_post['name'])); $email = @trim(stripslashes($_post['email'])); //$subject = @trim(stripslashes($_post['subject'])); $message = @trim(stripslashes($_post['message'])); $email_from = $email; $email_to = 'emailxxx@gmail.com'; $body = 'name: ' . $name . "\n\n" . 'email: ' . $email . "\n\n" . 'message: ' . $message; $success = @mail($email_to, $body, 'from: <'.$email_

java - Error reading multiple lines of integers using BufferedReader -

i getting exception: exception in thread "main" java.lang.numberformatexception: input string: "55 45 65 88 " @ java.lang.numberformatexception.forinputstring(unknown source) @ java.lang.integer.parseint(unknown source) @ java.lang.integer.valueof(unknown source) while using code: bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); string line = br.readline(); int noofstudents = integer.parseint(line); //firstline contains 1 integer. arraylist <integer> marks = new arraylist<integer>(); line = br.readline(); //second line contains line of integers stringtokenizer tokens = new stringtokenizer(line, "\\s+"); // break line tokens while (tokens.hasmoretokens()) { marks.add(integer.valueof(tokens.nexttoken())); //error here //when converting tokens integers giving error } sample input: 4 55 45 65 88 (here, when press enter gives me above stated errors) stringtokenizer doe

java - Conditional in a method that way more than often has already been satisified -

although question not specific java explanation targeted java helpful. problem have done several programs , have manipulated pre-existing games , find there checks 99% or more of time doesn't have person trying do. lets have achievement system , have earn achievement dance. people dance time , have earned achievement long ago , have been dancing hours on end. each time dance there going check see if have done achievement if haven't can given achievement. how can around checking once not apply person anymore? you can use event bus. dance method create event pushed event bus. initially, there part of code going listen dance event. once listener triggered dance event, unregister listener of dance event. edit: similar idea without using eventbus. interface danceeventhandler { void handle(danceevent e); } let there user object each user. class user { .... danceeventhandler danceeventhandler; } initially can use implementation dance event. cla

ios - UITraitCollection remains same for iPhone / iPad -

in ios 8.3, present view controller following code: uinavigationcontroller *nav = [[uinavigationcontroller alloc] initwithrootviewcontroller:controller]; nav.modalpresentationstyle = uimodalpresentationformsheet; nav.modaltransitionstyle = uimodaltransitionstylecoververtical; [self presentviewcontroller:nav animated:yes completion:nil]; upon presentation in ipad simulator, check uitraitcollection property of view ( po self.traitcollection ) in viewdidload() method , here get: <_uitraitnamehorizontalsizeclass = regular, _uitraitnameverticalsizeclass = regular> i switch simulator ipad iphone (5s or 6) , still regular horizontal size class trait in view. iphones should have compact horizontal size class trait. since horizontal size class wrong, wrong size class design loaded storyboard. ideas why framework providing wrong size class?

listview - pinned headerlistview and pulltorefresh ANDROID -

i'm learning using this:- https://code.google.com/p/android-amazing-listview/ and modified add pull refresh. any example headerview pulltorefresh custom listview? you can consider using combination of swiperefreshlayout , listview. see answer here: https://stackoverflow.com/a/31874079/2114334

python 2.7 - Password text filed in pyqt -

i new in pyqt4 want add password text field in design.i can't see password type text field there way convert simple text field password type?? editor = qlineedit() editor.setechomode(qlineedit.password)

java - How to detect web based popup such as the one Google Play store is using with Selenium Webdriver? -

example: go playstore app permissions , click link (view details) web based (javascript activate) popup. how detect it? since not ordinary web based or window pop up, doesn't detect @ all. pcontent = driver.switchto().activeelement().findelement(by.classname("model-dialog")); location = pcontent.findelement(by.xpath("//bucket-description[text(),'precise location (gps , network-based]")).gettext(); system.out.println(location); if know how detect selenium webdriver, please help! thank in advance! idk how code executed.it full of bugs 1.there no such class model-dialog modal-dialog .please copy paste html or cross check value at-least once. 2. by.xpath("//bucket-description[text(),'precise location (gps , network-based]") .is xpath.read xpath start creating once 3.that not popup.it's normal element that's hidden inside dom.read webdriverwait , expectedconditions , see how check visibility of element 4.

serialization - Serializing multiple files to binary Avro format -

i have directory of files taking large amount of space. i'd compress , serialize each of these files binary avro format free disk space. schema avro data file record containing single field store content of original file. i'm considering making use of utility in avro-tools jar provided apache serialize each file. utility takes avro schema , input file containing records serialized in json format , produces avro data file: $ java -jar ~/avro-tools-1.7.6.jar fromjson --schema-file twitter.avsc twitter.json > twitter.avro i'd write bash script executes tool each file in folder, i'm not sure how form equivalent record each file in json format tool expects. each of files hundreds of mb in size. wondering if forming json file ({'content': 'file content..'}) done using text processing commands or tools (awk, sed, etc.) command line. also, there better ways accomplish of achieving larger task, of migrating multiple files avro storage, approach i'm

javascript - Angular does not updated loop due to implementation $mdDialog (Material Design) -

based on previous post: angular loop not updating , updated code add dialog box button a user. the change in app.js file directive add $mddialog box. complete code app.js file is: var app = angular.module('adduser', ['ngmaterial']); app.controller('appctrl', function($scope, $http, $mddialog){ $scope.userinfo = []; /** function add details user in mysql referecing php **/ $scope.save_user = function() { $http.post('db.php?action=add_user', { 'user_name' : $scope.user_name, 'user_email' : $scope.user_email } ) .success(function (data, status, headers, config) { $scope.userinfo.push(data); $scope.get_user(); //this fetch latest record db console.log("the user has been added db"); console.log(data); }) .error(function(data, status, headers, config) { console.log("failed add user db"); }); } /** functio

windows - Delphi SaveDialog not displayed -

in application developed delphi xe6 , reportbuilder ( link ), , deployed on windows 7 computers, after reportbuilder report displayed on screen, user has option print file. a button allows user select directory file saved: /* source code provided digital metaphors; cannot change it. */ savedialog1: tsavedialog; ... procedure tppprintdialog.btnprinttofileclick(sender: tobject); begin if savedialog1.execute begin in of windows 7 computers application has been deployed, report works correctly. however, in computers, nothing happens when savedialog1.execute executed. i have found stackoverflow post reference embarcadero post states following: problem there resolved deleting executable name hklm\software\microsoft\windows nt\currentversion\image file execution options unfortunately, in case, problem has not been solved because application not listed on mentioned registry entry. i have contacted digital metaphors , embarcadero no avail. thi

c# - My ForgotPassword method is not sending email -

Image
i have problem in forgot password method although status=rantocompletion there no email received @ all. i've tried many email addresses , there nothing. can 1 tell me might problem. here code: // post: /account/forgotpassword [httppost] [allowanonymous] [validateantiforgerytoken] public async task<actionresult> forgotpassword(forgotpasswordviewmodel model) { if (modelstate.isvalid) { var user = await usermanager.findbynameasync(model.email); if (user == null || !(await usermanager.isemailconfirmedasync(user.id))) { // don't reveal user not exist or not confirmed return view("forgotpasswordconfirmation"); } string code = await usermanager.generatepasswordresettokenasync(user.id); var callbackurl = url.action("resetpassword", "account", n