Posts

Proper way to return a string in C -

i have following code: char* get_address_string(package* pkg){ char *c; sprintf(c, "%02x:%02x:%02x:%02x:%02x:%02x", pkg->address[0], pkg->address[1], pkg->address[2], pkg->address[3], pkg->address[4], pkg->address[5]); return c; } the code works fine. however, know not proper way return string in c. receiving warning "c used uninitialized in function". what proper way write function in c? c pointer, no memory allocated. return value ok, that's how can done in c. but need allocate memory.

elixir - "dialyzer: Analysis failed with error.." (dialyzer bug? or wrong use of map-type?) -

working on simple application in progress of learning elixir, ran minor roadblock when checking types dialyzer. running dialyzer on code results in analysis failed error... far dialyzer has given me warnings , not errors when violate type spec's, have no clue error about. trying narrow down problem, made ultra simple function performs offending return value. @spec blabla(integer) :: %{atom => any} def blabla(1) %{:error => 'wrong input (us-state)'} end def blabla(2) %{ location: 'new york city, central park, ny', temp_c: '23.3', visibility_mi: '10.00', weather: 'a few clouds', wind_dir: 'north', wind_kt: '0' } end when running dialyzer on following error proceeding analysis... =error report==== 14-jul-2015::17:26:55 === error in process <0.31.0> exit value: {function_clause,[{erl_types,t_form_to_string,[{type,12,map_field_assoc,{type,12,atom,[]},{type,12,any,[]}}],[{...

go - syntax error: unexpected name, expecting semicolon or newline -

i don't understand why code has syntax error. package main import ( "fmt" "os/exec" "time" ) func ping(curl_out string) endtime int64 { try_curl := exec.command("curl", "localhost:8500/v1/catalog/nodes") try_curl_out := try_curl.output() try_curl_out == curl_out { try_curl := exec.command("curl", "localhost:8500/v1/catalog/nodes") try_curl_out := try_curl.output() } endtime := time.now().unix() return endtime } func main() { run_container := exec.command("docker", "run", "-p", "8400:8400", "-p", "8500:8500", "-p", "8600:53/udp", "-h", "node1", "progrium/consul", "-server", "-bootstrap") container_id, err := run_container.output() if err != nil { fmt.println(err) return } run_curl := exec.co...

php - the curl link is not sent -

create message function not working form execute need go sms api link , not getting called please me fix this <?php include_once('inc/class.simple_mail.php'); include_once('inc/gump.class.php'); include_once('mail-config.php'); // check data $isvalid = gump::is_valid($_post, array( 'first-name' => 'required', 'last-name' => 'required', 'phone-number' => 'required', 'email-address' => 'required|valid_email', 'address' => 'required', 'city' => 'required', 'zip-code' => 'required', )); if($isvalid === true) { // submit mail $mail = new simplemail(); $mail->setto(your_email_address, your_company_name) ->setsubject('new car rental request') ->setfrom(htmlspecialchars($_post['email-address']), htmlspecialchars($_post['first-name'].' '....

java - Wrong 2nd argument type found 'com.technology.computer.mit.ctechmit.Menu_pageFragment' required 'Android.app.Fragment' -

i have written code fragment replacement on click of send button. code shows error saying wrong 2nd argument type found 'com.technology.computer.mit.ctechmit.menu_pagefragment' required 'android.app.fragment' in below line under word 'newfragment' transaction.replace(r.id.fragment_container, newfragment); when searched solution online says extend fragmentactivity instead of extending fragment. if home_activity (one has no errors) shows many errors. can please suggest me solution this? below home_pagefragment in sendmessage method replaces menu_pagefragment on click of send method in layout: package com.technology.computer.mit.ctechmit; import android.app.fragmenttransaction; import android.support.v4.app.fragment; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; /** * placeholder fragment containing simple view. */ public class home_pagefragment extends fragment { pu...

SAP BPC EPM dynamic table member -

Image
i'm quiet new bpc , struggle right looking easy. have table splitted in 3 parts. in first 2 data coming cube in 3rd part (in red), data calculated excel formulas formula of cell d33 :(=d26 - d40) .... work long dimension doesn't move, if add new member formualas , number shifted , don't match anymore.. solution solve , stay dynamic ? tried several option epmformattingsheet , excel formulas, local member , formulas :((( has idea on how solve ? thank e. local members formulas should work case

Private Variables vs Properties in C# -

this question has answer here: why use private members use public properties set them? 5 answers why use simple properties instead of fields in c#? [duplicate] 5 answers i teaching myself c# , curious need declaring private member variables accessed public properties. textbook i'm using says sake of encapsulation, why need private variables begin if properties can changed depending on 'get' or 'set' functions? here's example: namespace practice { struct person { private int id; private string name; public int id { {return id;} set {id = value;} } public string name { get; set; } public int age { get; set; } } class program { static void main(string[] args) { pers...

c# - how to call a method in a windows from another method in asp.net web-api -

i have c# solution has 2 projects: windows forms project (desktop) , asp.net web-api project (rest service). trying call method enablemachine() in form1.cs post() method in valuescontroller.cs , though referenced namespace shows errors. if define enablemachine() static works, cannot because need instantiate object within method. ideas on how solve problem ? in advance ! using system; using system.collections.generic; using system.linq; using system.net; using system.net.http; using system.web.http; using restlayer.models; using validatorconnector; namespace restlayer.controllers { public class valuescontroller : apicontroller { // post api/values public void post() { ... } } } using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using log4net; namespace validatorconnector { pub...

mocking - JMS Queue testing with spock -

i using activemq , trying send , whether possible test if own created mock sent message queue. using activemq & want automate test where, mock send message queue , spock make sure message has been sent. you can first create queuebrowser , using enumeration number of messages. let loop run till enumeration object has elements. check message in loop, if there. code should somehow looks this queuebrowser qbrowser = session.createbrowser(queuename); enumeration messages = qbrowser.getenumeration(); while (messages.hasmoreelements()) { textmessage message = (textmessage) messages.nextelement(); string a=message.gettext(); if (message there) { return true; } } cheers :)

