Posts

Showing posts from August, 2015

ios - Why is fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) occurring? -

an error occurring in swift app ios 8 in xcode 6.4. fatal error: unexpectedly found nil while unwrapping optional value (lldb) gyazo screenshot: http://i.gyazo.com/6bd9207655763cf941b44c8049f88549.png i've been trying fix error 2 hours now! please me. thanks, jamie mathieson well, that's simple problem solve.. usernametextfield.text , passwordtextfield.text can blank, can't put ! after it.. have this: if usernametextfield.text != nil && passwordtextfield != nil { user.username = usernametextfield.text user.password = passwordtextfield.text } hope helps..

android - FindViewById returns null on custom relative layout -

in init method, findviewbyid returns null on r.id.disable_view_content. public class disableview extends relativelayout { private view content; private view disableview; private int disablebackgroundcolor; private boolean isenabled; public disableview(context context) { super(context); init(); } public disableview(context context, attributeset attrs) { super(context, attrs); obtainattributes(context, attrs); init(); } public disableview(context context, attributeset attrs, int defstyleattr) { super(context, attrs, defstyleattr); obtainattributes(context, attrs); init(); } @targetapi(build.version_codes.lollipop) public disableview(context context, attributeset attrs, int defstyleattr, int defstyleres) { super(context, attrs, defstyleattr, defstyleres); obtainattributes(context, attrs); init(); } private void obtainattributes(context

javascript - combining two functions to check if true then continue -

i have 2 triggers, 1 returns boolean confirm , other sends ajax request . i noticed using functions are, if click cancel ajax still follows through. issue confirm trigger broad , used more 1 trigger used different things. how go checking if confirm returns false? heres example: this code check see if confirm link clicked $('div.answers').on('click', '.confirm', function() { return confirm('are sure?'); }); this code ajaxy things has confirm class: $('div.answers').on('click', '.trg-delete', function() { var = $(this); var itemid = that.data("id"); $.ajax({ type: "post", url: "./delete-answer.php", data: { itemid: itemid } }) .done(function(data) { if(data == 1) { .css("color", "#27ae60") .html('<i class="fa fa-fw fa-check"></i>'); }

javascript - Angular validators and ng-maxlength use -

i've got following div, want add bootstrap's class "has-error" if input length on 50 characters. html: <div class="form-group" ng-class="{has-error:[formdata.titulo.$error]}"> <label for="inputtitulo">título</label> <input type="titulo" class="form-control" id="inputtitulo" maxlength="50" ng-maxlength="50" ng-model="formdata.titulo"> </div> how can make work? guess when reach 50 characters, ng-maxlength throws error, $error object, have no clue on object is, how access it, , if have more work in controller or directive. any here? can't find "easy" info regarding issue , angular validators. edit 1: i've seen responses, learned new you, still somehow not working. way: <div class="form-group" ng-class="{'has-error': formdata.titulo.$error.maxlength}"> <lab

java - How to map weak entity hibernate -

Image
i have following relation in database: i have 1 strong table. i have 1 weak table has 1 one relation strong table. it's 0 1 relation, because strong table doesn't have 1 line in weak table. identify weak table enough id of strong table. and have weak table, manytoone relation first weak entity. needs id of onetooneweakentity (that id of strong table), , own id. it's historical of onetooneweaktable. i want map in hibernate, don't know how it. now have following code: @entity @table(name="table") public class table { @id @generatedvalue(strategy = generationtype.auto) @column(name="id_table") private integer idtable; private string otheratributes; .... } @entity @table(name="onetooneweaktable") public class onetooneweakentity { @onetoone(cascade = cascadetype.all, optional=false) @id @joincolumn(name="table_id_table") private table table; private string otheratribu

javascript - Change id of clone children in jQuery -

i have table on have hidden line clone in order add new lines dynamically. var $clone = $('#table-invoicing').find('tr.hide').clone(true).removeclass('hide'); $('#table-invoicing').find('table').append($clone); each line have id , data-type. hidden line set id ending in 99. change id when clone hidden line. i found similar topics, reason don't manage include in script. when clone line, there 2 elements same id, selector id won't work. i tried : $clone.$('#invoicing-row-descr-99').attr("id", "newid"); but tells me $clone not function. any idea ? $clone.$('#invoicing-row-descr-99').attr("id", "newid"); but tells me $clone not function. because $clone object. use attr or prop cloned element : $clone.attr("id", "newid");//change cloned element id as per comment, use this: $clone.find('your_element').attr("id&qu

passings array as props in reactjs -

i new react. i have been experimenting on react , got stuck on how pass array using props. case-1: var c = ['program']; var navigation = react.createclass({ getinitialstate: function () { return { opendropdown: -1 }; }, getdefaultprops: function () { return { config: ['everyone'] }; }, render: function () { return ( <div classname="navigation"> helloworld {this.props.config[0]}; </div> ); } }); react.render(<navigation config={c}/>, document.body); this rendering helloworld program. expected. later have tried. case-2: var c = ['program']; var navigation = react.createclass({ getinitialstate: function () { return { opendropdown: -1 }; }, getdefaultprops: function () { return { config: ['everyone'] };

php - How do I properly redirect with my own Dynamic DNS script -

i wrote relatively simple php script able receive requests routers update active ip isp mysql table. active ip linked subdomain-name. have domain wildcard subdomains, can redirect via script ip linked subdomain. domain points static ip , firewall forwards requests apache server. works fine long try access subdomain through browser, redirected ip database entry. ping subdomain static ip. my question have link subdomain ip. have run own nameservers, link them domain , have script edit nameserver config ips ping on subdomain ? any push right direction appreciated.

c# - How to sort string as numbers in DataGridView with DataSouce binded -

according latest question i've changed data source datagridview. bound datatable. in situation sortcompare event doesn't fire. how can call event sortcompare now? sorting perfectly... edit: don't need normal sorting "column_name desc" , dt.defaultview.sort doesn't work me.

jQuery - check if the element is visible and fade in -

i have <div> element on page (let's has .myelement class). have third-party script manipulates element , can change visibility style attribute " visibility: visible ". i need check if .myelement's visibility :visible , , if is, trigger jquery .fadein() function. i think mean check if element visible , if not , fade in. there no point in fading in element visible on page. if case should this: var $element = $('.myelement'); if ($element.is(':visible')) { element.fadeout(); } else { element.fadein(); }

java - Cannot Produce PDFs in Local System -

i'm getting following error when try produce pdf (xsl:fo generated) in local server: error 500: java.lang.noclassdeffounderror: com.sun.media.jai.codec.filecacheseekablestream given error doesn't show on our dev server, or other server application deploys to, i'm thinking issue missing .jar file in build path. knowing use fop (version 1.0, believe), code in java, , using xsl:fo format our documents, .jar files might missing build path?

Facebook Android SDK 4.0 not returning emailID -

Image
i trying implement facebook login using latest facebook sdk 4.0.it returning user-id , user-name. below code have implemented using graph apis. @override public void onviewcreated(view view, bundle savedinstancestate) { super.onviewcreated(view, savedinstancestate); loginbutton loginbutton = (loginbutton) view.findviewbyid(r.id.login_button); textview = (textview) view.findviewbyid(r.id.textview); list<string> permissions = new arraylist<>(); //permissions.add("user_friends"); permissions.add("email"); //permissions.add("user_birthday"); loginbutton.setreadpermissions(permissions); loginbutton.setfragment(this); loginbutton.registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { graphrequest.newmerequest( loginre

EF 6 Remove entity connected to read only view -

Image
i have 2 entities: 1 based on normal db table , base on db view. connected 1 many, this: entity city not have store procedures mapped because entity country enough have read collection of cities. , cascade rule not set. but want delete country instance have cities loaded i've received following error: unable update entityset because has definingquery , no 'deletefunction' element exists in 'modificationfunctionmapping' element support current operation. which forcing me create dummy stored procedure on db , use delete function, ugly solution. is there better solution?

rabbitmq - convertSendAndReceive is not working when the queue is Shoveled -

fyi, i'm newbie rabbitmq. i have use case application i'm trying use rabbitmq: producer sends message queue consumer process , send reply based on reply producer acts on for above scenario, used convertsendandreceive works charm when both producer , consumer in same rabbitmq server. same not work when queue shoveled. please let me know if using wrong method/configuration w.r.t rabbitmq. thanks in advance. adding code consumer public static void main(string[] args) throws interruptedexception { connectionfactory cf = new cachingconnectionfactory("10.223.19.89"); // set queue, exchange, binding on broker rabbitadmin admin = new rabbitadmin(cf); queue queue = new queue("myqueue"); queue queuereply = new queue("myqueue_reply"); admin.declarequeue(queue); admin.declarequeue(queuereply); topicexchange exchange = new topicexchange("myexchange");

PHP image save using curl giving garbage values -

Image
i trying save images using php code using curl. function scaleimageandsaveit($appname,$imageurl) { $format=time(); print_r($format); //$strf=strftime($format); $imagelocnname = $appname . "_" . $format ; $ch = curl_init($imageurl); print_r($imageurl); $fp = fopen($imagelocnname, 'wb'); curl_setopt($ch, curlopt_file, $fp); curl_setopt($ch, curlopt_header, 0); //exit; curl_exec($ch); curl_close($ch); fclose($fp); } when running in browser giving garbage values on screen , not saving image also. how save image , garbage values. image link

Twilio - The requested resource not found error. while transferring number between sub accounts -

i using sample code transfer number 1 sub account sub account. ( https://www.twilio.com/docs/api/rest/subaccounts ) // account sid , auth token twilio.com/user/account $sid = "acmastersid"; $token = "mastertoken"; $client = new services_twilio($sid, $token); // object sid. if not have sid, // check out list resource examples on page $number = $client->account->incoming_phone_numbers- >get("pn2xxxxxxxxxxxxxxxx"); $number->update(array( "accountsid" => "ac00000000000000000000000000000002" )); echo $number->phone_number; i getting error: the requested resource /2010-04-01/accounts/acxxxxxxxx/incomingphonenumbers/pnxxxxxxxxxxx.json not found it not clear issue code. any appreciated. thanks. the following code works fine. need phone number object account moving , update account sid. // account sid , auth token twilio.com/user/account $sid = "acmastersid"; $token = "

node.js - Can't run Grunt from PhpStorm -

i'm using latest phpstorm 9 under ubuntu 14.04 , have small project , installed grunt. works fine in normal terminal, if want run grunt tasks phpstorm's terminal following error: grunt: command not found ps: know it's not big thing pressing alt + tab switch terminal, hate that.

Using VBA or Ad-in for Outlook 2010 to copy new email subject to the message -

using vba or add-in or different automatic method want following: when create new email , before send it, copy subject of email , paste @ beginning of text message. after sending email, recipient see subject in subject box before , see @ the top of message. for example: before: subject: new schedule message: monday, wednesday, friday after applying macro or other automatic methods: subject: new schedule message: new schedule monday, wednesday, friday any example if possible? you can handle itemsend event of application class may modify message body. fired whenever microsoft outlook item sent, either user through inspector (before inspector closed, after user clicks send button) or when send method outlook item, such mailitem, used in program. the outlook object model provides 3 main ways working item bodies: body . htmlbody . the word editor. wordeditor property of inspector class returns instance of word document represents message body. so

How to run python programs in pycharm with passing parameters? -

i having problem running python programs in pycharm, used right click , run program. want run program this: python hrllo.py rahulkapoo vit university here error get: traceback (most recent call last): file "c:/users/rahul/pycharmprojects/untitled/hrllo.py", line 107, in <module> aggregate() file "c:/users/rahul/pycharmprojects/untitled/hrllo.py", line 88, in aggregate br = login() file "c:/users/rahul/pycharmprojects/untitled/hrllo.py", line 23, in login response = br.open('https://academics.vit.ac.in/student/stud_login.asp') file "c:\python27\lib\site-packages\mechanize\_mechanize.py", line 203, in open return self._mech_open(url, data, timeout=timeout) file "c:\python27\lib\site-packages\mechanize\_mechanize.py", line 255, in _mech_open raise response mechanize._response.httperror_seek_wrapper: http error 403: request disallowed robots.txt process finished exit code 1 in

perl - How do I pass an opened filehandle as the parameter of a function? -

i have main script calls function module. open file in main script, , want use filehandle attached file parameter in function called (i don't want open file in function because calling same function on same file several times, opening every time wouldn't make sense). in main script: open(my $in_file, "<input.txt") or die "can't open: $!\n"; open(my $out_file, ">output.txt") or die "can't open: $!\n"; anothermodule->processdbu($in_file, $out_file); in anothermodule : sub processdbu{ $in_file = $_[0]; $out_file = $_[1]; local $/ = ' '; while(<$in_file>){ someprocess(); } } however, when try run script, error occurs: readline() on unopened filehandle @ anothermodule.pm line 7. what's preventing me using filehandle? why unopened? can fix problem? you calling function method. anothermodule->processdbu($in_file, $out_file); should be another

How to get millis of timestamp since 1970 UTC in Oracle SQL? -

i have table 1 of columns of type timestamp(6) . how milliseconds of column's data since 1970 utc ? try this select (cast(your_column date) - date '1970-01-01')*24*60*60 your_table;

ruby on rails - Adding rows that are only associate with previous row -

i have table call municipalities , call forms. forms have 1 municipality, , stores variable called municipality_id. when select state drop down menu, show municipalities state_id. @ point, want display forms associated municipality. i'm having trouble getting municipality's forms show, , not of them. here code far: view: <div class="form-group"> <div> <% @municipalities.each |municipality| %> <tr class="active"> <td><%= link_to municipality.name, municipality_path(municipality) %></td> <td><%= municipality.state.state %></td> <td><%= municipality.population %></td> <% if user_signed_in? %> <td><%= link_to 'show', municipality %></td> <td><%= link_to 'edit', edit_municipality_path(municipality) %></td> <td><%= link_to 'destroy', municipality, method: :delete

Reading API response in PHP -

i making request mixpanel api $data = $mp->request(array('segmentation'), array( 'event' => 'loaded page', 'name' => 'loaded page', 'from_date' => '2015-07-01', 'to_date' => '2015-07-01', 'type' => 'unique', 'expire' => '1439089200' //'unit' => 'day', //'interval' => '7', //'format' => 'json' )); //echo $data; var_dump($data); here response getting. object(stdclass)#2 (2) { ["legend_size"]=> int(1) ["data"]=> object(stdclass)#3 (2) { ["series"]=> array(1) { [0]=> string(10) "2015-07-01" } ["values"]=> object(stdclass)#4 (1) { ["loaded page"]=> object(stdclass)#5 (1) { ["2015-07-01"]=> int(267691) } } } } can please me how can read response in variables. want count o

scala - Spark - Can't read files from Google Cloud Storage when configuring gcs connector manually -

i have spark cluster deployed using bdutil google cloud. installed gui on driver instance able run intellij it, can try run spark processes in interactive mode. the first issue faced spark-env.sh , core-site.xml not used @ when running intellij. managed set configuration manually in scala copying values configuration files. there way avoid ? the last thing not working if gcs connector seems "see" folder set source, each time tries read actual files in folder, java.io.eofexception. here's code tests : object sparkbasictest { def main(args: array[string]) { val conf = new sparkconf().setappname("simple application") conf.setmaster("spark://research-m:7077") conf.set("spark.akka.framesize", "512") conf.set("spark.driver.maxresultsize", "1631m") conf.set("spark.yarn.executor.memoryoverhead", "384") conf.set("spark.driver.memory", "3263m&quo

html - What does the fieldset element's name attribute do? -

i understand general semantics of <fieldset> , along how name attribute on <fieldset> can used give meaning group of inputs. w3 wiki has number of examples this. however, don't understand name attribute on <fieldset> elements when submitting forms. according mdn , name submitted form data. w3c mentions it's element's name, used in form submission. when trying out name attribute on <fieldset> though, don't see being submitted rest of form data. it's unclear me if has use other semantics. is name attribute on <fieldset> elements supposed submitted form data? if so, have value? do? however, don't understand name attribute on <fieldset> elements when submitting forms. nothing. you've tested yourself: when trying out name attribute on <fieldset> though, don't see being submitted rest of form data. it appears error in summary of spec (presumably copied input @ point) has

sharepoint - Sharepoit c# how to update 'Approval workflow' programatically -

i need update 'approval workflow' status programmaticaly in picture. please me or orient me solution. already tried below code: hashtable ht = new hashtable(); ht["formdata"] = spworkflowstatus.completed; ht[spbuiltinfieldid.completed] = "true"; ht[spbuiltinfieldid.percentcomplete] = 1.0f; ht["com"] = "test comments"; ht["reviewed"] = "yes"; ht["sendsignoffemail"] = "yes"; ht["taskstatus"] = "approved"; bool succed = spworkflowtask.altertask(t splistitem, ht, true); attached image understand me better. i prefer change task worklow workflow himself. since worklow associated task. have change status of task in order instance of workflow approved.

mongodb - Dump restore throws error -

i'm getting below error while restoring dump mongodb, mon jul 27 14:08:52.936 going namespace [test.bc_2022_tmp] mon jul 27 14:08:52.936 warning: restoring viacrm.bc_2022_tmp without dropping. restored data inserted without raising errors; check server log mon jul 27 14:08:52.937 file /home/dev/test/bc_2022_tmp.bson empty, skipping mon jul 27 14:08:52.937 creating index: { key: { _id: 1 }, ns: "viacrm.bc_2022_tmp", name: "_id_" } mon jul 27 14:08:52.938 error: error creating index test.bc_2022_tmp: 13347 err: "local.oplog.rs missing. did drop it? if restart server" abandon (core dumped) dump restore command: mongorestore -d test /home/dev/crm please can me resolve issue

Android url custom scheme dosent work -

i read post this, think code right (very simple), links dosen't appear clickable "manager://xxxx" , in mail, in qr, in whatsappp... whats happend? i try only <data android:scheme="coc" /> but in whatsapp work http links. why! <activity android:theme="@style/appthemefullscreen" android:configchanges="orientation|keyboardhidden|screensize" android:label="@string/app_name" android:exported="true" android:launchmode="singletask" android:name=".aloginconnect"> <intent-filter> <data android:scheme="coc" android:host="*" android:pathpattern=".*" /> <action android:name="android.intent.action.view"/> <category android:name="android.intent.category.default"/> <category android:name="android.intent.

c# - Increasing the size of the Siteroots drive in my Azure Cloud Service -

Image
i have cloud service web role . default siteroot drive small files need. now, have tried updating " vm size " in configuration of cloud service, increases size of other drives on cloud service vm. q: how make siteroot's drive larger? check duplicate . in general, there no control on size of drives.

java - Sudden increase of threads - JConsole -

Image
sometimes application becomes slow , don't know why. i found out that, when happens, there rather odd increase of number of threads in jconsole. the problem don't know how pinpoint threads created time , why. maybe jconsole has way on doing me, have no idea. does has clue on how resolving mistery? jconsole print below. (it happened around 12:00).

javascript - Trying to add bootstrap to rails. Need to install nodejs? -

i following tutorial install bootstrap on rails application. i've been following tutorial http://www.gotealeaf.com/blog/integrating-rails-and-bootstrap-part-1 thought run error, when change application.css application.css.sass. current execjs runtime does't support es5. please install node.js. (in c:/users/danielh/desktop/rotairapp/rubydev/rotairapp/app/assets/stylesheets/application.css.sass) extracted source (around line #9): 6 7 8 9 10 11 12 </style> <title>rotair</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> </head> the application css file looks @import "bootstrap-sprockets" @import "bootstrap" do need install node.js? you can use cdn too. putt cdn css file , js

Find files that match the regex pattern -

i need find files match particular pattern in grails. the files labeled "runid.started.xml". i'm looking find using following regex: /(? <=\.)(.*?)(?=\.)/ i can find files need likit files match pattern. found few examples none seem work. latest: new file (c:\\mydirectory\\test ).eachfilerecurse (files) { if (it.name ==~ /(? <=\.)(.*?)(?=\.)/){ println { println "nope" } this returns "nope"... i'm new grails i'm not sure i'm going wrong. regex seems correct in online regex tester may wrong. ==~ match operator. meaning string in question must exact match. , (? <=\.)(.*?)(?=\.) doesn't match "runid.started.xml". have 2 options: use search operator in if statement: =~ write regex exactly matches file names like: \w*\.(\w+)\.\w*

objective c - Linker error referring to _main when running iOS unit test in Xcode -

Image
i'm trying run unit test in xcode links against static library. static library "libgsg" includes static libraries other 3rd party providers. in 1 of them seems have declaration of "main" linker complaining about... is there can work around or out of luck? best can suggest trying untangle tests static library, don't need link against in test target.

Android NDK C++ files keep file structure -

i trying integrate c++ library i've created ios android project uses ndk build .cpp files. problem in ios, can include files using : #include "myfile.h" which works fine, regardless of these files placed, provided link xcode project. however, if place files using normal file structure, including .h not in same file requires relative url. along lines of : #include "../myotherfolder/myotherfile.h". is there way mimic xcode behaviour (flat file hierarchie) using android studio? perhaps there setting / flag specified in build.gradle file? thanks! you can explicitly add other include directories considered android studio using cflags/cppflags. for example: android.ndk { modulename = "mymodule" //... cppflags += "-i${file("src/main/jni/myotherfolder")}".tostring() //... }

javascript - Receive data in ajax call back from server without reloading and update current page. Express 4 and Node -

i have form form#form-reflow(action='/', method='post', onsubmit="docreflow()") input#textinp(type="text", name="textinp") input#submit(type="submit", name="submit") that runs following ajax client script send form data express. function docreflow() { $('#form-reflow').on('submit', function (evt) { evt.preventdefault(); $.post($('#form-reflow').attr( 'action' ), { data: $("#textinp").val(), headers: {'x-requested-with': 'xmlhttprequest'}, datatype: 'text', accepts: { text: 'text/plain' }, }) .done(function ondone (data) { console.log("returned data is: "); var data = json.

android initialize two times in two different activities -

not able initialize parse 2 times in 2 activity call data 2 classes of parse , put them in different list views. @ second time when opening contact activity action item app stops main activity.java public class mainactivity extends actionbaractivity { private countryadapter madapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); parse.initialize(this, "0fgkgokshcbpqspy**********", "f1hz9w4c***********"); parseobject.registersubclass(country.class); madapter = new countryadapter(this, new arraylist<country>()); listview mlistview = (listview) findviewbyid(r.id.country_list); mlistview.setadapter(madapter); updatedata(); } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu_main, menu); return true; }

iphone - How to do logout with Parse Swift iOS 8 Xcode 6.4 -

how log out parse swift ios 8 xcode 6.4? here's screenshot. i need add action button can log out parse. http://i.gyazo.com/905df0a5f4bf29e7dd1a2b44e0c35865.png please help. thanks, jamie mathieson after log out need present loginview controller or sign pfuser.logout() let login = storyboard.instantiateviewcontrollerwithidentifier("someviewcontroller") as! uiviewcontroller self.presentviewcontroller(login, animated: true, completion: nil)

java - How to acces jdbc properties file (for Spring security configuration) which is outside WEB-INF folder? -

how can access jdbc properties in spring security configuration outside web-inf folder of webapp ? project heirachy below tomcat webapps appname configuration jdbc.properties other configuration files here webpages jsps/htmls here web-inf web.xml spring-security.xml classes/ lib/ tlds/ inside spring-security.xml trying refer jdbc.properties , everytime file not found exception, <bean class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="location" value="file:${catalina.home}/webapps/appname/configuration/jdbc.properties"/> <property name="location" value="file:${catalina.base}/webapps/appname/configuration/jdbc.properties"/> <property name="location" value="/configuration/jdbc.properties"/> <property name="location" val

algorithm - Number of Binary Search Trees of a given Height -

how can find number of bsts upto given height h , discard bsts height greater h given set of unique numbers? i have worked out code using recursive approach static int bst(int h,int n){ if(h==0&&n==0)return 1; else if(h==0&&n==1)return 1; else if(h==0&&n>1)return 0; else if(h>0&&n==0)return 1; else{ int sum=0; for(int i=1;i<=n;i++) sum+=bst(h-1,i-1)*bst(h-1,n-i); return sum; } } you can speed adding memoization @davideisenstat suggested in comments. you create memoization table store values of computed results. in example, -1 indicates value has not been computed yet. example in c++ long long memo[max_h][max_n]; long long bst(int h,int n){ if(memo[h][n] == -1){ memo[h][n] = //compute value here using recursion } return memo[h][n]; } ... int main(){ memset(memo,-1,sizeof memo); bst(102,89); } this execute in o(h*n) compute bst on

c++ - Suppress C4189 in Visual Studio for each -

i'm working on visual studio 2013 , got simple loop for each (const std::string &foo in stringlist) { /*things happen here foo never used for*/ } in loop pop n elements list dont use foo here , got c4189 warning (w4) want suppress here. i looked around , found several solutions like for each (const std::string &foo in stringlist) { (void)foo; /*things happen here foo never used for*/ } or define solutions #define unused __pragma(warning(suppress:4189)) personally define solution, seems not work in loop because still got warning if use define. so question: is there way suppress warning without setting compiler flags? don't want use line inside loop suppress warning.

oop - Issue accessing a relation in a PHP object -

i using laravel 4 , have line: $report = deliveryprofitreport::where('id', $id)->with('car_info', 'basic_customer')->get(); i access 'car_info' so: $report->car_info->id but getting errors time: undefined property: illuminate\database\eloquent\collection::$car_info the object looks (if dd() $report): object(illuminate\database\eloquent\collection)#823 (1) { ["items":protected] array(1) { [0] object(deliveryprofitreport)#798 (20) { ["table":protected] "delivery_profit_reports" ["guarded":protected] array(0) { } ["connection":protected] null ["primarykey":protected] "id" ["perpage":protected] 15 ["incrementing"] true ["timestamps"] true ["attributes":protected] array(29) { ["id"] "13" ["updated_at"] "2015-07-15 10:11:3

asp.net mvc - Adding two lists together with duplicates C# MVC -

i have 3 lists of product entity keys want put one big list . want duplicates present want determine product mentioned in final list. i trying use .union removes duplicates final list. //union selector results iqueryable<productmodel> unionproducts = categoryproducts.union(attoptproducts); if (manufacturerproducts != null) unionproducts = unionproducts.union(manufacturerproducts); if (brandproducts != null) unionproducts = unionproducts.union(brandproducts); any appreciated. use concat instead of union keep duplicates: iqueryable<productmodel> unionproducts = categoryproducts.concat(attoptproducts); if (manufacturerproducts != null) unionproducts = unionproducts.concat(manufacturerproducts); if (brandproducts != null) unionproducts = unionproducts.concat(brandproducts);

Rails Devise, using Onliner gem for list of online users -

i'm trying use onliner gem ( https://github.com/kbokhonko/onliner ) display list of online users. however, when try view page list should on "undefined method `each' nil:nilclass". note if change "user.online" "user.all" error message goes away , can view page it's not methods in wrong place or that, must doing wrong in implementation of gem. if familiar gem explain i'm doing wrong, great! i'm sure it's def online method not being set properly, i'm not sure how else write it. users_controller.rb: def online @users = user.online end online.html.erb: <table> <thead> <tr> <th>users online</th> </tr> </thead> <tbody> <% @users.each |user| %> <tr> <td><%= user.email %></td> <td><%= user.user_type %></td> <% if user_signed_in? && current_user.user_type == 'a

c++ - sum of all the elements in an array in less than O(n) -

i tried adding places , odd places in loop add both final answer making complexity o(n/2) need better way you manage array , update sum when there changes. shifts time modifying operations , technically calculate (or not) sum in 0 time.

php - Fatal error: Cannot redeclare PHPMailerAutoload() -

i using phpmailer send emails local host. i have written function supposed send emails registered users have chosen option receive them. (i.e. newsletter subscription, etc) function email_users($subject, $body) { include('core/db/db_connection.php'); $sql = "select email, first_name `_users` allow_email = 1"; $query = mysqli_query($dbcon, $sql); while (($row = mysqli_fetch_assoc($query)) !== false) { $body = "hello ". $row['first_name'] . ", <br><br>" . $body; email($row['email'], $subject, $body); } } the code calling function: if (isset($_get['success']) === true && empty($_get['success']) === true) { ?> <h3 class="email_success">emails have been sent</h2> <a href="admin.php" class="email_success_a">go admin page</a> <?php } else {