|
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 September 05 2017 02:30 sc-darkness wrote: I've got another question. Has anyone dealt with large databases (MySQL specifically) where you have more than 500,000 records in a single table? Is it really supposed to be that slow to delete thousands of records but not all? I'm sure 'truncate' is really fast, but is solution really to have hourly/daily/monthly tables which you just truncate rather than delete one record at a time? Again, I emphasise on deleting some records but not all.
Are the columns you are deleting by indexed? That's usually the first thing to look at when encountering SQL performance problems.
Calendar column indices can also be finicky in MySQL. An EXPLAIN statement may reveal something that's not immediately obvious. Sometimes it's possible to use tricks like finding the first and last row to delete and then just use the primary key in the delete statement. But that only works if the rows are inserted in the same order as the calendar column increases.
In any case, tables in the order of 500k rows should usually be quite manageable, just need to find the right schema and queries.
|
I'm not sure if columns are indexed, but that's something I need to check. Thank you. I was wondering why MySQL could be a bitch when I know there are companies out there with millions of customers. Maybe indexing is the issue here.
|
On September 05 2017 03:55 sc-darkness wrote:I'm not sure if columns are indexed, but that's something I need to check. Thank you. I was wondering why MySQL could be a bitch when I know there are companies out there with millions of customers. Maybe indexing is the issue here. 
First of all, MySQL is pretty much abandonware now (that's why you get MariaDB by default in Debian systems now). PostgreSQL is much better as a freeware RDBMS as it has a lot more features (like native support for arrays and JSON, GIN indices) and is more actively developed.
The companies with millions of customers rarely use a single database (or even database type, you can have some RDBMS for critical stuff that needs to be kept in sync, neo4j for storing relations that would be a pain to get in a regular RDBMS, CouchDB for documents etc. etc.).
Either way, unless you perform heavy joins you should be fine even with millions of records. We've been recently testing PGSQL and fetching/deleting/sorting through millions of rows can be done in ~200ms (assuming proper indexing), and that's with uuid instead of int id (which is slower). Also, cascades do matter in this case. If you're deleting millions of records at a time and you have some cascades/checks/triggers on each row for them then it might take some time to finish.
|
On September 05 2017 03:55 sc-darkness wrote:I'm not sure if columns are indexed, but that's something I need to check. Thank you. I was wondering why MySQL could be a bitch when I know there are companies out there with millions of customers. Maybe indexing is the issue here.  I do hope you are using a single delete statement to delete the rows. But then it shouldn't take that long, so you must be doing something out of the ordinary.
|
doing a ruby project, need to check the content of strings
per the directions, the strings can have: commas, uppercase and lowercase letters, numbers, underscores, dashes, periods, apostrophes, forward slashes.
I'd like to validate that I can check for this with:
if !(string_name !~ /[^-_0-9a-zA-z_.',/]/)
edit: well it looks like the forward slash needs something special, at minimum but I don't know what... trying to find out. just now learning regex
edit2: ok, maybe: if !(string_name !~ %r[^-_0-9a-zA-z_.',/]) ?
|
On September 05 2017 05:31 travis wrote:doing a ruby project, need to check the content of strings per the directions, the strings can have: commas, uppercase and lowercase letters, numbers, underscores, dashes, periods, apostrophes, forward slashes. I'd like to validate that I can check for this with: if !(string_name !~ /[^-_0-9a-zA-z_.',/]/)
edit: well it looks like the forward slash needs something special, at minimum but I don't know what... trying to find out. just now learning regex edit2: ok, maybe: if !(string_name !~ %r[^-_0-9a-zA-z_.',/]) ?
Don't use "if !cond" in ruby, use "unless" instead.
NAME_REGEX = %r{\A[-_0-9a-zA-z_\.',\/]*\z}
def valid_name?(name) return false unless NAME_REGEX.match(name)
true end
valid_name?('alpha-01-abc./,') # => returns true
And for practicing regex, I suggest you use this: https://regex101.com/ This site is really good for checking your patterns. It also explains everything in there.
|
I'm 99% sure that you can use c++ in unity in some form or another.
|
On September 05 2017 11:02 Manit0u wrote:Show nested quote +On September 05 2017 05:31 travis wrote:doing a ruby project, need to check the content of strings per the directions, the strings can have: commas, uppercase and lowercase letters, numbers, underscores, dashes, periods, apostrophes, forward slashes. I'd like to validate that I can check for this with: if !(string_name !~ /[^-_0-9a-zA-z_.',/]/)
edit: well it looks like the forward slash needs something special, at minimum but I don't know what... trying to find out. just now learning regex edit2: ok, maybe: if !(string_name !~ %r[^-_0-9a-zA-z_.',/]) ? Don't use "if !cond" in ruby, use "unless" instead. NAME_REGEX = %r{\A[-_0-9a-zA-z_\.',\/]*\z}
def valid_name?(name) return false unless NAME_REGEX.match(name)
true end
valid_name?('alpha-01-abc./,') # => returns true
And for practicing regex, I suggest you use this: https://regex101.com/This site is really good for checking your patterns. It also explains everything in there.
I second that. This is great page, very helpfull. Just dont rely on it without thinking.
|
On September 05 2017 20:01 Silvanel wrote:Show nested quote +On September 05 2017 11:02 Manit0u wrote:On September 05 2017 05:31 travis wrote:doing a ruby project, need to check the content of strings per the directions, the strings can have: commas, uppercase and lowercase letters, numbers, underscores, dashes, periods, apostrophes, forward slashes. I'd like to validate that I can check for this with: if !(string_name !~ /[^-_0-9a-zA-z_.',/]/)
edit: well it looks like the forward slash needs something special, at minimum but I don't know what... trying to find out. just now learning regex edit2: ok, maybe: if !(string_name !~ %r[^-_0-9a-zA-z_.',/]) ? Don't use "if !cond" in ruby, use "unless" instead. NAME_REGEX = %r{\A[-_0-9a-zA-z_\.',\/]*\z}
def valid_name?(name) return false unless NAME_REGEX.match(name)
true end
valid_name?('alpha-01-abc./,') # => returns true
And for practicing regex, I suggest you use this: https://regex101.com/This site is really good for checking your patterns. It also explains everything in there. I second that. This is great page, very helpfull. Just dont rely on it without thinking.
You shouldn't rely on anything without thinking 
Also, travis, if you're working with ruby, please install and use this gem: https://github.com/bbatsov/rubocop It will help you a lot in the beginning (and stuff like RubyMine integrates with it seamlessly).
|
On September 05 2017 11:02 Manit0u wrote:Show nested quote +On September 05 2017 05:31 travis wrote:doing a ruby project, need to check the content of strings per the directions, the strings can have: commas, uppercase and lowercase letters, numbers, underscores, dashes, periods, apostrophes, forward slashes. I'd like to validate that I can check for this with: if !(string_name !~ /[^-_0-9a-zA-z_.',/]/)
edit: well it looks like the forward slash needs something special, at minimum but I don't know what... trying to find out. just now learning regex edit2: ok, maybe: if !(string_name !~ %r[^-_0-9a-zA-z_.',/]) ? Don't use "if !cond" in ruby, use "unless" instead. NAME_REGEX = %r{\A[-_0-9a-zA-z_\.',\/]*\z}
def valid_name?(name) return false unless NAME_REGEX.match(name)
true end
valid_name?('alpha-01-abc./,') # => returns true
And for practicing regex, I suggest you use this: https://regex101.com/This site is really good for checking your patterns. It also explains everything in there.
While I like the refactor, why have the useless not in there in the first place?
NAME_REGEX = %r{\A[-_0-9a-zA-z_\.',\/]*\z}
def valid_name?(name) return true if NAME_REGEX.match(name)
false end
I dunno. I just prefer testing the positive case to the negative (if you can), even though "do.. unless" is far more intuitive than "if not".
|
On September 05 2017 21:47 Acrofales wrote:Show nested quote +On September 05 2017 11:02 Manit0u wrote:On September 05 2017 05:31 travis wrote:doing a ruby project, need to check the content of strings per the directions, the strings can have: commas, uppercase and lowercase letters, numbers, underscores, dashes, periods, apostrophes, forward slashes. I'd like to validate that I can check for this with: if !(string_name !~ /[^-_0-9a-zA-z_.',/]/)
edit: well it looks like the forward slash needs something special, at minimum but I don't know what... trying to find out. just now learning regex edit2: ok, maybe: if !(string_name !~ %r[^-_0-9a-zA-z_.',/]) ? Don't use "if !cond" in ruby, use "unless" instead. NAME_REGEX = %r{\A[-_0-9a-zA-z_\.',\/]*\z}
def valid_name?(name) return false unless NAME_REGEX.match(name)
true end
valid_name?('alpha-01-abc./,') # => returns true
And for practicing regex, I suggest you use this: https://regex101.com/This site is really good for checking your patterns. It also explains everything in there. While I like the refactor, why have the useless not in there in the first place? NAME_REGEX = %r{\A[-_0-9a-zA-z_\.',\/]*\z}
def valid_name?(name) return true if NAME_REGEX.match(name)
false end
I dunno. I just prefer testing the positive case to the negative (if you can), even though "do.. unless" is far more intuitive than "if not".
Technically, it could all be refactored to this:
# we want a perdicate here that only returns boolean values # Regex.match can return an object or nil def valid_name?(name) %r{\A[-_0-9a-zA-z_\.',\/]*\z}.match(name) ? true : false end
In my original example I wanted to keep the sense of what travis was trying to accomplish (for some reason he needed the condition when the name doesn't match) and I wanted to illustrate unless vs if !. Unless is such an elegant construct in ruby - it makes reading the code a lot easier and natural (so does the ability to put guard clauses at the end of statement).
|
I have never touched ruby, but can't you do somethig like:
return !NAME_REGEX.match(name).nil? Seems pretty awkward to me to have these "if (condition) true else false" statements since the result mirrors the condition. Apparently it is slightly obscured because of implicit conversion from object to bool in ruby? Actually, can't you just cast the result of match to bool in some way? After all the language kinda does it to evaluate the condition anyways.
Also is there no isMatch method? Has come in handy in .net a bunch of times.
|
On September 06 2017 16:39 spinesheath wrote:I have never touched ruby, but can't you do somethig like: return !NAME_REGEX.match(name).nil? Seems pretty awkward to me to have these "if (condition) true else false" statements since the result mirrors the condition. Apparently it is slightly obscured because of implicit conversion from object to bool in ruby? Actually, can't you just cast the result of match to bool in some way? After all the language kinda does it to evaluate the condition anyways. Also is there no isMatch method? Has come in handy in .net a bunch of times.
In reality, it depends on your Ruby version and if you need to do something with the matches (like printing out what did and what didn't match). For simple boolean return you should use other things:
2.4+ use Regexp#match? (notice the ? sign at the end) which is heavily optimized version of it (especially for more complex regexes).
pre 2.4 you have to do a bit of workarounds like above. Even the "=~" operator returns first match offset or nil if it didn't match (which can be awkward to check against as it can return 0 for a match). "!~" operator will always return a boolean but is a negative match condition so it might also be awkward to use (negating the negation) and hard to read at times.
Also, you don't need a return statement in Ruby if it's going to be just this single line. Ruby methods return the result of last operation in them by default.
In summary:
# Ruby < 2.4 def valid_name?(name) !(NAME_REGEX !~ name) end
# Ruby >= 2.4 def valid_name?(name) NAME_REGEX.match?(name) end
|
edit: nevermind, problem isn't what I thought it is.
|
Anyone have a sugestion of a language to learn for personal interest? I feel fluent in c, c++, python, java, and javascript. Leaning pretty heavily towards haskell.
|
|
On September 07 2017 14:23 Nesserev wrote:Show nested quote +On September 07 2017 11:56 bo1b wrote: Anyone have a sugestion of a language to learn for personal interest? I feel fluent in c, c++, python, java, and javascript. Leaning pretty heavily towards haskell. For Haskell, the biggest problem is getting your paws on a book/source to learn from that fits your taste. - Learn You a Haskell by Lipovaca (free) - Haskell Programming from First Principles by Allen, Moronuki (<-- my recommendation, it's great) - Programming in Haskell by Hutton - Real World Haskell by O'Sullivan, Goerzen and Stewart Other than that, you could potentially look at Prolog? It's deceptively easy, and the computational model and theory behind it is pretty interesting if you start going deeper. Both are definitely worth picking up.
If you already know C, go with Lisp. These are the 2 programming languages that all the others stem from. It'll be relatively easy then to grasp any other language.
|
Haskell programming from first principles looks like a really good book, thanks for the recommendation 
On September 07 2017 20:19 Manit0u wrote:Show nested quote +On September 07 2017 14:23 Nesserev wrote:On September 07 2017 11:56 bo1b wrote: Anyone have a sugestion of a language to learn for personal interest? I feel fluent in c, c++, python, java, and javascript. Leaning pretty heavily towards haskell. For Haskell, the biggest problem is getting your paws on a book/source to learn from that fits your taste. - Learn You a Haskell by Lipovaca (free) - Haskell Programming from First Principles by Allen, Moronuki (<-- my recommendation, it's great) - Programming in Haskell by Hutton - Real World Haskell by O'Sullivan, Goerzen and Stewart Other than that, you could potentially look at Prolog? It's deceptively easy, and the computational model and theory behind it is pretty interesting if you start going deeper. Both are definitely worth picking up. If you already know C, go with Lisp. These are the 2 programming languages that all the others stem from. It'll be relatively easy then to grasp any other language. Only reason I'm not is I feel like I have a fairly vague understanding allready from editing my emacs quite a lot. I'll doubtlessly learn it anyway as I keep going forward.
|
Anyone here know iOS development? I know squat and my current work is forcing me to learn on the fly.
Our app is supposed to have a dynamic menu wherein depending on the logged-in user's role, he might not be able to perform several of the actions on that menu.
What's the best way to implement this? I was thinking of making a static table view and just hiding cells that the user shouldn't have access to. Is this the right approach or am I better of making a dynamic view, and populating the menu based on what roles the user can do? Just worried about how navigation will work as well with a dynamic menu.
|
I made a dynamic view before for a big name app. Just implement it however you can manage. For me I used run-time defined constraints, and manually added/removed different elements from the view via code. I used auto-layout just to setup an initial state and place things that aren't dynamic. It was quite a lot of work.
|
|
|
|