sql - Can not use ORDER BY when creating materialized view with SDO geometry in Oracle 11g -

i using oracle 11g 2.0.1.0 spatial , oracle sql developer on client. have table places primary key id , view coordinates tw columns: id referencing post in places , , sdo geometry point . i want create materialized view following sql: create materialized view placecoordinates nocache noparallel build immediate using index refresh on demand complete disable query rewrite select places.id, coordinates.point places left outer join coordinates on places.id = coordinates.id order places.id this gives me error: ora-30373: object data types not supported in context no matter sort on (even if silly 1 ) same error. however, if remove order by statement works fine. works fine sorting if ordinary select without creating materialized view. why wouldn't able sort? there anyway around problem? the key thing order in materialized view makes no sense. under covers, materialized view table gets automatically updated when tables based on updated. being table ...

c# - Output table with nested repeaters -

i nest 2 asp.net repeaters output content of table (dynamic number of columns). table contained in sqldatasource object. i know how gridview, bind events controllers in different cells aswell. how go doing this? ie for rows columums output cell attempt: <asp:repeater id="repeater1" runat="server" datasourceid="sqldatasource1"> <headertemplate> <asp:repeater id="repeater2" runat="server" datasourceid="<%# (datarowview)container.dataitem %>"> <itemtemplate><%# ((dataitemcontainer).dataitemcontainer)%></itemtemplate> </asp:repeater> </headertemplate> </asp:repeater>

asp.net mvc 4 - itextsharp advance pdf generation by configuration xml -

i generating pdf using itextsharp.i got many sample code in google how can configure pdf setting required generate pdf like var doc = new document(pagesize.a5); var doc = new document(new rectangle(100f, 300f)); these setting wanted set config xml file , read xml , generate pdf on fly. professional sample example code available?plz help..

excel - Finding if a value is located in a range of cells in a corresponding column, to a row with the same value as a given cell in a given row -

Image
given column contains directory paths, , column b contains actions on these paths; i'd resultant cell contain specific string if specific string located in column b (per column a). granted can sort column, believe can use offset , know how locate ending index of cells can search range returned offset . for example: path operation /share/admins accessed /share/admins removed /share/admins added /share/admins changed /share/network accessed /shared/projects accessed in case, want search path unique value (in case /share/admins , /share/network , , /shared/projects ), , given range in path , i'd search corresponding operation , , if operation matches removed , added , changed exists, i'd cell value write ; , if values aren't found, "read". in case, expect column (with header result ) read: path operation result /share/admins accessed write /share/admins remov...

jquery - Javascript : Change img src After some interval of time -

this question has answer here: how delay function call 5 seconds? [duplicate] 2 answers guys don't know how add interval of time in javascript. know how add time before changing src of image. code w3schools document.getelementbyid("image").src = "http://www.w3schools.com/js/landscape.jpg"; <!doctype html> <html> <body> <img id="image" src="http://www.w3schools.com/js/smiley.gif" width="160" height="120"> <p>the original image smiley.gif, script changed landscape.jpg</p> </body> </html> jsfiddle settimeout(function() { document.getelementbyid("image").setattribute("src", "http://www.w3schools.com/js/landscape.jpg"); }, 5000); <img id="im...

