• Who's Got Your Back

    Explores the idea of creating a few deep relationships to help you get farther in your goals then you could by yourself. Basically, creating relationships where you can get and give honest feedback to overcome obstacles and roadblocks, some that you probably can’t see yourself.

    Groups

    Notes

    The 4 mind sets: Candor < Vulnerability < Accountability < Generosity

    9 steps

    1. Articulate your vision
    2. Find your lifeline relationships
    3. Practice the art of the long slow dinner
    4. Broaden your goal-setting strategy (learning and performance goals)
    5. Create your Personal Success Wheel
    6. Learn to fight
    7. Diagnose your weaknesses
    8. Commit to improvement
    9. Fake it till you make it then make it stick

    Starting point for staring your own group: How to Conduct a Meeting (Kindle Locations 3793-3794).

    Who’s Got Your Back Author: Keith Ferrazzi

  • The Undoing Project

    This was an interesting read about where some of hte current thinking about decision-making came from. It’s more a story about the two people who worked together to create the these papers, Daniel Kahneman & Amos Tversky.

    While the store was interesting, the biggest take away for me was another reminder that people do not make ration decisions. That they can be manipulated to make different choices about the same things based on how those things are presented.

    I was suprised by how much push back there ideas received, even though it’s obvious that you personally make the mistakes they are talking about.

    The Undoing Project Author: Michael Lewis

  • Steal Like an Artist

    10 Things Nobody Told You About Being Creative

    Steal Link an Artist: 10 Things Nobody Told You About Being Creative is a short quick read with lots of ideas about being creative and getting inspiration.

    Author: Austin Kleon

  • Create or Hate

    Make Things!

    Create or Hate is a quick, short read but very inspiring. Get out there and create things!

    Author: Dan Norris

    Other books

  • Rake Package to Create Zipfile

    Small Rakefile to package a WordPress plugin into a zip file that can be installed by uploading.

    The Rake::PackageTask requires FileTasks that describe how to build the files, since we don’t really need to do anything, we just need to define what the files are.

    require 'rake'
    require 'rake/packagetask'
    
    file 'README.txt'
    file 'admin/**'
    file 'includes/**'
    file 'languages/**'
    file 'public/**'
    file "index.php"
    file "LICENSE.txt"
    file "README.txt"
    file "remote-api.php"
    file "uninstall.php"
    
    Rake::PackageTask.new("remote-api", :noversion) do |p|
      p.need_zip = true
      p.package_files.include(
        "admin/**",
        "includes/**",
        "languages/**",
        "public/**",
        "index.php",
        "LICENSE.txt",
        "README.txt",
        "remote-api.php",
        "uninstall.php")
    end
    

    Then to create the zip, just run rake package. It’ll create the file in the pkg/remote-api directory, or whatever name you gave the package.

  • Clojure Duct setup with MongoDB, Foundation, and Buddy - Part 2

    Zurb Foundation && SASS

    Add Zurb Foundation or whatever webjars you want to use.

     [org.webjars/foundation "6.2.0"]
     [org.webjars/font-awesome "4.6.2"]
    

    Setup a SASS file

    I put these in src/sass/. You can import from webjars like this.

    @import 'foundation/scss/foundation';
    @import 'foundation/scss/util/mixins';
    @import 'font-awesome/scss/font-awesome';
    

    Watching SASS files in dev

    Need to add SASS support. Checked out sass4clj. There is a lein plugin, but that didn’t play well with figwheel. I did end up using some ideas from that and the sass4clj project to integrate with figwheel.

    I started with this SASS Watcher which was a good starting point, but didn’t load in the webjars. So the next step is replace with sass4clj which does reference webjars.

    in dev.clj require these

    [sass4clj.core :refer [sass-compile-to-file]]
    [watchtower.core :refer :all]
    

    Next create a new component to watch the SASS files and recompile on changes. A lot of these came from the lein-sass4clj project.

    (defn- main-file? [file]
      (and (or (.endsWith (.getName file) ".scss")
               (.endsWith (.getName file) ".sass") )
           (not (.startsWith (.getName file) "_"))))
    
    (defn- find-main-files [source-paths]
      (mapcat (fn [source-path]
                (let [file (io/file source-path)]
                  (->> (file-seq file)
                       (filter main-file?)
                       (map (fn [x] [(.getPath x) (.toString (.relativize (.toURI file) (.toURI x)))])))))
              source-paths))
    
    (defn watch-sass
      ""
      [input-dir output-dir options]
      (prn (format "Watching: %s -> %s" input-dir output-dir))
      (let [source-paths (vec (find-main-files [input-dir]))
            sass-fn 
            (fn compile-sass [& _]
              (doseq [[path relative-path] source-paths
                      :let [output-rel-path (clojure.string/replace relative-path #"\.(sass|scss)$" ".css")
                            output-path     (.getPath (io/file output-dir output-rel-path))]]
                (println (format "Compiling {sass}... %s -> %s" relative-path output-rel-path))
                (sass4clj.core/sass-compile-to-file
                  path
                  output-path
                  (-> options
                      (update-in [:output-style] (fn [x] (if x (keyword x))))
                      (update-in [:verbosity] (fn [x] (or x 1)))))))
            ]
        (watchtower.core/watcher
           [input-dir]
           (watchtower.core/rate 100)
           (watchtower.core/file-filter watchtower.core/ignore-dotfiles)
           (watchtower.core/file-filter (watchtower.core/extensions :scss :sass))
           (watchtower.core/on-change sass-fn))
        )
      )
    
    (defrecord SassWatcher [input-dir output-dir options]
      component/Lifecycle
      (start [this]
        (prn "Starting SassWatcher Component.")
        (if (not (:sass-watcher-process this))
          (do
            (println "Figwheel: Starting SASS watch process:" input-dir output-dir)
            (assoc this :sass-watcher-process (watch-sass input-dir output-dir options))
            )
          this))
      (stop [this]
        (when-let [process (:sass-watcher-process this)]
          (println "Figwheel: Stopping SASS watch process")
          (future-cancel process))
        this))
    

    Next setup a config for compilation and add the compoent to the dev system.

    (def sass-config
      {:input-dir "src/sass" ;location of the sass/scss files
       :output-dir "resources/nspkt/ui/public/css"
       :options 
       {:source-map true
        ;:output-style :nested, :compact, :expanded and :compressed
        ;:verbosity 1, 2
        }
       })
    
    (defn new-system []
      (into (system/new-system config)
            {:figwheel (figwheel/server (:figwheel config))
             :sass (map->SassWatcher sass-config)}
            ))
    

    Now we’re watching the files and updating on change. I think figwheel should pick up those changes and push an reload, but something doesn’t seem to be working there.

  • Clojure Duct setup with MongoDB, Foundation, and Buddy

    Setup a new duct site

    Why Duct? Well it’s a great starting point using most of what I want. Compojure, Ring, Component, ClojureScript, 12 Factor methodology.

    lein new duct nspkt.ui +cljs +example +heroku +site
    cd nspkt.ui && lein setup
    

    Ok, we need some other stuff, like MongoDB, a css framework (Foundation), and authentication.

    MongoDB Setup

    I like Monger, so let’s add that. In project.clj, add the dependency.

    [com.novemberain/monger "3.0.2"]
    

    We need to add a connection string to the env for monger. This took a minute to figure out.

    In the project.clj file, under :profiles > :project/dev > :env, add :url. This will write the values to .lein-env.

    {:port "3000", :url "mongodb://localhost:27017/nspkt"}
    

    Then we need to update the config.clj to grap the value. Like so.

    (def environ
      {
       :http {:port (some-> env :port Integer.)}
       :db {:url (some-> env :url)}
       })
    

    And add a compontent for System.

    (ns nspkt.ui.component.mongodb
      (:require [com.stuartsierra.component :as component]
                [monger.core :as mg]
                )
      )
    
    (defrecord MongoDb [url]
      component/Lifecycle
      (start [this]
        (let [{:keys [conn db]} (mg/connect-via-uri (:url this))]
          (assoc this :conn conn :db db)
          )
        )
    
      (stop [this]
        (if-let [conn (:conn this)]
          (do
            (mg/disconnect conn)
            (dissoc this :conn :db)
            )
          this
          )
        )
      )
    
    (defn db-component [options]
      (map->MongoDb options)
      )
    

    Next add the component to the system, add have the example endpoint depend on it. Don’t forget to add to the :requires. In system.clj.

    ...
    (-> (component/system-map
         :app  (handler-component (:app config))
         :http (jetty-server (:http config))
         :db   (db-component (:db config))
         :example (endpoint-component example-endpoint))
        (component/system-using
         {:http [:app]
          :app  [:example]
          :example [:db]}))
    ...
    

    And using the component in the example endpoint, endpoint/example.clj.

    (ns nspkt.ui.endpoint.example
      (:require [compojure.core :refer :all]
                [monger.collection :as mc]
                [clojure.java.io :as io]))
    
    (defn example-endpoint [{:keys [db] :as config}]
      (context "/example" []
        (GET "/" []
          (prn-str 
            (mc/find-maps (-> db :db) "reports")
            )
          )))
    

    Great! Let’s make sure everything is working. We need to lein deps and start the REPL again.

    If you run into trouble it’s some times easier to see what’s going by lein runing.

    I added a test record in MongoDB just to see everything works.

    It’s not pretty, but it’s pulling stuff out of the DB! Now let’s add a CSS framework to help thing look a little better.