• Breaking News

    Thursday, May 6, 2021

    Permutations of neighboring elements Ask Programming

    Permutations of neighboring elements Ask Programming


    Permutations of neighboring elements

    Posted: 06 May 2021 11:05 AM PDT

    I have a quite specific problem. I want to combine every element of an array (string in this case) with neighboring elements to a new array of minimum length 2. Im not sure if Im explaining that correctly so here's an example:

    Given the array:

    $array = ['a', 'b', 'c', 'd']; 

    I want to create a new array that looks like this:

    [ ['ab', 'c', 'd'], ['ab', 'cd'], ['abc', 'd'], ['a', 'bc', 'd'], ['a', 'bcd'], ['a', 'b', 'cd'] ] 

    Not necessarily in that order. ['abcd'] is not returned since it is only of length 1. It dosent really matter if ['a', 'b', 'c', 'd'] is returned or not, but I rather it didn't.

    I feel recursion could be useful here, but I can't figure it out.

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

    Professional code in GitHub?

    Posted: 06 May 2021 05:28 PM PDT

    Guys, do you usually put professional codes on GitHub? As if it were open source? I have this doubt hammering here because I know that these codes can serve as a portfolio, but I don't know if it is a good idea to leave the code that I am selling on display, even with a license, you know?

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

    Git Help; how to ignore 'notes' files

    Posted: 06 May 2021 02:17 AM PDT

    Essentially I've got some files that belong to the project, but must not be tracked. I would normally add it to the gitignore, but I don't want to push that as a commit. I am lazy so I want do git add . but that would include either my gitignore or this note file.

    Is there any way around this, through git?

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

    Trying to recreate a pixel perfect representation of an image from JS code?

    Posted: 06 May 2021 04:51 PM PDT

    Hi so I'm trying to get a pixel perfect skin from this tetris site, https://blockwars.miniblip.com/ Whenever I screenshot the blocks though, it's always pixelated and the edges aren't precise. And it looks like the blocks are drawn from code, instead of using a png image. Any way to construct the blocks using the information from the code to get a pixel perfect representation? This is the code https://blockwars.miniblip.com/js/blockwar.min.js

    I tried to do it myself, using 12x12px for each color block, to get this skin. https://i.imgur.com/7fmpqwH.png (I used nearest neighbor x4 so that's why it's 48x48. But 12x12 was just my guess. Is each block actually supposed to be 24x22? Since it's a little bit wider than it is tall, and i found this piece of code that I surmise might be talking about its dimensions: this.ctx.scale(24,22). I know I got the colors right because I can see the hex codes match up in the code, but not sure about the dimensions, and also not sure about the exact location and lengths of the little white strips on the top left of each block. Can someone help me to recreate a block from the code? I have no experience in programming.

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

    Editing a site powered by weebly?

    Posted: 06 May 2021 09:33 AM PDT

    A company I'm working for wants me to add some stuff to their website that was originally created through weebly.

    Would I need to rebuild the site from scratch if I wanted to customize it using VS code? I don't know if weebly allows access to the css and js files.

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

    Discord: how programmatically see if there’s a new post in a channel?

    Posted: 06 May 2021 12:49 PM PDT

    I have a task I'd like to automate involving Discord. In the most general sense, whenever a specific channel on a discord server has a new message (not on a server I run, but a foreign one), I want to be able to "see" that message in order to (potentially) programmatically respond to it. Is this possible? Something like IFTTT does not seem helpful as it appears to only trigger automated stuff based on activity outside of discord, not within it.

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

    Best EEG headset compatible with Python/respective library?

    Posted: 06 May 2021 12:49 PM PDT

    Hi! I am trying to begin development of a device that utilizes EEG readings. I was wondering if anyone knew of a headset & library that I could use?

    Thank you for your time.

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

    I have a truth table that contains the values Sometimes, Always, Never for Ands and Ors. How do I implement this?

    Posted: 06 May 2021 05:17 AM PDT

    Boolean logic doesn't seem to work due to 'Sometimes', but I have the logic to implement in the form of a 12 line truth table.

    I have the data in conjunctive normal form, so as long as I solve parenthesis first, things seem pretty straight forward.

    However the actual evaluation is hanging me up. Something like (A or B or C or D) is easy with boolean logic, but with 'sometimes', I need to write my own way of handling this.

    I was considering using IFs to apply replace on a string or using a dictionary to replace a string.

    These seem a bit manual, and requires an additional scenario for parenthesis. Any ideas/links?

    (Python, Pandas, Sympy)

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

    list and tuple exercise left me clueless

    Posted: 06 May 2021 10:17 AM PDT

    My python teacher barely gives us any example of how to write a code that does something like this but I hope you guys can help. The task is a basically coding a program that would be used to order something at a fast food restaurant. As you can see, this code won't run, but if we get rid of the last 3 lines, it would run but do nothing other than take in values. The code must 1. exit if I input 0, 2. If I give a valid input, the code will automatically tell me at the end what I ordered and how much I need to pay.

    So if I input 3 and 2, the code will exit after telling me "order list: triple pack, 2 total price: $16"

    I know the solution is to make it so that placeholder gets translated to the price (ie if I enter 1, then 1 gets translated into 6 for "totalprice = //price of the item// * item_qnty" and it gets translated to the name of the item at "print('order list: ', //the name of the item//, item_qnty)".) The teacher literally didn't tell us how to do any of this and only taught us basic list and tuple function that barely helps.

    I've tried to do something like

    itemtranslate = ['all in one pack', 'couple pack', 'triple pack'] 'all in one pack', 'couple pack', 'triple pack' = test print(1, 2, 3) 

    to somehow try to translate the number to the name so that it shows up properly at where //the name of the item// is written. Of course, the teacher didn't tell us how to work with values that have spaces in them while making a list and this doesn't work at all.

    This is the code in question. Those 2 pieces of code are suppose to be in the same cell but it's an absolute clusterfrik so I decided to separate them. I'm sorry for sounding mad. I'm very irritated at the moment as I've been at this task for 7 hours.

    print('Order options\n 0: exit menu\n 1: all in one pack, prince $6\n 2: couple pack, price $7\n 3: triple pack, price $8\n 4: family pack, price $10') item_num = input("please pick a product number ") itemnum = int(item_num) print('selected product name', item_num) item_qnty = input("how many would you like ") itemqnty = int(item_qnty) print('selected quantity', item_qnty) totalprice = //price of the item// * item_qnty print('order list: ', //the name of the item//, item_qnty) print('total price:', totalprice) 
    submitted by /u/johnmoney69
    [link] [comments]

    Basic workflow for user registration app?

    Posted: 06 May 2021 09:44 AM PDT

    Im new to app development and am doing a very basic project where I implement an app which allows users to sign up and message each other.

    What I have decided on right now:

    Frontend: Flutter

    Backend: Python

    Protocol: gRPC

    Database: postgreSQL

    I've been looking at examples of grpc bidirectional streams with python, and using pstgreSQL with python (psycopg2?). Just wanted to get feedback on what I have right now and what I believe is the server process:

    the server script handles both the grpc stuff and the database stuff? Not entirely sure how the signing up would work atm.

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

    Is programming worth pursuing?

    Posted: 06 May 2021 09:39 AM PDT

    The title stands for itself. Is it really worth pursuing? Wherever u see, there r children who can whip up advanced softwares with the help of their laptops. Programming can be taught to virtually anyone and it does not require you to have a degree. Also, this side of the job sector is quickly becoming very saturated. So it possible to find a job? And if so, is the job secure?

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

    Generate all the possible permutations of the first N numbers in Assembly Inline with Visual Studio

    Posted: 06 May 2021 09:22 AM PDT

    I am new to Assembly Inline in C.

    I have to solve the following problem with the inline assembler of Visual Studio:

    • Input: a DWORD (the number N, N≤ 6)
    • Output: a vector of DWORD (all permutations, see description in the code), a DWORD (the number of permutations)

    /*Description: Generate all permutations of the first N natural numbers. The permutations generated must be inserted within a single array of integers. For example, if N = 3, the array must contain: {1,2,3,1,3,2,2,1,3,2,3,1,3,1,2,3,2,1}.*/ #include <stdio.h> void main() { // Variables int N=4; // number of integers (try with values ​​<= 6) int Perm[4326]; // array permutations: size is sufficient for N <= 6 int Num; // At the end it must contain the number of permutations generated // asm block __asm { XOR EAX, EAX //N MOV ECX, 1 //Counter MOV EDX, 1 //Value of integers <= N MOV EAX, N L1: MOV Perm[ECX*4-4], EDX INC EDX INC ECX CMP EDX, EAX JLE L1 } // Print on video { int i,j,k; printf("Permutations of the first %d natural numbers\n",N); for (i=k=0;i<Num;i++) { for (j=0;j<N;j++) { printf("%3d",Perm[k++]); } printf("\n"); } } } 

    I tried to solve this problem but I can't find a solution.

    Can anyone help me?

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

    If I want to produce an open source program to do a specific task, using other open source libraries, what would be the proper way?

    Posted: 06 May 2021 09:06 AM PDT

    For example if I wanted to include use of the PRAW library.

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

    SQLSever & Python , Need Help exporting csv's

    Posted: 06 May 2021 12:38 AM PDT

    Hey guys hope yall are safe and doing well ,

    So the thing i need help with is that i have a database and it contains a lot of tables , what i am trying to do is export each one of them onto a separate csv file in my local directory using SQLAlchemy

    The table format goes something like 'Databasename.dbo.Tablename'

    what i am doing rn :- con = engine.connect(credentials)

    #getting all the table names in a list

    rows = con.execute('select table_name from information_schema.tables')

    tables = [print(row) for row in rows]

    for t in tables:

    dataframe = pd.read_sql('select * from Databasename.dbo.'+t'where cast(modify_timestamp as date) = (select max(cast (modify_timestamp as date)), con = con)

    dataframe.to_csv(t '.+csv')

    but this isn't working, any and all help would be highly appreciated.

    Have a safe one <3

    submitted by /u/15deaths
    [link] [comments]

    Explain like I'm 5, what is a web service, SOA and ROA ?

    Posted: 06 May 2021 07:44 AM PDT

    [HELP] Script not working when called by cron

    Posted: 06 May 2021 07:05 AM PDT

    Hi, I have a script which works perfectly fine when running manually:

    #!/bin/bash speedtest-cli --csv --csv-delimiter ";" >> /home/pi/Documents/speedtest-cli/speedtest-cli_cron.csv 

    and want to call it every 15mins wirh cron. I set up many other scripts like that with cron but this one doesn't work:

    #speedtest-cli 0,15,30,45 * * * * /home/pi/Scripts/cron/speedtest-cli_cron.sh 

    Do you have an idea why?

    edit:

    rsyslog output:

    May 6 16:29:01 RaspberryPi4B CRON[10666]: (pi) CMD (/home/pi/Scripts/cron/speedtest-cli_cron.sh) May 6 16:29:01 RaspberryPi4B CRON[10665]: (CRON) info (No MTA installed, discarding output) 

    submitted by /u/3Domse3
    [link] [comments]

    C program

    Posted: 06 May 2021 03:29 PM PDT

    I need to get some strings like B001,B002……how to write the code?plz help

    submitted by /u/Accomplished-Copy-41
    [link] [comments]

    What program/language should I learn to make games?

    Posted: 06 May 2021 06:15 AM PDT

    I want to make a crafting/survival/farming game akin to Minecraft or Stardew Valley. I have some experience with Python but don't know where to start on something like this.

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

    My friend claims this Python script as a bot which can fill Google Forms

    Posted: 06 May 2021 01:22 AM PDT

    /** * A special function that inserts a custom menu when the spreadsheet opens. */ function onOpen() { var menu = [{name: 'Set up conference', functionName: 'setUpConference_'}]; SpreadsheetApp.getActive().addMenu('Conference', menu); } /** * A set-up function that uses the conference data in the spreadsheet to create * Google Calendar events, a Google Form, and a trigger that allows the script * to react to form responses. */ function setUpConference_() { if (ScriptProperties.getProperty('calId')) { Browser.msgBox('Your conference is already set up. Look in Google Drive!'); } var ss = SpreadsheetApp.getActive(); var sheet = ss.getSheetByName('Conference Setup'); var range = sheet.getDataRange(); var values = range.getValues(); setUpCalendar_(values, range); setUpForm_(ss, values); ScriptApp.newTrigger('onFormSubmit').forSpreadsheet(ss).onFormSubmit() .create(); ss.removeMenu('Conference'); } /** * Creates a Google Calendar with events for each conference session in the * spreadsheet, then writes the event IDs to the spreadsheet for future use. * @param {Array<string[]>} values Cell values for the spreadsheet range. * @param {Range} range A spreadsheet range that contains conference data. */ function setUpCalendar_(values, range) { var cal = CalendarApp.createCalendar('Conference Calendar'); for (var i = 1; i < values.length; i++) { var session = values[i]; var title = session[0]; var start = joinDateAndTime_(session[1], session[2]); var end = joinDateAndTime_(session[1], session[3]); var options = {location: session[4], sendInvites: true}; var event = cal.createEvent(title, start, end, options) .setGuestsCanSeeGuests(false); session[5] = event.getId(); } range.setValues(values); // Store the ID for the Calendar, which is needed to retrieve events by ID. ScriptProperties.setProperty('calId', cal.getId()); } /** * Creates a single Date object from separate date and time cells. * * @param {Date} date A Date object from which to extract the date. * @param {Date} time A Date object from which to extract the time. * @return {Date} A Date object representing the combined date and time. */ function joinDateAndTime_(date, time) { date = new Date(date); date.setHours(time.getHours()); date.setMinutes(time.getMinutes()); return date; } /** * Creates a Google Form that allows respondents to select which conference * sessions they would like to attend, grouped by date and start time. * * @param {Spreadsheet} ss The spreadsheet that contains the conference data. * @param {Array<String[]>} values Cell values for the spreadsheet range. */ function setUpForm_(ss, values) { // Group the sessions by date and time so that they can be passed to the form. var schedule = {}; for (var i = 1; i < values.length; i++) { var session = values[i]; var day = session[1].toLocaleDateString(); var time = session[2].toLocaleTimeString(); if (!schedule[day]) { schedule[day] = {}; } if (!schedule[day][time]) { schedule[day][time] = []; } schedule[day][time].push(session[0]); } // Create the form and add a multiple-choice question for each timeslot. var form = FormApp.create('Conference Form'); form.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId()); form.addTextItem().setTitle('Name').setRequired(true); form.addTextItem().setTitle('Email').setRequired(true); for (var day in schedule) { var header = form.addSectionHeaderItem().setTitle('Sessions for ' + day); for (var time in schedule[day]) { var item = form.addMultipleChoiceItem().setTitle(time + ' ' + day) .setChoiceValues(schedule[day][time]); } } } /** * A trigger-driven function that sends out calendar invitations and a * personalized Google Docs itinerary after a user responds to the form. * * @param {Object} e The event parameter for form submission to a spreadsheet; * see https://developers.google.com/apps-script/understanding_events */ function onFormSubmit(e) { var user = {name: e.namedValues['Name'][0], email: e.namedValues['Email'][0]}; // Grab the session data again so that we can match it to the user's choices. var response = []; var values = SpreadsheetApp.getActive().getSheetByName('Conference Setup') .getDataRange().getValues(); for (var i = 1; i < values.length; i++) { var session = values[i]; var title = session[0]; var day = session[1].toLocaleDateString(); var time = session[2].toLocaleTimeString(); var timeslot = time + ' ' + day; // For every selection in the response, find the matching timeslot and title // in the spreadsheet and add the session data to the response array. if (e.namedValues[timeslot] && e.namedValues[timeslot] == title) { response.push(session); } } sendInvites_(user, response); sendDoc_(user, response); } /** * Add the user as a guest for every session he or she selected. * @param {object} user An object that contains the user's name and email. * @param {Array<String[]>} response An array of data for the user's session choices. */ function sendInvites_(user, response) { var id = ScriptProperties.getProperty('calId'); var cal = CalendarApp.getCalendarById(id); for (var i = 0; i < response.length; i++) { cal.getEventSeriesById(response[i][5]).addGuest(user.email); } } /** * Create and share a personalized Google Doc that shows the user's itinerary. * @param {object} user An object that contains the user's name and email. * @param {Array<string[]>} response An array of data for the user's session choices. */ function sendDoc_(user, response) { var doc = DocumentApp.create('Conference Itinerary for ' + user.name) .addEditor(user.email); var body = doc.getBody(); var table = [['Session', 'Date', 'Time', 'Location']]; for (var i = 0; i < response.length; i++) { table.push([response[i][0], response[i][1].toLocaleDateString(), response[i][2].toLocaleTimeString(), response[i][4]]); } body.insertParagraph(0, doc.getName()) .setHeading(DocumentApp.ParagraphHeading.HEADING1); table = body.appendTable(table); table.getRow(0).editAsText().setBold(true); doc.saveAndClose(); // Email a link to the Doc as well as a PDF copy. MailApp.sendEmail({ to: user.email, subject: doc.getName(), body: 'Thanks for registering! Here\'s your itinerary: ' + doc.getUrl(), attachments: doc.getAs(MimeType.PDF) }); } 

    Title

    So basically my friend calls this a 'bot' that can fill his google form and as a 'proof' he told me that among the class his form is filled first. So the question is, is this above piece of code coded in phyton really a bot? Pls take a quick glance

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

    Expanding storage Ubuntu VM truenas

    Posted: 06 May 2021 12:28 AM PDT

    hi all,

    have a vm in truenas running ubuntu server with the docker containers.
    I enlarged its size from 25gib to 100gib in the truenas gui but it doesnt appear in sonarr/radarr gui as bigger. This is for the storage of the config of apps and the os itself.

    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 55.5M 1 loop /snap/core18/1997 loop1 7:1 0 55.4M 1 loop /snap/core18/1944 loop2 7:2 0 32.3M 1 loop /snap/snapd/11588 loop3 7:3 0 70.4M 1 loop /snap/lxd/19647 loop4 7:4 0 69.9M 1 loop /snap/lxd/19188 loop5 7:5 0 31.1M 1 loop /snap/snapd/10707 sda 8:0 0 100G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 48.5G 0 part └─ubuntu--vg-ubuntu--lv 253:0 0 24.3G 0 lvm / 
    submitted by /u/zierbeek
    [link] [comments]

    No comments:

    Post a Comment