• Breaking News

    Sunday, October 21, 2018

    read from a doc file with python or javascript Ask Programming

    read from a doc file with python or javascript Ask Programming


    read from a doc file with python or javascript

    Posted: 21 Oct 2018 04:07 PM PDT

    Hello, i need to pass all the data from a doc file to an html file but i need that every bold gets inside a h3 tag, every paragraph inside a p and every list inside ul li

    i thought of making a script with python or javascript but i need a library that has an option to tell me if the line i'm reading is bold or italic or something else...

    Is there something like that? what are other options? word let's me select all the data with the same style (ex, all bolds) but i don't know how to append data to it

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

    Is there any reason why complexity theory has a bunch of stuff in all caps?

    Posted: 21 Oct 2018 09:42 PM PDT

    lel shitpost but I'm actually a bit curious about this.

    I'm sure other people have wondered the same thing at some point.

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

    CS50: Music

    Posted: 21 Oct 2018 02:48 PM PDT

    I'm auditing the cs50 course on EdX by Harvard and am currently working on pset 3 (Music). I'm trying to implement helpers.c, but am having difficulty troubleshooting errors that come up when i do check50. My program calculates the frequency of the notes incorrectly. Here is a description of the assignment: https://docs.cs50.net/2018/x/psets/3/music/music.html

    Here is the code I've wrote in my helpers.c file:

    // Helper functions for music

    #include <cs50.h>

    #include <stdlib.h>

    #include <stdio.h>

    #include <string.h>

    #include <math.h>

    #include "helpers.h"

    // Converts a fraction formatted as X/Y to eighths

    int duration(string fraction)

    {

    // Parse line into note and duration

    string eighths1 = strtok(fraction, "/");

    string eighths2 = strtok(NULL, "/");

    int eighths3;

    int eighths4;

    eighths3 = atoi(eighths1);

    eighths4 = atoi(eighths2);

    if (eighths4 == 2)

    {

    return eighths3 * 4;

    }

    else if (eighths4 == 4)

    {

    return eighths3 * 2;

    }

    else

    {

    return eighths3;

    }

    }

    // Calculates frequency (in Hz) of a note

    int frequency(string note)

    {

    int f;

    double freq;

    char str[88][4] = {"C8", "B7", "A#7", "A7", "G#7", "G7", "F#7", "F7", "E7", "D#7", "D7", "C#7", "C7", "B6", "A#6", "A6", "G#6", "G6", "F#6", "F6", "E6", "D#6", "D6", "C#6", "C6", "B5", "A#5", "A5", "G#5", "G5", "F#5", "F5", "E5", "D#5", "D5", "C#5", "C5", "B4", "A#4", "A4", "G#4", "G4", "F#4", "F4", "E4", "D#4", "D4", "C#4", "C4", "B3", "A#3", "A3", "G#3", "G3", "F#3", "F3", "E3", "D#3", "D3", "C#3", "C3", "B2", "A#2", "A2", "G#2", "G2", "F#2", "F2", "E2", "D#2", "D2", "C#2", "C2", "B1", "A#1", "A1", "G#1", "G1", "F#1", "F1", "E1", "D#1", "D1", "C#1", "C1", "B0", "A#0", "A0"};

    long str3[88] = {39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48};

    char str1[36][4] = {

    "Bb7",

    "Ab7",

    "Gb7",

    "Eb7",

    "Db7",

    "Bb6",

    "Ab6",

    "Gb6",

    "Eb6",

    "Db6",

    "Bb5",

    "Ab5",

    "Gb5",

    "Eb5",

    "Db5",

    "Bb4",

    "Ab4",

    "Gb4",

    "Eb4",

    "Db4",

    "Bb3",

    "Ab3",

    "Gb3",

    "Eb3",

    "Db3",

    "Bb2",

    "Ab2",

    "Gb2",

    "Eb2",

    "Db2",

    "Bb1",

    "Ab1",

    "Gb1",

    "Eb1",

    "Db1",

    "Bb0",

    };

    long str2[36] = {37, 35, 33, 30, 28, 25, 23, 21, 18, 16, 13, 11, 9, 6, 4, 1, -1, -3, -6, -8, -11, -13, -15, -18, -20, -23, -25, -27, -30, -32, -35, -37, -39, -42, -44, -47};

    for(int i = 0 ; i < 88; i++)

    {

    if (strcmp(note, str[i]) == 0)

    {

    freq = pow(2,str3[i] / 12) * 440;

    f = ceil(freq);

    break;

    }

    else

    {

    continue;

    }

    }

    for(int i = 0 ; i < 36; i++)

    if (strcmp(note, str1[i]) == 0)

    {

    freq = pow(2,str2[i] / 12) * 440;

    f = ceil(freq);

    break;

    }

    else

    {

    continue;

    }

    return f;

    }

    // Determines whether a string represents a rest

    bool is_rest(string s)

    {

    if(strcmp(s, "") == 0)

    {

    return true;

    }

    else

    {

    return false;

    }

    }

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

    What is the probability of integer overflow when multiplying two random 64-bit integers?

    Posted: 21 Oct 2018 08:37 PM PDT

    Can someone tell me whats wrong with this code?

    Posted: 21 Oct 2018 08:15 PM PDT

    #include <stdio.h>

    int main()

    {

    char fName[20],lastN[25],code,status;

    int numPerson,phone,custom_id;

    float deposit,transCost,entryFee,tourFee,balance,discount,ovrlTour;

    printf("Enter 7 Digit Customer ID\n");

    scanf("%i",&custom_id);

    while ((custom_id != "XXX")||(custom_id!="xxx")){

    printf("Enter First Name\n");

    scanf("%s",fName);

    printf("Enter Last Name\n");

    scanf("%s",lastN);

    fflush (stdin);

    printf("Enter Destination Code\n");

    scanf("%c",&code);

    while ((code!='J')&&(code!='M')&&(code!='A')){

    printf("Invalid Code!\n Enter Valid Code\n");

    scanf("%c",&code);

    }

    printf("Enter Tele-Phone Number:\n");

    fflush (stdin);

    scanf("%i",&phone);

    printf("Enter Number of Persons\n");

    scanf("%i",&numPerson);

    while ((numPerson < 5) || (numPerson > 25)){

    printf("Minimum number of person in a Travel Party is 5. Maximum is 25. \n Please Enter Number of Persons\n");

    scanf("%i",&numPerson);

    }

    printf("Enter Deposit\n");

    fflush (stdin);

    scanf("%f",&deposit);

    while ((deposit < 0) || (deposit>175000)) {

    printf("Deposit Cannot be Less than 0 or More Than 175000. Enter Deposit Between 0 and 175000\n");

    scanf("%f",&deposit);

    }

    if(code=='J'){

    transCost= 2500*numPerson;

    entryFee=2000*numPerson;

    tourFee=4000;

    ovrlTour= transCost + tourFee + entryFee;

    balance= deposit-ovrlTour;

    }else if(code=='M'){

    transCost=3700*numPerson;

    entryFee=600*numPerson;

    tourFee=5200;

    ovrlTour= transCost + tourFee + entryFee;

    balance= deposit-ovrlTour;

    }else if(code=='A'){

    transCost=3000*numPerson;

    entryFee=4000*numPerson;

    tourFee=0;

    ovrlTour= transCost + tourFee + entryFee;

    balance= deposit - ovrlTour;

    }

    if((numPerson > 10) || (numPerson < 16)){

    discount= transCost*0.05;

    transCost=transCost-discount;

    }else if(numPerson <= 25){;

    discount=transCost*0.1;

    transCost=transCost-discount;

    }else if(numPerson >= 5){

    discount=0;

    transCost=transCost-discount;

    }

    if(balance<0){

    balance=balance*-1;

    }

    if (balance >= 0){

    status='C';

    }else {

    status='B';

    }

    printf ("Customer ID is:%i \nFirst Name:%s \nLast Name:%s \nDestination Code:%c \nNumber of Persons in Party:%i \nDiscount Given:%.2f \nOverall Tour Price:%.2f \nDeposit:%.2f \nBalance to be Paid:%.2f \nTransaction Status:%c",&custom_id, fName, lastN, &code, &numPerson, &discount, &ovrlTour, &deposit, &balance, &status);

    }

    return 0;

    }

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

    Pick 4 Lotto javascript help

    Posted: 21 Oct 2018 08:14 PM PDT

    I am super new to coding and I am in dire need of some help with this question. Sorry for the sloppy copy/pasting of the question, just didn't know how else to get all of the info in there. I am completely stumped with this. Yes, I know it is probably super simple to solve, but I am an idiot. Thank you for any help you can give.

    3 Instructions

    Create a lab08 folder on your machine and, in that folder, open a new HTML file named lab08.html. Copy the following into your HTML file:

    <html> <head> <title> PICK-4 Lotto </title> <script type="text/javascript" src="r/http://balance3e.com/random.js"> </script> <script type="text/javascript"> function DrawUntilWinner() // Assumes: user has entered 4 numbers in pick boxes // Results: repeatedly generates pick-4 winners until match user pick { var num1, num2, num3, num4, pick1, pick2, pick3, pick4, count; num1 = parseFloat(document.getElementById('num1').value); num2 = parseFloat(document.getElementById('num2').value); num3 = parseFloat(document.getElementById('num3').value); num4 = parseFloat(document.getElementById('num4').value);  pick1 = RandomInt(0, 9); pick2 = RandomInt(0, 9); pick3 = RandomInt(0, 9); pick4 = RandomInt(0, 9); // We will add code here. document.getElementById('outputDiv').innerHTML = 'The number of picks needed to get ' + num1+'-'+num2+'-'+num3+'-'+num4 + ' was ' + count; } </script> </head> <body> <div style="text-align:center"> <h2>Pick-4 Lotto</h2> <p> This page demonstrates the futility of lotteries. <br> Click on the button to perform LOTTO drawings until <input type="text" id="num1" size=1 value=0> <input type="text" id="num2" size=1 value=0> <input type="text" id="num3" size=1 value=0> <input type="text" id="num4" size=1 value=0> appears. </p> <input type="button" value="Click to begin drawing" onclick="DrawUntilWinner()"> <hr> <div id="outputDiv"></div> </div> </body> </html>

    Save your file and load it into the browser.

    3.1 Building a loop

    We want to repeat this loop until a time where we a match for each of the numbers we selected. Our loop needs to keep track of the number of times that we do NOT match the picked numbers.

    Your code should look similar to this:

    count = 1; while (pick1 != num1 || pick2 != num2 || pick3 != num3 || pick4 != num4) { pick1 = RandomInt(0, 9); pick2 = RandomInt(0, 9); pick3 = RandomInt(0, 9); pick4 = RandomInt(0, 9); count = count + 1; }

    3.2 Using a nested loop

    Suppose we want to repeat this experiment twenty times. Modify the function DrawUntilWinner() to make this happen. First use a while loop to implement this change and then replace this while loop with a for loop.

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

    Trouble with visualizing the percentage of one variable in R

    Posted: 21 Oct 2018 07:57 PM PDT

    I am working with a Supreme Court dataset. I am trying to visualize the percentage of cases in each term that were decided by a one-vote margin. I have variables for terms, the number of votes in the majority, and the number of votes in the minority. The best option for visualization is a line graph with terms as the x-axis and the percentage of decisions decided on a one-vote margin as the y-axis. ``` library(tidyverse) library(dplyr) scdbv %>% select(majVotes, minVotes, term)

    |term|majVotes|minVotes| |<int>|<int>|<int>| |:-|:-|:-| |1946|8|1| |1946|8|1| |1946|8|1| I created a new variable for the vote margin. scdbv %>% select(majVotes, minVotes, term) %>% mutate(margin = majVotes - minVotes) |term|majVotes|minVotes|margin| |<int>|<int>|<int>|<int> |:-|:-|:-|:-| |1946|8|1|7| |1946|8|1|7| |1946|8|1|7| Since then, I feel like I have tried every method under the sun to get the percent of single margin votes to apply in ggplot for my graph. This is the most recent method: scdbv %>% select(majVotes, minVotes, term) %>% mutate(margin = majVotes - minVotes) %>% mutate(margin1 = if_else(margin == "1", "1", "NA")) %>% mutate(margin1 = as.integer(margin1)) %>% ggplot(aes(x = term)) + geom_line(aes(y = count(margin1) / n())) Which returns: NAs introduced by coercionError in UseMethod("groups") : no applicable method for 'groups' applied to an object of class "c('integer', 'numeric')" ``` I am sure there is something very simple I am missing with how to do this.

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

    c - Need help with recursion example

    Posted: 21 Oct 2018 12:04 PM PDT

    Here's the code:

    https://repl.it/@dft95/ex1

    I know that it repeatedly calls the G function, bringing ch and n down until n is 0. It prints the ch and n value prior to a new line being created. But what I don't get is how exactly n is increased. From what I see here, there is never any point in which it increases, aside from calling G('M',3) again, which would just restart the whole thing.

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

    Where can i buy a .an domain suffix?

    Posted: 21 Oct 2018 04:56 PM PDT

    Finding bearing between two locations

    Posted: 21 Oct 2018 11:12 AM PDT

    I am trying to find bearing between two locations on Android using Location.bearingTo() and manually applying this formula

    θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )

    but both are giving wrong results as compared on here and here.

    val myBearing = Math.toDegrees( Math.atan2( Math.sin( qibla.longitude.minus(location.longitude) ) .times( Math.cos(qibla.latitude) ), Math.cos(location.latitude) .times( Math.sin(qibla.latitude).minus( Math.sin(location.latitude) ) ) .times( Math.cos(qibla.latitude) ) .times( Math.cos(qibla.longitude.minus(location.longitude)) ) ) ) .plus(360) .rem(360) var bearing = location.bearingTo(qibla) .plus(360) .rem(360) 

    this is the code I'm using and here myBearing is what I have calculated and bearing is what Location.bearingTo gives me and both have answers about 70-80 degrees deviated, direction is right but numbers are wrong.

    What is wrong with Location.bearingTo and my formula, have I not applied formula correctly? Also new to Kotlin

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

    Software project is getting too complicated!

    Posted: 21 Oct 2018 08:25 AM PDT

    I sincerely hope someone can point me into the direction of a tool, website, or book that gives tips for organizing a complicated software project... 'cause I'm about to lose my mind. Yes, I comment my code. I've even documented stuff in five separate notebooks. But they're really not reducing the insanity 'cause this thing jumps around various parts of itself like a bunch of horny rabbits (it has to actually).

    So how does one rein in the madness? Is a flowchart the answer? I'm afraid if I made one, it would be as big as one of my walls! To give you an idea of how bad things can get, I found myself coding functions that I forgot were already coded. (More than once, too.)

    All suggestions are greatly appreciated.

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

    Track time via file system changes?

    Posted: 21 Oct 2018 03:05 AM PDT

    I saw a tool a while back that would estimate your time based on file system changes, but I can't find it anymore. Does anybody have an idea on this?

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

    Any ideas for a developping project ?

    Posted: 21 Oct 2018 11:38 AM PDT

    Hi,

    i'm currently in a computer Science and cognitic sciences engineer school and I have a project to do.

    Subject is totally up to me and even after researchs and discussions, nothing comes to my mind.

    This is quite big project (for school i mean), I want to work 100ish hours on it. The only constraint is that it must be a project with development in it, any kind (web, software, mobile application, VR, database...) and I'm okay with anything.

    I'm sending this message in a bottle, if you have any idea about something that could be interesting and fun :)

    Have a nice day!

    (Not sure about the subreddit .. haha)

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

    Create a Google Sheets function that uses a deepl API to translate a cell

    Posted: 21 Oct 2018 04:34 AM PDT

    Hi!

    I'd like to create a function in Google Sheets that works like the GOOGLETRANSLATE function: it has 3 arguments: a range where the source text is, the source language and the target language (see here: https://www.labnol.org/internet/google-translate-for-spreadsheets/10086/).

    I know that Google Sheets has a script editor where one can write custom functions in gscript.

    I have found this (unofficial) Python API for deepl: https://github.com/EmilioK97/pydeepl

    My question is, how do I create this function? How do I connect this API to a custom script in Google Sheets?

    I only have a very basic knowledge of Python.

    Thank you!

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

    I'm an idiot, how do I make a calculator like this? I was thinking of using C#

    Posted: 21 Oct 2018 07:50 AM PDT

    C# just because I want to learn that language.

    ok so I want to make a calculator where I put in like values for "A" for answer then I put in "Bmg" and "Cmg" for dose of the two ingredients I have that it takes to make that, and it tells me "D" which is made up of "E" and "F" and "E" is how many of the ingredients of "Bmg" is needed to me "A" and "F" is how many of the ingredients of "Cmg" is needed with "Bmg" to make "A".

    sorry if this is written weird

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

    What is your most highly recommended laptop for work/coding?

    Posted: 21 Oct 2018 06:39 AM PDT

    Ideal (maybe currently impossible, but I can dream) setup is a laptop that could be easily transported, parts easily upgradable/replaceable, can install multiple OS installations without spending days figuring out what went wrong (that really seems dependent on the motherboard/bios), has ports for multiple additional screens to extend to (bonus for either attached extra screens or separate ones easy to transport), can compile lots of code (possibly including code from visual-oriented languages like java or c# or anything from the android SDK (personal project), so effectively good CPU, RAM, SSD, bus speeds, and a not built-in graphics card) and display its results very quickly, and can have multiple external parts attached (I like my personal keyboard and mouse when I'm home).

    Yes, I could do a shit ton of research and figure this out on my own, but I also have a one-person limited perspective. Also, asking you all is probably quicker XD

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

    No comments:

    Post a Comment