<tpanarch1st>
hi, is it possible to set up a mysql database connection without developing an app using ruby on rails please - the reason i ask is because all of the youtube tutorials cover rails
jottr has joined #ruby
<baweaver>
tpanarch1st: Use Sequel
<tpanarch1st>
oh yeah sure but i presume that there is some reading to do in relation to ruby
<tpanarch1st>
and i cant even find anything that doesn't tell you to do it using rails
<tpanarch1st>
thanks for this :)
<tpanarch1st>
is there something a bit more basic and a bit more comprehensive please - for a start, i'm looking to do this with mysql
<tpanarch1st>
in other words, geared towards a newbie!
<baweaver>
How much Ruby do you currently know?
<tpanarch1st>
i've watched giraffe's tutorials on youtube
<havenwood>
tpanarch1st: What are you making?
<tpanarch1st>
now ready to have a play
<tpanarch1st>
i want to make a database for my vinyl collection!
<baweaver>
I'd probably start on codewars.com
segy has joined #ruby
<tpanarch1st>
ok just clicking this
chouhoulis has quit [Remote host closed the connection]
<tpanarch1st>
oh that's a bit much, i just want to hit problems, research solutions and learn "on the job!"
<tpanarch1st>
i just can't find a starting point for "how to work with mysql with ruby"
<havenwood>
tpanarch1st: Ruby ships with support for a very simple DB called DBM.
<tpanarch1st>
not ruby on rails - bit beyond me this framework stuff currently
<tpanarch1st>
can i by any means stick with what i know and work with mysql havenwood :)
mat_bug has joined #ruby
<tpanarch1st>
i'm quite excited by ruby, i'd heard about it before but i've now spent a few hours watching youtube and i think it seems a lot more friendly than php as a mild dyslexic that struggles with syntax matters
jottr has quit [Ping timeout: 268 seconds]
<tpanarch1st>
i'm struggling to find a search term that doesn't involve rails
<tpanarch1st>
it blew my mind that stuff, it seems obvious to work on a ruby website before moving into playing with rails
hutch has quit [Ping timeout: 268 seconds]
<havenwood>
tpanarch1st: You can use the mysql2 gem directly or use it from the Sequel gem.
<havenwood>
tpanarch1st: Have you created a simple Rack app? Or a Roda or Sinatra app?
<tpanarch1st>
i may appear totally thick here but the first time gems was mentioned was in terms of rails
<tpanarch1st>
no idea what those things are :) frameworks are well beyond me as yet!
<baweaver>
It takes a while to get all these things sorted
<baweaver>
and everyone has to start somewhere on it
<baweaver>
If I were you I would consider starting with CSVs
<baweaver>
make a "database" using files
<tpanarch1st>
i've watched tutorials that shout "learn the freaking language before trying to move to their frameworks"!
<havenwood>
tpanarch1st: We call snippets of Ruby code we package and share "Gems."
sarink has quit [Remote host closed the connection]
<baweaver>
Eh, do what feels fun to you
<tpanarch1st>
oooh so gems is not exclusive to rails havenwood
<baweaver>
Most of those people yell that to the wind, I tend to ignore them
<tpanarch1st>
it seems logical to play with ruby's tools to get a website up
<tpanarch1st>
oh wow baweaver
<tpanarch1st>
this approach seems to fit with where my heart is though
<baweaver>
Just go straight for Rails if that's what interests you
<baweaver>
then fill in the knowledge as you go.
<baweaver>
"The Rails Tutorial" is a decent place to start as it goes through enough Ruby to get started
mat_bug has quit [Ping timeout: 252 seconds]
<tpanarch1st>
too much for me, i want to play with what giraffe's tutorials tought me but actually do a project that appeals
<tpanarch1st>
giraffe's didn't cover mysql though
<tpanarch1st>
or databases at all
<baweaver>
Rails tutorial goes through building basically Twitter
<tpanarch1st>
yeah head overload there with rails
<tpanarch1st>
want to try and avoid this MVC stuff (is it MVC?) for the moment
<tpanarch1st>
so the Mysql2::Client.new( i presume is the starting point here - what is mysql2 as well?
<tpanarch1st>
(please and thanks)
<tpanarch1st>
is anybody else familiar with the giraffe tutorials as well - i really liked the way he taught
<havenwood>
tpanarch1st: mysql2 is a gem. You can install it with: gem install mysql2
<havenwood>
tpanarch1st: then from Ruby you can use it: require 'mysql2'
<tpanarch1st>
ah so, i take on board that gems are not unique to framework?
<havenwood>
tpanarch1st: Gems are just snippets of Ruby code that people are sharing in formalized packages.
<tpanarch1st>
but i'm sitting here thinking "I have my own web server", where to start with installing stuff, is this like installing php mods?
<havenwood>
tpanarch1st: It's like downloading some code and evaling that code from the Ruby interpreter. It's not like apache modules, per se.
<havenwood>
tpanarch1st: You're not loading the code for all Ruby programs. Just yours.
<tpanarch1st>
oh Lord, this is a messy learning curve!
<tpanarch1st>
i don't even know where to start, my way is a) avoid overload (the way my mind works) and just stick with things I know, like mysql, where i can (not an expert in mysql mind but i can muddle through with that i think)
<havenwood>
tpanarch1st: Start with in-memory.
<tpanarch1st>
what is that please?
<tpanarch1st>
i dont have much memory on my server, i am hammering it with proxmox!
<havenwood>
tpanarch1st: Not saving anything to disk - just model it in Ruby.
<tpanarch1st>
i think i need to study some more but what materials should i use following on from giraffe's tutorials please, i'm clearly not ready
<tpanarch1st>
not the best reader - better with videos
<havenwood>
tpanarch1st: I'm not familiar with giraffe. Show your code? We could probably help.
<tpanarch1st>
i'm lost with getting ruby up and running let alone coding it :-D
<havenwood>
tpanarch1st: Do you have Ruby installed?
<tpanarch1st>
that's why i say i'm clearly not ready :)
<baweaver>
Eh
<havenwood>
Start with installing Ruby.
<baweaver>
No one's ever "ready"
<baweaver>
We just wing it as we go and hope for the best
<tpanarch1st>
i don't know havenwood to be honest - i have entire access to my linux box though :)
<tpanarch1st>
thanks for your humble answer there baweaver :)
<havenwood>
tpanarch1st: From the command line, type: ruby -v
<tpanarch1st>
ah yeah, sugar, i've seen that before!
<baweaver>
Give me a year or so and I could recommend you a Ruby book.
<havenwood>
tpanarch1st: So you have Ruby 2.3. It's a bit dated, but it'll do.
<tpanarch1st>
sweet :)
<havenwood>
tpanarch1st: Now type: irb
<tpanarch1st>
sure
<baweaver>
irb is a...
<baweaver>
freaking ninja
<havenwood>
;)
<havenwood>
?irb tpanarch1st
<ruby[bot]>
tpanarch1st: irb is "interactive ruby", it is part of ruby. You can run ruby code and see results immediately. it's useful for testing code. Also see ?pry, a gem which is a popular alternative to irb.
<tpanarch1st>
ah yeah i've seen a tutorial on this
<tpanarch1st>
irb(main):001:0>
<tpanarch1st>
it doesn't save anything
<tpanarch1st>
im better with getting some sort of draft website up
<tpanarch1st>
and seeing it in the browser
<havenwood>
tpanarch1st: Try: 42 * 42
<havenwood>
tpanarch1st: Or: print "Hello world"
<tpanarch1st>
plus it saves my work!
<baweaver>
Let's start with some Ruby itself
<tpanarch1st>
oh yeah - i get that you can do the maths equations, i've watched a tutorial on that
<havenwood>
tpanarch1st: So how would you represent a list of things?
<baweaver>
Have you experienced the magic of Enumerable?
sarink has joined #ruby
braincrash has quit [Quit: bye bye]
<tpanarch1st>
well havenwood the syntax is a tricky matter but the basic logic is the same as any other programming language - use an array
<baweaver>
I swear you're reading my train of thought
<baweaver>
How would you, say, double every element of that array?
<tpanarch1st>
never heard of an enumerable (i don't think)
<havenwood>
tpanarch1st: Great, yes, in Ruby the Array literal is square braces. This is an empty Array: []
<baweaver>
You can learn Ruby with cartoon lemurs :D
<tpanarch1st>
right so to be totally honest with you havenwood, the def bit i know is the format for functions but the 200 and content type etc, never seen that before
mat_bug has quit [Ping timeout: 252 seconds]
<tpanarch1st>
:-p baweaver
<baweaver>
The presenter is out of their danged mind
<baweaver>
I'm surprised they let them on stage
<havenwood>
tpanarch1st: In Rack, you respond to requests with three parts, 1) the status code, 2) a Hash of the HTTP headers, and 3) the body.
<tpanarch1st>
i'm not lazy but i've been totally locked out of programming because I am entirely crap at reading technical documents
baweaver is now known as lemur
<havenwood>
tpanarch1st: The 200 is just the status code for "OK"
<bougyman>
and 418 is "I'm a teapot"
<lemur>
No one likes dull tech docs D:
<havenwood>
tpanarch1st: These are the headers: {'Content-Type' => 'text/plain'}
<lemur>
bougyman: watch that talk above
<tpanarch1st>
havenwood: to take a step back, i seem to remember 200 being ok (absolutely no idea where i've heard that before, is that http??) what is rack please?
<lemur>
and pay close attention to the background elements :D
<bougyman>
lemur: I have :)
<lemur>
I may have made that joke
lemur is now known as baweaver
<baweaver>
hehehe
<baweaver>
lemur was my original alias
<havenwood>
tpanarch1st: Yes, it's an HTTP status code. 200 OK
<baweaver>
I still keep it about
<tpanarch1st>
oh Lord, baby steps if you have the patience please
<havenwood>
tpanarch1st: Rack is a gem.
<tpanarch1st>
i'm trying to grasp on to the little things that you are saying currently and trying to cling on for dear life
<tpanarch1st>
oh it's ok if we are talking http this is fine right, it's pretty straight forward that, it's the "meat" of the wqeb
<tpanarch1st>
web*
<tpanarch1st>
how does http fit in with all of this, i'm totally surprised that http codes have come into the conversation so you can see how lost I am
<tpanarch1st>
so, in really basic terms, how have we come on to http status codes in a conversation about ruby, you're obviously trying to teach me something here and I appreciate your time :)
<baweaver>
Ah, they get 2.6 up?
<al2o3-cr>
oh yeah :P
<tpanarch1st>
never heard of a 418 or a 503 :-p
<tpanarch1st>
i could stop being lazy and go on to wiki for that :-p
* baweaver
should probably go get groceries already
<havenwood>
tpanarch1st: In Ruby most webservers (Rails included) use Rack under the hood. You can make a simple Rack app directly to start groking what's going on.
<tpanarch1st>
baweaver: you're not a covert drug dealer are you :-p :-p
<havenwood>
tpanarch1st: It's a spec for handling HTTP 1.1 requests and responses.
<baweaver>
My drug is Ruby
<baweaver>
and you've already been dealt
<tpanarch1st>
wicked, so this is a great start - "Ruby uses Rack under the hood"
<tpanarch1st>
so taking it from there, what the goodness is rack!
<baweaver>
Now where's shevy with that danged quotes list
<tpanarch1st>
will this give a total newbie a good idea
<tpanarch1st>
oh wicked yes it does
<havenwood>
tpanarch1st: It takes web requests, gives you an `env` Hash with info about the request and then you give it the response.
<baweaver>
Rails uses Rack under the hood
mat_bug has joined #ruby
<baweaver>
Rack is written in RUby
<tpanarch1st>
ok so just to paste this
<tpanarch1st>
To use Rack, provide an "app": an object that responds to the call method, taking the environment hash as a parameter, and returning an Array with three elements:
hutch has quit [Ping timeout: 268 seconds]
<havenwood>
tpanarch1st: Yes, so that little snippet I wrote is one way to do that ^
<tpanarch1st>
a) what is an app, b) what is a call method c) i thought hashes were things like md5 and d_ where does an array come into it when i haven't even started writing code :)
<havenwood>
tpanarch1st: a) an app is an application, which in the sense of web application is a little server that responds to HTTP requests with HTTP responnses
<tpanarch1st>
i think there needs to be a "ruby in basic english" website and then i can continue :-p
<tpanarch1st>
cool so can we say my web server is an app
<havenwood>
tpanarch1st: yes
<tpanarch1st>
ok cool, so i shall substitute that word in my brain :)
<havenwood>
tpanarch1st: b) a call method is a method named #call.
<havenwood>
def call
<tpanarch1st>
and rack doesn't provide my web server though :) a quicker way is can someone rewrite that quote in really dumbass terms for me please
<tpanarch1st>
i won't take offence, the more basic the better!
mat_bug has quit [Ping timeout: 252 seconds]
<tpanarch1st>
and not bbc basic either :-p :-p
<havenwood>
tpanarch1st: You can write an HTTP request by hand and type it out over socket. We don't though, since that's tedious. We use http clients.
<tpanarch1st>
yeah in other words a web browser right
dviola has quit [Quit: WeeChat 2.3]
<tpanarch1st>
that does that stuff for you i thought
<havenwood>
tpanarch1st: Likewise, you can parse each HTTP request yourself when you receive it, but handling those connections and doing the parsing is tedious and complicated.
<havenwood>
tpanarch1st: Rack ties together a pluggable webserver and a spec for easily creating web apps that respond to HTTP requests with HTTP responses.
<uplime>
tpanarch1st: (c) md5 is a hashing algorithm. hash in this case refers to a Hashmap (which internally will use a hashing algorithm, but probably not md5). you might have seen it called an associative array or dictionary
<uplime>
its got the syntax of { key => value } or { key_sym: value }
<tpanarch1st>
oh cool, yeah last two terms i've heard of uplime
<havenwood>
c ^
<baweaver>
d?
<uplime>
tpanarch1st: cool, its a similar idea in ruby
<tpanarch1st>
so like everything i've heard so far is not a basic start to php, there's obviously a good reason for this but i'm clearly failing to grasp it
gothicsouth has joined #ruby
<tpanarch1st>
it might help if i make clear i've never become competent in even one programming language :)
<baweaver>
Gotta start somewhere :D
porg has joined #ruby
<tpanarch1st>
yeah indeed
<tpanarch1st>
so like, this is not meant to be rude, and how often do comments get taken the wrong way by text") but how does http requests, rack etc come into starting to type some code and shove some crap in a database and query it please
hutch has joined #ruby
\void has joined #ruby
<tpanarch1st>
thanks ever so much guys, i'm going to go to bed now :)
mat_bug has joined #ruby
tag has joined #ruby
tdy has joined #ruby
tpanarch1st has quit [Quit: Thanks for your help, nice to see you, take care.]
mat_bug has quit [Ping timeout: 252 seconds]
gothicsouth has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
Sauvin has joined #ruby
mat_bug has joined #ruby
cschneid has quit [Remote host closed the connection]
bga57 has quit [Ping timeout: 245 seconds]
mat_bug has quit [Ping timeout: 250 seconds]
hutch has quit [Ping timeout: 272 seconds]
davidw has quit [Ping timeout: 246 seconds]
dinfuehr has quit [Ping timeout: 258 seconds]
dinfuehr has joined #ruby
za1b1tsu has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
dinfuehr has joined #ruby
dinfuehr has quit [Ping timeout: 250 seconds]
dinfuehr has joined #ruby
tdy has quit [Ping timeout: 268 seconds]
jottr has joined #ruby
dinfuehr has quit [Ping timeout: 268 seconds]
dinfuehr has joined #ruby
jottr has quit [Ping timeout: 258 seconds]
dinfuehr has quit [Ping timeout: 268 seconds]
dinfuehr has joined #ruby
mozzarella has joined #ruby
sarink has quit [Remote host closed the connection]
drbrain has quit [Quit: Goodbye]
sarink has joined #ruby
mat_bug has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mat_bug has quit [Ping timeout: 252 seconds]
esrse has joined #ruby
reber has joined #ruby
conta has joined #ruby
dellavg_ has joined #ruby
Inline has quit [Quit: Leaving]
rawrg has joined #ruby
\void has quit [Quit: So long, and thanks for all the fish.]
mat_bug has joined #ruby
paranoicsan has joined #ruby
rawrg has quit [Remote host closed the connection]
polishdub has quit [Remote host closed the connection]
szulak_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<fredolinhares>
Found it: rb_const_get(rb_cObject, rb_intern("Gem"));
cschneid has joined #ruby
jenrzzz has quit [Ping timeout: 250 seconds]
<cschneid>
Trying to find the source of an idea I ran into a long while ago, but trying to show to a junior dev. "Push messes to the edge of your system" - I thought it was a sandi metz book or blog post, but I can't seem to find it. Anybody have any ideas?
orbyt_ has joined #ruby
donofrio has joined #ruby
donofrio has quit [Ping timeout: 268 seconds]
<leftylink>
that wouldn't be gary bernhardt's boundaries talk, would it...
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]