Programming

Good playlist transfer to youtube

Learn Programming - Tue, 12/19/2017 - 17:42

I want to code something that will transfer playlists from Spotify, Apple Music, etc. to Youtube. Some tool do this, but are inaccurate and don’t work perfectly. I want to make a tool that takes the songs and makes a youtube playlist out of only the youtube autogenerated videos for music. (example here) I sadly have no coding experience and I have no idea where to start. I just want a more organized and more accurate way to transfer playlists to youtube. I’ve tried Soundiiz and SongShift. Thanks in advance!

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

Is there a program that automatically updates the template/layout of a website as-needed without having to hire a developer?

Learn Programming - Tue, 12/19/2017 - 17:31

I'm looking for something like this and would like to work on building it but I'm not sure where to begin:

I would like to build a program that automatically updates a website template into another template without me having to go in as the developer to (1) update the content of the website pre and post-template, (2) convert the old template to the new template format without messing up with the website data. The program will update any website to a new template/design from an old one without needing someone to do it manually every single time.

Example: I have a website with template A. I decide I want to switch the look of my website from template A to template B. The program would be able to (1) switch my website from template A to template B without me having to manually switch/update the templates, (2) convert the content from old website to new website, and (3) recognize all the data from the old version of the website to input it into the new version

A site like Wordpress still requires me to go on the back-end to update the templates manually. Someone still has to go through and manually update from Template A to Template B and convert all the data.

Is this possible?

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

[Question] Python Selenium Scraping: Should I be using an OOP approach?

Learn Programming - Tue, 12/19/2017 - 17:29

Here is my code:

#Selenium Based Imports from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import TimeoutException #Miscellanous Imports import time import csv import os from datetime import date '''Functions for accessing Selenium Pages''' def access_stats(driver, query): driver.get("http://www.nhl.com") try: box = driver.wait.until(EC.presence_of_element_located( (By.XPATH, '//*[@id="nhl-homepage_index"]/div[2]/div/div[2]/div/nav[2]/ul/li[5]/a'))) button = driver.wait.until(EC.element_to_be_clickable( (By.XPATH, '//*[@id="nhl-homepage_index"]/div[2]/div/div[2]/div/nav[2]/ul/li[5]/a'))) button.click() button.click() except TimeoutException: print("Box or Button not found in google.com") '''CSV related functions''' def FirstWriteDictToCSV(csv_file,column_title_row,data): try: with open(csv_file, 'w') as csvfile: writer = csv.DictWriter(csvfile, fieldnames=column_title_row) writer.writeheader() for data in dict_data: writer.writerow(data) except IOError as (errno, strerror): print("I/O error({0}): {1}".format(errno, strerror)) return def SecondWriteDictToCSV(csv_file,data): try: with open(csv_file, 'a') as csvfile: writer = csv.DictWriter(csvfile, fieldnames=column_title_row) for data in dict_data: writer.writerow(data) except IOError as (errno, strerror): print("I/O error({0}): {1}".format(errno, strerror)) return def CheckCSV(csv_path): with open(csv_path, 'r') as csvfile: csvreader = csv.reader(csvfile) for row in csvreader: if row[0] in (None, ""): print('nothing') return 0 else: return 1 def CSVWrite(csv_path, column_title_row, dict_data): a = CheckCSV(csv_path) print(a) if a == None: FirstWriteDictToCSV(csv_path,column_title_row,dict_data) else: SecondWriteDictToCSV(csv_path, dict_data) '''Scraping Functions''' def GetGoalLeader(): get_goal_leader_firstname = driver.find_elements_by_xpath('//*[@id="leaderboard-container"]/div/div[2]/div[1]/div[2]/p[1]/a/span[2]/span[1]') goal_leader_firstname = [x.text for x in get_goal_leader_firstname] get_goal_leader_lastname = driver.find_elements_by_xpath('//*[@id="leaderboard-container"]/div/div[2]/div[1]/div[2]/p[1]/a/span[2]/span[2]') goal_leader_lastname = [x.text for x in get_goal_leader_lastname] get_goal_leader_team = driver.find_elements_by_xpath('//*[@id="leaderboard-container"]/div/div[2]/div[1]/div[2]/p[2]/a/span[1]') goal_leader_team = [x.text for x in get_goal_leader_team] get_goal_leader_goals = driver.find_elements_by_xpath('//*[@id="leaderboard-container"]/div/div[2]/div[2]/p[2]') goal_leader_goals = [x.text for x in get_goal_leader_goals] return (goal_leader_firstname), (goal_leader_lastname), (goal_leader_team), (goal_leader_goals) #Accessing NHL stats page driver = webdriver.Chrome('/Users/AnabolicHippo/code/Scripts/Selenium/chromedriver') driver.wait = WebDriverWait(driver, 5) access_stats(driver, "Selenium") time.sleep(3) #Scraping Goal Leader and adding to CSV File csv_path = '/Users/AnabolicHippo/code/Scripts/Selenium/data/data.csv' goal = GetGoalLeader() column_title_row = ['firstname', 'lastname', 'team', 'goals', 'date'] dict_data = [ {'firstname': str(goal[0][0]), 'lastname': str(goal[1][0]), 'team': str(goal[2][0]), 'goals': str(goal[3][0]), 'date': str(date.today())} ] CSVWrite(csv_path, column_title_row, dict_data) driver.quit()

