Last active
November 1, 2015 17:55
-
-
Save lukemorton/755cd25ebf2904afd31b to your computer and use it in GitHub Desktop.
Reasons why I prefer ruby and clojure to js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
className () { | |
let className = 'purchase_orders_table'; | |
if (this.state.sticky) className += '--sticky'; | |
return className; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn class-name [state] | |
(string "purchase_orders_table" | |
(if (state :sticky) ("--sticky")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def class_name | |
"purchase_orders_table#{'--sticky' if @state.sticky?}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
renderCols () { | |
const cellWidths = this.cellWidths(); | |
let cols = []; | |
for (let i = 0; i < cellWidths.length; i++) { | |
cols.push(( | |
<col key={i} style={{ width: cellWidths[i] }} /> | |
)); | |
} | |
return cols; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn render-columns [] | |
(map-indexed #(col {:key %1 :style {:width %2}}) (cell-widths))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render_columns | |
cell_widths.each_with_index.map do |width, i| | |
col(key: i, style: { width: width }) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function removeEmptyKeys(object) { | |
for (let key in object) { | |
if (object.hasOwnProperty(key) && (object[key] == null || object[key] === '')) { | |
delete object[key]; | |
} | |
} | |
return object; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn remove-empty-keys [map] | |
(into {} (filter #(not (nil? (% 1))) map))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_empty_keys(hash) | |
hash.keep_if { |_, v| !v.nil? } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment