Hello! Founder of Code Climate here. A few random thoughts:
In short, it's an important issue to consider. For most organizations using GitHub.com or BitBucket, CodeClimate.com is a good fit. For organizations using GitHub Enterprise or Atlassian Stash behind the firewall, our Code Climate Enterprise product can be deployed along side it, behind the firewall also.
If you'd like to discuss security further, or learn more about Code Climate Enterprise, feel free to contact me at anytime. My email is bryan@ our domain name.
James was the founder of /r/ruby almost seven years ago: http://www.rubyinside.com/ruby-gets-its-own-reddit-702.html
There's more information on https://news.ycombinator.com/item?id=8804624 which includes that he was in Mexico and involved in a car accident.
I'm not totally sure why there's not more activity in the comments. There's some conversation over on lobste.rs https://lobste.rs/s/j1gmob/room_where_it_happens_how_rails_gets_made.
I appreciate that this is a difficult topic (I know, I wrote it!). If you're struggling for how to say something, I invite you to try out the NVC framework.
I wrote this hoping for some conversations. My twitter DMs are open too if you want to say something but don't want it to be public.
The code of conduct they ended up merging is terrible because it's a blacklist which reels off the trendy social issues of the USA in 2015. It carries too much political baggage:
> We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
What about nationality, political leanings, social class or criminal history? Whoops, it's fine to discriminate based on things that aren't considered important this specific person.
Debian's is much better and doesn't carry the same political baggage:
> The Debian Project welcomes and encourages participation by everyone.
> No matter how you identify yourself or how others perceive you: we welcome you. We welcome contributions from everyone as long as they interact constructively with our community.
> While much of the work for our project is technical in nature, we value and encourage contributions from those with expertise in other areas, and welcome them into our community.
I enjoyed working with Gosu , a 2d game development library for Ruby. There is a book that walks you through making games with Gosu that I bought for my brother when he was learning Ruby.
Use Vagrant to create a Virtual Machine for development. You can create one for each project and it will likely mimic the environment you will be deploying to.
https://gorails.com/guides/using-vagrant-for-rails-development
Ruby Koans is the first thing to come to mind.
The zeroth thing to come to mind is to learn how to be a good programmer. Kernighan and Pike's The Practice of Programming is an oldie but a goodie.
Even Cygwin won't do it. The format of Windows paths, with limitations on directory name length, and backslashes instead of forward slashes causes issues. Lack of support for certain software packages in Cygwin. It's just not possible, and even if you make it work you'll eventually run into a limitation that you can't get past.
If you use Windows, you'll need to use a virtual environment such as VirtualBox with Ubuntu, CentOS, or some other Linux distribution.
Edit: Or just get a Mac (or hackintosh)
I would either consider Sinatra, or Rum. Rum is probably the closest you'll get to Rack without implementing too many low-level things yourself.
If you just need to execute something when a request comes in, they can both do it well.
Sinatra:
class Main < Sinatra::Base
get '/diskspace' do
df -h
end
end
Rum:
App = Rum.new {
on path("diskspace") do
puts df -h
end
}
Rum can get you more requests-per-second theoretically, but I think Sinatra will surely be just fine for your purposes as well.
Other things to consider would be Camping, and maybe just plain ol' Rack.
This has little to do with rails and less to do with ruby programming. I'm tempted to remove it, but I guess it still discussion worthy.
> As part of the effort, we launched a new real-time search engine, changing our back-end from MySQL to a real-time version of Lucene
So they switched to using Apache Solr, A+ twitter; That took awhile.
For ruby, there's rsolr and sunspot which are awesome.
> we launched a replacement for our Ruby-on-Rails front-end: a Java server we call Blender.
3 x faster is fair when you switch out a framework with a custom server, but I don't get how it correlates to rails or ruby programming.
Not sure about testing, but some comments on performance.
Obviously it's going to depend a lot on the number of clients and logic complexity. Not sure about the issues with multi-threading benefits now, but last I learned about threads in Ruby, MRI was quite limiting with Global Interpreter Lock, but JRuby did not have these issues, so you might want to look at that implementation later.
If you're not using too many gems and still have performance problems, you might also prefer to use crystal lang which is supposed to have Ruby like syntax (very easy to port) and C performance.
> What jobs hire people skilled in ruby?
Mostly web development jobs using Ruby on Rails at smaller companies/startups.
> What is ruby mostly used for in the real world to make?
Ruby can be used to create anything, but is mostly used for websites and sysadmin tasks.
> Also, how is ruby on rails related to ruby (and what can you make with that)?
Ruby on Rails is related to ruby because it is a web framework built with ruby. It helps you organize and build your website quickly by using ruby code.
If you're interested in learning Ruby on Rails I'd recommend starting with learning the syntax of ruby, or you may end up lost with the "magic" that Ruby on Rails does :).
For an intro to Ruby check out: http://tryruby.org/
For an intro to Rails check out the screencasts at: http://rubyonrails.org/screencasts
Hope that helps :)
As a current student, i'm doing The Odin Project which is an open source full stack web curriculum going over the ruby, rails, html, css, javascript, etc. It is entirely free and work at your own pace and i am in love with it.
My apologies.
Let's start where we should. You will need a code-aware text editor. I suggest you stay away from the more powerful stuff like vim and emacs for now, and just get something that works and is intuitive. I say you go with sublime for now. You can use it for free for a time. Editors like MS Word, Pages, and other "rich text" applications are not code aware, and will not produce usable source code.
Next, code lives in source files. These files are plain text files that contain source code. You use the editor above to edit them. Rails is notorious for using a lot of files, so it might be confusing. I would suggest you get more familiar with Ruby, and then learn a little about Rails. Both are easy, and it will pay off. Trying to fiddle with a Rails app before you know either of these, or git, or how to even use any of it, will simply confuse you.
Git will help you keep track of changes made to your code over time. I'm told version control is hard for newbies to pick up, so if you find it confusing, just ignore it for now, and focus on the programming part. Github is somewhat of a social application build on top of git, that allows programmers to share and discuss code, as well as collaborate on projects. I know I'll get slapped over the head for this, but I like to think of Github as Facebook for coding nerds.
To run a Rails application, you will need a server. Configuring a server is not hard, but considering the kind of question you're asking, it's probably beyond what you would want to learn right now.
This is one of my first public releases in Ruby, and I did it specifically to learn more about the language's metaprogramming capabilities. Here's a blog post I also just published about it.
As stated, I'm still pretty new to Ruby so any feedback/criticism would be greatly appreciated!
I see your fizz buzz script and propose you attempt these fun little problems.
Click on About to learn more, but it's just a bunch of math problems which require the use of a computer to solve. (Like finding the sum of all the even Fibonacci Numbers smaller than 4,000,000)
It's useful for getting used to the syntax of new languages. :) Enjoy!
One thing I suggest you really not miss out learning are the tiling window managers like AwesomeWM. For a VIM guy like me that package is a dream. Also, don't miss freetype2-infinality. It brings the 'details and customizability' you crave to the 2nd order of magnitude in font rendering.
As a Mac guy now those are the two things I miss about Arch (GNU/Linux in general really, Arch just makes it all simple and easy).
I previously used New Relic and was never a huge fan. Too "enterprisey" for my taste. I much prefer Scout for Ruby apps. It has a better UI and is focused solely on Ruby/Rails, so transaction traces and debugging tools are actually useful - I actually found the source of multiple issues and was able to fix them. I use Raygun for error reporting.
You're quite welcome. I'm just happy that people are interested in the content.
Also, the content for the book and code examples can be forked on github, if you're keen: https://github.com/jbrownlee/CleverAlgorithms
Definitely, definitely The Pragmatic Programmer.
And then also The Mythical Man-Month.
We seem to be missing a good set of macro benchmarks for Ruby (and Rails). We have isrubyfastyet.com, which tries to benchmark simple Rails application but doesn't track JRuby / RBX very well and it's benchmarks could be improved. We have http://jruby.org/bench9000/ which is a set of micro benchmark.
I am excited about https://rubybench.org/ and the support for it by RubyTogether.org.
@headius, are you guys involved in this effort as well?
I don't think they're related. Actually, I've not heard of ruby being associated with meditation/monks/enlightenment more than any other language.
See this History of Ruby for the properties Matz wanted in a language.
You should read Clean Code and follow Uncle Bob. He is highly opinionated, a little brash, and I certainly don't agree with everything he says, but he does make many, many good points about writing code. Even though most of his examples are Java, there is good knowledge there for anyone. I am saying all of this to apologize ahead of time for sounding like a jerk.
The right amount of comments is 0. As a programmer, you have 2 jobs, to communicate to the computer, and to communicate to your fellow programmers. Comments sound like a good idea, except that much like any documentation, they are always always always out of date as soon as the code changes. Maintaining documentation is expensive, and nobody does it. Thus, when you read other people's code, you can't trust the comments. The only thing you can trust is the code. If you have to write comments, you are admitting failure, in that for this unit of work, you cannot communicate clearly through the code alone.
If the code is obtuse, it is worth the effort to refactor it to be more readable through code.
As a portfolio project you have 2 choices, either write the best code you can to your own standards, then look for jobs that match that standard, or write the code that you believe potential employers are looking for. If you feel concerned about comments (which is perfectly reasonable), you may want to have 2 portfolio projects, one with expressive comments, and one with none, to prove to employers that you can write code either way.
The ways that Unicorn and Passenger work are more similar than different. Passenger makes it trivial serve a rails app. Just point it at your app and it works... unless you need to do anything exceptional. Passenger performs a bit of wizardry to check if you are pointing to a rails app or a rackup file~~, which, unfortunately makes it pretty much useless if you want to start your rails app with a custom rackup. Also, Passenger hands off requests to worker processes via its nginx/apache module, Unicorn spawns and manages workers via the unicorn master process which speaks in standard HTTP~~.
Unicorn makes hot restarts graceful, allowing you to restart your application without stalling out or dropping any active requests.
To restart Passenger, you touch the restart.txt file, but Passenger drops your app instance and all of its workers. While your app loads, it blocks on all requests until it can spawn more workers.
If you have a rails app with nothing out of the ordinary as far as config and bootstrap, Passenger is the easy choice. Just point it at your app and everything magically works.
If you followed along with this comment without scratching your head WTF style and your app needs to be able to be upgraded gracefully or your app is a mix of rails/rack/sinatra/whatever, take a closer look at Unicorn. It is simply impressive. Well designed, sleek, and impressive.
Edit
Corrections thanks to FooBarWidget's comment below.
Most of the pitfalls in the article can be addressed by switching to slim, which is sort of "haml fixed".
But really, almost all of these complaints seem like bollocks. There are a few real complaints with HAML, and they are, in order of severity, difficulty managing whitespace, difficulty with inline elements, and the fact that typing % all the fucking time (particularly when doing HTML5 that uses all those article
and section
tags) is frustrating.
But again, SLIM fixes that. It doesn't use alligators to control white space (but they are there, just in case), it has a syntax for automatically putting whitespace around a line (the '
syntax). As for inline code, just use basic HTML within the SLIM file. As for the %
, slim doesn't use it
I'm seeing a small but statistically significant speedup of around 4% compared to 2.2.3, but 2.2.3 was down compared to 2.1.7 and we still haven't made the difference up yet.
These are my benchmarks, you may care about other benchmarks etc etc
It's '2.3.0', or '2.3' btw, never '2.30', which would be a release way in the future.
What you are attempting to do is technically possible, but it's not exactly what ruby is great at.
In other languages like C, the code goes through a compilation step where the code is translated from text (source code) into computer instructions (a binary or executable). The resulting binary file can be distributed and then others can run it on their computer without needing to know anything about the language it was originally written in.
Ruby, on the other hand, is an interpreted language. There is no way to take ruby source code and turn it into computer instructions. In order to run ruby code, you need something that can take the code and interpret it. So, if you were to distribute your ruby program to others, they would need to have ruby installed in order to run it.
This is why ruby is a great language for all things server side. When you set up your server, you just need to have ruby installed and then it'll run your code. This is also why ruby isn't great for all things client side, because it requires the client to install things.
One way around this limitation is to also include a ruby interpreter along with your source code. There are some projects out there that attempt to do just that, each with their own limitations and degrees of success. One such project is https://github.com/pmq20/ruby-packer. With this, you can give it your ruby code and it will bundle it up with a ruby interpreter so that you can hand out a single executable file to run.
Depending on what you're doing, that might be good enough for you. If not, you may want to consider using a compiled language. Crystal (https://crystal-lang.org/) is a compiled language based on ruby that might work well for you, though it is still in its infant stages in terms of third party libraries.
While you're wondering what project to try, I sincerely suggest checking out The Odin Project, https://www.theodinproject.com/ - it's a free open source web developent course with Ruby on Rails. You start with the basics for both front-end and back-end web development, which will probably not take you too long, and then get into Ruby more extensively, after that Rails, then front-end again.
There are no mentors, but there is a Gitter chat which a lot of people use to ask questions and share stuff.
The cool thing is that there are small projects after every few lessons and big ones at the end of each part of the curriculum and you upload everything to github so you can use it as a portfolio. For example, the final Ruby project is a command line chess game.
It won't be easy, I think, and you'll need a lot of self-discipline as there will be no teachers, but it was very, very helpful to me.
I would suggest scheme (or common lisp) to learn about computation (work through this: http://mitpress.mit.edu/sicp/), and C to learn about the machine. (Read K & R's The C Programming Language). If you know these two languages moderately well, you can pick up most others fairly easily.
If you are a Ruby developer, C is a good language to know since the MRI was implemented in C.
I'd just post your question here. It sounds like what you're doing may require some JavaScript. Something similar to this: https://codepen.io/systemnate/pen/oPNoox?editors=1011, but you will have to put the JavaScript inside slim. You could either do it in its own .js file or in the view like:
javascript:
document.addEventListener('DOMContentLoaded', function() {
...
});
Imma be honest with you: this is incredibly low quality blogspam. I think the worst offence is stating It's a bad idea to use the Mac system Ruby.
Not only do you cop-out and not provide an explanation, you've entirely missed the point of the free-code-camp article you link to (https://www.freecodecamp.org/news/do-not-use-mac-system-ruby-do-this-instead/)
To quote them:
It's fine to use the system Ruby for running sysadmin scripts, as long as you don't alter the system Ruby by attempting to update it or add gems.
But you don't want to use it when you are developing projects in Ruby.
You blow through that nuance.
I've personally had a lot more sane behavior out of my systems with rbenv than RVM. I really don't like the way things get handled with RVM and have had problems keeping it happy more than once.
For local development I use chruby/ruby-install.
For servers I'll tend to use apt provided ruby, however I'd use the brightbox ppa over the system provided ones. The Ubuntu one isn't currently up to date, trusty is at 1.9.3 at the moment.
Gems are in the ubuntu repos, however I'd avoid them like the plague. Weird versions, managing dependencies, just seems like it's inviting problems.
I don't think nokogiri's that bad. When I google "nokogiri" the first page is only get results related to the gem. The name alone doesn't tell you what it does but since its unique its easy to google and its common enough.
Hoe goes with rake so that makes sense too.
I'm surprised the "poorly chosen" list doesn't include Sphincter although it works with sphinx and I've been told the body has many sphincters.
I don't know what the hell "zeef" is -- presumably a place that algorithmically aggregates content in a vain attempt to sell ads.
The real asciidoctor site is where you'd expect it: http://asciidoctor.org/
EDIT4: tldr: two simple regexp-based solutions, one that finds the words where vowels are correctly ordered:
/^[^eiou][^aiou][^aeou][^aeiu][^aeio]*$/
and an equivalent one that finds the words where vowels are not correctly ordered:
/e.a|i.[ae]|o.[aei]|u.[aeio]/
ORIGINAL POST:
/e.a|i.[ae]|o.[aei]|u.[aeio]/
Basically, to check if all the vowels are correctly ordered, we just need to check that there are no vowels badly ordered. You can see in http://rubular.com/r/8TFTbzKfAd that it correctly match the three last words.
/e.*?a|i.*?[ae]|o.*?[aei]|u.*?[aeio]/
may or may not be quicker by using the non-greedy version of *
.
EDIT: to correct your regexp, you need to modify some things:
a
so .
need to become [^aeiou]*
a*[^aeiou]*
becomes (a*[^aeiou]*)*
^
and $
So your regexp would become for example (http://rubular.com/r/ZG5yxwuSvw):
/^[^aeiou](a[^aeiou])(e[^aeiou])(i[^aeiou])(o[^aeiou])(u[^aeiou])*$/
You can also see that we actually find the same result as /u/amdpox: by removing /[\^aeiou]/
from the string, we only need to check /^a*e*i*o*u*$/
EDIT2: In fact, the reason your regexp matches everything is that a word where the vowels are bardly ordered is simply the concatenation of multiples subwords where the vowels are well ordered ("Broke" = "Brok" + "e"
), and your regexp finds all these subwords. You can verify if by running "Broke".scan(/.a*[^aeiou]*e*[^aeiou]*i*[^aeiou]*o*[^aeiou]*u*[^aeiou]*/)
EDIT3: the first regexp was originally /e(!?.*a)|i(!?.*[ae])|o(!?.*[aei])|u(!?.*[aeio])/
Crystal is a statically typed programming language inspired by Ruby: https://crystal-lang.org/
Kind of like having the concurrency and performance of Go with the syntax of ruby. It overall looks really great though I have little hope of it ever being more than a niche hobbyist language.
I think more people would use Lisp or Haskell or OCaml, but those languages never had a large community focused on making the tooling around the languages better. Rubyists take for granted that Bundler and RubyGems.org came along and made dependency management as easy as it was. Making and distributing packages for Ruby is one of it's best features, and it's something that people have replicated in multiple other languages, Cargo for Rust now Yarn for Javascript. Both of which happen to be designed by the person who designed Bundler. Besides it's minimalist flexible syntax, Ruby is to me at least, one of the most expressive languages to come out of the 90's language boom. Even if Matz's interpreter fades away, the syntax and ideas of Ruby will live on (see Crystal, and RubyTruffle).
The official docs don't tell you much (Ruby language official docs are getting better, but still kind of sparse).
Just google for "ruby scope". Here's one piece
But basically, a block creates a new scope. Local variables created in outer scopes are available in the new socpe created by a block (which is what makes it possible to use proc/lambda as a closure). Variables created in a block will not exist in the outer scopes once you return to them.
And def x
, class X
, and module X
create new scopes, but local variables in outer scopes are not available to the new scopes created by those keywords. (Which is one big difference between defining a method with standard def
, and with define_method
. Since the define_method
approach uses a block to define the method body, and variables from outer scopes are available in a block -- variables from outer scopes are available in method body, as a closure, when you use define_method
).
I can't think of anything else that creates a new scope. if/else does not. begin (perhaps counter-intuitively) does not.
That's pretty much all you need to know, that I can think of.
JRuby has excellent threading support, with a TON of tools from the JVM to help you do things concurrently. Rubinius also has excellent threading support.
I just gave a talk on this at RubyNation: here's the slides: http://speakerdeck.com/u/davetron5000/p/dont-fear-the-threads-simplify-your-life-with-jruby
Sorry, no Amazon links but they're all easily available there:
Here's the thing:
Testing is hard. Read Michael Feather's "Working Effectively with Legacy Code". If you are writing tests after the code, then you are writing legacy code and then figuring out how to test it. That's hard. No doubt about it.
Test-Driven Development (/slash/ Test-Driven Design /slash/ Behavior-Driven Development) aren't about testing /at all/. They are about driving out the design of your system through the use of tests. That means when you are writing a test first, and it's hard, you are immediately going, "Something is very wrong in my design, because it shouldn't be this hard to write this test".
Packages like FactoryGirl have made it a bit worse, because it seems easy enough to just setup an entire system with it. That is bad. Very, very bad. Unless you are dealing with legacy code, your unit tests shouldn't be hitting the database.
So, to become good at writing tests-first - /really/ good - you have to become really good at understanding and recognizing abstractions and patterns in software. Tests shouldn't be hard to write, and when they are, there's something missing from your system.
I'd highly recommend picking up Head-First Design Patterns, Kent Beck's Test-Driven Development, Michael's book from above, and Growing Object-Oriented Software and Avdi's Objects on Rails (http://objectsonrails.com/). And if you really want to understand patterns, pick up Alexander's "The Timeless Way of Building" which is an architecture book, but surprisingly applicable (though it is a challenging read)
Ruby's an object-oriented language --
By defining the behavior of objects in classes, a programmer can write code which resembles the behavior of objects in the real world.
For larger applications, this abstraction tends to be preferable over writing all programs as a strict sequence of commands.
Take some time to read up on object-oriented programming. I think the question you're asking is "Why have multiple classes? Why not make everything one big class?"
Check out Chapter 1 of Practical Object-Oriented Design in Ruby, by Sandy Metz, and consider the intricacies of stepping on cats!
For those who don't know and are lazy such as myself wondering what the hell ETL is.
http://www.wikiwand.com/en/Extract,_transform,_load
> In computing, Extract, Transform and Load (ETL) refers to a process in database usage and especially in data warehousing that:
> - Extracts data from homogeneous or heterogeneous data sources - Transforms the data for storing it in proper format or structure for querying and analysis purpose - Loads it into the final target (database, more specifically, operational data store, data mart, or data warehouse)
apart from other sites already mentioned,
I have a few basic to intermediate level exercises - you could either use the files provided in that github repo and solve them locally or use repl.it to solve using a browser
Puma is not going to solve the garbage collection issue. Ruby's garbage collector is stop-the-world. When the GC runs, all threads are paused.
Puma also does not support out-of-band garbage collection like Unicorn and Phusion Passenger do. It's a bit hard in Puma's case because anything it does out-of-band can affect other concurrently running threads.
On the other hand, Phusion Passenger does provide out-of-band garbage collection, even for multithreaded apps, in its Enterprise edition. It does this by managing the threads in an intelligent way, waiting until all threads finish their requests, spawn another process if necessary to take over the traffic, and then runs the GC on the original process.
Even in the open source edition, Phusion Passenger's out-of-band garbage collector avoids starvation situations, which Unicorn could suffer from. In Unicorn it's possible that all processes happen to be running out-of-band GC at the same time. Phusion Passenger actively avoids this situation by ensuring that only one process at a time is running the out-of-band GC.
There is also work on the way to make out-of-band garbage collection in Phusion Passenger better by integrating into Aman Gupta's garbage collection work. See https://news.ycombinator.com/item?id=7488578
You might be interested in exercism.io. It only covers relatively simple programming problems, but after you've submitted your solution, you can see everyone else's solutions and give/receive code reviews. Seeing all the different approaches to a single problem, and comparing them to your own, is a pretty good way to learn.
As for reviews of larger changes, like adding a feature to a Rails app, I'm not sure.
Firstly, be careful with your terms. 'Interprocess threading' is not a thing -threads are multiple concurrent execution contexts within a single process.
To get you started, here's a stack overflow question about signalling between threads: https://stackoverflow.com/questions/534919/ruby-thread-programming-ruby-equivalent-of-java-wait-notify-notifyall
I think the easiest way to do this is to use a shared queue, similar to the one used here: https://stackoverflow.com/questions/6558828/thread-and-queue
One thread runs ICMP pings, and writes the site name to the queue if the response is an even number.
One thread attempts to pop content from the queue, sleeping when there is none.
This is a producer/consumer model, which lends itself well to the problem you're trying to solve.
Others have answered the question of how to simplify one method. It seemed to me like the question was how to fix the duplication, or in other words, not have four similar methods with so much code duplicated from one to the next. Edit: It looks like /u/zoso might have been going for something similar.
Go here and click on the Source tab to see what I mean.
Here's one way to do that, following /u/tomthecool's basic approach:
def dblookup(key, match_value, return_key) return '' if match_value.nil?
line = db.find {|line| line[key].eql?(match_value) } line ? line[return_key] : '' end
def mac_to_ip(mac) dblookup(:mac, mac_flatten(mac), :ip) end def ip_to_mac(ip) dblookup(:ip, ip, :mac) end def locate_mac(mac) dblookup(:mac, mac_flatten(mac), :location) end def locate_ip(ip) dblookup(:ip, ip, :location) end
It is passing because the a and the b match. I'm not sure what your exact specs are but this one will satisfy "match on strings which contain only characters from the character class"
\A[abc]{,4}\z
This is checking that the line starts and ends with a, b or c with no other characters. You might even be able to simplify it to
\A[abc]+\z
rubular.com is good for playing around with regexes. Hope it helped!
> I've managed to rewrite something from ruby to crystal and got over 6x speed improvement in production!
This is a pretty useless comment without even a link to a gist.
And... oh jesus it's yet another new language. Call me jaded for being a bit fatigued by this. I'm sorry but (IMHO) if it doesn't have immutable data and isn't functional then it's eventually going away. Been doing OO Ruby for 15 years now, it leads to too much app complexity via holding onto state everywhere. And without immutable data, your concurrency is going to deal with a lot of locking, and locking is crap (if there's another way... which is immutable data... in an era of cheap memory, it finally makes more sense).
And of all the things to bring into Crystal from Ruby that should have been dropped... Global variables. Seriously? Is it 1982 on the Commodore PET in BASIC again?
I kind of wish more developers would get behind fewer projects. I've been very happy with Elixir (also ruby-like) and it already has the entire Erlang standard library behind it, which is a pretty good bootstrapping, as well as being 2-10x as fast as Ruby, as well as having sub-microsecond process spawning (great for handling new web requests), a great process management API built-in called OTP (great for uptime), immutable data, pattern matching (although I see Crystal has that too, although I'm not yet sure how sophisticated it is), functional paradigms, mainly dealing with data in a few very-well-optimized types, and all that which I have learned are Good Things™ for maintainable code. I think it's the way forward for reliable, concurrent server-side coding, not another OO lang with mutable vars.
Not sure what he's going to say but here's my latest reason (besides the long JVM startup time):
Fork/Join setup in Java; it takes many many milliseconds to fork so forking is typically only recommended to parallel-compute pools of data a million elements or larger.
Task.async in Elixir (which takes advantage of underlying Erlang facilities). It's as idiot-proof as it can get. Time to spawn a concurrent node: 1 millisecond.
sure. - autocomplete - you can disable any plugin that you dont use - find/replace - you have js at your fingers(we are using vue) - css and saas, less - haml, slim, erb - refactoring that works - find usage - debugging
but best just have a look here: https://www.jetbrains.com/ruby/features/
This is a really good point and its consideration can't be understated. I think in general, the answer is, "you'll know when you need it". Unfortunately, that moment might come too late to do anything about it, i.e. the app is already mostly built out.
One cool recent trend in front-end JS development is blurring the distinction between "pages" and "an SPA". See Next.js (React) and Nuxt.js (Vue) for examples of such projects. You get the advantages of boring old relatively-static pages when desired, with the ability to supercharge individual components using the full power of the front-end framework.
> Maybe someone needs to work on a pretty project management system that gets stored inside the git repo itself
You might be interested in Fossil. It isn't based off of git
, but it does the project management stuff all as part of the same distributed repo.
You can use SCAN but scanning the entire keyspace is sub-optimal unless the database is dedicated to Rack-Attack:
https://redis.io/commands/scan
Imagine Redis with 1,000,000 cache keys and 10 Rack-Attack keys. That's a lot of scanning to find 10 keys. Better to put 10 entries in a SET and use SSCAN on it.
I checked the code in irb and it works as you would expect.
I don't have any experience with Visual Studio or Windows, so I'm not sure how to get that working for you. Normally for what you are doing I would type the program up in my text editor then run ruby person.rb
on the console.
In terms of running simple ruby programs on the web for learning programming, I suggest trying repl.it.
Basically good choices for first language are: javascript, ruby, or (maybe) python. Anything else is madness.
Javascript is actually a shitty language, but the tooling to get something impressive done and motivate beginners is unmatched. There's also real good on-ramp - starting from html (ridiculously forgiving), then css (still very forgiving), then actual programming. Without having to learn terminal, git, editors etc. same time - you can start with something like freecodecamp and get really smooth learning experience. Basically the default first choice.
From language quality point of view, ruby wins. It's good, beginner friendly, and it's easy to teach people proper TDD etc. As long as you don't need to run it on Windows, then don't even bother. And it's basically useless terminal program, which to be honest isn't terribly motivating for most beginners.
Python is kinda, close enough, especially if you have some data science adjacent background. There's no really any advantage over ruby. Tooling is awful, half the online resources are still Python 2, and nowadays it's a lot more complicated language than Ruby since they added 50 features to cover 1% of use cases for blocks instead of just having blocks. Python 1 used to be simpler than Ruby 1, but that's long been false. TDD is also kinda an exotic idea in Python world. There's also related issue that beginners tend to be godawful with indentation, and Python is really unforgiving on that. They learn eventually, but it's another layer of pain. I guess it runs better on Windows at least.
Source: I taught a lot of beginners, also all the bootcamps etc.
(learning one of those as second or fifth language is a very different story - javascript doesn't really have much advantage there)
I develop on a windows machine. Ignore the haters, it's fine.
I use Uru for ruby environment manager: https://bitbucket.org/jonforums/uru
And Sublime for text editor: http://www.sublimetext.com/
I hope this helps.
Heres is my opinion. In last 6 month:
The greatest ideas for how to design and write code I've get from Sandi Metz videos and books. From upcase I've increased my productivity by deeper learning vim and tmux. Filled some gaps of knowledge of Rails and ActiveRecord query interface. Learn some nice things from RubyTapas. And everyday practise on my hobby project where I can apply all new knowledge.
But about the deal 400$. I think you can spend 1-2 month on upcase, get RubyTapas for 6 month and it will be 30 * 2 + 18 * 6 = 168$, buy few books and it will about 200$ - twice cheaper.
Please note, it's only my opinion.
It's been too long since i read Programming Perl but "The Ruby Programming Language" is the book that i use the most.
While the Pickaxe is good, you can't beat the pedigree of "The Ruby Programming Language" what with Yukihiro Matsumoto aka Matz aka The guy who created the ruby programming language in the first place, co-writing the book along with Mr.Flanahan.
TIL the DOM creates implicit variables on window for each element with an id.
Here is vanilla JavaScript showing implicit id variables on window. This magic has nothing to do with Opal. http://jsfiddle.net/5otkje79/1/
I personally disagree with the "Write for 1.8" statement.
And why would you gist it when the original is there and has been there for over a year? Besides, it's from the author of Rack, so I don't see this going anywhere any time soon.
Is there any advantage to doing it this way instead of having a simple cronjob that calls the letsencrypt client and have it renew the certificate automatically? (Source: https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04 )
I believe this is the non-secret Stripe token.
This is similar how it is done in their docs. https://stripe.com/docs/checkout/rails
customer = Stripe::Customer.create( :email => params[:stripeEmail], :source => params[:stripeToken] )
The publishable and secret ones are in a secrets.yml file and used like so.
Rails.configuration.stripe = { :publishable_key => Rails.application.secrets.stripe_publishable_key, :secret_key => Rails.application.secrets.stripe_secret_key }
Stripe.api_key = Rails.configuration.stripe[:secret_key]
OS X is what would initiate turbo boost, and an intense script of any kind could motivate OS X to overclock the CPU.
To find out for sure, I'd suggest an experiment. Install watch, run your script and in another terminal, run 'watch sysctl hw.cpufrequency' to get the current frequency.
I'm sure there are GUI alternatives as well.
If installing a dependency is an option, on non systemd systems use something like Monit or Daemon Tools. If you are building your own daemon, it is probably going to be easier to use one of these than to write your own init script and juggle pids and stuff yourself.
awesome_print kind of like pp but way, way prettier. It makes even complicated object graphs, arrays, and hashes much easier to comprehend. Also can hook into your logger to add a logger.ap method to make pretter/more readable logs.
Oh, I use them too. I can get rid of coderay (because syntax highlighing in shell is not very helpful), but not coolline. About coolline I have some plans btw. For example, it would be great to add autosuggestions there (like in fish http://fishshell.com/assets/img/screenshots/autosuggestion.png ).
Many of these may or may not fit your concept of a beginner level talk, so take anything you like. I'm just throwing out ideas that I would've appreciated hearing about. I'm definitely in favor of the topics you've already listed in the OP.
If you cover any of the gem skeleton tools like Jeweler, please be sure to point out the caveats, and if possible, cover simpler alternatives like bundle gem
or simply doing it by hand.
One topic that tripped me up early on was the concept of load paths and require
. Perhaps touching on that would be helpful, and mention 1.9.2's require_relative
while you're at it.
Brief mention of 1.9.2-only code in general as it relates to gem publishing might also be a good topic. How to specify that your gem requires 1.9.2 in the .gemspec, for example.
RVM and/or Bundler for simplifying gem development/testing. Using RVM to test against multiple ruby versions, for example, or Bundler (and maybe gemsets) to allow collaborators to get up to speed on your gem quickly and easily.
The recently unveiled Gem Testers service from EngineYard. [Announcement blog post]
The (spooky hands) eviiiiiiils of monkey-patching and alias_method_chain
, clarifying when they're appropriate and when they're a symptom of code smell or programmer laziness. I realize this topic may be a bit beyond the basics of gem development, but they're very important considerations for sharing re-usable code, imho.
Crystal has Enums which they prefer using over Symbols as most of the time you are working with a finite number of values that can be passed in. You can even pass in Symbols to methods that accept an Enum, and the compiler will map them to the Enum value; both test(:ONE)
and test(:one)
will map to MyEnum::ONE
. That said, I kind of like having the ability to accept arbitrary Symbols to allow extending an API. Maybe in the future Ruby could add something like keyword arguments but for restricting Symbols (ex: def foo(type: [:foo, :bar, :baz])
) for when you only want to allow a finite number of Symbols?
That's basically the reason why I wrote this blog post: https://crystal-lang.org/2016/07/15/fibonacci-benchmark.html
But it can't be helped, fibonacci and factorial are one of the easiest and simplest programs to compare benchmarks.
Also note that in my article I talk about adding the possibility of mutating BigInt, and I think we'll eventually add that into the standard library.
You're probably looking for something like YAML.
Your lists could be YAML objects.
>require 'yaml'
And then generate your lists as YAML objects. You can then cycle through for comparison, or spawn off several comparisons at once. The objects don't have to be written to storage, they can just sit in memory (iirc).
While not entirely enumerables, I found codewars to be good practice for this sort of thing. Many of the problems can be solved using enumerables, or at least as part of the solution. As a bonus after you submit your solution to each problem you get to see other submission (with voting) which often introduces you into some clever solutions you wouldn't have thought of.
I am aware of https://about.gitlab.com/2017/02/01/gitlab-dot-com-database-incident/ but what was the other?
AFAIK GitLab.com has better uptime than GitHub. And you have the option of hosting it yourself.
Even AWS has had its fair share of incidents. Like the deletion of ELB configuration https://aws.amazon.com/message/680587/
Programmers are just people. Learning to work with other people is mostly the application of social skills. If people enjoy your company and see you as an equal/peer, life and work both become much easier to deal with.
Look for local meetups and other groups to join. They don't have to (and some would argue shouldn't) be related to software development. Anything you're remotely interested in will do. The farther it is out of the comfort zone, the better.
Take some online courses like Career Success on Coursera. Study the basics of project/product management. There are plenty of other ways to improve you own soft skills.
TL;DR: see here for a brief explanation and here for a possible solution (although not very practical)
Author here.
My analysis is based on a single extension, one that benefits from being rewritten in a faster language.
Depending on what the extension is doing, you might get a huge gain from writing an extension in Go, but Go isn't exactly a speed champion, it still has to carry its runtime and that add a noticeable overhead too.
FFI won't help much in this case, FFI just load the shared object and map the functions, without passing for the extension initializer, that's the only difference.
In fact I've started with FFI and then switched to the C programming interface to check if there was some significant performance change, there wasn't.
There are other languages if speeding up Ruby is your goal: Rust is one of them, but not the only one, especially if you wanna avoid the language barrier.
in the next episodes I'm going to introduce all of those that make sense.
(Technically it's possible to write an extension in Haskell, but I don't think it'll be a good idea).
EDIT: grammar
I've played around w/ a lot of languages and I really enjoy Ruby.
I've been learning on the new, free, App Academy course: https://lifehacker.com/learn-web-development-for-free-with-app-academy-1829843012
It teaches full-stack Ruby on Rails w/ some JS and HTML and CSS, which IMHO everyone should know at least the basics of HTML and CSS.
Thank you, Lynda has nice courses on the topic. Wikipedia + Coltrane(this software) can also give you a hand. A good starting point would be to check about musical intervals. It's where my music theory interest has started. http://www.wikiwand.com/en/Interval_(music)
Both characters have multiple uses depending on their location in the code. Without further info I would have to guess *obj
is a splat of some kind and & is actually &:symbol
as in arr.map(&:to_s)
or something, which converts a method to a proc.
You are correct that passing by reference and passing by value is not a thing in Ruby, pretty much everything is by reference. Do you have an example how the operators are used in the code you are looking at?
You can generally assume unless something is called "SecureRandom" or better yet CSPRNGRandom, it probably isn't.
PHP's rand_mt is a well known source of repeated vulnerabilities, despite the somewhat humorous description of the function on the PHP website linked.
I'm going to assume it's as secure as the Random class, which is a completely deterministic Mersenne Twister.
> it's nearly impossible to move away from the way RVM overrides built-ins
The only built-in that rvm
overrides is cd
, no? (I may be wrong, but that was what I thought.)
You can easily opt-out of that behavior, by setting <code>rvm_project_rvmrc=0</code>.
The business about cd
has gotten the lion's share of attention, but really rvm
and rbenv
are very different tools (different styles of shell scripting, different goals, etc.). There's no good reason that both can't exist and flourish. There should be plenty of room for both of them.
Fellow novice here, but maybe one step beyond where you're at. I think this RPG-style thing is a great way to learn some basics. One thing I'd recommend is to really start thinking in an Object Oriented way. For instance, what happens to your game if Ted the Mighty is joined by Eris the Brave? As it stands now, you'll run into problems with your character sheet variables (STR, etc.). This is where object thinking comes into play. Take a look at this: https://hastebin.com/noqubowida.rb
In addition to a few minor changes to clean up where you've unnecessarily repeated yourself, I made one huge change: I create a Character
class that allows you to generate characters for your game. You can see on line 37 where I create Ted the Mighty using his particular stats. To get at his name and stats later in the program, you can use the helper methods created for each attribute (that's what attr_reader is doing at the beginning). So, after creating Ted the Mighty using hero = Character.new("Ted the Mighty", 8, 6, 5, 2, 7)
you can get at various parts of his character by using hero.name
, hero.str
, etc. You can see where I do this on line 40 to get at his name.
Having that Character
class will allow you to later do something like: a_new_hero = Character.new("Eris the Brave", 3, 4, 5, 6, 5)
and you can access information about her, and have her fight
or run
in the same way, but using her unique attributes.
I hope that makes sense. Just wanted to point you toward starting to wrap your mind around the usefulness of Classes and objects!
I'm not an expert, but relying on ActiveRecord without rails seems a bit overwhelming and painful. Why don't you try other ORMs like Sequel ? I have a little project which uses it: https://github.com/estebanz01/uwrrugby
It's not perfect code 'cause it's an MVP, but it can be a start if you decide to move to Sequel.
Now, regarding your question, checking this: https://stackoverflow.com/questions/38212305/cant-access-localhost-on-ruby-on-rails
it seems an issue with the gem. Check that your env is loading the SQLite3 gem as expected. You can use bundler and a Gemfile for that.
I don't think that's the case but I'd like to know why you think that and how we can improve.
https://github.com/rubygems/rubygems/pulls
As you can see, we've got 14 [edit:that's open count only, the real number is 52] closed pull requests (a mixture of rejected vs accepted--hard to summarize with github). That's just since switching rubygems to git, there were a lot more over the years on rubyforge.
We do reject a number of contributions but we do so for good reasons like compatibility, an idea just doesn't fit our design, or it is just as easy to do as a plugin (which we designed in order to allow for more tangental contributions to not be excluded). At the same time, we've taken on regular contributors (qrush, erikh, and um... me) and gotten a lot out of it.
P.S. I'll be the first to admit that I don't suffer fools lightly, but I doubt you're referring to my interactions with Trans.
How? Do you have an example where it is accomplished in the way we describe it? This guy also claims it's possible with Varnish and linked to two resources, but the resources he linked to looks nothing like what we're after.
As for "bullshit marketing": the entire point of the blog post is to call for research participants who could not only test our ideas, but who could also point out anything we might have missed. The blog post does not promote a product: it very clearly states that it is research and asks for help. Furthermore, all produced code is free and open source, so I'm confused where your hostility comes from.
So far, this comment has been the most helpful. This guy is polite, constructive, provides a counterexample in a very clearly explained manner, and we can learn a lot by conversing with him.
I don't doubt that our idea isn't new. Most ideas in computer science are 30+ years old and somebody, somewhere, would have done it before. But that doesn't stop reimplementations from being useful. Even if Varnish can actually do it, there is still value in reimplementing it on the app server level, e.g. because it's more convenient for the user.
Graph QL is awesome, webpack is awesome, but you kind of missed the point of the long-term Rails vision and mission
please listen to this interview to fully understand what I mean
or this talk by DHH:
A bit of googling found me this, https://stackoverflow.com/questions/1345843/what-does-the-question-mark-operator-mean-in-ruby for the question mark - it gives the ASCII value.
The upto block does exactly what you'd expect - it runs once for each number in the range (?a, ?z).
Download Oracle VM Virtualbox for free and use its Guest Additions. This is critical. With the Guest Additions, you can do stuff like share folders and copy and paste between Windows and your VM. It makes Linux development on Windows pleasant.
The benefit of installing ruby via the package manager is a) the package specifies all runtime dependencies b) the package can easily be upgraded or uninstalled c) the packages are PGP signed. You should consider creating a PPA like brightbox's ruby-ng. You also might want to look into deterministic builds, which allows users to verify the binary was built from the source and that no extra code inserted.
If you want to get rid of the deprecation warnings try my Chicken Little hack gem install chicken_little
then just run chicken_little install
.
To use Chicken Little install the gem then run the app:
$ gem install chicken_little $ chicken_little
The problem is RubyGems 1.8.2 seems to be broken for Ubuntu 10.10, it doesn't work for me, so if you already updated you're going to have to manually uninstall RubyGems and go back to an older version.
Source code: https://github.com/mikbe/chicken_little
Cldwalker here, by the way, is the author of Ripl.
...Not that that's something to complain about, I use it everyday and I can vouch for it's wonderfullness.
Also, protips:
alias irb=ripl
gem install ripltools; echo "require 'ripltools'" >> ~/.riplrc
)Thanks; I hadn't heard of Isolate. For anyone else in the same situation, here's a link to the project and one team's rationale for using it.
Check out Contest. It takes Test::Unit and makes it perfect with 100 lines of code. I use it on everything.
Explanation: http://blog.citrusbyte.com/2009/05/19/introducing-contest/ Github: https://github.com/citrusbyte/contest
Ruby 1.9 has similar niceties baked into Test::Unit, which may be worth looking into. Contest works on 1.8 and 1.9 so I'll probably stick with it for awhile.
I agree with DHH, I don't like how RSpec dumps crap into all the objects, and I abandoned it a while ago after finding out it was causing too many bugs with this approach. Testing should be simple, and should never create bugs from its implementation ever! Also, the documentation was fairly abysmal at the time.
You shouldn't do that. Search is quite a hard problem to solve. It's common for Ruby on Rails apps to make use of elastic search in order to implement that. Take a look here:
http://www.toptal.com/ruby-on-rails/elasticsearch-for-ruby-on-rails-an-introduction-to-chewy
Your Gem structure is pretty standard from what I can tell. Not bad there. Actual functionality seems alright, so that looks good as well.
As for ordered options... I don't like ordered flags so much. Subcommands would be better in my opinion. There is a gem called Subcommand that lets you do just that. You can call gojira issues open --list 15
would be different than gojira issues list 15 --open
or whatever you want.
Having ordered flags, while easy to type, are difficult to remember without a detailed help file and are very difficult to interpret. Diverging from UNIX-style command usage would be confusing for a lot of users.
If you really want to look at gem structure, then browse http://rubygems.org/ and find some popular ones, then check out the source.
We launched Rack support in March 2009: https://blog.heroku.com/archives/2009/3/5/32_deploy_merb_sinatra_or_any_rack_app_to_heroku
Heroku was 1.5 years old at that point, and it looks like the first version of Rack dates back to 2007: http://rubygems.org/gems/rack/versions
Prawn is pretty cool, and generates nice PDFs. Right now I think that if I had to do a new PDF project, though, I'd use wkhtmltopdf. Being able to use HTML / CSS to create a PDF makes it a lot easier for front-end folks to contribute effectively; sure they can pick up the Prawn DSL, but it's nicer if they can just use what they know.