I'm looking at functions like GetGoalLeader() and realizing that I'm going to be replicating this function dozens of times. Rather than repeat my code over and over, should I just create classes?

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

Automated dashboard with google apps script and google sheets

Learn Programming - Tue, 12/19/2017 - 17:15

I have recently been working with google sheets and google apps script so I wrote a blog post about how to use them to make dashboards. I hope it can help someone out.

https://www.lucidchart.com/techblog/2017/12/18/how-to-build-automated-dashboards-with-google-apps-script-and-google-sheets/

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

Change order of Days in Drupal 8 Date picker

Drupal - Open Source Content Platform - Tue, 12/19/2017 - 17:13

I'm creating a custom form using an element of type="date". This creates a field that will produce a datepicker. For some reason it wants to put Sunday as the last day of the week, rather than the first. I went into "admin/config/regional/settings" and made sure that Sunday was saved to be the first day of the week, but it the datepicker doesn't seem to respect that. Does anyone have any suggestions? My users will never accept this.

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

Looking for explanation in programming that detects carrying long multiplication and how convolution is used (Jelly)

Learn Programming - Tue, 12/19/2017 - 17:11

The source is here: https://codegolf.stackexchange.com/questions/151130/easy-to-multiply-numbers Description of task (link rot): Your task is to determine whether two numbers are easy to multiply. This means that their base-10 long multiplication doesn't have any carrying (regrouping) between place values, looking at both the multiplication steps and the addition step. This happens when each pair of digits being multiplied gives 9 or less and the sum of each column is 9 or less.

To be concise, I would like a better explanation of the following program:

Dæc/>9Ẹ

The first character 'D' From what I understand is that the integer input is put into a decimal list instead.

æc is like a function that takes two inputs, it is called convolution. I don't understand the use of convolution here. How is it defined in Jelly? A convolution being defined as

[f*g](t) = integral from 0 to t of f(x)g(t-x) dx

that doesn't really seem relevant to me, like the infinite sum of the products of the tiny slivers of a function times another function with the input of the first function's input length from the limit.

/ seems to take the repeated application of the convolution æc using the list of the input that has been decimalised (right word) as a sequence to squish in as arguments for convolution.

Then for some reason it spits out a list that you go through and compare if each element is more than 9 and this operation of >9 is basically vectorised. Then the last operation Ẹ goes through the list to try and see if there is an exception to the hopeful no carried digits as this would show up as a truth value (some addition of multiples > 9 or a multiple of 2 digits that is > 9).

How is the data structured if you input two integers? Is it just a decimal list of the first number not seperated followed by the other?

Could someone explain to me how the convolution works and checks for digit carrying? It would seem to check if each digit multiplied gets something more than 9. Then checking for if the sums of the corresponding digits implies a carry over. I'm not sure why.

I don't have much experience with programming, just a little bit of Python so no Jelly yet sorry if it seems too elementary. I'm not concerned with whether or not this is practical or a good coding practice.

Edit: This is probably isn't how the program works just how I'm kind of guessing.

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

Applets in Java - Is it ever still used?

Learn Programming - Tue, 12/19/2017 - 16:27

Is an Applet any sort of GUI interface in java? is mobile using applets?

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

At what point did you understand ALL of the reasons that pointers are used in a language like C?

Learn Programming - Tue, 12/19/2017 - 16:26

For example, right now I'm having a hard time understanding why you would want to use function pointers, even after reading through some explanations for it.

Now, just being more general- Are you copying data literally every time you pass it into a function? I'm hoping to confirm what I think I know while this thread is active. When I look at example snippets of C code, it seems like pointers to numeric datatypes like ints are far less common than pointers to strings (or char might be more accurate).
My use case for knowing C would be to use it in Python extensions. and, to understand programming more since there doesn't seem to be as much to learn in Python as many other languages. I've also considered learning a sugary systems programming language like Nim where calling C is more natural, but the problem is no one really uses that.

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

Writing a script that deletes files from a specified directory.

Learn Programming - Tue, 12/19/2017 - 16:25

I don't have a ton of scripting experience as I primarily write web apps, but I had an idea for a personal project over break and I'm having some difficulty figuring out how to begin it. Essentially, when this program is run, it'll do one of two things (I haven't figured out what's more reasonable yet):

  1. Run an npm command to generate boilerplate, and then delete the unnecessary files from the created directory.

  2. Assume that the npm command has already been written, and take in a command line argument specifying the location. The program would cd to this location and then delete the unnecessary files.

From what I know, this seems relatively reasonable to do as a shell script, but I'd much rather do it in python. From the looks of it, the os library seems like it'd be helpful. Any other resources that might be helpful? Additionally, would I be able to alter the contents of a file from within a python script?

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

Pages