• Breaking News

    Friday, February 21, 2020

    How do you make it so that you don't have to re-declare a helper class? Ask Programming

    How do you make it so that you don't have to re-declare a helper class? Ask Programming


    How do you make it so that you don't have to re-declare a helper class?

    Posted: 21 Feb 2020 04:10 PM PST

    I think I'm missing something, but sometimes I like separating logic into some "utilities" class like splitting a text or parsing stuff.

    it ends up looking like:

    public class Utilities { public void DoStuff(string text) { } } 

    So, I was wondering how to write this so that I don't always have to keep calling:

    var util = new Utilities(); util.DoStuff(text); 

    Think I forgot how to do it. Is this a case for a singleton pattern?

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

    [Request] Nonprogrammer, needing help to find the best solution

    Posted: 21 Feb 2020 06:44 PM PST

    Background: Law Enforcement

    Need: A Photo Array/Lineup Generator

    Overview:

    • A lightweight tool that can be opened and used on any computer

    • No internet connection needed

    • Users will upload 6 jpeg/png images (1 of suspect, 5 of random people)

    • Each image will include name & source

    • Once the user uploads these, they "run" the program

    • The result will include 8 pages:

      • Page 1 (reference page): 6 images with names and source, 2x3 layout, landscape orientation
      • Page 2: 6 images in the same order, numbered 1-6, 2x3 layout, landscape orientation
      • Page 3 - 8: 1 enlarged image on each page with corresponding number

    Considerations:

    Needs to automatically adjust images (resize & crop)

    Needs to be able to export to pdf

    Needs to be saveable and allow users to return to the make modifications

    Needs to track all modifications and store previous versions

    Needs ability to 'randomize' order of images

    What would be the best route to tackle this?

    If I was to build this from scratch, with little to no programming experience, what steps would you suggest I take to make this happen?

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

    How to implement a genetic algorithm into the Directions API?

    Posted: 21 Feb 2020 08:29 AM PST

    Hi there!

    I wonder if is there a way to implement a simple genetic algorithm that solves the TSP problem (meaning it finds the shortest path from one place to another without visiting the same place again). I have used Direction API however it is already automated and it actually costs money to use it. I want a genetic algorithm that will do the same job, but I am confused and I don't know how to use with a Directions API. I got the API JSON file which has the distance and duration data. Can I use it as parameters for the genetic algorithm and lastly but most importantly how can I display that on the map.

    For now, I got a screen of what I can do with a Directions API. I want the same but using a genetic algorithm. The app I build is for Android, therefore I use JAVA only. Cheers!

    Any suggestions?

    https://imgur.com/93FS1V5

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

    How to clone taiga anime in python

    Posted: 21 Feb 2020 07:49 PM PST

    I would like to clone this program with python. The reason is i watch movies, anime and many other media in my pc, besides reading books and would like my clone to do all this things. I only know how to program in python and I don't aim to become software developer or something like that so i don't mind make a spaghetti code and also think that learning to make a app like this could help me to make anothers similar projects.

    I know how to program in python because as a mathematics student I used to work in a bank and i did little scripts in python and write pseudocode of algorithms so other people would write them.

    I dont have idea how to make the grafical part, how to code it so i can interact with the gui.

    Any recomendations?

    Is any easy technologie to make gui with pthon?

    Should I make little apps to learn the mvc paradigm?

    Would some one mentor me?

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

    I'd like to create an in-house photo gallery that pulls images based on their server location and searched keywords. Where do I start?

    Posted: 21 Feb 2020 07:39 PM PST

    I have a small amount of programming under my belt (Python, some batch scripting, etc.) and I'm decent with computers, especially Excel & Photoshop. I just don't know the best way to accomplish what I need.

    We have tons of jpgs where I work. They're in different places on our server, as they are digitized photos from archival collections. So they're arranged by collection, etc. I'd like to create something so that my less-computer-literate co-workers and superiors can search through the photos. I could just teach them to search keywords in Windows Explorer, but not all of them have IPTC metadata attached to them. So, I'd like it to be a gallery that could even display, maybe, a title or collection under each photo, but also allow them to search keywords for those that have been described.

    Where do I start? What tools should I look at for doing this?

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

    Language/platform recommendations for a hobbiest?

    Posted: 21 Feb 2020 06:52 PM PST

    EDIT: Thinking more on this, it's better to figure out a project that fits my specifications, and pick the language based on that instead of the other way around. There's a SAAS webapp I wanted to make for myself so I'm going to go with golang. Thank you everyone who read my wall of text and took the time to respond!


    I know the basics of coding in a few languages but I haven't specialized on anything. What are some good languages and platforms to develop on as a hobby?

    I'm don't want to spend much all my time dealing with breaking changes from platform API and dependency updates. I'll only have a couple of hours a week and I don't want to use it fighting bit rot. But I want to keep my skills up and keep improving.

    I have experience with Linux shell scripting, go, java, and dart/flutter. A little bit of webdev and C.

    I'm also interested in OS design and low-level programming but not sure if a few hours, one day a week, will get me anywhere significant with that. I'm not planning on pursuing a career in software development. Also interested in functional programming (haskell) but I want my hobby projects to have some real utility, at least for me personally.

    I'm leaning towards getting better at dart and flutter for apps, but any recommendations are welcome!

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

    I read somewhere that it was bad to use external identifiers as parameters from a user interface to reference an object such as openDoor(“dave”) it should be openDoor(dave).. In what case is it ok to use an external identifier as a parameter as a reference to an object in an operation?

    Posted: 21 Feb 2020 05:41 PM PST

    Why is disk IO on my new AWS EC2 spot instance so much slower?

    Posted: 21 Feb 2020 04:08 AM PST

    I have an instance A with a 200GB SSD filled with data. I used this disk to create an AMI and used that AMI to spin up a spot instance B.

    B started almost instantaneously which surprised me since I thought there would be a delay while AWS copies my 200GB EBS to the SSD corresponding to the new instance. However I noticed IO is extremely slow on B. It takes 3x as long to parse data on B.

    Why is this, and how can I overcome this? It's too slow for my application which requires fast IO.

    submitted by /u/Future-Professional
    [link] [comments]

    [Request] I need to create a project based on specific techs

    Posted: 21 Feb 2020 01:01 PM PST

    Hello. I will be doing an internship this summer. I've found a company, got accepted, but my internship counselor from the uni forces me to develop a project based on the technologies that the company is currently using. He says that he wants to make sure I find a legit place, and not do the internship based on the paper. Long story short, I have contacted the company to give me a homework project, but they said that they can't because of privacy protocols. So I need you guys to advise a project for me to complete based on these criterias:

    -J2SE / JEE knowledge

    -Server side techs (JSP, Servlets, Web Services, Spring, Hibernate etc.)

    -Application services (Apache Tomcat, JBoss, Glassfish, WebSphere, WebLogic etc.)

    -Database systems (PostgreSQL, Oracle, SQL Server etc.)

    -Basic HTML, CSS, JavaScript, JQuery knowledge

    -Preferably Linux knowledge

    I got these from the company's "Java Developer" job offering. I'd appreciate greatly anyone who tries to give me a project idea. Thank you.

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

    How would you go about programming a Shopify-like tool?

    Posted: 21 Feb 2020 04:44 PM PST

    I have an eCommerce business and I'm thinking on expanding by developing a custom solution for sellers in my country, as I feel that a lot of platforms are not that good or don't have that much features.

    From what I've gathered, I've found out that maybe Ruby on Rails would be my best bet, do you think that would be a good option?

    I'd also need php, javascript and mysql, I have a bit of experience on those as well, I'd like to get started on learning the required technologies ASAP, but if needed, I could hire an agency to help me with the missing portions.

    Any help is greatly aprecciated!

    submitted by /u/-5677-
    [link] [comments]

    Deleting an element in a database based on which HTML-element that is clicked

    Posted: 21 Feb 2020 03:30 PM PST

    I am creating a "Notes" web app. For every Note in my database, I am creating a div-container showing the text content stored in my database.

    I want each div-container to have a delete-button, which is supposed to delete that specific Note immediately from my database. How can I accomplish this?

    The Database function for deleting my Note ready. My source code is currently something like this:

    // my delete-function in my database class

    public Boolean DeleteNote(Note n) {

    deletes note from Database

    }

    // my HTML element displaying each Note in the database

    .@foreach(Note n in myNotes) {

    <div class="container note">

    <button onclick="**???????**">Delete Note</button>

    <p>@n.Text</p>

    </div>

    }

    PS. I am using C# and .NET MVC if that is relevant.

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

    I need to create a set of colored buttons using array and a for loop to initialize

    Posted: 21 Feb 2020 11:23 AM PST

    The error i keep encountering its in the context.setFill(colors[i]); any help? id appreciate it

    Button[]colorsButton = new Button[10];

    Color[]colors = {Color.RED, Color.BLUE, Color.GREEN, Color.BLACK, Color.YELLOW, Color.ORANGE,

    Color.WHITE, Color.PINK, Color.PURPLE, Color.GRAY};

    String[]colorName = {"red", "blue", "green", "black", "yellow", "orange", "white", "pink", "purple", "gray" };

    for( int i = 0; i < colorsButton.length; i++){

    colorsButton[i] = new Button(" ");

    colorsButton[i].setOnAction((ActionEvent event)-> context.setFill( colors[i]));

    colorsButton[i].setStyle("-fx-base:" + colorName[i]);

    }

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

    gitignore pipenv file

    Posted: 21 Feb 2020 12:41 PM PST

    I installed matplotlib via pipenv and there's a file called matplotlib.pyplot created about an hour after Pipfile.lock.
    I don't know how it was made.
    It's quite large and not ignored by a generic python gitignore I found online.
    Should I add it to the gitignore?

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

    Session listener for Websession in Webflux

    Posted: 21 Feb 2020 11:39 AM PST

    I am starting a new project in Webflux but can't find a way to clear few database entries on session invalidation.

    As there was HttpSessionListener in MVC for session creation and invalidation event, is there anything relevant in Webflux?

    submitted by /u/Used-Math
    [link] [comments]

    Programming and social life

    Posted: 21 Feb 2020 04:44 AM PST

    What are the 2 main problems you have when it comes down to finding a relationship, especially that our profession demands us to sit most of the time behind the desk? I used to feel anxious in social interactions.

    PS: Sorry if this is a little bit out of topic, but I thought it would also resonate with some people here.

    submitted by /u/Rawad_Al-Kattan
    [link] [comments]

    LF Simple free project management tool

    Posted: 21 Feb 2020 09:00 AM PST

    Anyone got any recommendations for title? I'm not particularly interessed in timeschedules etc, just a half-decent way to setup project constraints, goals, features etc and mark their progress. Atm Im using postits and that just doesn't quite work well enough =D This is just for me and my small homeprojects.

    I would prefer standalone software vs a webpage, but I can do either!

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

    [JS] How to get the Date, and format it so it is meaningful when you put it into a database?

    Posted: 21 Feb 2020 08:51 AM PST

    https://www.w3schools.com/code/tryit.asp?filename=GC5HUZ7V3UAV

    This is a tough cookie. This Date() object seems really primitive. You either get some useless miliseconds since some random date, or you get some useless number that you have to increment by 1 (like months). You can't even get the number of the week. And formatting it into something meaningful? Good luck!

    I use the YYYYMMDD format, and I think it is superior for chronological stuff, and if you want to pull out months and days out of it. But I don't know what would be best for a database. I know people always have problems with dates because of some reason. Probably because of conversion or something.

    Personally, I was thinking of having my format for pure chronology, being topped off with a unique ID, and also having a third separate property that holds the computed number of the week because I will need that very much. But yea, querying the nth week will require a lot of looping unless I optimize it somehow to sort by date, and then assume the entries are between date x and date y.

    Is there a better thing in pure js than Date()?

    Why is it so hard?

    How should I set up my database so I can sort by weeks, and months. Those will probably be my primary sorts. Like, I would want to sum the values or get an average of the values in the nth month or nth week or forst 3 months or second half of the year.

    Tnx!

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

    Experimenting with time complexity; Can you cook up a computational problem whose underlying algorithm has a time complexity of theta(n^(3/2)) where n is a number given by the user.

    Posted: 21 Feb 2020 08:49 AM PST

    My attempt: 1.Consider a set consisting of elements 1 to log n (where log has base 1.58). Print all subsets of the above mentioned set.

    Any other cool ideas?

    submitted by /u/t_h-e-other-one
    [link] [comments]

    Working on a modern development team.

    Posted: 21 Feb 2020 08:40 AM PST

    I've been a professional developer for over 25 years. However, the last 20 years have been with a single company creating line of business applications by myself.

    I'm afraid that my company is about to be sold and that the buyers may not want to keep using our software but switch us to their platforms and that my services will not be needed anymore. A few years ago I saw this as a possibility and got a BS in Software Development to help jumpstart my impending job search.

    My concern is that managers won't want to hire me because I've never been a team player, which is fair because I don't really know how to be a team player.

    I've been reading up quite a bit on how to improve my soft skills to be a team player, but what I'm really concerned about is the actual technical aspects. I'm looking for specific suggestions on things like code reviews, pull requests, build tools and stuff like that.

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

    Can AWS spot stances with 200GB AMIs be spun up quickly?

    Posted: 21 Feb 2020 01:04 AM PST

    I have a data science application that I need to run once every 2-3 hours, where I need to use 64 cores for 6 minutes in an embarrassingly parallel fashion. Each of the cores needs to load 3GB of data from disk for a total of 192GB of disk data.

    To achieve this in a cost-effective way, my plan is to spin up a 64-core EC2 spot instance using a script whenever I need to run one of these jobs. I also plan to have a 200GB AMI with my required data. Then, when the EC2 instance starts, I can run my 64 jobs and they can each load their 3GB of data off the SSD there.

    Will this work, and how long will it take to spin up the EC2 spot instance with the large AMI? If it takes multiple minutes to start the instance then that's not good since these are only 6 minute jobs that I want to run quickly. Is there a better way to achieve my workflow?

    submitted by /u/Future-Professional
    [link] [comments]

    Change from void main into int main

    Posted: 21 Feb 2020 06:56 AM PST

    Anyone here know how to convert from void into int main? I'm beginner at C programming, really need your help guys :). I tried but still got nothing...the following code has error

    void largest(int scores[],int n)

    {

    int i;

    int max = scores[0];

    for (i = 1; i < n; i++)

    if (scores[i] > max)

    max = scores[i];

    return;

    }

    int main()

    {

    int scores[8], i;

    printf ("Enter 8 scores\n");

    for ( i = 0; i < 8; ++i )

    scanf ("%i", &scores[i]);

    int n = sizeof(scores)/sizeof(scores[0]);

    printf("Largest in given array is %d", largest(scores, n));

    return 0;

    }

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

    Function to calculate the distance between two strings in MIPS Assembly

    Posted: 21 Feb 2020 01:34 AM PST

    Hello, I'm having trouble writing a recursive function in MIPS assembly to calculate the distance between two strings. The function should take four parameters: string_a, string_b, length_string_a, length_string_b and return the distance between the two strings. For example findDistance("Sun", "Son", 3, 3) should return 1, which is the number of times the first string needs to be changed to resemble the second. The function should return -1 if the length of each of the two strings is less than 0

    Here is what I had attemped before I went blank. I just need someone to point me in the right direction and I can finish it

    .data

    string_a: .ascii "Sun"

    string_b: .ascii "Son"

    length_str_a: .word 3

    length_str_b: .word 3

    .text

    #copy starting address of each of the strings to registers

    la $a0, string_a

    la $a1, string_b

    lw $a2, length_str_a

    lw $a3, length_str_b

    #call function findDistance

    jal findDistance

    #The function findDistance

    findDistance:

    #if length of strings <= 0 jump to error, else continue to find distance

    #define base class

    #recursive

    #in the case that the lengths are 0 or less

    error:

    li $v0, -1

    j return

    return:

    j $ra

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

    What's the best language/interface to make a math program?

    Posted: 21 Feb 2020 04:53 AM PST

    Hi, so my experience with programming is very limited, I used to take classes for C# and C, Visual Studio, basic things. I'd like to make a program that spits out numbers based on some equations so I don't have to do the math manually every time I want something. What's the best/easiest language and IDE for such a thing?

    Thanks!

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

    Webpack's file loader and image-webpack-loader won't copy and optimize images from /src folder to /dist folder during production

    Posted: 20 Feb 2020 10:59 PM PST

    I have a Webpack setup which is split into 2 config files:

    webpack.config.js handles the development portion which is started using npx webpack-dev-server and webpack.config.prod.js respectively which handles the production by typing npm run build.

    The development config works as expected, but the production one has one problem: everything works fine, but the images aren't copied and optimized from the source folder: src/images/sm , src/images/bg to dist/images/sm , dist/images/bg.

    My folder structure is :

    • dist
    • node_modules
    • src
      • images
      • bg
      • sm
      • includes
      • scss
      • app.js
      • index.pug
    • package.json
    • webpack.config.js
    • webpack.config.prod.js

    webpack.config.js

    const HtmlWebpackPlugin = require('html-webpack-plugin'); const webpack = require('webpack'); const path = require('path'); module.exports = function(){ return { mode: 'development', entry: [ './src/app.js' ], watch: true, watchOptions: { aggregateTimeout: 300, // Process all changes which happened in this time into one rebuild poll: 1000, // Check for changes every second, ignored: /node_modules/, // ignored: [ // '**/*.scss', '/node_modules/' // ] }, devtool: 'source-maps', devServer: { contentBase: path.join(__dirname, 'src'), watchContentBase: true, host: '0.0.0.0', hot: true, open: true, inline: true, port: 9000 }, plugins: [ new HtmlWebpackPlugin({ title: 'Webpack starter project', template: path.resolve('./src/index.pug') }), new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }), new webpack.HotModuleReplacementPlugin() ], module: { rules: [ { test: /\.pug$/, use: ['raw-loader', 'pug-html-loader'], }, { test: /\.scss$/, use: [ 'style-loader', "css-loader", "sass-loader" ] }, { test: /\.(jpg|jpeg|gif|png|svg|webp)$/, use: [ { loader: "file-loader", options: { outputPath: './images', name: "[name].[ext]", }, }, ] }, { test: /\.html$/, use: { loader: 'html-loader', } }, ] } }; } 

    webpack.config.prod.js

    const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const {CleanWebpackPlugin} = require('clean-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const path = require('path'); module.exports = function(){ return { mode: 'production', entry: [ './src/app.js' ], optimization: { minimizer: [ new OptimizeCSSAssetsPlugin() ] }, plugins: [ new CleanWebpackPlugin(), new HtmlWebpackPlugin({ title: 'Webpack starter project', filename: 'index.html', template: path.resolve('./src/index.pug') }), new MiniCssExtractPlugin({ filename: '[name].css', chunkFilename: '[id].css' }), new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }), new webpack.HotModuleReplacementPlugin() ], module: { rules: [ { test: /\.pug$/, use: ['raw-loader', 'pug-html-loader'], }, { test: /\.scss$/, use: [ MiniCssExtractPlugin.loader, "css-loader", "sass-loader" ] }, { test: /\.(jpg|jpeg|gif|png|svg|webp)$/, use: [ { loader: "file-loader", options: { outputPath: '/images', name: "[name].[ext]", }, }, { loader: 'image-webpack-loader', options: { bypassOnDebug: true, mozjpeg: { progressive: false, quality: 45 }, // optipng.enabled: false will disable optipng optipng: { enabled: true, }, pngquant: { quality: '65-90', speed: 4 }, gifsicle: { interlaced: true, optimizationLevel: 3 }, // the webp option will enable WEBP webp: { quality: 20 } } }, ], }, { test: /\.html$/, use: { loader: 'html-loader', } }, ] } }; } 

    I uploaded my webpack setup to Google Drive and if anybody wants to check it out, here it is.

    I googled all day and I don't see anything wrong with my code.

    I tried other webpack configs and they have the same code as mine and their images get copied in the dist folder.

    Can anyone help me figure this out?

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

    No comments:

    Post a Comment