• Breaking News

    Wednesday, May 2, 2018

    Asking for a raise Ask Programming

    Asking for a raise Ask Programming


    Asking for a raise

    Posted: 02 May 2018 07:38 PM PDT

    I currently am making 55,000 which is well below industry standard and have been working at the company for over a year. I have three major projects under my belt and plan on asking for a raise tomorrow. How should I approach it to maximize the amount I could receive?

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

    Advice requested on an efficient data structure for lisp

    Posted: 02 May 2018 06:39 PM PDT

    Hi all, i'm currently working on my lispy-like language (look in my post history for BearLang) and after profiling found that looking up variables in a local hashtable is ruining performance.

    I was thinking of using this approach to replace the current approach (which uses a hashtable from uthash to lookup values, the pointer to the symbol object is the key):

    1 - When interned by the parser, each symbol is assigned an integer ID

    2 - Each function's environment, instead of using a hashtable, just has a dynamically allocated array big enough so that the integer ID can be a direct offset into the array, enabling immediate lookup.

    Naturally this is very inefficient in terms of memory (though that said, it might be MORE efficient than uthash in some instances), but it should fix some of the performance issues i'm currently having.

    I'm also pondering NOT dynamically allocating a new environment on every function call, but instead allocating just one when the function is created, and on every invocation wiping it - but that means of course that recursive calls that do stuff after recursion (i.e not tail recursive) will not work.

    Anyone got thoughts or suggestions?

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

    How can I get Spyder or another IDE to work with SageMath?

    Posted: 02 May 2018 01:50 PM PDT

    I have to use SageMath for an upcoming project, but I'm kind of new to programming. I would like to have an offline environment to work with in Sage. I've read in some forums that it is possible to use it in Spyder, however I can't get it to work. Does anyone know how this might work or another IDE I might use?

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

    What is something that is either a constant or a variable?

    Posted: 02 May 2018 07:27 PM PDT

    So I have a "thing", it might be a constant (in which case no computation is required), or it might be a variable (in which case evaluation is required each time you want to know its value).

    Is there a name for such a concept? And it there a good way of implementing it in C++?

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

    What free web search APIs (Duck duck go, qwant ecc.ec) are available with a unlimited/very high number of queries ?

    Posted: 02 May 2018 12:50 PM PDT

    I need a web search API that i can include in my software (written in python), I have to do a lot of queries that will take in input a list of strings that are name of products, and with the web search API will output all the urls of web pages where I can buy this products.

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

    5 Years IT Support migrating to programmer.

    Posted: 02 May 2018 10:42 AM PDT

    I am in 5+ years at IT Support/SysAdmin. I am looking to see what it takes to migrate over to a programming position (keep flopping between C#, and JS/Python (vendor neutral). I am not looking to make much, but at least more than I am making now (I currently make sub 40k, and I am barely able to pay for rent). How easy it to get a job being a fresh programmer? Do I need to freelance or intern in order to be accepted as an entry level programmer?

    Background status: ~2 years PowerShell scripting, about 6-9 months learning HTML/CSS, and a few months of indecisive flopping around. Self-taught, HS diploma at best. I do IT, and enjoy it a fair amount, but anything in regards to programming I am in love.

    Any info, recommendations, honesty, wraith is welcome.

    submitted by /u/16o1denRatio
    [link] [comments]

    Help with a Pascal's Triangle problem

    Posted: 02 May 2018 02:03 PM PDT

    Hello, I have been given a problem for a intro the python class and I am at a stand still when it comes to even starting on the problem. I have to make a program that produces a Pascal's Triangle.

    This is the code I have been given in order to start on the problem.

    To complete this assignment, replace the code for the

    combination function with the proper definition.

    def combination(n, k):

    return "C(" + str(n) + "," + str(k) + ")"

    def pascals_triangle(rows):

    for row in range(rows):

    answer = ""

    for column in range(row + 1):

    answer = answer + combination(row, column) + "\t"

    print(answer)

    pascals_triangle(10)

    The requirements for the problem are as follows:

    • Each number in the triangle of size 10 is correct.
    • The numbers are lined up in tabbed columns. Hint: When you create the strings to print, incorporate the tab ('\t') character.
    • The following calls all work as intended: pascals_triangle(1), pascals_triangle(2), pascals_triangle(3) and pascals_triangle(4).
    • A recursive function named combination(n, k) is used to calculate individual values in Pascal's Triangle using this formula:

    📷

    By definition, if k is equal to either n or 0, the answer is 1. The formula is read as a top row and a bottom row. **In other words when you substitute for n you get the information from the top line of the formula (n-1) + (n-1).** * The Python code is properly commented, easy to understand and doesn't contain significant redundancies

    Thank you in advance for any help I am given!

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

    [SQL] Pagination with joined tables?

    Posted: 02 May 2018 05:31 PM PDT

    Hey!

    Say I have a table structure for a blog. Each blog post can contain many blog post comments. It is set out like so:

    CREATE TABLE post ( id BIGINT UNSIGNED PRIMARY KEY, ;; More fields ); CREATE TABLE comment ( id BIGINT UNSIGNED PRIMARY KEY, post_id BIGINT UNSIGNED, ;; More fields ); 

    I want to select all the blog posts plus their comments. That's fine, this query accomplishes that:

    SELECT * FROM post LEFT JOIN comment ON comment.post_id = post.id; 

    Now lets say I want to implement pagination, and only want to fetch posts in chunks of 25. I cannot use LIMIT and OFFSET, because the left joined comments throw off the counts. Instead of paginating to 25 posts, i'd end up fetching less than 25, and some comments would be cut out.

    What's the best way to paginate with LEFT JOINed data?

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

    Parsing string by black spaces and commas & how to handle unions (C++)

    Posted: 02 May 2018 05:58 AM PDT

    I am struggling to figure out exactly how to parse a string to get the data out. I may have to use regex but I may be able to do it easier with string.find.

    My data comes out like this:

    <paramID1 ParamType1 Value1, paramID2 ParamType2 Value2,....> 

    Where paramID can be alpha-numeric or numeric, paramType is alpha-numeric, and value can be int/float/string/etc.

    One thing I did was make a union for paramID and value but for some reason it doesn't allow a string in the union. My first question is, how do you get around that?

    My second question is, what do you think is the best way to parse the data? I assume that regex could be used to look for everything from a point up to a space or comma but is there an easier way with string.find?

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

    How to efficiently store and search Base64 strings?

    Posted: 02 May 2018 10:12 AM PDT

    I am wondering if there are any databases that have a datatype designed specifically for Base64 strings, or any other pre-existing tools that can help store a large amount of Base64 strings as well as read/write to them optimally. I can always just dump them in varchar but I thought there might be something out there specifically designed to handle them better than a conventional string.

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

    Of the average person's best computer today, how many flop (float ops) can be requested by and returned to CPU within the same .01 second range of time?

    Posted: 02 May 2018 03:36 PM PDT

    of course I mean when copying between ranges of memory and device sync is not the bottleneck, such as matrix multiply is a higher bigo of flops than memory copies.

    I am not interested in hardware thats optimized in a way that sacrifices response time that gamers expect, nor do I claim such softwares are less important than any critical business system (as games are normally thought of), even if the kind of calculations are not normally done in games since my realtime interactions with users are not limited to that.

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

    Payment processing for POS software

    Posted: 02 May 2018 03:30 PM PDT

    Hey everyone,

    I'm writing my own POS software designed specifically for fast food restaurants. I am stumped on how to handle payment. Cash is obviously easy, just open the till and calculate change. I would like to know how to handle card payments, and what sort of things i would need to do it

    Keep in mind i do not own a EFT terminal, those are expensive and I am a university student.

    Thank you all

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

    How do I Update a Mongoose Model Array?

    Posted: 02 May 2018 11:12 AM PDT

    I am fairly new to programming so I apologize if there is a very simple answer to this question.

    I am trying to create a simple website where users can upload multiple images and have those images be displayed somewhere else on the website. I am accomplishing this with Mongoose, Express, and Node. I am using Multer as the uploading middleware and I am also using body parser which I've heard can cause complications when used with Multer. I am using the Cloudinary API to upload and host the uploaded images.

    Ideally, the user would select which images they want to upload, those images would be uploaded to Cloudinary, then the direct link to each image would be saved in the Mongoose Model for that particular post and then each image would be displayed using the image link that has been saved.

    So far, I have everything working perfectly except for one issue. The issue that I am running into is when I try to push the supplied link for the uploaded image into the Mongoose Model array, I receive an error and I cannot figure out a workaround.

    Here is the code where the images are uploaded and pushed into the array:

    var imageLength; var newImage = new Array(); router.post("/", isLoggedIn, upload.array("image"),function(req, res){ image: []; imageLength = req.files.length; for(var i = 0; i < imageLength; i++){ cloudinary.uploader.upload(req.files[i].path, function(result) { // add cloudinary url for the image to the campground object under image property newImage.push(result.secure_url); console.log(newImage[i-1]); console.log(req.body); req.body.campground.image.push(newImage[i-1]); console.log(req.body); }); } 

    Here is the Mongoose Model for "campground":

    var mongoose = require("mongoose"); var campgroundSchema = new mongoose.Schema({ name: String, image: [String], image_id: [String], description: String, author: { id: { type: mongoose.Schema.Types.ObjectId, ref: "User" }, username: String }, comments: [ { type: mongoose.Schema.Types.ObjectId, ref: "Comment" } ] }); module.exports = mongoose.model("Campground", campgroundSchema); 

    And here is the error that I receive:

    https://res.cloudinary.com/jpisani/image/upload/v1525280683/r1cs0zmjrznopot7lmu9.jpg { campground: { name: 'g', description: 'g', author: { id: 5aaaf25986f338289129f8ea, username: 'frff' } } } /home/ubuntu/workspace/YelpCamp/v10/routes/campgrounds.js:50 req.body.campground.image.push(newImage[i-1]); ^ TypeError: Cannot read property 'push' of undefined 

    As you can see, the image successfully uploaded to Cloudinary and I have a direct link to that image. The issue lies in console.log(req.body);. There is no image property listed which prevents me from pushing the link into the image array.

    I understand that req.body only contains what has been submitted by the user but I have not found a solution to this problem with any other method.

    Here is the code for the create a new post page:

    <div class="row"> <h1 style="text-align: center">Create a New Campground</h1> <div style="width: 30%; margin: 25px auto;"> <form action="/campgrounds" method="POST" enctype="multipart/form-data"> <div class="form-group"> <input class="form-control" type="text" name="campground[name]" placeholder="name"> </div> <div class="form-group"> <label for="image">Image</label> <input type="file" id="image" name="image" accept="image/*" multiple required> </div> <div class="form-group"> <input class="form-control" type="text" name="campground[description]" placeholder="description"> </div> <div class="form-group"> <button class="btn btn-lg btn-primary btn-block">Submit!</button> </div> </form> <a href="/campgrounds">Go Back</a> </div> </div> 

    As you can see, the image upload portion of this code(found in the center) is named "image" which should make the image array in the Mongoose Model appear when I console.log(req.body); but it does not seem to do this.

    If any information is required please ask, I will respond promptly. Any help would be greatly appreciated. Thanks in advance.

    Edit: A solution has been found! For anyone coming across this in the future, here is the answer to the problem.

    //create - add new campground to DB router.post("/", isLoggedIn, upload.array("campground[image]"), async function(req, res){ // add author to campground req.body.campground.author = { id: req.user._id, username: req.user.username }; req.body.campground.image = []; for (const file of req.files) { let result = await cloudinary.uploader.upload(file.path); req.body.campground.image.push(result.secure_url); } Campground.create(req.body.campground, function(err, campground) { if (err) { return res.redirect('back'); } res.redirect('/campgrounds/' + campground.id); }); }); 
    submitted by /u/bootlesgg
    [link] [comments]

    How do most commercial software handle large files?

    Posted: 02 May 2018 10:26 AM PDT

    I've been learning C++ and one thing I've been looking into is to how write/read binary files. One thing that bothered me is the method used to edit/remove registries in an existing binary file (or even a text file for that matter).

    Pretty much every tutorial I look into said that the best way to edit a registry in a binary file is to store the file in a buffer, edit that buffer, write that buffer to a file with a different (temporary) name from the original file, delete the original file and then rename the temp file to the original file.

    This works perfectly fine when we're talking about small files, but what about large files that are accessed and edited frequently, isn't it inefficient and slow to wipe a file and rewrite it from scratch? I've read that you can actually edit a file without wiping it, but you have to change the exact same amount of bytes of your registry, no more and no less, so this method is rarely used by anyone.

    Let's take Microsoft SQL Server as an example, where its database files can easily reach GBs in size. What happens when the user edits or deletes a row a in a large database file, are the contents of the file copied to a smaller buffer one at a time and then written to another file or does the SQL Server use something akin to memory mapped file?

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

    Please anyone helpp[C++]

    Posted: 02 May 2018 01:52 PM PDT

    I am trying to make a calculator using functions for each operation in C++ I wrote this but it gives lots of errors, and I don't know how to fix

    double addition(int num1, int num2, char choice); double substraction(int num1, int num2, char choice); double division(int num1, int num2, char choice); double multiplication(int num1, int num2, char choice); int main() {

     int num1, num2; char choice; cout << "Enter the first number : " << endl; cin >> num1; cout << "Enter the second number : " << endl; cin >> num2; cout << "Enter + if you want to apply addition operation" << endl; cout << "Enter - if you want to apply substraction operation" << endl; cout << "Enter / if you want to apply division operation" << endl; cout << "Enter * if you want to apply multiplication operation" << endl; cout << "Enter Q if you want to quit(please don't :/)" << endl; cin >> choice; cout << addition(num1, num2, choice); cout << substraction(num1, num2, choice); cout << division(num1, num2, choice); cout << multiplication(num1, num2, choice); while (choice != 'Q') { cout << "Enter the first number : " << endl; cin >> num1; cout << "Enter the second number : " << endl; cin >> num2; cout << "Enter + if you want to apply addition operation" << endl; cout << "Enter - if you want to apply substraction operation" << endl; cout << "Enter / if you want to apply division operation" << endl; cout << "Enter * if you want to apply multiplication operation" << endl; cin >> choice; } } double addition(int num1, int num2, char choice) { if (choice == '+') { double result = 0; result = num1 + num2; return result; } } double substraction(int num1, int num2, char choice) { if (choice == '-') { double result = 0; result = num1 - num2; return result; } } double division(int num1, int num2, char choice) { if (choice == '/') { double result = 0; result = num1 / num2; return result; } } double multiplication(int num1, int num2, char choice) { if (choice == '*') { double result = 0; result = num1 * num2; return result; } } 
    submitted by /u/m_elfaq
    [link] [comments]

    Should I choose Docker Containers to package applications? Or is there a better option.

    Posted: 02 May 2018 01:06 PM PDT

    Just read this https://www.scalablepath.com/blog/get-started-docker-windows/ and I'd love to get opinions on whether Docker Containers are really a good way to package an app. Or is there a better way?

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

    4 Join on Mysql bad?

    Posted: 02 May 2018 07:52 AM PDT

    I have query that goes like so:

    SELECT * FROM a JOIN b ON a.id = b.id JOIN c ON c.id = b.id JOIN d ON d.id = c.id JOIN e ON e.id = b.id WHERE b.condition = 1;

    Assuming proper indexing, is this a bad call to make?

    I know as a general rule you want to limit hits on the DB, but doing this call would provide me with a lot of duplicate information.

    The other options is to grab information from table a and b and then do a loop to get data from d and e. This would give me only the data that I need, but would hit the DB significantly more. DB optimization is driving me nuts, so I'm just wondering what others thoughts are.

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

    How to properly allocate an array of strings in C

    Posted: 02 May 2018 01:54 AM PDT

    Been trying this for a while and came up with:

    int main(void) { int l_size; int i, j; scanf("%d", &l_size); char **str_list; str_list = (char **)(malloc(sizeof(char*) * l_size)); for (i = 0; i < l_size; i++) str_list[i] = (char *)(malloc(sizeof(char) * MAX_LEN + 1)); for (i = 0; i < l_size; i++) scanf("%s", str_list[i]); for (i = 0; i < l_size; i++) printf("%s\n", str_list[i]); return 0; } 

    Also, what's the correct way of dealocating all those pointers in the list? Can I just use one: free(str_list);

    or do I have to loop through each element?

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

    How to expand on basic programming knowledge

    Posted: 02 May 2018 07:42 AM PDT

    Hi, I am a physics major but want to learn programming skills. I know the absolute basics they teach in introductory level courses in Java, C++, Python but I have no idea how to progress from there and do real projects? Are there resources for guided bigger projects or could someone give me some advice? Thank you!

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

    Trying to figure out how to automate repetitive tasks in BAS system based in java.

    Posted: 02 May 2018 07:30 AM PDT

    The program is called Niagara, it is an implementation of the BACnet protocol, and I'm trying to figure out how to interact with the navtree via a script that will repeat a specific kind of task. The documentation doesn't seem to be written with this sort of thing in mind, and seems to assumed you've already read a nonexistent getting started guide. I am still trying to figure out how to compile and run code in the program, and have been looking through the companies forums online. I'm a bit lost at this point. Any guidance would be appreciated.

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

    boolean equation from truth table

    Posted: 02 May 2018 12:19 AM PDT

    is there a way to find the best possible equation?

    there are a few tools that will produce sum-of-products or p-of-s, but they are not even considering using xor and are unable to produce the best equation for my reference test cases.

    also, putting a suboptimal SOP or POS solution from these tools into gcc or clang does not produce the optimal equation either in assembly code. isn't a compiler supposed to be able to do this kind of thing?

    thanks for help

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

    Full stack developer job requirements in India?

    Posted: 02 May 2018 11:13 AM PDT

    Hey there! You guys probably already know I'm a student? I'm looking to know what employers look for in candidates for a full stack developer job in India (I'm living and learning in India). Help me out, please?

    I have a background in programming. I can make okayish console applications (don't expect any operating systems yet) using, you know, 'desktop programming languages' like C++/Java/Ruby/some others I have forgotten but can refresh, and I can make nice shiny web apps using HTML/CSS/JS (add in PHP/NodeJS which I've just started learning?) and a working knowledge of SQL

    Please clarify:

    • What qualifications (degree) candidates are supposed to have - will a bachelor's in electronics/communications engineering suffice?
    • Does it matter a lot which college I study in?
    • How much experience is required? Can a youth fresh out of college make it into a good place?
    • What technologies are we supposed to know? Apparently LAMP stacks went out of vogue? One source says ReactJS is a de facto qualification; another says MEAN stack; a post on Reddit (I do't remember which) says "[If you can whip up a webpage using Bootstrap/Foundation in minutes, or an SPA using jQuery in minutes, then you've probably got yourself a place]"
    • Will things like background knowledge and experimentation (of front/back-end development technologies) be considered? If so, I can link to my codepen or github!
    • What exactly do employers look for in us?

    I know the above qualities vary significantly from employer to employer, and that I'm being very specific; so please give me the average, or how you would select an aspirant.
    Also, if you want me to include just how full-on crazy I've been going trying to sort my life out, then here you go.

    Thanks very much!

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

    Restarting git project from scratch

    Posted: 02 May 2018 01:39 AM PDT

    Hello there! I need some advice. I have a project from a few years back that is about 80% complete. I'm revisiting it now to complete it. However I found several flaws on the core of the program, along with outdated tools and some uhh... ugly code. So I decided I'll just start from scratch.

    Is it worth keeping the repo and build on top of it, or should I just create a new one?

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

    No comments:

    Post a Comment