Posts

Showing posts from March, 2010

Any way to simplify R code? -

i have following code seems long winded - i'm doing same thing each file figured there must method simplify alludes me @ present! appreciated always: .lvb.sf.1.1 <- read.csv("lvb_sf_1-1.csv", header=t, sep=","); .lvb.sf.1.6 <- read.csv("lvb_sf_1-6.csv", header=t, sep=",") .lvb.sf.1.2 <- read.csv("lvb_sf_1-2.csv", header=t, sep=","); .lvb.sf.1.7 <- read.csv("lvb_sf_1-7.csv", header=t, sep=",") .lvb.sf.1.3 <- read.csv("lvb_sf_1-3.csv", header=t, sep=","); .lvb.sf.1.8 <- read.csv("lvb_sf_1-8.csv", header=t, sep=",") .lvb.sf.1.4 <- read.csv("lvb_sf_1-4.csv", header=t, sep=","); .lvb.sf.1.9 <- read.csv("lvb_sf_1-9.csv", header=t, sep=",") .lvb.sf.1.5 <- read.csv("lvb_sf_1-5.csv", header=t, sep=","); .lvb.sf.2.0 <- read.csv("lvb_sf_2.csv", header=t, sep=",...

SQL Server 2012: Constraint has NULL for name. How can I drop this? -

i not sure how happened, have primary key constraint on 1 of tables , name null. discovered because had drop/recreate table, , when tried add primary key, system responded constraint existed. i executed following: select i.object_id, i.name, i.type_desc sys.indexes inner join sys.tables t on i.object_id = t.object_id , t.name = n'organization' and result is: object_id name type_desc 1570377655 null heap 1570377655 ix_organization_ownedbyorganizationid nonclustered i tried dropping , recreating table several times , each time index there. how can drop constraint? you can try find index trying add using following query: select [table] = t.[name] , [index] = i.[name] , i.* sys.indexes inner join sys.tables t on t.[object_id] = i.[object_id] martin has right answer index find null name.

postgresql - SQL query working but gives syntax error in PHP -

