• Breaking News

    Sunday, December 31, 2017

    Does anyone ever spend a whole day writing code and feel like they get very little done? Ask Programming

    Does anyone ever spend a whole day writing code and feel like they get very little done? Ask Programming


    Does anyone ever spend a whole day writing code and feel like they get very little done?

    Posted: 31 Dec 2017 07:35 PM PST

    So I work as a professional, but I have a side project where I'm using Thymeleaf for the first time. There are a lot of plug-ins and technologies which just do not play well with it, and the documentation is for it is both spotty yet verbose. I've spent over six hours today writing code, and I have part update functionality complete.

    It makes me feel like a bad programmer. Am I the only one who gets like this? I keep telling myself it's a new tool and I don't have this problem at work or with tools I'm familiar with -- but this was like, very demotivational.

    Happy new year, by the way.

    submitted by /u/Modus--Tollens
    [link] [comments]

    [Javascript] Need multiple forms to be handled by the same javascript function.

    Posted: 31 Dec 2017 07:15 PM PST

    I have multiple forms on the page that are identical. I need a single javascript function to handle all of them and get the submitted form object so it can be serialized and sent and data returned and then processed and such. Th How would I do this? My issue is I don't know how to get the submitted form object so it can be processed within the function. I could give them different ids, but how would I get which id was clicked?

    <form ..... onsubmit="OnFormSubmit()" id="1">....</form>

    <form ..... onsubmit="OnFormSubmit()" id="2">....</form>

    <form ..... onsubmit="OnFormSubmit()" id="3">....</form>

    function OnFormSubmit(){ var frm= ????? frm.submit(function (e) { e.preventDefault(); console.log(frm.serialize()); $.ajax({ type: frm.attr('method'), url: frm.attr('action'), data: frm.serialize(), success: function (data) { console.log('Submission was successful.'); }, error: function (data) { console.log('An error occurred.'); } }); } 
    submitted by /u/PlexP4S
    [link] [comments]

    Is it reasonable to write a program that uses an online database for searching people and taking information?

    Posted: 31 Dec 2017 07:07 PM PST

    So I am trying to be vague here while also giving the required info for a decent answer, but this is kind of hard to explain. I am a compsci student at university and the only languages I currently know are java and C, but will soon be learning python as well. I know that Python is usable for internet applications though and for taking data from online sources, but I have no experience with how robust this is. I have seen it used for data research for reddit and stuff, but I really don't have a grasp on how robust it can be.

    Basically what I am trying to do it organize information from an online person finder database. So I would need the program to basically be able to log onto the site, search a list of names, and take some of the info and organize it, etc. but is that doable reliably considering that you have to log into the site every time and do a lot of copying and pasting and what not? The site would probably flag it as a bot, but is there an easier/ more legal way? Would it need to "physically" open up the browser and do everything or could it do all of it in the background? Is there an easier way to do stuff like this?

    I just need to get a decent grasp on the capabilities of python and programming with browser data. Thanks for the help in advance.

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

    How can an object have O(n) attributes?

    Posted: 31 Dec 2017 06:41 PM PST

    https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/lecture-2-models-of-computation-document-distance/

    https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/lecture-videos/MIT6_006F11_lec02.pdf

    In the lecture, Dr. Demaine says a python object with a constant O(1) number of attributes corresponds to the model of a pointer machine. How could an object in python have more than a constant number of attributes? He mentions messing with dictionaries, does this involve nested dicts?

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

    What's the best way to statistically extract the parameters passed to specific functions in a programming language?

    Posted: 31 Dec 2017 02:39 PM PST

    I want to get the parameters passed to specific functions in JavaScript. For example, in the following code snippet, my target function is console.log, I want to get the values "foo", "bar", and "baz4"

    console.log("foo") a = "b" + "a" + "r" console.log(a) console.log("baz" + Math.sqrt(16).toString()) 

    I need to do this statically, so hooking the function to a proxy won't work here. I don't need to support evaluation of all the functions in the language, just a specific set of them (may also include a few from external libraries).

    What's the best tool to accomplish such a thing?

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

    Need help getting a specific unicode character

    Posted: 31 Dec 2017 12:48 PM PST

    Hey guys,

    I want to type a unicode symbol that essentially combines í and ị, but the nearest I've been able to get is ị́ (if this doesn't render well on your browser try notepad), which is close but I want the letter i to be dotless (as in í).

    Any help would be greatly appreciated :)

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

    public input of map locations to a private resource?

    Posted: 31 Dec 2017 01:27 PM PST

    I'm looking to start a database whereby members of the public can input location data which I can then collate or map all the pins on one map.

    I'm concerned about privacy for individual's submissions, so I want to have an availability for people to drop a pin based on their own input to the survey and for the people who have submitted data to not be able to view other pins. This will also maintain integrity and independence of results.

    This is going to be for an agricultural and rural population so a user friendly interface would be important and for the sake of integration with other platforms or ability to extrapolate data, a mainstream platform would be ideal.

    Anyone have any suggestions? I'm an environmental student so I'm used to data collation, manual collection and statistical analysis. A survey on any large scale is outside of my skills at the moment!

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

    Need help writing windows batch file for loop

    Posted: 31 Dec 2017 01:17 PM PST

    Hello, I'm looping through all sub directories and then doing stuff to the files/folders inside.
    However, there are certain folders I need to exclude but I'm not sure how to do that.
    So given a for loop such as this:

    FOR /d /r "topDir" %%G in (*foo*) DO ( echo %%G ) 

    is there a way to exclude certain folders?
    Specifically do not echo anything if the folder name is foobar.
    But do echo if it contains foo and is anything but foobar

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

    Is it possible for someone to determine my location based on IP or some other factor if I am broadcasting on an ssl/https website?

    Posted: 31 Dec 2017 01:16 PM PST

    I know next to nothing about most tech stuff, I hope this is the right place for this. I am wanting to broadcast myself on a website but want to maintain my privacy and safety. Is it possible for someone to determine my location through my IP address on a site that uses ssl/https (ex. chaturbate)? I have no idea if those designations mean anything about security, but I read that I should only use a site with those designations and I am a bit worried about someone being able to track me or find out where I am.

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

    Problem with passing a array with refrence.

    Posted: 31 Dec 2017 05:44 AM PST

     #include <iostream> using namespace std; int bin_search(int (& arr)[10], int low, int hi, int target){ if(low > hi) return -1; else{ int mid = low + (hi-low)/2; if(arr[mid] < target) bin_search(int (& arr)[10], int mid + 1, int hi, int target); else if(target < arr[mid]) bin_search(int (& arr)[10], int lo, int mid - 1, int target); else return mid; } } int main(){ int array[10] = {3,12,23,45,56,78,89,123,456,899}; cout << bin_search(array, 0, 9, 123) << endl; } 

    I have this code for binary search and this code gives error on recursive calls to my bin_search function but not to my main funtion. I am not able to figure out what is wrong here. I searched and found this method of passing a array through refrence.

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

    Python- Am I handling string encoding correctly after my switch from Python2 to Python3?

    Posted: 31 Dec 2017 04:18 AM PST

    Hi Guys

    Compliments of the season to you all!

    As described, I recently switched from P2 to P3 and have encountered some issues with text encoding. I think I've solved them, but would really appreciate if someone could comment on the correctness of my understanding/method.

    Application involves:

    1. Webscraping with beatifulsoup;
    2. storing text in sqlite3 database;
    3. Periodically accessing sqlite3 database and performing string operations on the stored text.

    2. storing:

    in python2:

    text = soup.find(...).get_text() would return a bytestring. I then encoded this as utf-8 using text.encode('utf-8') and stored it.

    in python3:

    string is unicode by default

    text.encode('utf-8') now returns bytes which I don't want, so I must remove the .encode('utf-8') and the behaviour will be exactly as it was in python 2.

    3. accessing:

    text stored by code run in python2 that included .encode('utf-8'):

    type(text) is unicode and I can perform string operations on this

    text stored by code run in python3 that included .encode('utf-8'):

    type(text) is bytes. I need to include text = text.decode() which will convert the text to unicode.

    After this, I can perform string operations on my text which is now unicode.

    Going forward: Having made the change under the "2. storing" heading, text will continue to be stored as unicode with my system running python3 and any text accessed from sqlite3 will automatically be ready for string operations.

    Thanks very much for your time!

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

    [Interpreter] What should I keep in mind when designing a IR?

    Posted: 31 Dec 2017 07:00 AM PST

    Hello

    This is a follow up question : original question

    I'm starting to think about what my IR will look like in my interpreter. My end goal is to compile my language to a Stack Based VM Bytecode (also made from scratch)1, but, to make some optimizations easier, I need to use a IR, but I have a few questions :

    • Should I use SSA ? I've read that it's something you mostly use to perform optimizations in large compilers, but it's not really worth it for small language because it's complicated to implement and produces small, barely noticeable optimizations.

    • Should my IR and my Bytecode be the same thing?

    • If the answer to the 2 last questions is yes: Is it possible to use SSA in a stack based bytecode ? (Can you show me an example of how it would look like?), *and more generally, is it possible to implement the most common optimization techniques in the bytecode ? (Tail call elimination, Loop unrolling, constant propagation/folding,etc)

    • If applicable : Is it possible to implement optimizations such as Constant Propagation without SSA, and in a stack-based bytecode?

    • If I need to use a separate IR, how should it look like ? 3 Adress code ?

    If you can provide an example with your answer to help me understand what you say, that's even better :p

    Thanks !

    1 Example code : foo = bar()2 + 1 compiled

    callfunc bar iconst 2 iexp // exponential operation iconst 1 iadd istore foo 
    submitted by /u/Kywim
    [link] [comments]

    I hate asking these kinds of questions but I'm really confused while deciding my career. Should I go with c and kernel development Or Java and Android development?

    Posted: 31 Dec 2017 02:38 AM PST

    Quick question about assert(ions).

    Posted: 31 Dec 2017 03:47 AM PST

    If a have some method

    public void something(){ ... do something assert 2 == 1; } 

    shouldn't I get a AssertionError if I tried using the Method? - Because I am not. Or am I misunderstanding something about how to use assertions?

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

    Books suggestions for Regex/Regular expressions

    Posted: 31 Dec 2017 02:13 AM PST

    Hey guys,

    I'm trying to learn some regex. I did find some online websites with nice explanations, however I'd also like a book to read inbetween. Currently I'm checking out reviews for "Mastering regulard expressions" and "Regular Expressions Cookbook".

    Since I'm fairly new to this topic, I'm looking for a book with simple step by step explanations and/or lots of examples.

    What are your opinions on these books or just in general? Thank you!

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

    How can I automatically update this program with a batch file?

    Posted: 30 Dec 2017 11:27 PM PST

    Hey y'all. I'm not much of a programmer but do love to tinker with stuff. One of my hobbies is emulation and I play a LOT of PCSX2. The dev builds are updated fairly often too.

    I think it'd be super convenient to download the latest version of it from the following buildbot by clicking a batch file from my desktop. I tried using wget but didn't have a lot of luck. Any suggestions?

    https://buildbot.orphis.net/pcsx2/

    Thanks!!


    [link] [comments]

    No comments:

    Post a Comment