• Breaking News

    Saturday, March 16, 2019

    Save to database, or file? Ask Programming

    Save to database, or file? Ask Programming


    Save to database, or file?

    Posted: 16 Mar 2019 06:40 PM PDT

    So, I'm currently working on an online game and have come up to a dilemma.

    Do I save player character data to a database, or to an XML file?

    I was originally going to save to an SQL database, but now that I've reached the point of implementation I've started to wonder what would be best. I'm not going to need access to character data without the main server, so being able to query off-site and independently isn't necessary. Plus, being able to directly load into object seems as though it would be easier. I can't find any information on peoples' opinions on this or industry standards. So, to elaborate on my question;
    Which would be more storage-friendly? Which would be more reliable with reads/saves/updates? What do you recommend and why?

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

    Pitching tomorrow at Startup Weekend, can you help me validate an idea?

    Posted: 16 Mar 2019 03:58 PM PDT

    Building a match-making platform for NGO projects and developers. 1-minute survey

    https://dev.to/around25team/70-of-our-team-is-at-startup-weekend-care-to-help-o05

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

    C++ programmers, how do you do GUI?

    Posted: 16 Mar 2019 08:02 AM PDT

    There seems to be no proper resources to learn Gtkmm other than the official documentation. Is it that uncommon to do GUI with C++?

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

    do Something if condition is met VS do nothing if condition is not met

    Posted: 16 Mar 2019 09:21 PM PDT

    I'm currently working on a java project, where a user is asked if he wants to save an image and if he wants to override it, if the file already exists. Now i've got a couple of approaches and dont know which one to use.

    Approach 1 (save Image when conditions are met):

    dialog("save image?"); if (answer == yes) { if (fileExists) { dialog("override file?"); if (answer == yes) { saveImage(); } } else { saveImage(); } } 

    probbaly the easiest one to read, but: I'm calling saveImage() twice and if i would add more conditions, it would become very nested

    Approach 2 (stop if any conddition isnt met; saveImage at the end):

    dialog("save image?"); if (answer == no) { return; } if (fileExists) { dialog("override file?"); if (answer == no) { return; } } saveImage(); 

    looks less bulky, but worse readability using return statements in my opinion

    Approach 3 (saveImage is part else-block [when user wants to save the Image]):

    dialog("save image?"); if (answer == no) { return; } else { if (fileExists) { dialog("override file?"); if (answer == no) { return; } } saveImage(); } 

    additional else makes it more clear that saveImage is only called when the first dialog is corfirmed

    Approach 4 (Mixture/best of both worlds?)

    dialog("save image?"); if (answer == yes) { if (fileExists) { dialog("override file?"); if (answer == no) { return; } } saveImage(); } 

    has the benefit of approach 3 while loking less bulky

    I would probably use approach 2 or 4. what do you think is the best approach in this situation and why? in which situations would you do itdifferently and why?

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

    Question about programing an app that use NFC feature

    Posted: 16 Mar 2019 06:46 PM PDT

    Hello reddit,

    I am currently trying to develop an app that use the NFC technologie. Basicly, the app will receive an excel file via the NFC feature. The app will use the data in the file so the user will be able to filter the data and keep a track on it.

    I am trying to develop this app by myself. I have basic knowledge with C language. I need you guys to advise me on how I can make this project possible. What kind of software can I use for the programation? What steps do I need to follow to make it work?

    Thank you

    (Sorry for my poor english. It's my third language)

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

    Help with Strand Sort algorithm in C++

    Posted: 16 Mar 2019 05:21 PM PDT

    I have to implement Strand Sort in C++. But the caveat here is, that I MUST use arrays. No lists, linked lists, vectors, etc. allowed.

    Can anyone please help me out? I'm starting to lose my mind because I don't know how to implement this whole thing.

    Thanks in advance.

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

    How does hacking a website work? Do you just run scripts until one the website hasn't accounted for gets through?

    Posted: 16 Mar 2019 03:30 PM PDT

    How to change color in navigation bar for Blogger

    Posted: 16 Mar 2019 02:28 PM PDT

    This is my code that I used to change the color of the navigation bar on my blog , but the problem is is that it would only be that color the moment I go on to my blog. It then changes the color of my nav bar to black. I want it to to be that color permanently
    #navbar-iframe{background-color:#ff1493;}

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

    Help needed with 32 bit to decimal converter in Python

    Posted: 16 Mar 2019 02:14 PM PDT

    I'm very new to programming and was recently assigned to create a python program that takes a raw 32 bit input from the user and returns a dotted decimal equivalent. I've attempted to ask for help from my peers and instructor but my peers haven't been able to explain the process to me simply enough while my instructor isn't even sure how to accomplish the task himself! (The school has had some budget cuts).

    The instructions for the assignment are as follows:

    Write a program in Python to read a 32-bit integer and output its corresponding value in dotted decimal notation. For example the number 10000000111111110000001100001111 would become 128.255.3.15.

    If this is the wrong place to be asking for this sort of help I apologize. I'm pressed for resources and time so any help would be amazing!

    submitted by /u/cockalorum-smith
    [link] [comments]

    Looking for advice on how to construct something on a website

    Posted: 16 Mar 2019 10:06 AM PDT

    I'd like to build a similar website to https://jscompress.com

    However, the function will be completely different.

    All It does is to allow the user to uploads text files, and the program compiles all the text files into a single text file, which the user can download. How should I go about doing this?

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

    Simple PHP help

    Posted: 16 Mar 2019 01:08 PM PDT

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body>

    <form action = "site.php" method = "post"> <h1>Choose Your Role</h1> <input type = "button" name = "role" value = "Member"> </form> <?php $role = $_POST["role"]; if ($role == "Member"){ echo "You are a Member"; } ?> 

    </body> </html>

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

    Use AWS Cognito to Sign In User - Xamarin Cross Platform

    Posted: 16 Mar 2019 12:20 PM PDT

    Hello folk,

    I have implemented this code to register an user to my AWS Cognito Pool Sign Up Code and it runs ok.

    But when trying to log in the user with Sign In Code it crashes my app when using a correct user ( usuario) /password (senha) combo. If I let the password field blank it returns me an error with the try/catch ~thing~.

    Is there anything that I`m missing here?

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

    Question about Binary Search (i am using python)

    Posted: 16 Mar 2019 08:29 AM PDT

    Okay, so this is more an algorithmic question than a programming question per se, i think i understand how a binary search works. However, i am doing a problem set from Rosalind.info and the question says

    Problem

    The problem is to find a given set of keys in a given array.

    Given: Two positive integers n≤10^5n≤10^5 and m≤10^5m≤10^5, a sorted array A[1..n]A[1..n] of integers from −10^5 to 10^5 and a list of m integers −10^5≤k1,k2,…,km≤10^5−10^5≤k1,k2,…,km≤10^5.

    Return: For each kiki, output an index 1≤j≤n1≤j≤n s.t. A[j]=kiA[j]=ki or "-1" if there is no such index.

    Sample Dataset

    5

    6

    10 20 30 40 50

    40 10 35 15 40 20

    Sample Output

    4 1 -1 -1 4 2

    I understand that a binary search basically will take the list A[1...n] and a value to search for k. it will take A[n/2] and check it against k, if it is bigger than k it will recurse the upper half of the list, if it is lower than k it will recurse the bottom half and will keep doing this until it finds the value in the list.

    From looking at the sample dataset, i understand that the bottom list 'm' is being compared to the top list and returning the index location. what i dont understand is what the purpose of the 5 and 6 are. They seem to be the length of the two lists, but is that necessary in the code?

    I really appreciate any help. I would have post this on Stackoverflow but i am trying to get to 15 rep and this seems like a question that the group would downvote to hell, considering they did one of my questions that i posted asking about why my output on a program i wrote was wrong.

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

    Getting Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. error in flutter

    Posted: 16 Mar 2019 04:03 AM PDT

    Getting this error in flutter while running the project:

    FAILURE: Build failed with an exception.

    * What went wrong:

    Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

    > com.android.build.api.transform.TransformException: Error while generating the main dex list.

    * Try:

    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 1m 3s

    Running Gradle task 'assembleDebug'...

    Running Gradle task 'assembleDebug'... Done 63.9s

    Gradle task assembleDebug failed with exit code 1

    pubspec.yaml :

    name: sampledescription: A new Flutter project.version: 1.0.0+1environment:sdk: ">=2.1.0 <3.0.0"dependencies:flutter:sdk: flutter# The following adds the Cupertino Icons font to your application.# Use with the CupertinoIcons class for iOS style icons.cupertino_icons: ^0.1.2# package for saving the screenshotimage_picker_saver: ^0.1.0# packge for toast-msgfluttertoast: ^2.0.0# color pickerflutter_colorpicker: ^0.2.2# firebase storage pluginfirebase_storage: ^1.0.4# sharing pluginesys_flutter_share: ^0.0.9dev_dependencies:flutter_test:sdk: flutterflutter:uses-material-design: true# To add assets to your application, add an assets section, like this:assets:- assets/eraser.png- assets/screenshot.png- assets/angry.png

    build.gradle (android module) :

    buildscript {repositories {google()jcenter()}dependencies {classpath 'com.android.tools.build:gradle:3.2.1'classpath 'com.google.gms:google-services:4.0.1'}}allprojects {repositories {google()jcenter()}}rootProject.buildDir = '../build'subprojects {project.buildDir = "${rootProject.buildDir}/${project.name}"}subprojects {project.evaluationDependsOn(':app')}task clean(type: Delete) {delete rootProject.buildDir}//solving errorsubprojects {project.configurations.all {resolutionStrategy.eachDependency { details ->if (details.requested.group == 'com.android.support'&& !details.requested.name.contains('multidex') ) {details.useVersion "27.1.0"}}}}

    build.gradle (app module) :

    def localProperties = new Properties()def localPropertiesFile = rootProject.file('local.properties')if (localPropertiesFile.exists()) {localPropertiesFile.withReader('UTF-8') { reader ->localProperties.load(reader)}}def flutterRoot = localProperties.getProperty('flutter.sdk')if (flutterRoot == null) {throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")}def flutterVersionCode = localProperties.getProperty('flutter.versionCode')if (flutterVersionCode == null) {flutterVersionCode = '1'}def flutterVersionName = localProperties.getProperty('flutter.versionName')if (flutterVersionName == null) {flutterVersionName = '1.0'}apply plugin: 'com.android.application'apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"android {compileSdkVersion 28lintOptions {disable 'InvalidPackage'}defaultConfig {// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).applicationId "com.example.sample"minSdkVersion 16targetSdkVersion 28versionCode flutterVersionCode.toInteger()versionName flutterVersionNametestInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"multiDexEnabled true}buildTypes {release {// TODO: Add your own signing config for the release build.// Signing with the debug keys for now, so `flutter run --release` works.signingConfig signingConfigs.debug}}}flutter {source '../..'}dependencies {testImplementation 'junit:junit:4.12'androidTestImplementation 'com.android.support.test:runner:1.0.2'androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'implementation 'com.android.support:multidex:1.0.3'// firebaseimplementation 'com.google.firebase:firebase-core:16.0.1'}apply plugin: 'com.google.gms.google-services'

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

    Displaying image in Javafx Tableview

    Posted: 16 Mar 2019 05:33 AM PDT

    Hello,

    I have managed to create a table in JavaFX and fill it with data from an SQL database I am using (code sample below). The database table includes an image column where the file path to the image is stored. Is there any way for me to display the images in the JavaFX table? Any advice greatly appreciated.

    public void buildMusicTable(){

    try { data = FXCollections.observableArrayList();

     Connection connection=null; connection= DB.DBConnection.getConnection(); PreparedStatement ps = connection.prepareStatement( "SELECT event_id, event_name, event_image_path from events WHERE type = 'mus'" ); ResultSet rs = ps.executeQuery(); for(int i=0 ; i<rs.getMetaData().getColumnCount(); i++){ //dynamic table creation final int j = i; TableColumn col = new TableColumn(rs.getMetaData().getColumnName(i+1)); col.setCellValueFactory(new Callback<CellDataFeatures<ObservableList,String>,ObservableValue<String>>() { public ObservableValue<String> call(CellDataFeatures<ObservableList, String> param) { return new SimpleStringProperty(param.getValue().get(j).toString()); } }); tableview.getColumns().addAll(col); System.out.println("Column ["+i+"] "); } while(rs.next()){ //Iterate Row ObservableList<String> row = FXCollections.observableArrayList(); for(int i=1 ; i<=rs.getMetaData().getColumnCount(); i++){ //Iterate Column row.add(rs.getString(i)); 
    submitted by /u/_strangeways
    [link] [comments]

    GUI and writing to file

    Posted: 16 Mar 2019 10:52 AM PDT

    I am doing an OOP class, and I was wondering if anyone could help me out with a problem I have in my app controller.

    This method is activated by a button in my GUI:

    @FXML public void handleClick() { String v1 = (String) velg1.getValue(); String v2 = (String) velg2.getValue(); Ses s1 = new Ses(); int antall = (int) antallK.getValue(); for(int i = 0; i<antall; i++) { s1.sk(v1, v2);} M.setText(s1.toString()); L.setText(s1.getMD()); D.setText(s1.getSD());} 

    What I want to do is to create another button that when clicked writes the information stored in s1 in the code example abovet to file.. The methods for writing to file is already made, but I struggle to connect the buttons.. How can I integrate another button that allows me to access te object created within handleClick?

    @FXML public void saver(){ When the button is clicked and this method is activated I want to access s1 in the method above.. } 

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

    Download modpack for game using WebClient C#

    Posted: 16 Mar 2019 04:21 AM PDT

    Hello out there.

    I'm currently attempting to create a launcher that allows to download a modpack using the WebClient. However I have a problem in regards to check if the user is missing specific files, have been updated since or been delete since last check.

    What would be the easiest way for me to accomplish this? Perhaps I should use something else than WebClient?

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

    Windows filesystem manipulator

    Posted: 16 Mar 2019 08:25 AM PDT

    I want to write a program that lists out all the subdirectories of a folder and when I press a button on one of those list items, it copies the files inside to another directory (overwriting what's already there).

    I also want to keep track of some data related to each subdirectory in the list (like in an excel format) which is simple text that I will manually be adding/changing.

    My question is which programming language would be best to accomplish this?

    Platform: Windows Research: I think this would be possible with excel and VB but not sure if it is or if it's the best

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

    Question about code in JS

    Posted: 16 Mar 2019 08:21 AM PDT

    Hi good people,

    i have code that i wrote in JS (jQuery) that 'draw' element on click.

    And the code works, but i want to write it with JS class, but i am not very good with OOP.

    I want to know, in this code, do i need to set class method that append all of this divs like i wrote, or there is a better way?

    Code: https://jsfiddle.net/a901rovu/

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

    How do you increase the step count for a constexpr function?

    Posted: 16 Mar 2019 03:57 AM PDT

    I have a mapping function value = database[key*magic_number>>(64-s)] where for the right magic number, there are no (undesirable) hash collisions. (The map is surjective.)

    I have a function, constexpr uint64_t get_magic_number(); from which I call const auto magic_number = uint64_t get_magic_number();

    I have tested this for all keys, and it retrieves the correct value.

    magic_number is clamoring to be constexpr but I get the error message:

    Constexpr evaluation hit maximum step limit; possible infinite loop?

    Is there a way to change the compiler step size in Xcode?

    I want to add that I have simplified this in that there are actually 128 magic numbers for 128 hashtables. The compiler is happy to produce 49 of these before it gives up.

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

    How to access $scope variables in controller?

    Posted: 16 Mar 2019 07:01 AM PDT

    I am trying to use the variable in the controller, but I get undefined every time use console log to check the values

    Any sort of help will he highly appreciated :)

    https://stackoverflow.com/questions/55196580/how-to-access-scope-variable-in-controller

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

    Attach external debug console to JavaWS applciation

    Posted: 16 Mar 2019 06:33 AM PDT

    I've got a JavaWS application for which I don't have ready access to the original source code (aside from decompiling). I'm looking to add some debugging functionality. Ideally this will be in the form of a console window which outputs where the code currently is (class and method name) as a user navigates through and interacts with the application's GUI. I'd need to be able to isolate this to a specific package so as to avoid spam of native java output.

    My main question is, is this possible? My understanding is the JVM is closed off but there are ways to interact with it by attaching things such as additional .jar files to it via command line arguments. This could contain an application that monitors for certain things and could provide output? I've also found stuff about the JNI however I'm still trying to get my head around how that works and whether or not it is appropriate for what I'm trying to achieve.

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

    Help accepting 2 keyboard inputs at once using KeyListener

    Posted: 15 Mar 2019 10:32 PM PDT

     public void keyPressed(KeyEvent e) { if (e.getKeyCode() == 32){ //spacekey if (menu.isRun == true){ //Checks if menu is active or not if (framecount > 10){ //Prevents too many missiles instance.player.spaceKeyPressed(); framecount = 0; } } menu.isRun = true; //sets menu to inactive if (toggle != true){//prevents reopening game after a game over if (menu.spaceKeyPressed()){ instance.CanRun = true; //loads game toggle = true; menu.update();//updates menu } } } if (e.getKeyCode() == 39) instance.player.rightKeyPressed();//right key moves player right if (e.getKeyCode() == 37) instance.player.leftKeyPressed(); //left key moves player left } 

    With this the user can only move or shoot, not both at once. For example if the user is holding right arrow to move right and presses space the user will stop.

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

    No comments:

    Post a Comment