edit: issue not having comma after timestamp suggested in comment. timestamp not variable , postgres keyword convert time , date timestamp data type before inserting it. similar cast. i have following sql query in postgres , works no errors: insert sms (from_number, to_number, message, reply_time, sent_at) values ('10000000000', '0000000000', 'ffffffff', now(), timestamp '2015-05-27 18:45:31') i have function in php equivalent query: function insertwithsenttime($from, $to, $text, $senttime) { $con = pg_connect("host=$this->host dbname=$this->db user=$this->user password=$this->pass") or die ("could not connect server\n"); $query = "insert sms (from_number, to_number, message, reply_time, sent_at) values ($1, $2, $3, now(), timestamp $4)"; pg_prepare($con, "prepare1", $query) or die ("cannot prepare statement\n"); pg_execute($con, "prepare1", ar...

android - Execution failed for task ':app:mockableAndroidJar' -

i using local gradle of version 2.4 , intellij idea 14.1.3 when run project intellij runs fine when execute gradle clean build command command line gives flowing exception , build fails. failure: build failed exception. * went wrong: execution failed task ':app:mockableandroidjar'. > java.util.zip.zipexception: invalid entry compressed size (expected 2051 got 2050 bytes)

ember.js - Ember JS | How is ember differentiating Router resource and a route? -

ember makes use of router.js load resource , corresponding template application template. happens when particular route accessed? i.e how ember know accessing route not resource? google question, you'll find lots of answers. or, read source code. basically, resource resets directory path ember looks relevant assets @ top level of project. if have "authenticated" route checks authentication, , under have "users" route, you'll want make resource can keep "user" related assets such controller, route , template in user directory @ top level instead of under "authenticated" directory.

arrays - Find Value Type of a JSONValue (TJSONArray or TJSONObject) -

i standard library in delphi xe8 if assigned(jsonvalue) case jsonvalue.valuetype of jsarray : processarrayresponse(jsonvalue tjsonarray); jsobject : processobjectresponse(jsonvalue tjsonobject); end; end; (this sample come https://github.com/deltics/delphi.libs/wiki/json using deltics.json library). does know how standard library ? thank you you use is operator: if assigned(jsonvalue) begin if jsonvalue tjsonarray processarrayresponse(tjsonarray(jsonvalue)) else if jsonvalue tjsonobject processobjectresponse(tjsonobject(jsonvalue)); end; if want use case statement have create own lookup: type jsonvaluetype = (jsarray, jsobject, ...); function getjsonvaluetype(jsonvalue: tjsonvalue): jsonvaluetype; begin if jsonvalue tjsonarray exit(jsarray); if jsonvalue tjsonobjct exit(jsobject); ... end; ... if assigned(jsonvalue) begin case getjsonvaluetype(jsonvalue) of jsarray : processarrayresponse(tjsonarray(jsonval...

How To Disable Camel HTTP Endpoint Stream Caching When Using Servlet in OSGi -

i'm using apache camel route receive incoming http traffic using servlet component. route simple: <camel:route id="peoplesoftservletservice" errorhandlerref="errorhandler"> <camel:from uri="servlet:///peoplesoftservice" /> <camel:setheader headername="origin"> <camel:simple>peoplesoft server: ${in.header.x-forwarded-for}</camel:simple> </camel:setheader> <camel:inonly uri="activemq:peoplesoft" /> </camel:route> i'm encountering problems stream caching. i'm not explicitly using stream caching, seems using servlet component, camel httpconsumer implicitly created behind scenes , registered servlet via camelservlet.connect(httpconsumer consumer). want disable stream caching (which turned on default) on http endpoint of consumer, typically done using uri parameter ("disablestreamcache"). since i'm not explicitly creating endpoint in case, don...

c - Explain the statement related int *count for the algorithm -

i want make program find repeating integers in array. had 2 methods. use nested array. give time complexity of o(n²) use auxiliary array find frequency of array. i have seen solution, limited 1 digit number. uses count array. int *count = (int *)calloc(sizeof(int), (size - 2)); why ( size -2 )? the code is: #include<stdio.h> #include<stdlib.h> void printduplicate(int arr[], int size){ int *count = (int *)calloc(sizeof(int),(size-2)); int i; for(i=0;i<size;i++){ if(count[arr[i]] == 1) printf("%d,",arr[i]); else count[arr[i]]++; } } int main(){ int arr[] = {2,5,3,4,2,5,7,8,7}; int size = sizeof(arr)/sizeof(arr[0]); printduplicate(arr,size); return 0; } actually calloc statement writen here wrong. here memory allocation is 4*7=28 so here memory allocation 7 integers here can access more 7 elements. wrong in c language works fine days compilers c has no array...

rest - Implementing access token architecture in my API -

my app logic (android, ios , web) written in server. since things got complicated, decided build server rest web service querying contain logic in header. my login flow pretty simple, , somehow tried copy facebook api: the user login facebook. the user receive facebook access token the access token sent server other identifiers the server checks facebook access token valid facebook , other identifiers match ones on facebook. the server returns access token user, should use in each query until expires. the problem didn't add other restrictions endpoints limitations (scopes) , stuff this, access token generated server grant access each part of api. i think inventing wheel here foolish, i'm looking framework or generic solution allow me add logic access tokens in simple way. i read oauth, concern more user sharing other users, want use login flow , scope protector. is possible oauth ? there alternative oauth ? that's possible oauth 2.0 , in fac...

scheduling - Azkaban : Running Cluster of Azkaban Executor Servers -

is possible me run azkaban executor service in cluster. if 1 node goes down, can other pick , run scheduled jobs? haven't seen documentation on kind of set-up. all read somewhere can run 1 executor service each web server. ideal fault tolerant architecture have web servers , executor servers run independently. has handled such situation. please let me know if have pointers.. thanks, kranthi per azkaban's roadmap, facility available in 2.7 version. how plan handle time being. multiple executor services can run behind load balancer vip. web , executor 2 independent services. web can route request executor service since job , flow details persisted in mysql anyways , hence set-up work. if there others did differently, please let me know. thanks, kranthi

javascript - How do I get the value of radio button option in my Knockout.js wizard? -

to simplify things, here fiddle: http://jsfiddle.net/fyusd/157/ <script id="choicetmpl" type="text/html"> <label><input type="radio" value="boughtbefore" data-bind="checked: radioselectedoptionvalue" />purchase products have bought before</label> <br /> <label><input type="radio" value="searchproduct" data-bind="checked: radioselectedoptionvalue" />search product haven't purchased before</label> <br /> i guess have couple questions. building wizard , need different execution steps depending on option user selects. question want know is, how value of radio button select? like on step two, if select "purchase products have bought before" how can redirect question: create order guide or create order previous order (using radio buttons again)? i can't figure out how value of select...

gruntjs - Grunt required github token during docker build -

grunt requires github authentication token while executed during docker build image. how provide grunt required token? interactive passing doesn't work (as exacted). the message of grunt is: running "volo:add:-nostamp:twbs/bootstrap/3.3.2:packages/bootstrap/" (volo) task github auth required api.github.com/repos/twbs/bootstrap/tags: {"message":"api rate limit exceeded xxx.xxx.xxx.xxx. (but here's news: authenticated requests higher rate limit. check out documentation more details.)","documentation_url":"https://developer.github.com/v3/#rate-limiting"} github access token required complete action. in web browser, go to: https://github.com/settings/tokens , generate new "personal access token" volo. "repo" , "public_repo" permissions needed. paste generated token below. github personal access token: you can change url of repository to: https://<token>:x-oauth-basic@github.c...

create a private object for a class with private constructor in c# -

this question has answer here: how instantiate object private constructor in c#? 5 answers i want access of private members of class has constructor defined private. how create privateobject such class can access private members ? i tried cannot instantiate class "myclass1" not able instantite privateobject. myclass1 myclass = new myclass1(); //gives compilation error privateobject po = new privateobject(myclass); //gives compilation error is there workaround ? class private constructor can create own static method. example: class myclass1 { private myclass1() { } public static myclass1 createinstance() { return new myclass1(); } } it's private members fields or properties accessible inside of class (unless make tricks reflection). if field protected can access deriving class. other way it...

swift - NSURLSession returns data with bad access code -

this function returning nil value data variable reason , can't understand why. have searched through many posts , can't seem find difference. had working request using different data if curl responses identical. makes far line states: if let jsondata = responsestring?.datausingencoding(nsutf8stringencoding) { and never goes if because responsestring value never set. changing implicit like if let jsondata = responsestring!.datausingencoding(nsutf8stringencoding) { returns bad access code. func getdata(url: string, datatosend: string, username: string, password: string) { somevar = [myobjecttype]() let request = nsmutableurlrequest(url: nsurl(string: "%urltouse%")!) request.httpmethod = "post" let poststring = "%postdatahere%" request.httpbody = poststring.datausingencoding(nsutf8stringencoding) let task = nsurlsession.sharedsession().datataskwithrequest(request) { data, response, error in le...

javascript - Bar Stack Category Column -

i have following implementation: http://jsfiddle.net/7dhb4jh0/1/ even though have data men , women category, data displayed in 1 column. women category missing. { "series": "item5", "category": "men", "value": 54 }, { "series": "item7", "category": "women", "value": 50 }, for grouping work, need same item names men , women: { "series": "item5", "category": "men", "value": 54 }, { "series": "item5", "category": "women", "value": 50 }, updated fiddle

javascript - I keep getting unexpected token ) -

i'm doing coding academy, , doing right when annoying little message, ("jon".length * 2 / (2+1) === ) { console.log("the answer makes sense!"); } else { console.log("error! error! error!"); } there 2 problems in line ("jon".length * 2 / (2+1) === ) first, need sort of conditional @ beginning of line, if if("jon".length * 2 / (2+1) === ) second, need fill right side of equation after === target comparing, number if("jon".length * 2 / (2+1) === 1)

database - Organize table avoiding redundancy -

Image
i'm trying create database manage autobus data create table company( company_name varchar(12), tel int, primary key(company_name) ); create table line( id_line varchar(3), ncompany_name varchar(12), desc text, primary key(id_line, company_name), foreign key (company_name) references company(company_name) ); create table stop( id_stop varchar(3), geolat float(10,6), geolong float(10,6), primary key(id_stop) ); create table make( id_stop varchar(3), id_line varchar(3), hour time, primary key(id_stop,id_line), foreign key (id_stop) references stop(id_stop), foreign key (id_line) references line(id_line) ); the problem bus stops several times @ same stop in different hours, how store information avoiding redundancy? for example: id_line = 1 id_stop = 1 hour = 4:50 than id_line = 1 id_stop = 1 hour = 5:20 but isn't possible, thought of adding field (autoincrement) called id didn't know if best solution. advice? you interested in predicate "[id_...

javascript - Polymer: access polymer element objects -

i have polymer element called his-service: <polymer-element name="gis-service" attributes="response url"> <template> <style> </style> <core-ajax id="ajax" auto url="{{url}}" method="get" contenttype = 'application/json' on-core-response="{{postsloaded}}" body="{{body}}" handleas="xml"> </core-ajax> </template> <script> polymer('gis-service', { created: function() { this.response = []; }, postsloaded: function() { this.response = []; this.labels = []; this.coordinates = []; x = this.$.ajax.response.getelementsbytagname("customerservicecenterdata"); (i=0;i<x.length;i++) { if (x[i].getelementsbytagname("language")[0].innerhtml == "en") { this.labe...

angularjs - Jasmine not recognizing spied on method called from asynchronous function resolution -

from controller, upon instantiation, calling asynchronous method calls scope method: app.controller 'myctrl', ($scope,mysvc) -> ## initial stuff mysvc.asyncmethod .then (an_array) -> val = $scope.myscopedmethod my test so: describe "my tests", () -> $controller = undefined $scope = undefined $q = undefined createcontroller = undefined mysvc = undefined beforeeach inject ($controller, $rootscope, $q, _mysvc_) -> $scope = $rootscope.$new() mysvc = _mysvc_ deferred = $q.defer() deferred.resolve [] spyon(mysvc,'asyncmethod').and.returnvalue deferred.promise spyon($scope, 'myscopedmethod').and.callthrough() createcontroller = () -> return $controller('myctrl', {$scope: $scope, mysvc: mysvc}) # assertion works "should call asyncmethod", () -> controller = createcontroller() expect(mysvc.asyncmethod).tohavebeencalled() # works "should ...

c# - Activator.CreateInstance creates value of type T instead of Nullable<T> -

Image
look @ sample code below var genericnullabletype = typeof(nullable<>); var nullabletype = genericnullabletype.makegenerictype(typeof(bool)); var returnvalue = activator.createinstance(nullabletype, (object)false); for reason returnvalue variable of type bool , not bool? . why , how avoided? upd: here screenshot vs in particular case using overload of createinstance returns object . nullable<t> struct hence represented object need boxed. yet nullable<t> can't boxed rules of clr. instead underlying value or null used. why raw bool here instead of bool? . documentation: https://msdn.microsoft.com/en-us/library/ms228597.aspx edit there seems confusion around determining whether type of value nullable or not. in particular it's been pointed out following prints system.boolean , not system.nullable``1[system.boolean] : var x = (bool?)true; console.writeline(x.gettype()); this code falling prey boxing. call gettype has im...

sql - Selecting TOP 1 Columns where duplicate exists and selecting all where no duplicate exists -

given list of names, accounts , positions trying to: select 1st position there more 1 records same name , account if there 1 record name , account, select details. my current query looks following: select * cte cte1 join ( select name, oppname cte group name, oppname having count(name)>1 ) cte2 on cte2.name = cte1.name , cte2.oppname = cte1.oppname order cte1.oppname, cte1.name i have not posted rest of cte query way long. however, providing me results name , accounts same , positions different. i.e. if oera worked @ christie's sales analyst , developer select record oera worked @ christie's developer. how modify query accordingly? are looking this? select * cte cte1 join ( select name, oppname,count(name) partition (name,oppname) cnt cte ) cte2 on cte2.name = cte1.name , cte2.oppname = cte1.oppname cnt > 1 order cte1.oppname, cte1.name

javascript - Angular Nested Directives -

i'm trying have child directive isolated scope execute function. can't seem have directive isolated scope execute function of parent scope. doesn't work. usagea: <div data-outer data-controller="control"><div data-inner></div></div> usage b: <div data-inner data-controller="controltwo"></div> app.controller('control', ['$scope', function($scope){ $scope.onouterchange = function () { alert("outer change"); } }]); app.controller('controltwo', ['$scope', function($scope){ $scope.oninnerchange = function () { alert("inner change"); } }]); app.directive('outer', function($compile){ // runs during compile return { scope: { "onouterchange": "&", }, controller: function ($scope, $element) { }, link: function ($scope, ielm, iattrs, controller) { $scope.oninnerchange = function () { ...

Android studio takes half an hour to start on windows. Any fix? -

i have fresh install of complete android studio , every time start it, takes 27 34 minutes launch workable state. my pc specs: windows 7 ultimate ram: 4gb processor: intel core i3 graphics: intel hd graphics 3000 is there can fix this? tried searching everywhere seem 1 having problem "slow android" questions , solutions emulators , not actual android studio. appreciated! thanks! try eclipse luna download eclipse here and install adt plugin in eclipse luna how install adt

javascript - Knockout and bootstrap not binding -

i cannot value of bound data-bind. when try read value undefined. i have setup fiddle here: http://jsfiddle.net/tonymaloney1971/2qjhb5pw/5/ i think possibly problem in way have setup knockout binding: $(document).ready(function () { var data = [{ postcodestart: "", postcodeend: "", mileage: "", notes: "" }]; add: function () { //this part not working this.postcodestart() === "" alert("how value of postcodestart"); if (this.postcodestart() === "" || this.postcodeend() === "" || this.mileage() === "") { alert("empty field"); } else this.journeylist.push({ postcodestart: this.postcodestart(), postcodeend: this.postcodeend(), mileage: this.mileage(), notes: this.notes() }); }, also, in fiddle notice dot added each time add new row, how can not display . thanks ...

python - Set delay between tasks in group in Celery -

i have python app user can initiate task. the whole purpose of task execute given number of post/get requests particular interval given url. so user gives n - number of requests, v - number of requests per second. how better design such task taking account due i/o latency actual r/s speed bigger or smaller. first of decided use celery eventlet because otherwise need dozen of works not acceptable. my naive approach: client starts task using task.delay() inside task this: @task def task(number_of_requests, time_period): _ in range(number_of_requests): start = time.time() params_for_concrete_subtask = ... # .... io monkey_patched eventlet requests library elapsed = (time.time() - start) # if completed subtask fast if elapsed < time_period / number_of_requests: eventlet.sleep(time_period / number_of_requests) a working example here . if fast try wait keep desired speed. if slow it's ok client's pros...

java.util.scanner - Run Java Console Input as Statement -

i writing command-line matrix manipulation tool in java, , wondering if possible run java statements through console input. i thinking of using java.util.scanner object since that's i'm using rest of application, open solution. here copy of tool's application class, can see mean: package projects.matrix.main; import static java.lang.system.*; import java.util.scanner; import projects.matrix.util.matrixtool; /** * matrix :: application class matrix toolset. * @author toner * @version may 28 2015 * @since 1.8 **/ public class marixapp { public static void main (string [] args) { out.println("****************************** start*****************" + "*************\n"); runcommandline(); out.println("****************************** end *****************" + "*************\n"); } /** * matrix.main :: runcommandline runs loop command line * @param none * ...

python - I am receiving \\r\\n on carriage return instead of \r\n -

the project uses sockets read connecting client until either there no more characters read or receives \r\n. here snippet of code: while true: ch = connection.recv(1) data += ch.decode('utf-8') if data.endswith('\r\n') or not ch: data = data.replace('\r\n','') break the code works intended when windows used run server reads clients. when try run on raspberry pi running rasbian, reads carriage return '\\r\\n'. example when client sends: -list_networks wlan0 5180<return> yields string looking like: -list_networks wlan0 5180\\r\\n why this? because of not read carriage return , missed. know different os return different of strings carriage return didn't find string when researched bit. missing something? suggestions , explanations appreciated. edit: forgot add command sent through telnet connection. want able connect socket via telnet. type command , when enter key pressed command loop recogn...

algorithm - How should graphing tool behave in case SNMP counter has smaller value than previous reading? -

Image
i'm building small monitoring solution , understand correct/best behavior in situation previous reading larger current reading. example ifhcoutoctets snmp object counts bytes transmitted interface in cisco router. how should graphing application behave if counter resets 0 example because of router reboot? in option following algorithm correct behavior: if [ ! $prev_val ]; # reading used set baseline value "prev_val" variable # if "prev_val" not exist. prev_val="$cur_val" elif (( prev_val > cur_val )); # counter value has set zero. # use "cur_val" variable. echo "$cur_val" prev_val="$cur_val" else # in case "cur_val" higher or equal "prev_val", # use "cur_val"-"prev_val" echo $(( cur_val - prev_val )) prev_val="$cur_val" fi i made small example graph based on algorithm above: traffic graph built based on this: reading 1: cur_val=0, pre...

java - How to get image information (Image Name, Date, Time) from a specific album in Android -

first question posting here! having tough time trying figure out. working android devices , programming in android studio. i came program half finished i've been trying complete it. application takes picture , analysis stores in album (the album called camerasample). need put information images in album list view in application, note album size can continue grow user takes pictures. i pretty new android development i'm not sure kind of commands need in order information pictures. predecessor before looked trying store information database left undone , sloppy. i'm not sure if route need take or if there possibly way information without using database. i've searched around online awhile i'm having tough time figuring out. i figured out needed do. i had create database when picture taken , file made picture stored. record uri, pass immediate time , date database well. used database create photo object array list , used custom adapter fill in row o...

javascript - Input button - Onclick Color Changer -

i have following html code specific calendar purpose. should perform following function. 1) first user select gender 2) user shall select 1 date 3) selected date should in red color function focusme(el) { el.style.backgroundcolor = "red"; } <table border="3" cellspacing="3" cellpadding="3"> <tr> <td colspan="7" align="center"><b>first visit calendar</b> </td> </tr> <tr> <td colspan="7" align="center"><i>select gender</i> <select> <option value="male">male</option> <option value="female">female</option> </select> </td> </tr> <tr> <td colspan="7" align="center"><i>select date</i> </td> </tr> <tr> <td align=...

javascript - Cookie not going through -

i'm trying set cookie in express framework, isn't going through, , life of me can't figure out why. relevant code looks this: module.exports = function(app) { return function(req, res, next) { if (req.cookies.user_token) { req.session.cookie.httponly = false res.cookie('user_token', req.cookies.user_token, { domain: 'www.example.com', httponly: false, path: '/', maxage: 900000 }); } return res.redirect('https://www.example.com/index.jsp?other_stuff=value'); } } i can see request going out, , cookie not getting set. i've stepped through debugger, , know code getting hit. i found question: how set cookie in node js using express framework? based on that, tried calling var express = require('express'); app.use(express.cookieparser()); earlier in code, didn't seem make difference. anybody have ideas i'm going wrong here? if redirected d...

c# - Track download / upload transfers (size) -

i have wcf service (c#) has 10 methods 5 getting data (.net dataset) , 5 updating data (.net dataset). example of methods: // getting data method public dataset getemployeecontractinfo(guid uid) { dataset ds = null; database db = infotacto.framework.webservices.common.getdatabase(); using (dbcommand cmd1 = db.getstoredproccommand("sp_employee_contractinfo_get")) { db.addinparameter(cmd1, "employeeuid", dbtype.guid, uid); ds = db.executedataset(cmd1); } if (ds.tables.count > 0) { ds.tables[0].tablename = "contract_info"; } return ds; } /// <summary> /// /// </summary> /// <param name="ds"></param> /// <returns></returns> public...

c# - DropdownListFor Returns null after HTTP PostBack -

Image
the context of application maintaining security orders investment advisors. on screen users amends orders problem appears. in such screen have dropdown list specify order type whether buy or sell , shows values security, quantity , price. problem have witnessed while being in edit screen, after doing amendment (tests have performed not changing buy/sell others i.e price). if performed http post, values of dropdownlist returns null. refer screenshot: initialization of selectlist type public static list<selectlistitem> getbuyselllist() { list<selectlistitem> buysell = new list<selectlistitem>(); selectlistitem item; item = new selectlistitem(); item.text = "buy"; item.value = "buy"; buysell.add(item); item = new selectlistitem(); item.text = "sell"; item.value = "sell"; buysell.add(item);...

c# - What is a NullReferenceException, and how do I fix it? -

i have code , when executes, throws nullreferenceexception , saying: object reference not set instance of object. what mean, , can fix error? what cause? bottom line you trying use null (or nothing in vb.net). means either set null , or never set @ all. like else, null gets passed around. if null in method "a", method "b" passed null to method "a". the rest of article goes more detail , shows mistakes many programmers make can lead nullreferenceexception . more specifically the runtime throwing nullreferenceexception always means same thing: trying use reference, , reference not initialized (or once initialized, no longer initialized). this means reference null , , cannot access members (such methods) through null reference. simplest case: string foo = null; foo.toupper(); this throw nullreferenceexception @ second line because can't call instance method toupper() on string reference pointing null ....

linux - How to install an app on a VM using Mean Stack -

i have created vm mean stack (using bitnami image) on azure running. i've never used vm before, have fair few mean apps using cloud hosting , github continuous deployment. i'm confused , i'm noob using command line tools. i've found bitnami folder index.html etc. connecting through ssh. have ready built angular application runs on machine. how onto vm , start running? understand may fair few steps, after lots of reading assume upload it, stop apache server, npm install dependencies , restart server? how app onto vm in first place, let along running. even slightest insight brilliant - quite out of depth vm's , have surface level understanding. if lead me in right direction appreciated. bitnami developer here, to upload files, can follow guide: https://wiki.bitnami.com/howto/how_to_connect_to_your_server?#upload_your_files_with_sftp we follow structure: installdir/ apps/ conf/ apache files , certs htdocs/ public files ...

printing - Is there a portable way to print a message from the C preprocessor? -

i able like #print "c preprocessor got here!" for debugging purposes. what's best / portable way this? the warning directive closest you'll get, it's not entirely platform-independent: #warning "c preprocessor got here!" afaik works on compilers except msvc, on you'll have use pragma directive: #pragma message ( "c preprocessor got here!" )

java - Comparing an object with a String using equals() method -

in below example, expecting equals() return true : public class flower { string flower; public flower (string flower) { this.flower = flower; } public static void main(string[] args) { flower 1 = new flower("flower"); boolean issame = false; if(one.equals("flower")) { issame = true; } system.out.print(issame); } } however, result false ... because i'm comparing object string ? read equals() method , said compare string s objects . why getting result false although same? the short answer: need override implementation of equals() in flower (note: capital f ) class. like do: @override public boolean equals(object o) { return (o instanceof flower && ((flower)o).flower.equals(flower)) || (o instanceof string && o.equals(flower)); } @override public int hashcode() { return flower.hashcode(); } overriding hashcode() equ...

javascript - Collapse arrow on mouse click -

Image
i have example of collapse row on mouse click: jsfiddle.net/7bz5au97/ i ask how can add arrow 1 @ beginning of question , rotate when question expanded? can done css or need add javascript? you entirely css: var arr = document.queryselector('.arrow'); arr.addeventlistener('click', function(event) { event.target.classlist.toggle('down'); }); .arrow { margin: 1em; } .arrow::before { position: absolute; content: ''; width: 0; height: 0; border: .5em solid transparent; border-left-color: gray; transform-origin: 0 50%; transition: transform .25s; } .arrow.down::before { transform: rotate(90deg); transition: transform .25s; } <div class="arrow"></div>