c# - How to invoke a generic method with weak-typed parameter -

i've got generic interface , bunch of classes implement it. here simplified example: interface iprinter<in t> { void print(t args); } class intprinter : iprinter<int> { public void print(int args) { console.writeline("this int: " +args); } } class stringprinter : iprinter<string> { public void print(string args) { console.writeline("this string: " + args); } } i have dictionary of classes generic argument's type key (i use reflection populate it): private readonly dictionary<type, object> printers = new dictionary<type, object> { {typeof (int), new intprinter()}, {typeof (string), new stringprinter()} }; now recive instance of list<object> input, contains bunch of parameters of arbitrary type. each parameter want pick object, implement appropriate interface , call print method. not sure how implement that. var args = n...

Not sure about instance variable scenario in Typescript -

here's class (ignore console.logs left on attempt debug) import fs = require('fs'); export interface answer { order: number, text: string } export class config { answers:answer[]; timestamp_column: string; name_column: string fromjsonfile(filename: string) { var filestring = fs.readfilesync(filename); this.answers = json.parse(filestring.tostring()); console.log(this.answers); } mapanswertonum(answer:string):number { console.log(typeof this.answers); (var in this.answers) { if (a.text == answer) { return a.order;} } (var in this.answers) { console.log(a.text); } console.log(typeof this.answers); throw new error(`invalid response string ${answer}`); } } and here's invocation: import { config } './config'; var config = new config(); config.fromjsonfile("./csvconfig.json"); ... var respints:number[] = respstrings.map(this.config.mapanswertonum); ... the question: ins...

How to show a prompt window on setting the cursor on a button with JavaFX? -

i want show prompt window while user set cursor on button. asking exactelly of how action on setting cursor on controller button, don't need butn.setcursor(cursor.hand); how can , thanks. you can use button.setonmouseentered event show textinputdialog , wait user input , use it. here small example, shows textinputdialog , prints data entered user. import javafx.application.application; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.control.textinputdialog; import javafx.scene.layout.stackpane; import javafx.stage.stage; import java.util.optional; public class main extends application { public static void main(string[] args) { launch(args); } @override public void start(stage primarystage) throws exception { stackpane box = new stackpane(); button button = new button("hover on me !!!"); textinputdialog dialog = new textinputdialog("itachi"); dialog...

javascript - how to sort elements in the array: jQuery -

summary: have table rows added each btn click. using jquery-ui sortable() function move/sort rows. let have this: <tbody> <tr><td>a</td></tr> <tr><td>b</td></tr> <tr><td>c</td></tr> <tr><td>d</td></tr> <tr><td>e</td></tr> <tr><td>f</td></tr> </tbody> issue: can move rows using sortable() function. not able update elements in rows. using $('.report-configuration .configuration-table tbody').sortable({ 'change': function(event, ui){ arr=['a','b','c','d','e','f']; console.log(ui); var tmp = arr.splice(ui.originalpostion);//i missing logic here arr.splice(ui.postion, tmp); console.log(arr); }}); i looking logic update positions in array. after sortable has ended html changed. jquery can select changed html , determin...

css - Safari shows bigger font-size in landscape mode -

in current responsive project have issue when using iphone in landscape mode, font-size lot bigger , introducing -webkit-text-size-adjust: none; didn't (see jsfiddle below). i use these definitions in project: <meta name="viewport" content="width=device-width, user-scalable=yes"/> and breakpoints @media screen , (max-width: 35em) , (orientation:portrait) { ... } @media screen , (max-width: 47em) , (orientation:landscape) { body { -webkit-text-size-adjust: none; } } @media screen , (max-width: 35em) , (orientation:portrait), screen , (max-width: 47em) , (orientation:landscape) { ... } you can directly test @ result page of jsfiddle . <div class="test">this test</div> <div class="test">this test</div> <div class="test">this test</div> <div class="test">this test</div> <div class="test">this test</div> and @vie...

java - Most efficient data structure for sorting an ArrayList by categorical factors -

i have created object, let's call eventobject, hold results of sql query. objects aggregated single arraylist. trying develop method @ each eventobject in arraylist, , if equals given value of categorical factor, copies group. for example, if timestamp value eventobject1 falls on sunday, copy object sunday level of weekday factor; if same timestamp falls in month of may, copy may level of month factor well, etc. i stuck type of data structure(s) efficient sorting. not know how many eventobject fall level of given factor, , number of factors analyzed dependent upon id pass method. required have k factors, each known number of levels; , each level can have number of eventobjects after soring occurs. should attempt hold factors in single arraylist? requires 3 dimensional structure. more prudent create separate data structure each factor?