• Breaking News

    Wednesday, January 16, 2019

    Just "finished" my first Chrome extension, and would love some feedback / a code review! learn programming

    Just "finished" my first Chrome extension, and would love some feedback / a code review! learn programming


    Just "finished" my first Chrome extension, and would love some feedback / a code review!

    Posted: 15 Jan 2019 06:56 PM PST

    Code link


    Hey everyone, my name is Jared and I just finished my first Chrome extension (or, at least mostly finished)! This is definitely the largest thing I've ever built on my own. I am looking to have it code reviewed, because I would like to put it on my resume as I start to look for internships. And of course, I'm sure everyone can help me improve it :). I am a second year CSE student, for reference.

    What the extension does:


    This extension is essentially a tab manager + note taker. I had the idea for it when I realized I always had way too many tabs open in Chrome. However, I didn't just want to close the tabs, because they often had something notable in them (e.g., an interesting fact, something about computers or programming that I'd like to note, etc etc etc). So my idea was to make an extension where I could save a tab away, along with a note summarizing whatever I wanted to remember about that site. I figured this would be a good way to learn too, cause I've always found trying to summarize topics a great way to learn them. I also wanted there to be a tag system.

    That is what the extension, which I am tentatively calling Capture, does. When you are on a site, you can press Alt+S or click the extension's icon which pops up a little dialog box that looks like this. Here is where you enter your note about the site, along with any tags you may want (prefaced by a #). You then click Save. I am (again tentatively) calling each site+note combination a "snip".

    You can then hit the Open Snips button to get this. This is the main UI of the extension, where you can see all your Snips, filter by tags, read over and edit your notes, delete a snip, and reopen the site you took the snip on (the titles are clickable links). There is also an "Export all Snips" button so that data never gets "stuck" in the extension. The sidebar is fixed; the main part of the page is where you can scroll through all your snips.

    One last thing to note: the tag system. Filtering by a tag works by clicking on the tag in the sidebar, toggling it on and showing only the snips with that tag, like this. You can also click on multiple tags to show a union of snips: i.e., if the prog and css tags are on, then it will show both the snips with the prog tag and the snips with the css tag, like so. Deselect All button works as you'd expect.

    Code explanation


    Chrome extensions are basically zipped bundles of HTML, CSS, and JS. They also contain a manifest.json file that tells Chrome some basic info about the extension. See here for more about them -- any web developer could build one :).

    In my extension, I also used PouchDB as a database. PouchDB is a NoSQL database, so it stores data in unstructured documents. Each document contains an _id field used to retrieve it from the database. Essentially (as far as I understand) PouchDB is a nice wrapper API for "lower level" database technologies, like IndexedDB. It can also do some handy stuff like keeping databases in sync, but the extension doesn't do any of that. It just uses the local storage on your machine. It is also worth noting that the PouchDB API is asynchronous.

    Speaking of databases, here are how the two databases that the extension uses are set up:

    1. The dbForSnips database

    This database stores snip objects, which have the following properties:

    Property Description
    ._id date of the when the snip was created, and also the unique id used to get it out of the db
    .url URL of the site the snip was created on
    .title title of site the snip was created on
    .snipText the note associated with the snip
    .tags an array of all the tags in this snip

    2. The dbForTags database

    My idea here is that I wanted to keep a database that keeps a [tag]--->[array of snip ids with tag] mapping, so that it would be easy to look up snips with a certain tag. That is what this second database does: its objects are structured like so:

    Property Description
    ._id a tag, and of course the unique id used to get this object from the databse
    .snipsWithThisTagArray an array of all the ._id's of the snips with this tag

    I figure from here on out the easiest way to explain the code would just be to go file by file:

    manifest.json is just the manifest file for the extension; nothing too interesting here.

    popup.html and popup.css define the layout and styling of the aforementioned popup / dialog box. popup.js contains the code used to save snips, and keep the two databases up to date. This code regrettably uses a global variable, but I tried to be clear about exactly when and where it will be updated. I couldn't think of a more elegant solution to the "user may click save multiple times on a page, but only one snip should be saved" problem.

    snipModule.js just defines one function, deleteSnip(), that is used in two different JS files in the extension. As it turns out, deleting a snip is no trivial task, because you have to update the dbForSnips, but you also have to keep the dbForTags up to date (eg, remove that snips entry from any of it's previous tags). So that's why that is abstracted out.

    snips.html and snips.css define the main UI of the extension, the one seen here. snips.js is the main bulk of the extension. This is what renders all the snips into the page, and keeps the tags up to date on the side, whilst also adding in the "tag filter" functionality. Again, regrettably, I do have one global variable here that I use. It is heavily commented, but again it's there cause I couldn't think of a better solution. Here I use it to keep track of the snips that should be rendered based on the users tag selection / whether or not they have clicked the "deselect" button.

    Lastly, contact.html, export.html, and export.js are all just in there to make the Export All Snips and Contact buttons on the Main UI work (they just open those pages).

    What I would like reviewed


    The main thing I would like reviewed is my JS code. I think I did alright, but I do think it could be better.

    When I started the project, I did not have any knowledge about asynchronous code (so I actually learned a ton doing this!). But as a result, I stuck with the basic callback technique throughout the project for async code. PouchDB actually supports the more modern Promises and Async/await techniques though, and I probably should migrate to those. I do notice the callback depth gets a little deep in places. So I figure that could be one area of improvement.

    There may also me more idiomatic JS that I didn't use. If I'm being a dummy anywhere, please feel free to call me out.

    Lastly, the UI of the extension may still need work too. If anyone has any advice for that, it would be much appreciated. See above images for examples of the UI.

    All in all, I would be appreciative of any and all advice you could give me! Even HTML and CSS -- I'm sure there is still more I could learn there too.

    My hope is that this project could help me in my internship hunt. Any specific advice on securing an internship would be welcome too; I will have this on my GitHub when I start applying (assuming ya'll don't tear it to shreds, haha).

    TL:DR


    Made a Chrome extension called Capture. It lets you take a note with a website, then save it away in a database. I call those note-site combos "snips". You can then view all your snips on a page that looks like this. On that page you can also do things like filter by tag(s). It uses the PouchDB API for the database, and runs with two databases, a dbForSnips and a dbForTags. Mostly looking on advice about my JS Code; any idiomatic practices I missed? Anything particularly dumb I did? Got an idea on how to get rid of those two annoying global variables? Did I structure anything wrong? Any advice is appreciated. Thanks for reading! :)

    Edit: rearranging post.
    Edit 2: fixed some grammar and worded some things a little better.
    Edit 3: just wanted to mention that I need to go to bed because I have quite a few classes tomorrow, so it will be awhile before I can respond to anyone. But I am definitely NOT ghosting this thread, and I have REALLY appreciated the feedback I've gotten so far! I will thoroughly respond to it all, I promise. Thanks so much everyone!

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

    Coding Bootcamps: Everything you need to know!

    Posted: 15 Jan 2019 06:53 AM PST

    Hello everyone! I'm Chris from the YouTube channel Dev Coffee. I've been browsing this subreddit for a while now and noticed a lot of questions pertaining to coding bootcamps. I have not only graduated from a coding bootcamp but I also had the opportunity to work at one for several months. I made a video outlining the entire process of choosing a coding bootcamp to what lies in store after graduation. If anyone has any specific questions feel free to comment on this post and I would be more than happy to answer. Thanks so much.

    https://youtu.be/xZQtIL6dUBQ

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

    A husband and wife learning to code

    Posted: 15 Jan 2019 09:23 PM PST

    My wife and I are learning to code. I have only begun and my wife will start shortly. I am currently working on JS and will go on to study HTML, CSS and some node.js

    My wife wants to be able to do web design. I mainly want to learn any code that I should be able to make money in if I dedicate myself.

    The reason I'm taking on JS is because I found a group of people and we will work on it together and create projects. I learn best this way. Also because JS is widely used.

    So my question is this. Should my wife learn all the code I'm doing? Or start with something more back end and we can work together on projects and learn from each other building new skills?

    Also another question if you want to learn HTML,JS,and CSS. What do you recommend for learning back end. I know there's lots of options. I guess what I'd like to know is what is a disirerable / indemand language that can go together with HTML, JS, and CSS.

    Thanks in advance :)

    btw someone suggested my wife learn Ruby on rails. I haven't had a chance to find out why yet though.

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

    looking for a website to teach me c#

    Posted: 15 Jan 2019 04:18 PM PST

    hi, so i wanted to do game design (im pretty young, 14) and do it for a career, and the first thing i want to learn is how to code. i plan on using unity3d so i need to learn c#. all i really am asking for is sites that teach you c# for free (preferably) so i can start making games! would be greatly appreciated!

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

    Need help setting up simple (exe file)

    Posted: 15 Jan 2019 11:44 PM PST

    atleast i think its simple.. my coding skills are 0 to a negative 1.

    Anyways, i day trade, and when i win i want my keyboard to light up green.. so i have managed to fix that.. my trading software automatically opens up a random .exe file of my chosing when a position wins, the random .exe file is connected to my "keyboard profile" which in turn lights up green.

    So i might go for lunch, come back and see my green keyboard..and im happy because i know i just won a trade. (it´s more a fun thing, than a necessity)

    Now, i´d like to set up a winning streak mode..i.e when this .exe file is opend 3 times in a row, i want automatically that another .exe file upens up which will call "winstreak.exe" Then i can go to my keyboard profile, set up a nice effect for that.

    Logic: Trade wins > tradewin.exe > keyboard lightsup trade wins > tradewin.exe > keyboard lightsup trade wins > tradewin.exe > keyboard lights up

    And here is where id like another .exe file to be opened automatically after 3rd consecutive time

    winstreak.exe opens up >keyboard lights up in another color.

    I hope you understand me, as english is not my primary language, neither do i understand coding lol.

    EDIT: the reason why im chosing this path, is because keyboard profile can only be linked to a "software" EDIT2: The exe files do nothing, they are just there so that i can connect a "keyboard profile"

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

    (Swift) Where is the best info for begginer/intermediate leveled programmers? (apple user)

    Posted: 15 Jan 2019 05:57 PM PST

    To begin, Ive created several simple IOS apps, and a simple game app; also for IOS. Creating the template for an app come easy for me, the Swift coding is obviously learned through experience so im working on that. Although im bouncing around youtube and random other websites to learn more.

    Also id like to move onto coding games for platforms such as on website broswers, which im assuming i should start with unity or java language?

    Does anyone know where i can go to find a more outlined and organized classes, preferably free. Although im focused on learning how to code games.

    Thanks and sorry if im coming off as an extreme newbie.

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

    Help coding on java) Pairing files by clicking

    Posted: 15 Jan 2019 09:25 PM PST

    First I will apologize if the English of the post is awkward.

    I started programming about a week ago, so I actually know nearly nothing about coding. I am trying to make a program that changes file names. For example there are two files A, B, C and D. When you click these files in ABC order A and B becomes a pair and C and D becomes a pair and when you click change the file name of B changes to the name of A and D to C.

    I searched on google and found out how open files and how to change file names. But I wasn't able to find how to pair the files by clicking them. So I am searching help for coding the part mentioned in bold.

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

    Creating my first full stack website

    Posted: 15 Jan 2019 09:13 PM PST

    I found a great visual to layout the steps of a web developer and a lot of terminology to google and learn more about but I quickly got overwhelmed. See: https://github.com/kamranahmedse/developer-roadmap

    I am a mechanical engineer by degree but I loved my c++ class in college. I am pretty inclined but feel kind of lost when deciding what front end, back end, scripting language to use. I want to build a website where I can start to showcase projects and etc. It is really just a starting point to get me coding. Learn by doing as they say. One project idea is connecting to a finance api, storing data, scheduling and doing some analysis on stock data etc to learn some of those concepts. For that reason, I was leaning towards using python with django. That way I can be more efficient by learning only one language right now but I feel like there may be better options to learn for front/back end and I don't want the hype of python for data science and ML to affect my decision for web development. I should probably mention I am on a linux os.

    What frameworks/languages do you recommend? I do not care about what is trendy but only what is going to be a solid foundation to build on and eventually switch career paths. For that reason, I have been hesitant to diving in with the MERN stack for 4 reasons. It seems trendy, I want to learn relational databases first, I want to learn a coding language other than just JS, and while I could create my website faster I think a lot of the magic will be done for me behind the screen and I want to learn it.

    LAMP? MERN? Django? Ruby on rails? Spring?

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

    [Python, HTML] Dynamic HTML Table creation from Python objects.

    Posted: 15 Jan 2019 05:11 PM PST

    Hi all,

    I'm trying to build a calculator for a product management game, I have a class; psudeocode:

    Class Factory: name = String days = Integer item = String ingredient1 = ClassObject(Factory) OR Integer ingredient_1_required = Integer ingredient_1_factory_required = Integer ingredient2 = ClassObject(Factory) OR Integer ingredient_2_required = String ingredient_2_factory_required = Integer ingredient3 = ClassObject(Factory) OR Integer ingredient_3_required = Integer ingredient_3_factory_required = Integer produce_per_month = Integer 

    I want to be able to print it dynamically to a HTML table structure so that it appears in a similar fashion to this bad mspain drawing: https://i.imgur.com/Io3nYfu.png so that all the factories will print their children under themselves, until there are no children left to print.

    Any help would be greatly appreciated :) Many thanks! edit: slightly better image

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

    Beginner looking for project advice

    Posted: 15 Jan 2019 08:55 PM PST

    Hey everyone,

    I've been looking to pick up programming and was wondering if I could use a program for a real world scenario. I draft contracts for a living and was wondering if I could create something that pulls certain information from Salesforce to a Microsoft word template. Kind of like the old mail merge technique except I want to write something ymself. What would be a good language to research? Is it even practical?

    Thanks

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

    As I've just started with CS Degree. I want to know which is the best option between Web Development and Android Development?

    Posted: 16 Jan 2019 12:28 AM PST

    I'm very confused while selecting the best option for me. And what will be the best one for me in future technologies? Please guide me in depth. What should I learn and why should I?

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

    Any advices for a beginner wanting to learn about AI?

    Posted: 15 Jan 2019 06:33 AM PST

    Hey guys, so I recently just became freshman in college studying CS. While most of my friends have already started to learn C++, Python, Java,... and wanting to become a software engineer, or game developer,... I'm still struggling to find my own path.

    I've always been fascinated, interested in technology but for months, studying in school hasn't helped me at all and I don't know how to learn, to work in order to stand out in a bunch of people.

    Can you guys give me some advices on how to start learning and which kind of resources should I be searching for? I would be so grateful, thank you so much!!!

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

    How do I use a local variable from a function with parameters/arguments on another function?

    Posted: 15 Jan 2019 08:19 PM PST

    I was wondering if anyone could explain to me how come I'm able to use a local variable from another function in this example:

    def func1(): a=8 b=9 return a,b def func2(x,y, func): a,b = func() z=x+y+a+b return z a=func2(4,6,func1) print(a) #Prints '27' 

    And when I have a function with parameters/arguments, like this:

    aVariable = 1 def func1(number): a=8 b=9 number = number + 1 return a,number def func2(x,y, func): a,number = func() z=x+y+a+number return z a=func2(4,6, func1) print(a) 

    I get this when I run it:

    TypeError: func1() missing 1 required positional argument: 'number' >>> 

    And how would I fix this? I've been trying things out for a couple hours.

    Many thanks in advance.

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

    C++ project with data structure and algorithm?

    Posted: 15 Jan 2019 11:35 PM PST

    Hi,

    What a good project in C++ where I need to use datastructures and algorithms?

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

    I wrote an article explaining Python decorators, focusing on the fundamentals

    Posted: 15 Jan 2019 11:44 AM PST

    Here is the article. I started from the fundamentals, explaining the object-oriented nature of Python, and how functions are first-class citizens in Python. Hope it helps you and would love your feedback!

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

    how do I "correctly" append to json using python?

    Posted: 15 Jan 2019 10:52 PM PST

    import json def inputter(): #with open("/home/foulek/dev/Python/TEMP Language/fartakamé.json", "w+") as dictionary: words = {} word = str(input("Add a new word: ")) engword = str(input("It's english translation: ")) wordtype = str(input("Enter it's type: ")) definition = str(input("Define it: ")) usecase = str(input("Use case example: ")) additional = str(input("Additional information(None for none): ")) newword = {} newword["engword"] = engword newword["wordtype"] = wordtype newword["definition"] = definition newword["usecase"] = usecase newword["additional"] = additional words[word] = newword with open("/home/foulek/dev/Python/TEMP Language/fartakamé.json", "a") as dictionary: dictionary.write(json.dump(words, dictionary, indent=1)) print(dictionary) print(word,"has been sucessfully saved to dictionary") inputter() 

    now this is the output in the json file when I add a second word in there:

    { "A": { "engword": "A", "wordtype": "A", "definition": "A", "usecase": "A", "additional": "A" } }{ "B": { "engword": "B", "wordtype": "B", "definition": "B", "usecase": "B", "additional": "B" } } 

    how do I make it output correctly?

    EDIT: Code is not spacing correcly so i edited

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

    Is there a library to get all installed software on ANY OS?

    Posted: 15 Jan 2019 10:47 PM PST

    I'm actually writing in Java. But I've done a bit of research, it seems there currently is no library/dependency to help retrieve all installed OS in Linux, Windows, and macOS.

    Question: Is there any programming language/script which I can invoke via Java to give me a list of all installed software?

    Notes:

    • Should also be able to install without opening up a browser as what I'm writing is a Desktop client that's supposedly to be downloaded by who knows who and uses who knows what linux or windows or mac
    • I'd still prefer if it was native Java. Although I've seen that I can retrieve installed software by executing a command line in Java, I'm simply looking if there's a better way.
    submitted by /u/imthecapedbaldy
    [link] [comments]

    Please some one help me with my JS snake game

    Posted: 15 Jan 2019 10:41 PM PST

    Hey guys I'm making a snake game in JS. The original problem i was working on was trying to get the game to stop running by using clearInterval(game); once the snake head makes contact with the edge of the canvas. Once I figured that out it created a new problem. You can't ride the snake on the edge of the canvas. This is a problem because the food will generate on the edge sometimes. Any ideas, I'm stumped. Thanks:)

    http://jsfiddle.net/yd0n8k1j/1/

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

    Pretty specific question about Visual Basic programming in my class

    Posted: 15 Jan 2019 06:41 PM PST

    Hey all, I had a question about Visual Basic, you see in my programming place we are replicating a pong game and I'm almost done except on the collision parts sometimes the pong ball will hit a ladle and change directions really fast in the paddle, until I move it. I'm pretty new to programming, especially VB so if you reply please keep it simple.

    Thanks to all who reply

    Here's a little thing of what my code is:

    If pongball. Left <= leftpaddle.right and pongball.top <= leftpaddle.bottom and pongball.bottom>=leftpaddle.top then

    {pongball changes direction} End If

    A few things: I can't have it just if it =, it has to be <=/>= because it moves at intervals more than 1

    Edit: I think what is happening has to do with the changing direction. It might be that when it changes direction it doesn't wait long enough to try to change the pongball's direction again, so it thinks it isn't going to the opposite side.

    Is there a way to make it wait before trying to do something again?

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

    Various questions on programming career while being self-taught.

    Posted: 15 Jan 2019 10:00 PM PST

    So I have done some minor coding in the past with VB.Net and am interested in potentially making a career out of it but the fact is I don't think college is realistic. With that in mind what learning resources do you guys recommend to cover things that would be required in a team setting? Any programming logic courses I should take and anything along those lines? What languages would you say are the top 3 most important?

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

    Need help with solving a python question

    Posted: 15 Jan 2019 09:54 PM PST

    I'm a beginner learning python and I've been a bit stumped about the answer to a question. I have the question and the answer here. If someone could explain why that is the answer and the reasoning and logic behind it, that would be awesome! Thanks in advance!

    Question:

    Define a function called 'myfunc' that takes in a string, and returns a matching string where every even letter is uppercase, and every odd letter is lowercase. Assume that the incoming string only contains letters, and don't worry about numbers, spaces or punctuation. The output string can start with either an uppercase or lowercase letter, so long as letters alternate throughout the string.

    Answer

    here

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

    Searching for fellow programming learners

    Posted: 15 Jan 2019 08:17 AM PST

    I've been learning programming(web development and Python) for a year now and I have trouble finding anyone near me who is also interested in it. I heard it's good to be surrounded by fellow learners to progress faster and get motivated, especially with programming and this subreddit seems like a perfect place to get to know some people for that. I'm usually not the social type, but if anyone is interested in sharing progress, projects, advice or just talk tech then I'm down for it. We can text somewhere or talk on Skype. Comment if you're interested.

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

    Picking first project

    Posted: 15 Jan 2019 09:45 PM PST

    Hey so I am a junior in high school and I began learning python around 2 months ago. I've been watching videos and doing mini projects to learn the language, but want to start applying for summer internships by the end of next month. Are there any simple projects that would look good on a resume that I could finish in the next couple of weeks with my current knowledge of the language? I have a couple of hours everyday to program.

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

    No comments:

    Post a Comment