Stack question

Learn Programming - Fri, 03/16/2018 - 08:37

I am on the first year of CS and the teacher just dropped all of his c# knowledge on his before the test. So im having a really tough time getting what exactly am i supposed to do here:"create a class, static class DecimalConvert. in this class create a fucntion, static bool[ ] decimal2binary(uint n), and a function, private static void d2b(uint n, Stack<bool> pilha). The first function must call the second in a way to recursively put on the pile the boolean value so that in the end the first function returns a vector of bits representing n" i don't really want you to do it i just don't get what im suposed to do

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

[C++] Why is wrong with this short snippet?

Learn Programming - Fri, 03/16/2018 - 08:29

This piece of code is doing something not allowed with the memory. I don't know what it is. Can you help me? Thank you

#include <iostream> using namespace std; int main() { int i, * a = new int (73); for ( i = 0; i < 73; i ++ ) a[i] = i; delete a; cout << i; } submitted by /u/nutidizen
[link] [comments]

Why do we have to import classes in java?

Learn Programming - Fri, 03/16/2018 - 08:28

Why aren't all the classes available to every source code file? My guess is performance reasons (a lot of classes in a file would make it bloated and slower to load) but i'd like it confirmed.

Also - if we "import" classes, where are they "exported" from? Where do they come from?

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

What are some good ways to take full advantage of going to a developer conference?

Learn Programming - Fri, 03/16/2018 - 08:24

i got a student scholarship to RWDevCon, which is an iOS conference organized by Ray Wenderlich outside of Washington DC. this is my first time ever going to one, and i’m kind of nervous/anxious as to what to expect and how to maximize my experience/learning.

i started iOS development about a year ago, so i’m in no way a master, but there’s tons of workshops to attend and a hackathon (would this be something beneficial to my resume/experience?)

if anyone has gone to this conference/ any conference, any tips or tricks you have would be much appreciated. thank you!

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

return function in python.

Learn Programming - Fri, 03/16/2018 - 08:14

im writing test cases to understand functions and return. but it dosent work for me ? can someone help a brother out :)

character_name = "barbarian" # focus on strenth character_level = 1 # start level character_str = 2 # higher strength cause barbarian character_int = 1 # start value character_dex = 1 # start value # tesxt that shows what the values where before we run the function print(f"my character: {character_name}, have theese stats") print("\n") print(f"Level: {character_level}") print(f"Strength: {character_str}") print(f"Inteligence: {character_int}") print(f"Dexterity: {character_dex}") print("\n") # the function for leveling up def level_up(l, s, i, d): # temp var for reciving values from outside l = l + 1 # level always go up by one number s = (s * l) * 1.3 # strength value input * level * 1.3 stored back in s i = (i * l) * 1.1 # int value input + level + 1.1 stored back in i d = (d * l) * 1.1 # dex value input + level + 1.1 stored back in d return (character_level, character_str, character_int, character_dex) # return values to outside var ???? level_up(character_level, character_str, character_int, character_dex) # run functions with char stats in values #print values to test if it changes print("my character level up!, it should now have theese stats") print("\n") print(f"Level: {character_level}") print(f"Strength: {character_str}") print(f"Inteligence: {character_int}") print(f"Dexterity: {character_dex}") print("\n") submitted by /u/wontner82
[link] [comments]

My 6 month progression

Learn Programming - Fri, 03/16/2018 - 07:54

Hallo fellow Redditors,

Please excuse me, my english grammatic is not very good.

I make a education career as a SAP/ABAP Developer with a bit Selenium/C# for Automatisation tests. Besides i learn Java OOP for my school.

I never did programming before, so my experience is build in those 6 months.

I learn the SAP/Abap Basics, the Java Basics and the C#(very identical with Java) Basics.

The easiest part for me is Automatisations with Selenium/C#.

I have the feeling that my progression is very slow for those 6 months. Right now i improve my Java OOP skills, because i have the biggest problems there.

SAP/Abap is for me like the "Stockholm Syndrome", it's not the best Situation you wanna be but somehow you fall in love with it.

C# is compared to Java alot more fun and i make the fastest progression there.

My input is alot and i try to focus every week on one specific topic.

I dont know if my progression is good or to slow, but i have the feeling my progression is to slow.

Maybe you have some Tips and advices for me!

Greetings :)

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

whatsapp bot

Learn Programming - Fri, 03/16/2018 - 07:44

i need a bot for whatsapp. i dont know alot about computer software writing, i need a bot that responds on messages automatically , anyone know’s how to start up?( i’m not going to use this bot for anything else than trolling my friends stalker)

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

Loading the contents of a csv file (relative to the JS file) into a string?

Learn Programming - Fri, 03/16/2018 - 07:30

Hello there. First time poster. I've scoured the internet for a solution to my problem to no avail.


function doingCSVThings() { var filePath = "path to CSV file relative to this JS file. This will NOT be a local file on the user's PC"; var outputString = ""; //This is where the contents of the file goes //Using the filepath, open the file, and put its contents into the string //outputString now has the contents of the CSV file! }

In the file structure of this hypothetical 'site' we have a HTML file, a JS file, and CSV file next to each other in the same folder. Remember, a CSV file just contains text.

Things I cannot use:

  • Input forms. This is meant to be automatic without the user having to browse for the files themselves. And besides, in the end the user won't have access to the files

  • XML HTTP Request.

  • Plugins. I'm trying to do it in pure JS. As painful as it may be.

  • Databases.


  • Yes I know this is a bit of a bodge job, but I want to know how to do this specific thing.

  • I've tried making a var file = new File ([""], "path to file") but it didn't read the file. No idea why. I'm starting this from scratch anyway.

  • I've already cracked the CSV parsing. That isn't what I'm looking for. I'm just trying to get the contents of the CSV file to parse in the first place.

  • This isn't my actual code but I have fabricated this situation so there isn't any confusion.

  • I know that there are vastly better methods its just this specific action I'm trying to do.

Thankyou very much for any help and suggestions and for your time and patience!

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

Someone wants to join me in a small adventure?

Learn Programming - Fri, 03/16/2018 - 07:19

I am not exactly new to C#, but I wanna learn how to code bigger things, without letting it sink into chaos.
I want to code a text based adventure game.
I've tried a few times, but there has always been a point at which I just could not go on anymore, because of weird interactions and stuff...
So what I am asking here is, does someone wanna collaborate with me here? I doubt that there will be anyone that bored, but ... I thought I might just ask.
Or someone knows any helpful tutorials to start CORRECTLY into development?
What I have been doing is define the ideas what I will need; then create the classes; then start with the game mechanics (level up, combat, abilities....).
I would appreciate any help!
With the best regards,

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

Help with a DX overlay

Learn Programming - Fri, 03/16/2018 - 06:59

I have been working on a overlay for BF4, i got it to work and hook on the game. my problem is that the overlay is click-able, not just a "transparent" window that goes over the game. this is my best guess where i need to go to change how the overlay is drawn but i'm lost, i'm not every good at coding so anything can help. edit: is the code in Overlay.Designer.cs

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

[Python/Django] Can't identify which variable does not exist in VariableDoesNotExist error

Learn Programming - Fri, 03/16/2018 - 06:54

My site works fine but my log.django file is showing a django.template.base.VariableDoesNotExist error and I can't identify which variable is not valid.

Here's the full traceback:

Traceback (most recent call last): File "/home/zorgan/app/env/lib/python3.5/site-packages/django/template/", line 903, in _resolve_lookup (bit, current)) # missing attribute django.template.base.VariableDoesNotExist: Failed lookup for key [lst] in "[{'None': None, 'True': True, 'False': False}, {'user_inbox': <QuerySet [<Inbox: Inbox object>]>, 'allauth_login': <LoginForm bound=False, valid=False, fields=(login;password;remember)>, 'request': <WSGIRequest: GET '/post/'>, 'messages': < object at 0x7fd0339c67f0>, 'user_settings': <UserSettings: UserSettings object>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7fd033a1db70>,'user': <SimpleLazyObject: <User: zorgan>>, 'DEFAULT_MESSAGE_LEVELS': {'ERROR': 40, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'DEBUG': 10}, 'csrf_token': <SimpleLazyObject: 'bagt2zVjPiMiyi0ojTxTVbHHOBiIei7hqZQZ5sDITfzZ9khSbszkDCvcawQuHSxR'>, 'allauth_signup': <SignupForm bound=False, valid=False, fields=(username;email;password1;password2)>, 'inbox_status': 'read'}, {}, {'form_post': <PostForm bound=False, valid=False, fields=(title;content;entered_category;image;imageURL;user)>, 'via': 'news'}, {}, {'block': <Block Node: footer. Contents: [<TextNode: '\\n\\n'>, <IfNode>, <TextNode: '\\n\\n'>]>}]"

Any idea?

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

Problem setting a global variable to a null value

