• Breaking News

    Wednesday, April 4, 2018

    What programming concepts can be used to optimize your day to day life? Ask Programming

    What programming concepts can be used to optimize your day to day life? Ask Programming


    What programming concepts can be used to optimize your day to day life?

    Posted: 04 Apr 2018 01:24 PM PDT

    Do you use any concepts from programming/logic/computer science to be more efficient in your day to day life? If so which ones, and how do you implement them?

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

    I am fairly fluent in Python & would like to build my resumé. Long story short I have decided to pick up Java & would like to know if there are any free online books for beginners. Any other helpful input is appreciated even if not related to the book. Thanks!

    Posted: 04 Apr 2018 07:53 PM PDT

    Add stringbuilder's index's values together for every index and store the values in a list

    Posted: 04 Apr 2018 09:31 PM PDT

     var answers = new List<int>(); foreach (var i in Enumerable.Range(0, sb1.ToString().Length)) { MainClass.answer = sb1[i] + sb2[i]; Console.WriteLine(MainClass.answer); } } } 
    submitted by /u/redyellowbluered
    [link] [comments]

    [Netbeans] [Java] [JavaFx] I have a JavaFx gui project, and a database Java project I want to combine into one project? How do you do this?

    Posted: 04 Apr 2018 09:06 PM PDT

    Why does garbage collection affect performance so much and will we ever see tripple A fps games in a garbage collected language?

    Posted: 04 Apr 2018 01:33 PM PDT

    .. where the game created in ex C# or Java . Unity as I understand it has a C++ core that is scripted (no jit) with C# . I'm talking GCed language for all parts except shaders.

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

    In your professional experience, after how many hours a week do diminishing returns begin? After how many hours do negative returns begin?

    Posted: 04 Apr 2018 10:22 AM PDT

    If you already know what "diminishing returns" and "negative returns" mean, skip this paragraph:

    For some amount of time, work hours and production output scales linearly. Work X hours, get X work done. At some point, the point of diminishing returns, the curve is no longer linear. Work X more hours, get X/Y work done (where Y > 1). Then at some later point in time, the point of negative returns begins, where you begin writing more hours worth of bugs to fix than it took to write. Or, for X hours worked, get -Y work done (where Y >= 0).

    In your professional experience, around what hour-mark per week do these points occur?

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

    Novice Programmer looking for webdev starter kit and projects to dive into to learn.

    Posted: 04 Apr 2018 07:18 PM PDT

    Hey all,

    I'm a novice programmer, meaning I'm familiar with HTML/CSS and learning JavaScript. I want to be a Full-Stack developer eventually. But I'm now trying to teach myself JavaScript by building a web app. I learn best by doing. I've tried codeacademy but can't seem to focus. I find it so monotonous. So I thought I'd just build a project from scratch to learn. So can anyone recommend projects to just jump into and learn by trial and error? And a webdev set up (kit)? I use windows btw.

    submitted by /u/66jeromemorrow99
    [link] [comments]

    ¿How can I store tree nodes data?

    Posted: 04 Apr 2018 06:32 PM PDT

    Sorry for the misleading title, I didn't know how to express myself.

    My problem is: I have a list that I read from a file.txt, and each element in a list contain children. These children are defined with an indent. Example of file.txt:

    • Node 1
      • Node child
      • Node child
        • Node child of child
      • Node child
        • Node child of child
          • Node child of child of child

    If I have to read a list like that and store it in an hashmap, array or whatever is the best option, how do I do it?

    Edit: I've been thinking to do it this way:

    1.- Read the indent of n line and store it in a node var

    2.- Read the indent of n+1 line. If n+1 line indent is > than n indent, then n+1 line is a child of n. But if n+1 line indent is < than n line indent then n+1 is a child of n-1 line.

    Is that a good way? I don't know if that will work I haven't try it yet.

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

    How to populate object when initialized without using a constructor?

    Posted: 04 Apr 2018 05:54 PM PDT

    I have an object, which is a data structure. Issue is, I need the data structure to be populated with other objects upon creation and initialization. Normally, I'd do this all in the constructor, but it's a long piece of code to even do this. (In short, I have to pull information from a url (ie. Use a try-catch) and convert it into an object, then toss this object into the arraylist with a for each loop.

    How do I go about this? Will I have to create a separate class that creates the final, populated arraylist and pass it to my other class? Should I be calling methods in the constructor?

    This is in Java, by the way.

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

    Producer-Consumer Problem In Python

    Posted: 04 Apr 2018 05:45 PM PDT

    I'm stuck trying to get this to work and new to the whole concept. If anyone could help that swells. The program has Producer and Consumer threads, which currently do not synchronize themselves between each thread of the same type and also between Consumer and Producer.

    The program processes a file, which contain 3 fields per line: <transaction id>,<sleep time in ms for the consumer>,<sleep time in ms for the producer>.

    The transaction must be processed in a FIFO manner between the producer and the consumer.

    When a producer threads reads a transaction, it increments the idCounter, puts it in the FIFO, then sleeps the number of producer ms specified in the transaction. When a consumer threads gets a transaction from the FIFO, it then sleep the number of consumer ms specified in the transaction before trying to obtain the next transaction from the FIFO.

    import threading from array import array import sys import time from collections import deque #to store the transaction read from the file by the producer fifo = deque() #file to be read by all the consumer transactionFile = open( sys.argv[ 1 ] ) #max number of entry allowed in the fifo object maxFifo = sys.argv[4] #counter to set the internalId of each transaction idCounter = 0 #Transaction object to store the transactionid, producerSleep and consumerSleep #the sleep time is in 1000s of a second class Transaction: def __init__(self, transactionId, producerSleep, consumerSleep): self.transactionId = transactionId self.producerSleep = producerSleep self.consumerSleep = consumerSleep self.internalId = 0; #function used by the producer to read the file, and to queue the transaction in the global fifo def threadProducer(filename): global idCounter with transactionFile: for line in transactionFile: params = line.split(",") t = Transaction( params[0], params[1], params[2] ) idCounter += 1 t.internalId = idCounter print 'Producer:' + t.transactionId + ' internalId:' + str(t.internalId) fifo.append( t ) time.sleep( float( t.producerSleep ) / 1000 ) print 'Producer completed' return #function used by the consumer to get the transaction from the global fifo #it stops when the transactioId is 9999 def threadConsumer (): while True : t = fifo.popleft() if int(t.transactionId) == 9999: break print 'Consumer:' + t.transactionId + ' internalId:' + str(t.internalId) time.sleep( float( t.consumerSleep ) / 1000 ) return #it receives as input the name of the transactionFile, the number of producer, the number of consumer as parameters #and the maximum number of transaction which are allowed at once in the fifo threads = [] print 'Starting producer:' + sys.argv[2] for num in range(0,int(sys.argv[2])): t = threading.Thread(target=threadProducer, args= (sys.argv[1], )) t.start() threads.append( t ) print 'Starting consumer:' + sys.argv[3] for num in range(0,int(sys.argv[3])): t = threading.Thread(target=threadConsumer, args=( )) t.start() threads.append( t ) for i in range(0, len(threads)-1 ): threads[i].join() 
    submitted by /u/SushiSush1
    [link] [comments]

    What are some tech jobs that are more design orientated?

    Posted: 04 Apr 2018 05:42 PM PDT

    I'm still in school and have decided my shift my major towards to be something programming related. I'd love to have a career programming but I think I would be more interested in something that is on the design side such as web designers or graphic interfaces. What are some other jobs that I could look into?

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

    Any hash function gurus here? JavaScript MurmurHash3 vs my custom 64-bit hash

    Posted: 04 Apr 2018 03:45 PM PDT

    JavaScript absolutely sucks for hash functions. The Number object can only safely resolve whole numbers up to 52 bits, and all bitwise operations are bound by 32-bits. This effectively makes it difficult to port any algorithm that doesn't use 32-bit integers (like uint32_t).

    The bottom line is: I want a fast (as fast as possible) hash function with the collision probability matching at least 64-bit. 32-bit is not good enough. If it's 128-bit and still fast? Fine with me.

    My use case? Checksum or error detection. Collisions need to be minimized at all costs.


    I implemented MurmurHash3 (32-bit) here and it's significantly faster than even this so-called "optimized" version of the same algorithm. The only difference is it uses Math.imul from ES6, which is fast.

    I implemented MurmurHash3_x86_128 and it's immesely faster (benchmark) than this JavaScript implementation. Sadly, this specific function seems to be flawed. My version is slightly modified to circumvent the inherent flaw, but I don't have much confidence in it.

    I also implemented: MurmurHash2_160 (unofficial), xxHash_32 and Jenkin's lookup3.c. They perform quite well, but 32-bit MurmurHash1 and MurmurHash2 are the absolute fastest of the bunch.


    I modified MurmurHash2 to squeeze out performance which is pretty much the fastest now. Building from that, I made a 64-bit version, which is even faster than my already fast 32-bit MurmurHash3 implementation.

    Here it is:

    function cyb_beta2(key, seed = 0) { var m1 = 1540483507, m2 = 3432918353, m3 = 433494437, m4 = 370248451; var h1 = seed ^ Math.imul(key.length, m3) + 1; var h2 = seed ^ Math.imul(key.length, m1) + 1; for (var k, i = 0, chunk = -4 & key.length; i < chunk; i += 4) { k = key[i+3] << 24 | key[i+2] << 16 | key[i+1] << 8 | key[i]; k ^= k >>> 24; h1 = Math.imul(h1, m1) ^ k; h1 ^= h2; h2 = Math.imul(h2, m3) ^ k; h2 ^= h1; } switch (3 & key.length) { case 3: h1 ^= key[i+2] << 16, h2 ^= key[i+2] << 16; case 2: h1 ^= key[i+1] << 8, h2 ^= key[i+1] << 8; case 1: h1 ^= key[i], h2 ^= key[i]; h1 = Math.imul(h1, m2), h2 = Math.imul(h2, m4); } h1 ^= h2 >>> 18, h1 = Math.imul(h1, m2), h1 ^= h2 >>> 22; h2 ^= h1 >>> 15, h2 = Math.imul(h2, m3), h2 ^= h1 >>> 19; return [h1 >>> 0, h2 >>> 0]; } 

    Is this a good hash function? Are h1 and h2 uncorrelated enough that the collision probability matches that of a native 64-bit hash?

    It passed my own basic collision and avalanche tests. Can anyone test it on SMHasher or any thorough benchmark? I have no idea how to compile that thing.

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

    Why should I not use a single table for database?

    Posted: 04 Apr 2018 09:37 AM PDT

    I understand that normalizing your database is the most efficient way, but why not a single table for centralized data?

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

    New to C++, struggling with OOP/ inheritance

    Posted: 04 Apr 2018 05:44 AM PDT

    Can someone take a look at my code and explain why it is not running as well as how to fix the problem to get it running? Thank you.

    code: https://pastebin.com/krwNTKA7

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

    Does this school's curriculum look worth it?

    Posted: 04 Apr 2018 02:50 PM PDT

    Hey this is my first post here so I'm not sure how valid of a question this is but I'm wondering if my local university's computer science program looks like it's worth the money and time investment. Alternatively there is also a local community college program that I might also be interested in if it's spectacular looking to you all. With the research I've down however, I've heard associates degrees are usually a waste of time in computer science.

    I know it'll be important for me to have projects outside of school that will look better on my resume and show me passion for programming. I'm just wondering if this specific schools program looks good compared to what others have learned or just in general. I've been interested in learning software development for about year now and after learning via Treehouse and Codeacademy I think this is something I want to pursue as a career.

    Any help is appreciated.

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

    [x-post] Good textbooks/references for software testing philosophies?

    Posted: 04 Apr 2018 02:49 PM PDT

    Note: I previously posted this on /r/learnprogramming and got no responses.

    Hello there,

    When I currently develop software, I generally conduct testing by exhaustive unit testing. While this works, I assume it is rather inefficient in the sense that I'm trying to think of every possible test scenario and end up dwelling on small features.

    I'm curious if there are good textbooks/references to software testing philosophies so I could improve my efficiency and effectiveness. Thanks.

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

    How do you make a batch file overwrite certain files with something?

    Posted: 04 Apr 2018 02:22 PM PDT

    For example: I want to overwrite all files named ''kitty.gif'' with a file called ''penis.gif'' (which is located in the path C:\Windows\penis.gif) . How will I do that? I'm using a Windows 98SE virtual machine.

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

    I want to write my own MIDI hardware/software code. Where should I begin?

    Posted: 04 Apr 2018 10:34 AM PDT

    Let me begin by saying i have zero knowledge in coding. My background has always been in design/audio production. Having said that I think I have always been inclined to see how the machine works.

    I am good at problem solving (thanks google) but more importantly I want to understand the hardware and software that I use in a deeper level. I use Ableton Live 9 and Pro Tools 11 and have access to both Mac and Windows platforms. I want to design my own MIDI controllers or modify my own. My questions are what coding langues should i focus on? Is there a specific degree that would be applicable to this? Or should I focus on learning the code from an online source?

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

    VBA Userform script editing

    Posted: 04 Apr 2018 01:33 PM PDT

    Hello guys, I'm trying to make this code open specific sheets in excel using the exact sheet name as an input to get to it. If the sheet name is not there or spelled incorrectly it should display the "Please use another Sheet name" message. I have this so far. I appreciate your help.

    { Private Sub CommandButton1_Click() Dim Sheetname As String whichSheet = InputBox("In which sheet do you wish to enter data? Specify sheet number as Toner, Copy Paper,etc.", "Input") Dim ws As Worksheet For Each ws In Worksheets Select Case ws.CodeName Case "Toner", "Copy Paper", "Mail Package", "Alteration", "Gloves", "Special Requests" Worksheets(whichSheet).Activate ws.Name Case Else MsgBox "Please use another Sheet name" Exit Sub End Select Next ws

    Worksheets(whichSheet).Activate Dim lastrow lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

    lastrow = lastrow + 1 Cells(lastrow, 1) = TextBox1 If Application.WorksheetFunction.CountIf(Range("A2:A" & lastrow), Cells(lastrow, 1)) > 1 Then MsgBox "Submitting Entry" Cells(lastrow, 1) = ""

    Cells(lastrow, 1) = TextBox1.Text Cells(lastrow, 2) = TextBox2.Text Cells(lastrow, 3) = TextBox3.Value Cells(lastrow, 4) = TextBox4.Text Cells(lastrow, 5) = TextBox5.Text End If

    End Sub }

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

    Need help fixing an undefined identifier

    Posted: 04 Apr 2018 12:47 PM PDT

    I hope this is the right place to ask but I've hit a wall. For some reason, my identifier used in my if-statement within my for loop ("i") is undefined and I don't know why. Can anyone shed some light on my idiocy?
    Here's my code: https://pastebin.com/VrPGP5bn

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

    Rules/Etiquette on Pull Requests because of spelling errors.

    Posted: 04 Apr 2018 12:15 PM PDT

    I wanted others opinions on this. Say if I'm reading through documentation on a repository and I see a spelling error in a code sample:

    var dogHuse = "woof"; // `House` spelled incorrectly 

    Although this example is minor to what I found. Would you submit a PR to fix this? I'm conflicted in that:

    A. There may be more spelling errors. Although I noticed this one, I don't want to feel obligated now to run the whole thing through a spell checker

    B. Maybe it's just me but I'm worried that projects will be overwhelmed with multiple 1 change PR because someone accidentally misspelled something. This might be able to be lumped into a more meaningful code change.

    C. I read https://yihui.name/en/2013/06/fix-typo-in-documentation/, although it mentions it's good practice for people that want to get familiar with Git and Pull Requests. I'm already familiar with this process.

    What do you guys think?

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

    (HELP) What language should I learn next???!!!

    Posted: 04 Apr 2018 12:11 PM PDT

    I am currently enrolled in an AP computer science class at my high school and I have learned python and am just finishing up the intro to JavaScript. Next year I am learning java and was wondering if I should begin learning it on my own over the summer and my free time or if I should pick a different language. The other thing is that I don't know of any good courses (preferably free) that I could use learn it. If anyone has any suggestions that would be appreciated!

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

    Can you suggest the best language and development setup to program biomechanical simulations?

    Posted: 04 Apr 2018 12:03 PM PDT

    What I need to do will look somewhat similar to this, but moving:

    picture

    Basically, I'll need to "animate" very simple shapes with code. I tried using GameMaker Studio, but its array- and map-related abstractions are very low - and I gonna use lots of arrays and hashes. I was hoping there's a better option - I was thinking Ruby-based, or Python. Basically, I'll need to do very little 2D graphics, but quite a lot of relatively complex programming. Can you advise the best language and "graphical" library for this task?

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

    How to find a programmer/partner?

    Posted: 04 Apr 2018 09:54 AM PDT

    I'm interested in finding a good/new programmer who can develop systems or ideas with me.

    There are many simple tools and systems I need for my business that could easily be resold as a business on a subscription basis.

    I have had bad luck finding reliable programmers in the past, even with pay upfront.

    Is there even a market for this? Anyone interested? I'm not sure where to start so any advice is appreciated.

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

    How to hide these elements in YouTube using Tampermonkey?

    Posted: 04 Apr 2018 08:40 AM PDT

    If you click the top left "3 lines" icon, the following tab opens up. I want to hide the red circled elements because I don't really use them. Most likely, it can be done using "GM_addStyle" but I can't select these elements without affecting other parts of the website.

    https://ibb.co/jACAcH

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

    No comments:

    Post a Comment