• Breaking News

    Sunday, June 3, 2018

    How to make an array lowercase? (Node.js) Ask Programming

    How to make an array lowercase? (Node.js) Ask Programming


    How to make an array lowercase? (Node.js)

    Posted: 03 Jun 2018 07:41 PM PDT

    title says all

    submitted by /u/Wistful__
    [link] [comments]

    Trouble with insertion on Doubly Linked list [C++]

    Posted: 03 Jun 2018 06:53 PM PDT

    I'm not sure if this is the right place to ask this, so feel free to tell me if I am in the wrong. I have been assigned to make a doubly linked list (not circular) for class and I am about there but something with my insertion member function keeps bombing.

    It works just fine if I use these test words:

    list.insert("cat"); // insert back...into empty list

    list.insert("doggo"); list.insert("fish"); list.insert("buttface"); list.insert("poop"); 

    But when I run a 3000 word input file it bombs and i will mark where. Any pointers to where I could look for my issue would be greatly appreciated- I'm at my wits end here.

    Code: https://pastebin.com/XQbqDtSF

    submitted by /u/SNsilver
    [link] [comments]

    What approach is best?

    Posted: 03 Jun 2018 06:08 PM PDT

    I have seen 2 approaches used by developers when dealing with database results.

    1. Mapping the results to an object and use the object to get each attribute.
    2. Getting the results straight and use them without mapping.

    What do you think is the best one'

    submitted by /u/camillegarcia9595
    [link] [comments]

    Running a file with VTK [Javascript]

    Posted: 03 Jun 2018 09:39 PM PDT

    It's been a while since I've touched javascript and I'm running into a problem with just running the file. I created two files, one with javascript sample code with vtk.js and the other with HTML code that, all it does, runs the script. I tried finding a guide to vtk but I couldn't find a good one. It's giving me a compilation error at the very first line when I ran it. My initial thought was that I needed to relocate where the javascript file is looking at to find the vtk.js framework because they're not in the same directory. But it still was giving me the 800A03EA compilation error at the first line whenever I ran it (I'm using Sublime if that matters at all). Could anyone help me out here? That would be swell!

    import * from '../../../node_modules/vtk.js/Sources/favicon'; import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow'; import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; import vtkElevationReader from 'vtk.js/Sources/IO/Misc/ElevationReader'; import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import vtkTexture from 'vtk.js/Sources/Rendering/Core/Texture'; // ---------------------------------------------------------------------------- // Standard rendering code setup // ---------------------------------------------------------------------------- const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0], }); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow(); // ---------------------------------------------------------------------------- // Example code // ---------------------------------------------------------------------------- const reader = vtkElevationReader.newInstance({ xSpacing: 0.01568, ySpacing: 0.01568, zScaling: 0.06666, }); const mapper = vtkMapper.newInstance(); const actor = vtkActor.newInstance(); mapper.setInputConnection(reader.getOutputPort()); actor.setMapper(mapper); renderer.addActor(actor); renderer.resetCamera(); renderWindow.render(); // Download and apply Texture const img = new Image(); img.onload = function textureLoaded() { const texture = vtkTexture.newInstance(); texture.setInterpolate(true); texture.setImage(img); actor.addTexture(texture); renderWindow.render(); }; img.src = `${__BASE_PATH__}/data/elevation/dem.jpg`; // Download elevation and render when ready reader.setUrl(`${__BASE_PATH__}/data/elevation/dem.csv`).then(() => { renderer.resetCamera(); renderWindow.render(); }); // ----------------------------------------------------------- // Make some variables global so that you can inspect and // modify objects in your browser's developer console: // ----------------------------------------------------------- global.reader = reader; global.mapper = mapper; global.actor = actor; global.renderer = renderer; global.renderWindow = renderWindow; 
    submitted by /u/daalegend
    [link] [comments]

    I've installed ubuntu 18.04 on virtual box, but its only showing the terminal. How do change to GUI like Unity GUI?

    Posted: 03 Jun 2018 01:50 PM PDT

    Reviews / SEO API

    Posted: 03 Jun 2018 08:29 PM PDT

    I'm trying to aggregate all reviews for my business from yelp, google, etc. on a regular basis. Is there a single API which gathers all that information with one call? Or do I need to use each of their individual APIs?

    submitted by /u/pind02
    [link] [comments]

    [php][ajax] Stuck on something stupid

    Posted: 03 Jun 2018 11:39 AM PDT

    I just can't figure it out why data is not posted to another file. I'm staring at the code for hours.

    Please no hate, just learning to code as a hobby .

    1. Got this form // full disclosure - it's echoed by php , if it makes any difference .

     <form class='form-group' id='adding' name='s1' > <td><input type='text' class='form-control' id='inp1' name='inp1'></td> <td><input type='text' class='form-control' id='inp2' name='inp2'></td> <td><button type='button' class='btn btn-success' id='subb' name='subb'>Insert</button></td> </form> 
    1. Got this ajax thingy

      $("#subb").click(function() { var d2 = $('#inp1').val(); var d3 = $('#inp2').val(); $.ajax( { url: "insert_with_ajax2.php" , type: "POST", dataType: "text", data: {data1: 'XXX', data2: d3}, success:function(data) { if (data='success') { $('#this_tr').before('<tr><td>'+d2+'</td><td>'+d3) ; $('#d2').val(''); $('#d3').val(''); } }, error:function(data) { if(data!='success') { alert(':('); }
      } } )}) ;

    2. the php file

      try{ if(!isset($_POST['data1'])) ECHO 'Howww is this posibllle'; $dd1=$_POST['data1']; $dd2=$_POST['data2'];
      $insert= "INSERT INTO tel (num, mob) VALUES (:dd1, :dd2) "; $insertStmt = $conn->prepare($insert); $insertStmt->bindValue(":num",$dd1); $insertStmt->bindValue(":mob",$dd2); $insertStmt->execute();

      echo "success"; 

      } catch(PDOException $ex) { echo $ex->getMessage();

      }

    3. Php file is outputing : [kept the relevant parts ]

      Howww is this posibllle ( ! ) Notice: Undefined index: data1 in insert_with_ajax2.php on line 17 ( ! ) Notice: Undefined index: data2 on line 18 SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

    submitted by /u/milkstake00
    [link] [comments]

    Evil Hangman Assignment

    Posted: 03 Jun 2018 06:03 PM PDT

    hello i know that there are various version of this assignment floating around, but we are supposed to implement a slightly less evil version of hangman.

    For a partially malicious strategy, the computer does not honestly choose a word, but instead keeps track of a whole set of possible words. When the user makes a guess, the computer checks against its set of possible words, and finds one of two things:

    1. There are words remaining that don't include the guessed character. The computer reports that the word is not in its secret word, and updates its word set to get rid of all words containing that letter.

    2. Every word contains that letter. The computer can no longer cheat, so it randomly picks a word from its set, and plays honestly from this point on (as in a standard game of hangman).

    import java.util.ArrayList; import java.util.Random; import java.util.Set; import java.util.TreeSet; public class PartialMaliciousHangman extends Hangman { private Set<String> dictionary; private Set<String> possWords; private Set<String> currWords; private String word; public PartialMaliciousHangman(Set<String> dictionary, int length, int guessCount) { super(length, guessCount); this.dictionary = dictionary; possWords = new TreeSet<>(); currWords = new TreeSet<>(); for(String words : dictionary) { if(words.length() == length) { possWords.add(words); } } } private void updateList(char c) { for(String word : possWords) { if(word.contains(String.valueOf(c))) { possWords.remove(word); } } currWords = possWords; } // this method should update the state of the current word being // guessed. it is responsible for updating wordlists as well.' // i am unsure of how to split up this code, making sure it // updates the word lists, but also fills in the correct letters // when properly guessed @Override protected boolean makeNewGuess(char c) { boolean isInWord = word.contains(String.valueOf(c)); //get index of guess if exists //and replace with char if(isInWord == true) { for(int i = 0; i < state.length; i++) { if(word.charAt(i) == c) { state[i] = c; } } } return isInWord; } // this is supposed to return a word that may be possible at current point @Override public String getWord() { Random r = new Random(); int select = r.nextInt(currWords.size()); String theWord = ""; word = theWord; return word; } } 
    submitted by /u/tensadbois
    [link] [comments]

    How important it is to be able to write your own functions vs using something someone else already made? (specially in Math heavy fields such as Optimization, Machine Learning and CFD)

    Posted: 03 Jun 2018 06:57 AM PDT

    Hello r/AskProgramming . This question is probably trivial but I wonder because I come from a non-programming background and this semester I'm taking a course on Optimization. It's been math and programming heavy and I struggled a lot in the first assignments where we had to write our own codes to minimize the objective functions even if I understood the math behind the methods (at that time it was single and multivariable nonconstrained optimization so things like Golden-section, Conjugate gradient, Gradient descent, Quasi-Newton methods and so on) due to the fact that for me in the past programming has been mainly a hobby and my ability to translate those equations into code is subpar for not saying straight up bad.

    Fast forward a few weeks and for the subsequent assignments the instructor allows us to use existing code and functions to solve the problems and I have been doing much better. For this particular case we're dealing with linear programming, sequential quadratic programming and penalty function methods to solve linear and nonlinear constrained optimization problems. I have used functions from MATLAB and from users who posted them online and I have been able to obtain the results I wanted after some time debugging and changing the code for my particular needs.

    Now my question is for someone who is interested in this field (or in other highly mathematical heavy fields such as CFD), how important it is to be able to write code from scratch vs modifying and using existing code, functions and libraries from someone else to do the job?

    submitted by /u/xEdwin23x
    [link] [comments]

    How do I limit a number of visitors to my website?

    Posted: 03 Jun 2018 09:09 AM PDT

    And how I make the exceeders (who exceed the counter) get automatically redirected to a "sorry" subdirectory?

    submitted by /u/Rand_Reddics
    [link] [comments]

    What is the best way to store, read, and extract info from a giant json file (18mb) to use in my React.js project?

    Posted: 03 Jun 2018 10:25 AM PDT

    I am creating a local weather web app by applying data from openweathermap api.

    THe instructions for openweathermap api recommend to use cityId to query the endpoint and get data for a specific city. The cityId's are stated to be found in a json file that can be downloaded from this link: [weathermap api json][1]

    [1]: http://bulk.openweathermap.org/sample/

    Each object in the json looks like this:

    {

    "id": 707860,

    "name": "Hurzuf",

    "country": "UA",

    "coord": {

    "lon": 34.283333,

    "lat": 44.549999

    }

    },

    {

    "id": 519188,

    "name": "Novinki",

    "country": "RU",

    "coord": {

    "lon": 37.666668,

    "lat": 55.683334

    }

    },

    I first downloaded this json file and placed it in my project but it slows its performance down quite a bit so I did some research and thought that my best answer was creating a citylist table in postgresql where each city has an id and a jsonb column that would simply be a parsed city object from the json file.

    My problem is I don't know how to load each object from the json to the postgres db without manually writing insert sql queries for each object.

    What is the most efficient way to load this json file into postgres? Do i need to export the json from it's file and write a script in my project that imports the json, parses each object and converts it into a sql query string? That doesn't sound efficient and my gut tells me there's an easier way. Is there a way to do this with psql command lines?

    Suggestions on how to do this with postgres or any other approach would be appreciated.

    submitted by /u/sendNudesNotNukes132
    [link] [comments]

    SonarQube analogue

    Posted: 03 Jun 2018 11:21 AM PDT

    Hi. Does anybody know alternative of SonarQube?

    submitted by /u/HoneyDimasik
    [link] [comments]

    Eigenvectors without the need of covariance

    Posted: 03 Jun 2018 08:05 AM PDT

    Trying to recreate program mentioned in https://pdfs.semanticscholar.org/fdca/5ecdf5fff9b5580a6bf18a813e3982693ea9.pdf

    I am currently working on a project that involves performing PCA on a covariance matrix.

    It first involves turning N 250x250 (MXM) images into a (250x250)x1 matrix effectively turning every pixel into its own "feature" after doing this I then work out the average feature values denoted by X.

    I then work out the difference between each image and X and store these differences in a variable Y.

    This is where it becomes a little tricky in the paper described they state that they created covariance for each image and then took the means of these covariance matrices however the size of these matrices would be (250x250)x(250x250) which causes memory errors. I mentioned this to my supervisor who has recommended me to investigate decomposing an NxN matrix and then convert the eigenvectors instead, this to me makes it seem as though I can find the eigenvectors without computing the covariance matrix of each image and averaging them.

    So my question is how do I work out eigenvectors without computing a covariance matrix over N samples?

    I hope this makes sense, thanks for reading.

    submitted by /u/CSStudent3
    [link] [comments]

    Confused about functions passed in as arguments to other functions and when its executed (Javascript)

    Posted: 03 Jun 2018 07:34 AM PDT

    Hello all. I am a fairly new to programming and i am currently taking the course "JavaScript: Understand the Weird Parts" and going through the section on Functional Programming.

    function mapForEach(arr, fn) { var newArr = [] for(var i = 0; i < arr.length; i++) { newArr.push( fn(arr[i]) ) }; return newArr; } var arr1 = [1,2,3]; var arr2 = mapForEach(arr1, function(item) { return item * 2; }); console.log(arr2); 

    Logically, i understand that we are simply running the passed in function against every item in arr1 and the result is being added to the newArr but somehow there is a disconnect. I just can seem to visualize when that passed in function is actually executed.

    So my two questions are:

    1.How does it look visually from a syntax standpoint if you were to replace 'fn' with the actual function being passed in?

    1. More importantly, When exactly is this passed in function actually executed (i.e. after the for loop is completed? during the for loop? etc.)?

    I know its probably an extremely noob question, but after 24 hours of trying to visualize the steps i would appreciate any help

    submitted by /u/RSpringer242
    [link] [comments]

    Issue with a backgroud (C/Html)

    Posted: 03 Jun 2018 11:07 AM PDT

    Hey guys! I'm currently programming a game for a university subject and I'm having some trouble with an image.

    The image used as background appears above the place where it was supposed to be even though it programmed with the correct coordenates (I believe) (0,0).

    What should I do?

    (I hope you don't mind it is in Portuguese)

    Thanks

    Screenshots

    submitted by /u/TooMuchReverb
    [link] [comments]

    React/Redux - Selecting Items and fill a list in new page/view with more data from a api

    Posted: 03 Jun 2018 03:53 AM PDT

    Ok so what im trying to build is a list of products or items with some data that is fetched through the API, the user then selects which ever products they want, they click on a compare button and they get directed to a new page or a overlay modal with the selected products and the rest of the data of those products from the API.

    But i also want to be able to go back to the previous page and select more and de-select items while retaining the previously selected items.

    Im just wondering how to move forward with this idea? If there are any examples out there of people having done it before etc etc. any guides etc etc.

    thank you.

    submitted by /u/TotalTSB
    [link] [comments]

    Autosyncing database for filemaker pro like system

    Posted: 03 Jun 2018 05:51 AM PDT

    Hello everyone. I am working for a Lab. We mainly use google sheets to keep basic data. Whenever a change is made from a computer update is shown on every other computer too. We also use Filemaker Pro on some computers. I want the Structure and form of Filemaker Pro and autosyncing and formulas of googlesheets The one thing i can't seem to figure out on google sheets is how to change a cell's value from another cell. Google App script allows me to do this but i am wondering if there is another way. I am ok with learning another language and platform (SQL) as long as they have what i need. Thank you very much.

    submitted by /u/isyerindereddit
    [link] [comments]

    How do I make divs change their padding to fit the entire page?

    Posted: 03 Jun 2018 01:34 AM PDT

    So not really a programming question, more of a css thing, but my goal is to have divs, that are all inline-block. They should fit the entire page, maybe with some margin in between them. I want them to dynamically change their padding/width to fit along with their "sibling" divs and occupy 100% of the page. How can I do this?

    submitted by /u/aregak2005
    [link] [comments]

    Help on batch file automation with file names

    Posted: 03 Jun 2018 01:05 AM PDT

    I am a newb to this sort of thing and I've tried looking up for almost 3 hours on the internet not stumbling on any solution. Or maybe I'm just not searching for the right keywords so I decided to ask reddit for help.

    I am trying to do some automation for archiving purposes and here's a part of my code..

    @echo off for /r %%a in (*.mp3) do ( ( for %%b in ("%%~na") do echo ^Artist: %%~b echo ^Song: )>"%%~dpna.txt" ) 

    Assuming file name is TheBand - SongTitle.mp3 How would I echo them separately from artist and name of song?

    Output text file >
    Artist: TheBand
    Song: SongTitle

    Might be simple but I am not really that of a pc language expert.

    submitted by /u/Mr-RightHanded
    [link] [comments]

    Parent Process to create 3 child process to exec functions.

    Posted: 02 Jun 2018 10:41 PM PDT

    I am new to programming and i came across this post and am interested in figuring out how to create the 2nd and 3rd child process and have them execute other program/functions and then wait for them to execute to print out the parent is finished.

    I understand there is an answer there but i had issues trying to edit that code to make it work. Thank you.

    https://cboard.cprogramming.com/c-programming/103561-forks-child-processes.html

    submitted by /u/ScottyyB
    [link] [comments]

    No comments:

    Post a Comment