Skip to content

Instantly share code, notes, and snippets.

View ravicious's full-sized avatar

Rafał Cieślak ravicious

View GitHub Profile
@ravicious
ravicious / AutoSavingForm.md
Last active March 31, 2017 12:24 — forked from oyeanuj/AutoSavingForm.md
Auto-saving forms using Redux-Form – @oyeanuj solution piped through prettier

Here is how I ended up making this work. For more context and background on the discussion, I recommend reading conversation in ReduxForm#2169 (and chiming in with your learnings, etc).

So, as per the conversation there, I tried the 'many little forms' approach. I am sharing both my approach, and a crude abstracted out gist that can hopefully help out y'all.

Essentially, with this approach:

  1. You want to use each field as a little form which submits debounced onChange.
  2. For each field as a little form, you want to abstract that into a component which can be provided an input, as much as possible.
  3. Set autofocus for the first form.
  4. For debounced onChange, I used react-debounced-input.
class Fancy
def self.test
puts "Ask me a question:"
t = gets
puts "You said: #{t}"
puts "What about this other thing?"
t2 = gets
puts "Now you said: #{t2}"
end
end
require "irb/completion"
require "rubygems"
# Modify the prompt so it looks nice and tidy. Taken from Programming Ruby 2.
IRB.conf[:IRB_RC] = proc do |conf|
conf.prompt_c = "?>"
conf.prompt_i = ">> "
conf.prompt_n = ">> "
conf.prompt_s = nil
conf.prompt_mode = :SIMPLE
conf.return_format = "=> %s\n"
require 'rubygems'
require 'eventmachine'
require 'yajl'
require 'em-http'
require 'uri'
EventMachine.run {
body = ''
on_body = lambda { |chunk|
chunk.split(/\n/).each { |json|
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
@ravicious
ravicious / gist:50712
Created January 22, 2009 20:53 — forked from oki/gist:50703
# mam dwie tablice:
# a = [1,2]
# b = [3,4],
# chce je polaczyc w nastepujacy sposob: [[1,3],[2,4]]
# pytam wiec irba jak to zrobic :-)
>> a = [1,2]
=> [1, 2]
>> b = [3,4]