Skip to content

Instantly share code, notes, and snippets.

View cassiomarques's full-sized avatar
💭
I have no idea what I'm doing

Cássio Marques cassiomarques

💭
I have no idea what I'm doing
  • Multiverse
  • London, UK
View GitHub Profile
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
;; The idea is to replace the component's content when the atom's value changes.
;; The state for :initial is displayed when the component is first rendered but does not change
;; when `delete-button` is clicked, even though the atom is correctly reset.
(defn delete-button-component [card]
(let [on-delete-clicked (fn [] (reset! delete-state :confirming))
delete-button (fn [card]
[:button {:class "circular ui icon button delete-card" :title "Delete card" :on-click on-delete-clicked}
[:i {:class "icon erase"}]])
confirmation-buttons (fn [card] [:span
[:button {:class "ui button cancel"} "Cancel"]
(defn delete-button-component [card]
(let [delete-state (r/atom :initial)
on-delete-clicked (fn [] (reset! delete-state :confirming))
on-cancel-clicked (fn [] (reset! delete-state :initial))
delete-button [:button {:class "circular ui icon button delete-card" :title "Delete card" :on-click on-delete-clicked}
[:i {:class "icon erase"}]]
confirmation-buttons [:span
[:button {:class "ui button cancel" :on-click on-cancel-clicked} "Cancel"]
[:button {:class "ui button confirm"} "I'm sure!"]]]
(fn [card]
(defn bind-input [input-atom]
#(reset! input-atom (-> %1 .-target .-value)))
(defn some-component []
(let [value-atom (r/atom nil)
[:input {:type "text" :on-change (bind-input value-atom)}]))
irb(main):014:0> foo = "I am foo"
=> "I am foo"
irb(main):015:0> foo.is_a? String
=> true
irb(main):016:0> module Kernel
irb(main):017:1> private :is_a?
irb(main):018:1> end
=> Kernel
irb(main):019:0> foo.is_a? String
NoMethodError: private method `is_a?' called for "I am foo":String
irb(main):021:0> Kernel.send :private, :class
=> Kernel
irb(main):022:0> foo.class
/Users/cassiommc/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:498:in `block (2 levels) in eval_input': private method `class' called for #<NoMethodError:0x007fa8f51abaa8> (NoMethodError)
[1] pry(main)> show-source Random.rand
From: random.c (C Method):
Owner: #<Class:Random>
Visibility: public
Number of lines: 5
static VALUE
random_s_rand(int argc, VALUE *argv, VALUE obj)
{

Keybase proof

I hereby claim:

  • I am cassiomarques on github.
  • I am cassiomarques (https://keybase.io/cassiomarques) on keybase.
  • I have a public key ASAWM1-qEX5vR9A08DeSGXFDCjhsl8ZTN3fW6uYWoGMTMgo

To claim this, I am signing this object: