• Breaking News

    Sunday, January 6, 2019

    Education project: Looking for programmers to interview. Ask Programming

    Education project: Looking for programmers to interview. Ask Programming


    Education project: Looking for programmers to interview.

    Posted: 06 Jan 2019 03:52 PM PST

    Issues with porting TCP file transfer from Python 2 to Python 3

    Posted: 06 Jan 2019 09:18 PM PST

    Hello, friends. I'm having some weird issues getting a simple low-level file transfer in Python 2 work in Python 3. I basically have a simple server/client setup. The user, working on a prompt produced by the server, requests a file to be transferred to his machine from the client (this is a reverse shell setup, so the connection is initiated from the client machine and the server machine is sending commands to the client). It works without a hitch in Python 2, but I just cannot get it to work with seemingly equivalent Python 3 code. Here's the relevant functions:

    Python 2 Server:

    def transfer(conn,command): conn.send(command) f = open('/root/Desktop/test.png','wb') while True: bits = conn.recv(1024) if 'Unable to find the file' in bits: print '[-] Unable to find the file' break if bits.endswith('DONE'): print '[+] Transfer completed ' f.close() break f.write(bits) 

    Python 2 Client:

    def transfer(s,path): if os.path.exists(path): f = open(path, 'rb') packet = f.read(1024) while packet != '': s.send(packet) packet = f.read(1024) s.send('DONE') f.close() else: # the file doesn't exist s.send('Unable to find the file') 

    And here's what I've got in Python 3:

    Python 3 Server:

    def transfer(conn,command): conn.send(command.encode()) f = open('/root/Desktop/test.png','wb') while True: bits = conn.recv(1024) if 'Unable to find the file'.encode() in bits: print('[-] Unable to find the file') break if bits.endswith('DONE'.encode()): print('[+] Transfer completed ') f.close() break f.write(bits) 

    Python 3 Client:

    def transfer(s,path): if os.path.exists(path): f = open(path, 'rb') packet = f.read(1024) while packet != '': s.send(packet) packet = f.read(1024) s.send('DONE'.encode()) f.close() else: s.send('Unable to find the file'.encode()) 

    Based on my debugging, the file does transfer; it appears on my server machine as expected and opens just fine, but the command prompt hangs and the "Transfer complete" never appears. I believe the error is in this while loop:

    packet = f.read(1024) while packet != '': s.send(packet) packet = f.read(1024) 

    It seems to be locked in this loop. I've tried multiple ways of writing it to no avail. Anyone have any ideas?

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

    I realized the biggest issue that causes problems for me in programming is not mental fatigue but rather physical ergonomic strain.

    Posted: 06 Jan 2019 04:10 PM PST

    I'm finding that one of the biggest impediments to my programming efficiency is the ergonomics of using the mouse and keyboard it's just extremely nauseating overtime. You have to repeatedly click these little buttons and typing all this text.

    Even with a really great chair and desk after few hours it still gets really tiresome. Has anyone found some strategic workarounds with some creative input devices that solves this ergonomic problem?

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

    Help with sorting data issue - Python 3.7

    Posted: 06 Jan 2019 07:02 PM PST

    Update Edit: I'm trying to get my code cleaner so I began turning the for key, value line into a function. Now it prints the same system over and over again. You can try 'murus' to run the script search.

    import requests space = '----------------------------------' stations_api = requests.get('https://eddb.io/archive/v6/systems_populated.json').json() def stations_data(station): print('System: %s' % (station['name'])) print('Distance: %.4f' % (distance)) print('Allegiance: %s' % (station['allegiance'])) print(space) def stations_order(key): for key, value in sorted(stat_results.items(), key=lambda x: x[1], reverse=False)[:20]: stations_data(station) while True: stat_results = {} stat_search = input("Search: ").upper() for station in stations_api: if stat_search == station['name'].upper(): stat_search_x = float(station['x']) stat_search_y = float(station['y']) stat_search_z = float(station['z']) for station in stations_api: if stat_search == station['name'].upper(): print() print('Current system: %s' % (station['name'])) print(space) continue distance = ((float(station["x"]) - stat_search_x)**2 + (float(station["y"]) - stat_search_y)**2 + (float(station['z']) - stat_search_z)**2)**0.5 stat_results[station['name']] = distance stations_order(stat_results) elif stat_search == 'EXIT': break else: continue break 
    submitted by /u/kurotheactivist
    [link] [comments]

    What would be the best way to start a career in cyber security? I am a web developer but would like to switch to a career in cyber security, where is a good place to start?

    Posted: 06 Jan 2019 03:58 AM PST

    New to APIs, I want to learn how to hook up Google Tasks APIs to IFTTT, and have Google Home Action upon that.

    Posted: 06 Jan 2019 06:57 PM PST

    I know how to use IFTTT already, but I am having trouble understanding where to start and write this.

    This is the starting page for learning the API: https://developers.google.com/tasks/

    An easy ELI5 answer on how to start using APIs would be very nice.

    Thanks!

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

    Let’s say I have a web app with a web front end and a mobile app. How would I go about structuring the files? And how to tackle git?

    Posted: 06 Jan 2019 12:41 PM PST

    How can I create a .class file with Jython?

    Posted: 06 Jan 2019 01:22 PM PST

    There used to be the jythonc but now it's not supported anymore and I really don't know what to do.

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

    Array won't output correctly

    Posted: 06 Jan 2019 11:06 AM PST

    I'm trying to make a card game in C, and for the time being, I've hardcoded each player's hand of cards.

    I have an array initialised as so;

    const char player1Cards[] = { 'AofS','2ofH','4ofC','JofD','KofD' }; 

    and then outputted as so

    printf("Player 1's cards: %c ", player1Cards); 

    I think i may have incorrectly initialised the array but i'm unsure how to fix it.

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

    Smooth scrolling a custom TileMap / Grid (Infinity size) [Processing / Java]

    Posted: 06 Jan 2019 03:35 AM PST

    I wanted to recreate Conway's game of life. I want to be able to resize and to move the grid (resize: mouse whell, move: mouse click and drag). I have somehow managed to make the scrolling smooth, but the resizing is still very rough. After the resizing, scrolling is also very rough / jittery and glitched. This is my demo source code. Could anyone tell me what's wrong with the code and how I could fix this?

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

    No comments:

    Post a Comment