Skip to content

Instantly share code, notes, and snippets.

View Will-Sommers's full-sized avatar

Will Sommers Will-Sommers

View GitHub Profile
def application_props
{
routes: { user: { new: "/..." } },
special_integer: 42
}
end
def react_props!(obj)
application_props.merge(obj.as_json).to_json
end
var Hello = React.createClass({
getInitialState: function() {
return {
message: "hi hi hi",
color: "red"
}
},
updateMessage: function(event) {
var newValue = event.target.value;
@Will-Sommers
Will-Sommers / gist:4fe13e7a9383318f4bcd
Last active August 29, 2015 14:18
a terrible way to interleave names
FOLKS = %w( john
will
devin
nizar
pat
kai
sharell
hindi
chris
dave
We have a performance problem
Around 6 seconds.
This number belies two points. The first being that our site is slower than we would like it to be. The second is that it is not exact and gives us no idea of directionality. I’ll talk about each, in turn.
Our site is too slow.
Why in the age of cheap RAM, fast connections and copious caching is this the case. It should also be noted that while we are transitioning away from a separate mobile-only site, that the “around 6 seconds” number represents only our desktop users.
function hiManish(fn, calls) {
var calls_count = calls;
return {
completeCall: function() {
calls -= 1;
if (this.isDone()){
console.log("Begin to execute callback function")
fn.call(this)
}
},
# setup 2 functions
def a
puts "hi vidal"
end
def b
return "hi vidal"
end
(def app-state (atom {:board-info {:board-name "My Board"
:starred false
:private false}
:sidebar {:open true}
:columns [{:name "To Do" :cards [{:task "Sidebar"
:id 0}
{:task "Header"
:id 1}
{:task "Create new board"
@Will-Sommers
Will-Sommers / ABoardName
Last active August 29, 2015 14:03
y-om-one
(def app-state (atom {:board-name "Yo yo yo, get it done!"
:columns [{:name "To Do"}
{:name "Doing"}
{:name "Done"}]}))
(defn column-component [data owner]
(reify
om/IRender
(render [_]
(dom/div #js {:className "column"}
@Will-Sommers
Will-Sommers / gist:9949efd7c3901ccf8b8d
Created June 13, 2014 21:31
Flash of last state text
(ns community.location
(:require [community.routes :as routes :refer [routes]]
[sablono.core :as html :refer-macros [html]]))
...
...
(defn init-location! [app-state]
(routes/set-route! app-state)
(.addEventListener js/window "popstate" (partial routes/set-route-and-clear! app-state)))
function addLiTemplate(content) {
var template = $("#li-template").clone() // this template is hidden insid the HTML markup with css {display:none;}
return template.find("#todo").text(content)
};
// or
function addLiTemplate(content) {
$('<li/>', {
id: 'foo',
text: content