|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On November 05 2014 23:40 Gowerly wrote:I posted that link and then realised I didn't mean it. If I'm in Ruby, I will put braces in differently. If I'm doing something like myArr.each { |item| item.DoThing() }
then my braces are like that. I don't know if Ruby even works without it as I'm still rather new.
For ruby if you want to one-line a block you use braces, otherwise you use do ... end
# one liner with braces my_array.each { |item| item.do_thing }
# better one-liner my_array.each(&:do_thing)
# even better results = my_array.map(&:thing)
#block my_array.each do |item| item.do_thing end
A couple stylistic things: local variable and function names should be snake_case No parens if you're not passing anything to the function
|
On November 06 2014 22:55 djookz wrote: Hey guys, I've been an avid reader since this page came out but never felt the urge to make an account, but upon seeing this thread for the first time now (Usually not looking at General), I wanted to ask if some people here use R? I'm starting a large data analysis project at work, so I've been doing a lot of research on various solutions. Looking at R it seems very useful for expressing complex mathematical expressions succinctly. Using it within Hadoop map/reduce jobs wouldn't be the worst thing the world, but Python, Mlib, and GraphX on top of Spark make it kind of an out-of-the-way solution.
If I were working with a smaller data set and focusing on machine learning R would be on the short list.
|
On November 07 2014 11:49 CatNzHat wrote:Show nested quote +On November 06 2014 22:55 djookz wrote: Hey guys, I've been an avid reader since this page came out but never felt the urge to make an account, but upon seeing this thread for the first time now (Usually not looking at General), I wanted to ask if some people here use R? I'm starting a large data analysis project at work, so I've been doing a lot of research on various solutions. Looking at R it seems very useful for expressing complex mathematical expressions succinctly. Using it within Hadoop map/reduce jobs wouldn't be the worst thing the world, but Python, Mlib, and GraphX on top of Spark make it kind of an out-of-the-way solution. If I were working with a smaller data set and focusing on machine learning R would be on the short list. If you are a fan of shell scripting, perl, javascript and other inconsistent, ugly languages, then r is just for you.
|
Apparently R is beautiful if you're a mathematician versus a programmer. Read somewhere that the language constructs are designed to feel good for math usage.
|
Hi guys. I'm developing a web application in Ext JS 4.2.
I have a floating form where I have a print button which prints the form programmatically. I got the code from this wordpress website. So far, it works great if the form contains basic fields such as text fields, labels, images.
However, I'm starting to have problems printing a form with a Grid Panel and a Property Panel in it. Most of the time (around 9 times out of 10), when the print dialog comes up, it shows "Print Preview Failed". In instances that it does print, the bottom and right borders of the Grid Panel and the Property Grid doesn't show up at all - even if the form in the browser shows that my borders are there.
What I've done so far is I copy pasted my web app folder and tinkered with the duplicate. I've confirmed there that removing the Grid Panel and the Property Grid makes the printing process more consistent. Now I'm thinking that the CSS of the Grids may be messing me up. I've tried asking in StackOverFlow but they haven't answered.
Edit 1: The CSS doesn't matter.
Edit 2: Found a different way to do this using a different class, however, I'm having a tough time including an Ext.ux class while using the MVC framework.
Question in SO is over here
|
On November 05 2014 23:59 Manit0u wrote:Ok guys, now I have a different problem... Had to switch branches with the code, all looks fine, except there's 2x more code like stuff I posted on the previous page. I ignore it for the moment but there are other funny things happening. 1. Compiling this code to .war produces file that's 5x smaller than previously, probably missing some dependencies... 2. Errors be thrown: java.lang.NoClassDefFoundError, definitely dependencies are missing... 3. 'mvn depdendency:resolve' downloads all the required stuff, 1 and 2 remain unchanged. Help? I've recompiled the code like 15 times now, updated everything, all looks cool and dandy, maven is able to install, clean package and all that jazz, but it doesn't work  And yes, all deps are properly included in pom.xml and class that's throwing the error does import the right thing.
You make any progress on this? Did you switch maven versions from 2 to 3? Are you able to replicate the old build at all? Are you able to do a diff on the branches to see how the pom is different?
Just because the code compiles doesn't mean that you have have all your dependencies. If you are using internal libraries that don't declare their dependencies correctly then maven cannot correctly pull in all the transitive libraries. Did you mark all your dependencies as provided for some reason?
Do you have the old war file? Trying to spot the difference of which jars are in the old and not the new should help more quickly point you to why they are in the old but not the new.
|
C# - How I can draw a triangle using a cycle The size is set by the user. Please help. I can only make squares.
|
generic lambdas in c++ are so god damned, so GOD DAMNED COOL.
![[image loading]](http://stream1.gifsoup.com/view4/1401111/home-alone-2-marv-electrocuted-o.gif) screeeeaaaaaaaaaaaaaaaaaaaaaaaaaam!
|
On November 10 2014 02:50 berated- wrote:Show nested quote +On November 05 2014 23:59 Manit0u wrote:Ok guys, now I have a different problem... Had to switch branches with the code, all looks fine, except there's 2x more code like stuff I posted on the previous page. I ignore it for the moment but there are other funny things happening. 1. Compiling this code to .war produces file that's 5x smaller than previously, probably missing some dependencies... 2. Errors be thrown: java.lang.NoClassDefFoundError, definitely dependencies are missing... 3. 'mvn depdendency:resolve' downloads all the required stuff, 1 and 2 remain unchanged. Help? I've recompiled the code like 15 times now, updated everything, all looks cool and dandy, maven is able to install, clean package and all that jazz, but it doesn't work  And yes, all deps are properly included in pom.xml and class that's throwing the error does import the right thing. You make any progress on this? Did you switch maven versions from 2 to 3? Are you able to replicate the old build at all? Are you able to do a diff on the branches to see how the pom is different? Just because the code compiles doesn't mean that you have have all your dependencies. If you are using internal libraries that don't declare their dependencies correctly then maven cannot correctly pull in all the transitive libraries. Did you mark all your dependencies as provided for some reason? Do you have the old war file? Trying to spot the difference of which jars are in the old and not the new should help more quickly point you to why they are in the old but not the new.
A bit of progress. I managed to get old war to work on a new server partially. The biggest problem is the server configuration at the moment, because I have the old war (which is working on an old server perfectly) but I have no sources for it, only the compiled classes and there are no deps included in the old war, they're installed globally on the old server but I can't find them The dude who was setting it up did some truly magic things.
|
On November 10 2014 08:34 nunez wrote: generic lambdas in c++ are so god damned, so GOD DAMNED COOL. screeeeaaaaaaaaaaaaaaaaaaaaaaaaaam!
too bad the syntax for c++ lambdas is absolutely unreadable ;-;
|
|
|
Is there anyone who can help me with Apache Nutch? I need to match comments with articles from a website. Comments in the website have a url to the article in www.domain.com/?p=##### format but it redirects to www.domain.com/headline-of-the-article-identifier. Looks like i need to index original target urls as well in case of redirects. Edit: To be more clear, i am asking how can i get the value of original target urls and add them to nutchdocument for indexing? I am not hopeful to get an anwser but this is the best place on this forum to ask.
|
Hey i am currently learning classes and multiple files using headers. C++
I am running into an issue where i have 2 classes, two different .h files. One class holds all the functions for displaying information, labeled display.h, and the other holds all the information gathered from the user. information.h. (the classes are corrispondingly named).
I want to have the header file of information.h inside of my display.h. I have been reading about header gaurds, but i am not sure how to implement them. Any assistance would be great. I have yet to be formally introduced to these header file concepts, but am trying to figure it out regardless.
Here is what i understand. -at the top of the header file
display.h
#ifndef headername #define headername
#include "information.h" /* all content of .h file? Unsure. */
#endif
I cant seem to get it to work, and am a little confused on the header gaurd concept. Do i do this for every header? Does it go into main aswell? Any help will be great. I can easy finish my task without this, but i really want to understand this for my own desire.
|
relevant wiki-material: one definition rule!
display.h:
#ifndef DISPLAY_H #define DISPLAY_H
#endif in a translation unit, the first time the file display.h is included (barring any unfortunate circumstance), the macro DISPLAY_H is undefined, so the code between #ifndef DISPLAY_H and #endif will be compiled. the key point is that this code conatins the definition of the macro DISPLAY_H (second line of the code)!
the next time display.h is included in that same translation unit, the macro DISPLAY_H (barring any unfortunate circumstance) is now defined, and the code between #ifndef DISPLAY_H and #endif will be ignored.
thus any function definition within display.h will only appear once.
personally i just use #pragma once instead of header guards. this is not unproblematic, but it hasn't been a problem for me yet
|
On November 10 2014 19:26 actionbastrd wrote: Does it go into main aswell? Since it wasn't explicitly answered I'd like to mention that you do indeed only need header guards for header files (.h).
|
On November 10 2014 08:34 nunez wrote:generic lambdas in c++ are so god damned, so GOD DAMNED COOL. ![[image loading]](http://stream1.gifsoup.com/view4/1401111/home-alone-2-marv-electrocuted-o.gif) screeeeaaaaaaaaaaaaaaaaaaaaaaaaaam!
Haha, you're such a nerd. Do you work? If yes, I imagine your company hasn't yet transitioned to C++14 if there is a working compiler at all.
On a different note, I'll soon have to re-install Windows on my personal computer, and I wonder whether I should stick with Windows 7 or Windows 8.1. I've read Windows 8.1 is 'faster' but is that really true?
|
i have a part time programming job alongside my studies. i haven't used generic lambdas there yet though (~supported by vs14), but used decltype(auto) for return type deduction!
here's a pretty neat, and super terse way of defining a type trait via overloaded function definitions:
#include<iostream> #include<type_traits> using namespace std;
float type_trait(int); double type_trait(char);
template<class input> using type_trait_t=decltype(type_trait(*(input*)(0))); //altenatively decltype(type_trait(declval<input>()))
template<class input> type_trait_t<input> func() { return 0; }
int main(){ static_assert( is_same<decltype(func<int>()),float>::value&& is_same<decltype(func<char>()),double>::value, "type trait test fail" ); } the input type you want to specialize the trait for is placed as the argument type in the function overload definition, and the output type of the trait is placed as the return type. the output type for a given input type is produced by letting the compiler deduce the return type of the function call with a declvaled
the test is succesfull if it compiles, and it does. it doesn't impose any restrictions on the input types constructibility as the type traits output is deduced from an unevaluated context (inside decltype).
haven't tested it out much yet, as i only realized it was a viable approach today after writing that post about header guards, but in the cases i can get away with this instead of using nested type-aliases i think i prefer it.
here's the more common variant for comparison:
#include<iostream> #include<type_traits> using namespace std;
template<class input> struct type_trait;
template<> struct type_trait<int> { using type=float; };
template<> struct type_trait<char> { using type=double; };
template<class input> using type_trait_t=typename type_trait<input>::type;
template<class input> type_trait_t<input> func() { return 0; }
int main(){ static_assert( is_same<decltype(func<int>()),float>::value&& is_same<decltype(func<char>()),double>::value, "type trait test fail" ); }
|
Hey guys, quick C question :
Assume I have a linked list of structures containing structures containing an int and a string, and that I have to keep all this information through different calls to the function that creates and manages the list. I define the list as static, and this part seems to be working, but when I try to access the structures inside it segfaults on the second call to the function. I did not defined those as statics, is this where the error comes from ? I assumed only keeping the list of pointers would work...
|
If this was C++ and you had a class that housed a linked list, then declared a static instance of that class within a function, I'd say you were safe, and that any segfaults were likely an issue with your implementation of the linked list.
However in C, it depends. How are you allocating the memory for the structures that you are attaching to the static list header inside the function?
|
relevant code in the .c
int get_next_line(int const fd, char **line) { int ret; static t_list *files; t_list *cursor; t_file *new_file;
ret = 0; if (files) { cursor = files; while (cursor && cursor->content && ((t_file *)cursor->content)->fd != fd) cursor = cursor->next; if (cursor->content && ((t_file *)cursor->content)->fd == fd) ret = ft_read_file(fd, cursor->content, line); } else { if (!(files = (t_list *)ft_memalloc(sizeof(*files)))) return (-1); if (!(new_file = (t_file *)ft_memalloc(sizeof(*new_file)))) return (-1); cursor = ft_lstnew(new_file, sizeof(*new_file)); ((t_file *)cursor->content)->fd = fd; ((t_file *)cursor->content)->left_over = 0; ft_lstadd(&files, cursor); ret = ft_read_file(fd, cursor->content, line); } return (ret); } in the .h
#ifndef GET_NEXT_LINE_H # define GET_NEXT_LINE_H
# define BUFF_SIZE 32 # define EOF "\n"
#include <string.h>
typedef struct s_list { void *content; size_t content_size; struct s_list *next; } t_list;
typedef struct s_file { int fd; char *left_over; } t_file; The segfault happens with the second call to get_next_line, when if (files) is checked and the program tries to access cursor->content->fd.
|
|
|
|
|
|