Skip to content

Instantly share code, notes, and snippets.

@yunusemredilber
yunusemredilber / _form.html.erb
Last active April 11, 2024 09:57
Auto Growing text-area [Stimulus] [Rails]
<!-- Some form -->
<div data-controller="auto-grow-textarea">
<%= form.text_area :body, cols: 20, row: 2, placeholder: 'Bir yorum yazın...', class:'form-control', data: { action: 'input->auto-grow-textarea#resize', target: 'auto-grow-textarea.input' } %>
</div>
<!-- Some form continued -->
@sathish-io
sathish-io / Start and Stop PostgreSQL Service on Windows command line
Created May 5, 2014 08:04
Start and Stop PostgreSQL Service on Windows command line
NET START postgresql-x64-9.3 (64-bit windows)
NET STOP postgresql-x64-9.3 (64-bit windows)
NET START postgresql-9.3 (32-bit windows)
NET STOP postgresql-9.3 (32-bit windows)
Note: This is for Windows 7. Replace 9.3 with your version of PostgreSQL version.
@Jauny
Jauny / gist:3869758
Created October 11, 2012 02:13
Hash#sort

#Sorting a Hash I wanted to understand what happened under the hood when something like

hash.sort { |a, b| b[1] <=> a[1] }

is called. If you can't answer, you might want to read.
I'll be as basic as possible (I don't know much anyway...) so it should be understandable.


First let's begin by saying that we will be working on this hash

@mattsears
mattsears / README.md
Created October 3, 2011 13:16
Todo.rb: A simple command-line TODO manager written in Ruby

Todo.rb

Todo.rb is a simple command-line tool for managing todos. It's minimal, straightforward, and you can use it with your favorite text editor.

Getting Started

Todo.rb doesn't require any third-party gems so you can copy the file anywhere and use it as long as it's executable:

@runemadsen
runemadsen / description.markdown
Created September 26, 2011 15:23
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.