Learn Programming - Fri, 03/16/2018 - 06:30

In the code below I can not wait until line 136 to set driver = to Firefox(), I have to set it equal to something earlier as a global. And setting it equal to lambda: None as suggested on SO also didn't work. I'm not sure what the best fix is other than having it pop open a blank browser, as it does now, before the options get set. What is the proper way to deal with this?

from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains from import WebDriverWait from import expected_conditions as EC from import By from selenium.common.exceptions import TimeoutException from import Select from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.proxy import * from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.proxy import Proxy, ProxyType from import Options import os import time from openpyxl import load_workbook # don't remove. I can load lots of data this way import random import sqlalchemy import datetime # connect to database database_credentials = "postgres://user2:<removed>@localhost:5432/fb_data1" database = sqlalchemy.create_engine(database_credentials) metadata = sqlalchemy.MetaData(database) users_table = sqlalchemy.Table('users', metadata, sqlalchemy.Column("user_key", sqlalchemy.Integer, primary_key=True), sqlalchemy.Column("user_login", sqlalchemy.String), sqlalchemy.Column("facebook_password", sqlalchemy.String), sqlalchemy.Column("email_password", sqlalchemy.String), sqlalchemy.Column("date_of_birth", sqlalchemy.Date), sqlalchemy.Column("first_name", sqlalchemy.String), sqlalchemy.Column("last_name", sqlalchemy.String), sqlalchemy.Column("city", sqlalchemy.String), sqlalchemy.Column("proxy", sqlalchemy.String), sqlalchemy.Column("port", sqlalchemy.String), ) driver = webdriver.Firefox() # encapsulate program data (this will go into a db table later program_data = { 'anonymizing_website': ['', '', '', '', '', '', '', '', '', ''], "ad_texts": [ "Anyone want $10 to their paypal? Just send me a message if you know someone who wants a website built for low $; I'll pay you as soon as I get to work with that person :)", "Guys, I'm paying $10 via paypal for anyone who knows a friend/family member who could use a website. See my ad below and send me a message if you can refer someone", "Help a friend/family member out, introduce them to me for a nice looking $150 website made to their request! I'll even pay you $10 for the referral, just message me the person you're referring :)" ], "user_key": '', "user_login": '', "facebook_password": '', "email_password": '', "date_of_birth": '', "first_name": '', "last_name": '', "city": '', "proxy": '', "port": '', "ad_images": ['fb_logo1.png', 'fb_logo2.png'], "facebook_group_urls": [], } # this is how Vue does it too. One big data object def show_all_users(): all_row_select_statement = users_table_result = database.connect().execute(all_row_select_statement) # return users_table_results[account_key - 1] # index is one less than key for r in users_table_result: print("%s: %s. %s %s. %s. %s:%s" % (r[0], r[1], r[5], r[6], r[7], r[8], r[9])) def retrieve_user_data(account_key): # this is a bad function. Too limited # well, all scripts will use this code # select_statement = Target user target_row_select_statement = == account_key) users_table_result = database.connect().execute(target_row_select_statement) # return users_table_results[account_key - 1] # index is one less than key for table_row_data in users_table_result: print('full row: ', table_row_data) program_data['user_key'] = table_row_data[0] program_data['user_login'] = table_row_data[1] program_data['facebook_password'] = table_row_data[2] program_data['email_password'] = table_row_data[3] # convert date object back to datetime, then string-format it datetime_object = datetime.datetime.combine(table_row_data[4], datetime.datetime.min.time()) program_data['date_of_birth'] = datetime_object.strftime('%Y-%m-%d') program_data['first_name'] = table_row_data[5] program_data['last_name'] = table_row_data[6] program_data['city'] = table_row_data[7] program_data['proxy'] = table_row_data[8] program_data['port'] = table_row_data[9] return users_table_result def clear_user_data(): program_data['user_key'] = '' program_data['user_login'] = '' program_data['facebook_password'] = '' program_data['email_password'] = '' program_data['date_of_birth'] = '' program_data['first_name'] = '' program_data['last_name'] = '' program_data['city'] = '' program_data['proxy'] = '' program_data['port'] = '' program_data["ad_images"] = [], program_data["facebook_group_urls"] = [], def setup_browser(web_browser): if web_browser == 'chrome': # Chrome / Selenium Setup proxy = program_data['proxy'] + ':' + program_data['port'] chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--proxy-server=%s' % proxy) driver = webdriver.Chrome(chrome_options=chrome_options) elif web_browser == 'firefox': driver = webdriver.Firefox() driver.set_window_size(1000, 700) class BotAction(): def confirm_ip(self, website): return driver.get(website) # use this return as an input # make it a boolean later. right now it just isn't '' # add an ip text match check def get_anonymous_site(self): driver.get(random.choice(program_data['anonymizing_website'])) def log_into_facebook(self, user_login, user_password): driver.get('') driver.find_element_by_xpath("//form[contains(@id, 'log')]//input[@type='email']").send_keys(user_login) # username driver.find_element_by_xpath("//form[contains(@id, 'log')]//input[@type='password']").send_keys(user_password) # password # driver.find_element_by_xpath("//form[contains(@id, 'log')]//label[@type='submit' and contains(lower-case(text(), 'log'))]").click() driver.find_element_by_xpath("//form[contains(@id, 'log')]//label//input[@type='submit']").click() def grab_group_list(self): driver.find_element_by_xpath("//div[contains(@id, 'appsNav')]//li//a[contains(@href, 'groups')]").click() # explicit wait needed # WebDriverWait(driver, 10).until(EC.presence_of_element_located(By.XPATH("//span[contains(text(), 'Your Groups')]"))) WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "GroupDiscoverCard_membership"))) # double parens for some reason print "Groups page ID marker found" #scroll down to bottom of page # while True: driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") # time.sleep(3) # go to height 0. Sleep 3 seconds. Is height 0? # isolate groups already joined, no pending / favorite relative_group_urls = driver.find_elements_by_xpath("//div[contains(@id, 'member') and not(contains(@id, 'pending')) and not(contains(@id, 'favorite'))]//li//a[contains(@href, 'groups') and not(contains(@href, '?ref='))]") print "Found Group elements" for element in relative_group_urls: program_data['facebook_group_urls'].append(str(element.get_attribute('href'))) print program_data['facebook_group_urls'] def check_recent_posts(self): # and return true if there's a match, false if no match driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") # find the recent posters recent_names_list = [] recent_names_list = driver.find_elements_by_xpath("//div[contains(@class, 'userContent')]//a[contains(@class, 'profileLink')]") for facebook_full_name in recent_names_list: print "Names found on top of group page: " print(facebook_full_name.get_attribute('text')) if facebook_full_name is program_data['first_name'] + " " + program_data['last_name']: return True return False def autofill_ad_post(self): driver.find_element_by_xpath("//div[contains(@id, 'content')]//div[contains(@class, 'composer')]//input[contains(@type, 'text')]").send_keys(random.choice(program_data['ad_texts'])) # post a random ad text # TODO add a bunch of OR clauses to the Xpath, or use elifs # driver.find_element_by_xpath("//div[contains(@id, 'content')]//input[contains(@accept, 'image')]").send_keys(os.getcwd() + "\\FbAssets\\images\\" + random.choice(program_data['ad_images'])) # 2 backslashes, first to "escape". Tested working in shell # image upload options: def post_to_group(self, group_url): # looping to be done in main() driver.get(group_url) if bot_action.check_recent_posts() == 0: bot_action.autofill_ad_post() continue_message = raw_input("Press any alpha key + ENTER to continue: ") driver.find_element_by_xpath("//div[contains(@id, 'content')]//button[contains(@data-testid='post')]").click() if continue_message: # == 1 implied continue_message = '' bot_action = BotAction() # Actions def main(post_target_site): if post_target_site == 'facebook': # TODO add a switch for craigslist later show_all_users() retrieve_user_data(int(raw_input("Select a user_key: "))) setup_browser("firefox") bot_action.confirm_ip("") bot_action.get_anonymous_site() bot_action.log_into_facebook(program_data['user_login'], program_data['facebook_password']) time.sleep(random.choice([10, 14])) bot_action.grab_group_list() for scraped_group_url in program_data['facebook_group_urls']: bot_action.post_to_group(scraped_group_url) # autofills and asks for confirmation print "All group URLs visited for this account" clear_user_data() if raw_input("Run again?: (Enter 'y') ") == 'y': main('facebook') # TODO later I can add another parameter to main to pass the key straight to the first sub-function, if entered # run the script to target facebook if __name__ == '__main__': main("facebook") submitted by /u/seands
[link] [comments]

Getting Started with Flutter

Programming - Fri, 03/16/2018 - 06:16
Categories: Programming

True and false operators in C#

Programming - Fri, 03/16/2018 - 05:55
Categories: Programming