• Breaking News

    Tuesday, February 11, 2020

    Is there a script I can run to delete Reddit comments? Ask Programming

    Is there a script I can run to delete Reddit comments? Ask Programming


    Is there a script I can run to delete Reddit comments?

    Posted: 11 Feb 2020 01:05 PM PST

    I would like to delete my reddit comments with less than 5 upvotes for example.

    Does anyone know if there's a way to do that? Thank you

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

    Command line language, vs application, vs file

    Posted: 11 Feb 2020 05:22 PM PST

    I'm in my final year of a computer science bachelor's degree, and despite being able to USE a command line interface to get done what I want, I find myself not really understanding things.

    Sometimes command interfaces seem to be designated by a language. For example on linux, they use bash. Windows uses dos batch. Etc or powershell language.

    Sometimes its referred as a program. Like there exists external programs you can get on windows like windows terminal and cmder. They aren't languages, they're just better interfaces you can use to interact with command lines.

    Then sometimes they seem to be categorized as file times. There's .sh .cmd .bat etc etc.

    I honestly can't keep them straight in my head and its infuriating. google has failed me.

    Can someone as methodically as possible explain this to me?

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

    Issue understanding Generics in Typescript

    Posted: 11 Feb 2020 10:16 PM PST

    I'm trying to understand generics in typescript using the example here, but am having issues: https://pastebin.com/Pekq7RC6

    The generic gets created like this: const miniMaxSum = <arrType>( ) but when I try to assign it to my variables and parameters inside the function, i get TS errors.

    let maxSum : arrType = 0; // Error -> '0' is assignable to the constraint of type 'arrType', but 'arrType' could be instantiated with a different subtype of constraint 'number'. let minSum : arrType = 0;

    maxSum = maxSum + item; // Type 'number' is not assignable to type 'arrType'. 'number' is assignable to the constraint of type 'arrType', but 'arrType' could be instantiated with a different subtype of constraint 'number'. There is also a similar error why trying to add integers to the maxSum and minSum variables. I cant seem to understand why its happening,

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

    Which language to use when programming pcb?

    Posted: 11 Feb 2020 10:04 PM PST

    I am currently researching microcontrollers/programmable circuit boards to see which one can best meet the needs of my project but I am still trying to figure out all the details.

    That being said, since there are so many different microcontrollers out there on the market, is there a specific programming language that is ideal for many of them or does it vary?

    I've heard C is the best language to go with but I could use some advice.

    submitted by /u/1539CalvertSt
    [link] [comments]

    I was given this sticker and I absolutely cannot figure out what it is...

    Posted: 11 Feb 2020 09:41 PM PST

    At first glance, I thought it was React. But the logo isn't quite right. But I'm stumped... It's also possible that it's just a random image.

    http://imgur.com/a/yFU3r7z

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

    Need advice with creating a battery monitoring service

    Posted: 11 Feb 2020 09:21 PM PST

    I want to make a battery monitoring service (systemd) that sends notifications when the battery level goes below some thresholds.

    I was planning on running it every 1 minute (it's actually going to be a .timer).

    To avoid notification spam I wanted to define a delay between notifications, here's the question:

    What is the optimal solution to save the time at which the last notification was fired? I tried saving it to a /tmp/ file, but it is kinda slow: while testing it I could fire multiple notifications in a row before the script saves / reads the timings again (and I am not spamming, about 1 script launch / second).

    It is good enough for my use case but it is surprinsingly slow, which makes me think I am doing expensive stuff when it's supposed to be dead simple.

    ```

    !/bin/bash

    Battery thresholds beyond which notifications will be sent.

    LOW_BATTERY_PERCENT_THRESHOLD=20

    LOW_BATTERY_PERCENT_THRESHOLD=200 # for testing purposes. CRITICAL_BATTERY_PERCENT_THRESHOLD=10 # 10%

    Interval between notifications: the service will check every minute but we don't want to

    be spammed do we?

    NOTIFICATION_INTERVAL=300 # 300 seconds = 5 minutes.

    NOTIFICATION_INTERVAL=60 # 1 min for testing purposes CRITICAL_NOTIFICATION_INTERVAL=120 # 120 seconds = 2 minutes.

    Path to the temporary file where the dates of the last notifications are saved.

    path_tmp_battery_monitor_data='/tmp/battery_monitor_data'

    Default values.

    last_notification_time=0000000000 last_critical_notification_time=0000000000

    function retrieve_last_notification_times() { if [[ -r $path_tmp_battery_monitor_data ]]; then last_notification_time=$(head -1 $path_tmp_battery_monitor_data) last_critical_notification_time=$(tail -1 $path_tmp_battery_monitor_data) fi }

    function is_discharging_battery() { path_ac_online='/sys/class/power_supply/AC/online'

    # If the file is readable and it contains 0 (discharging); [ -r "$path_ac_online" ] && [ $(head -1 "$path_ac_online") -eq 0 ] }

    WIP, to eventually shorten the if statements

    function should_notify_battery_level() { battery_percent=$1 [[ "$battery_percent" -lt "$CRITICAL_BATTERY_PERCENT_THRESHOLD" && "$now" -gt "$next_allowed_critical_notification_time" ]] }

    If the battery is discharging, check levels and send notifications if needed.

    if is_discharging_battery; then retrieve_last_notification_times

    battery_percent=$(cat /sys/class/power_supply/BAT?/capacity)

    next_allowed_critical_notification_time=$((last_critical_notification_time + CRITICAL_NOTIFICATION_INTERVAL)) next_allowed_notification_time=$((last_notification_time + NOTIFICATION_INTERVAL))

    now=$(date +"%s") # Elapsed time in seconds since 1970-01-01 00:00:00 UTC. # echo "a $next_allowed_critical_notification_time" echo "next notif time $next_allowed_notification_time" echo "now $now"

    if [[ "$battery_percent" -lt "$CRITICAL_BATTERY_PERCENT_THRESHOLD" && "$now" -gt "$next_allowed_critical_notification_time" ]]; then last_critical_notification_time=$now notify-send --urgency=critical "Critical battery level! ($battery_percent%)"; elif [[ "$battery_percent" -lt "$LOW_BATTERY_PERCENT_THRESHOLD" && "$now" -gt "$next_allowed_notification_time" ]]; then last_notification_time=$now notify-send "Low battery level. ($battery_percent%)"; fi

    # Save the time at which the last notifications were sent. echo "$last_critical_notification_time" > $path_tmp_battery_monitor_data echo "$last_notification_time" >> $path_tmp_battery_monitor_data fi

    exit 0

    ```

    Is setting environment variables faster / a wise thing to do for example? Is there some other kind of Key-Value registry somewhere? In the end I'm just writing / reading 2 10-digits numbers, it should be fater than that.

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

    Games on steam

    Posted: 11 Feb 2020 09:03 PM PST

    What coding languages do I need to create a game on steam?

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

    Help please!

    Posted: 11 Feb 2020 04:49 PM PST

    I (27 M) really want to learn to code! I am a teacher who is looking for a career change but don't know exactly where to start. Is there an app out there that would help teach me how to code phone apps? I have apps like grasshopper and M1M0, but that's it.

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

    New student to Algorithm Design and Implementation

    Posted: 11 Feb 2020 03:08 PM PST

    Im in community college doing an Algorithm Design and Implementation class! I have been issues in class, i had one coding and design class in high school, i enjoyed it but i also didn't pay to much attention in it and i regret it now! Lol. You could call me a novice when it comes to coding but i have always loved computers as well as the thought being cyber security so this is something i need to know. I am using Visual Studios 2019 because it was free with my college course. Don't know if its the best but its what i have to use.

    But now i need more help than i would ever think when it came to a subject! We are only working with C and C++. I never worked with this in high school so its a completely different ball game from ANYTHING I did in the past. Im not doing my best in class and i would like any tips or tools to help. We have already done a couple of beginner assignments if you think it would help to look at them lmk and ill post the code for them. They were Hello, World and displaying a year on the screen.

    Right now my professor has me doing a candy sale program to help me better understand how to read, write and understand the coding concept and to make sure i have everything under control and learning at my pace! Although when it comes to doing calculations and using the quadratic formula in my coding is when its getting confusing now! My professor has hundreds of students he helps and cant ALWAYS rely on him to help.

    I have to do some input_data for my candy sale and he just wants me to do input(7) and output(8) in my code and i don't really have much a clue how im supposed to go it.

    What should i do help make it easier to understand or make it easier to put in Visual Studios.

    If this post feels like it all over the place its because i wrote it during class and kept going back to write in what i felt like i had difficulties with!

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

    Learn to write clean (Python) code

    Posted: 11 Feb 2020 11:13 AM PST

    I have some coworkers who need to learn to write clean code (which is acknowledged by them and higher ups). Right now things are messy, making it easier for bugs to hide, and harder for people touching their code to understand. Style guides, code reviews, and unit tests are all something we are going to try and use more, but my manager really wants to have them take a course on clean coding.

    I tried to convince him just to have them read the Clean Code Handbook by Martin, since that is what I did, but he insists that a course would be better. Does anyone know of such a course?

    A Google search gives mostly C# courses, which I think might just confuse the issue... The two courses that do pop up for Python seem like decent options, but maybe there are better ones.

    https://www.coursera.org/learn/program-code

    https://www.udemy.com/course/python-clean-coding/

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

    Does anybody remember a text-substitution scripting software incorporating randomness?

    Posted: 11 Feb 2020 06:01 PM PST

    Asking programmers because I'm looking for something that was like a scripting language and I can't find it. A while back there was a scripting software package that let you type something like:

    I'd {like|like to take a moment|really like} to show you {our project|this project} 

    And this script would be compiled into text, randomly choosing and inserting one of the bracketed values. I believe there were a bunch of other options, but this is the one in which I'm interested.

    I'm working on a project that would really benefit from this kind of thing, and while I don't mind creating it myself if I really need to, I'm hoping someone remembers what I'm referencing, or can point me toward a script-driven software package that provides similar features.

    Thanks!

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

    A question about processing Facebook message data for a visualization (C#)

    Posted: 11 Feb 2020 05:52 PM PST

    Is there's some resource that has all the possible types of things that can be sent in a Facebook message?

    Visual studio has this feature where it can take a JSON file that's copied to your clipboard and turn it into a class that can then be used to deserialize the JSON file into an object.

    I've downloaded my Facebook message data as a JSON file. I've already figured out how to process it. For example, count how many messages were sent and by whom in a particular conversation. But when I switched to another conversation, they had sent different types of media (photos, stickers) that my first conversation didn't have. The JSON class visual studio created didn't have those and I had to rework my program a bit to include them.

    So again, is there way of knowing what all a JSON message file can have? I've tired looking on Facebook's developer website but it's difficult

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

    The for loop I made to check for palindromes of an inputted number only prints what is outside the for loop, and nothing else.

    Posted: 11 Feb 2020 05:28 PM PST

    The code is supposed to take an inputted number, an inputted divisor, then go from 1 to the first number, and see which numbers in that range are both palindromes, and divisible by the divisor, and print them in a spaced list, but it won't output anything, even though i'm pretty sure this is how you do it:

    // Prints "The palindromes are: " and uses loops to find each palindrome from 1

    // to the first input number, and checks if its divisible by the second input

    // number, and if it is, then it is printed in a spaced list.

    System.out.println("The palindromes are: ");

    for (int i = 1; i <= num1; i++) {

    int n = i; while (n != 0 && n<= num1) { remainder = n % 10; reversedInt = (reversedInt \* 10) + remainder; n /= 10; if (n == reversedInt && n % divisor == 0) { System.out.print(n + " "); } 

    } 

    }

    Edit: It is in Java

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

    How do you make small talk/joke about programming with others?

    Posted: 11 Feb 2020 01:28 PM PST

    I'm the only data programmer in my office but generally in my career a superior or someone adjacent to me will occasionally say that what I'm doing is beyond their field of knowledge or mentions that my screen looks incomprehensible. "Wow, look at all that text!" Etc.

    I don't immediately have something to say in response to that, and I could explain what I'm doing but that doesn't feel entirely entertaining, or like a full response. How do I politely engage/ banter with this kind of small talk?

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

    Best resolution for Netbeans IDE

    Posted: 11 Feb 2020 03:41 PM PST

    My native res is too high is there any specific dimensions that work well?

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

    Emerging technology in CS

    Posted: 11 Feb 2020 02:48 PM PST

    So in IT there are a lot of technologies that have and are transforming how businesses do IT (cloud, SaaS, etc.). I was wondering, what sorts of technologies have emerged/are emerging on the CS/programming side that are impacting the way businesses/programmers do their work?

    Things from (a) technologies/programs/systems that businesses should already have implemented, (b) technologies that are in the process of becoming widely implemented, and (c) cutting edge tech that has the potential to change the programming industry but hasn't taken off yet for the most part.

    I'd love to hear about these and their impact on you

    Edit: right now I'm thinking of things like FaaS/Serverless, gui-based website builders, AI, new programming languages/paradigms, etc. Are machines going to be the ones writing computer programs in the future? etc.

    Thanks!

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

    Help: trigger a lambda function from DataPipeline

    Posted: 11 Feb 2020 01:54 PM PST

    Making simple Bat file prompting for password more user friendly

    Posted: 11 Feb 2020 03:11 AM PST

    Hi everyone. I hope it is okay that i post this question here.

    I have this simple bat file, that works the way i want it to. For a few selected users who need to open up a network share in explorer which is on another server. The share contains highly sensitive personal data of a lot of residents in the city. Therefore it was not allowed that the Network drive got mapped to a letter and opened automatically. Instead. Every time they run the script they should be prompted for the password set on the local user on the server where the share resides.

    net use \\SERVER\SHARE$ /user:DOMAIN\USERNAME start \\SERVER\SHARE$ 

    This script works as intended. But, my question is this:

    Is there a way to "hide" the cmd.exe popup, and make the way they type in the password "prettier"? This script just opens up cmd, and when you type in the password you can't see signs being added. I would like to make it more "user friendly" for the people who need to use it.

    Maybe one of you know of some tools to help me achieve this, that i can look into? Im very much for learning something new, but i have no idea what to really search for. Thanks so much in advance!

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

    How do you remember languages you haven't used in a while?

    Posted: 11 Feb 2020 09:18 AM PST

    I learned Java about two years ago and I was using it for everything, so I think it's safe to say I was getting very good at it. Last year, however, I started using Python because it was better suited for my needs. I've been using Python for the past year and again, I started getting very good at it and familiar with it's abundant libraries.

    Recently, I came across a project which I wanted to use Java for, for performance reasons as well as other things, but I found that I literally could not write Java code from scratch anymore! This had me a little concerned because I know how long it took me to learn the language the first time around, and I really don't want to spend the same amount of time on something I thought I had already mastered. An important distinction however is that I obviously remember the underlying paradigms and concepts of the language, I guess what I've forgotten is the syntax, semantics, and idioms. But there is a lot of that.

    So my question is, how do you either remember languages after a long period non-use, or how do you refresh your memory when you want to start using the language again? Since I've realized that I forget languages, I've started taking detailed notes on new languages that I am learning (Kotlin, JS, etc.), but the process is so tedious that it makes me unmotivated to learn anything new. Also, since these languages are so extensive, my notes redundantly end up looking like a mildly condensed version of the documentation itself. I even considered buying reference books, but I don't know how deep they get into the language.

    For reference I'm a university student which is why I have a little flexibility in the languages I use regularly. This is very frustrating for me because I love learning new languages (programming, that is), but this problem has stolen that interest from me. Any kind of advice from people that have experienced something similar would be extremely helpful, especially if you've found a solution to this problem yourself.

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

    Do any of you use any Object Relational models (such as UDT, inheritance, etc) in either your Oracle or PostgreSQL databases? If so, then what is the use case and why was it designed in that way?

    Posted: 11 Feb 2020 08:46 AM PST

    I have come to a complete blank when investigating object relational databases for my dissertation and Oracle's block on publishing benchmarks etc has made writing about it very difficult.

    The aparant low use of OR models has also hindered progress so any information you have is greatly appreciated.

    I am aware of PostGIS and Oracle Spatial but surely there are other examples.

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

    How best to prevent repetitive notifications

    Posted: 11 Feb 2020 12:23 PM PST

    I'm from a Linux background so can often get away with automating tasks or making basic prototypes in bash. I've made something that checks various services for a string, and if it detects it notifies me via a slack webhook.

    I loop through an array of strings, which works but when it successfully detects the string it keeps notifying until I manually disable due to it running via crontab which isn't ideal so have a few queries:

    • What's the de facto way to do this sort of repetitive check, but only notify once/once every few hours rather than every few minutes?

    • At what point is it worth me moving something like this to a more 'web/scrapey' type language or framework? I use bash because it's what/all I know and can usually get data from one source and push it to another through a mixture of curl/awk/grep type commands, but once I'm starting to require oauth/twitter and a few other integrations beyond a static webhook I'm wondering at what point it becomes beneficial/quicker etc to start learning python for example.

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

    [JS] If I query an array deep inside an object multiple times in a loop, would it be beneficial to store the path in a separate variable?

    Posted: 11 Feb 2020 04:01 AM PST

    Hello!

    I don't know, but I somehow suspect that:

    var path = my_object.potato.banana["squirrel"][2].spaceship; for (i=0; i<100; i++) { if (path[i]) {alert("yes");} } 

    is better than:

    for (i=0; i<100; i++) { if (my_object.potato.banana["squirrel"][2].spaceship[i]) {alert("yes");} } 

    1 Is the first better than the second?


    Also, regarding such long paths (or whatever they are called), is it beneficial to contain them in a readable variable (even though they themselves might be quite readable, but long)? Like this:

    var path = my_object.potato.banana["squirrel"][2].spaceship; var spaceship_length = path.length; for (i=0; i<spaceship_length; i++) { if (!path[i]) {return i;} } return spaceship_length; 

    instead of:

    var path = my_object.potato.banana["squirrel"][2].spaceship; var spaceship_length = path.length; for (i=0; i<my_object.potato.banana["squirrel"][2].spaceship.length; i++) { if (!my_object.potato.banana["squirrel"][2].spaceship[i]) {return i;} } return my_object.potato.banana["squirrel"][2].spaceship.length; 

    Well, I guess I answered it myself, regarding readability, but,

    2 does it do anything performance-wise? Worse? Better?


    And finally, and maybe the most importantly:

    3 How do I name a temporary variable that holds the main path to a distant part of an object?

    Naming it "path" is too generic, and doesn't reveal anything. Naming it something descriptive is hard, and doesn't reveal that it is shorthand for the long path. And suffixing "_path" to it seems kinda long.

    Tnx!

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

    Any tutorials/documentation on building an app with Angular and .Net Core and use Firebase Authentication?

    Posted: 11 Feb 2020 07:35 AM PST

    I've searched google and youtube but couldn't get anything that wasn't AngularFire and serverless.

    I want to know how to integrate Firebase Authentication into my application.

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

    No comments:

    Post a Comment